File: callstat.c

package info (click to toggle)
ifmail 2.14tx8.10-32
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,056 kB
  • sloc: ansic: 30,328; perl: 4,955; yacc: 839; makefile: 716; sh: 424; cpp: 235; lex: 206; awk: 24
file content (56 lines) | stat: -rw-r--r-- 865 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <sys/types.h>
#include <time.h>
#include <stdio.h>
#include "lutil.h"
#include "ftn.h"
#include "callstat.h"

extern char *stsname(faddr *,char);

static callstat st;

callstat *getstatus(addr)
faddr *addr;
{
	FILE *fp;
	time_t now;

	st.trytime=0L;
	st.tryno=0;
	st.trystat=0;

	if ((fp=fopen(stsname(addr,'f'),"r")))
	{
		fscanf(fp,"%lu %u %u",&st.trytime,&st.tryno,&st.trystat);
		fclose(fp);
	}

	(void)time(&now);

	return &st;
}

void putstatus(addr,incr,sts)
faddr *addr;
int incr;
int sts;
{
	FILE *fp;

	(void)getstatus(addr);
	if ((fp=fopen(stsname(addr,'f'),"w")))
	{
		if (sts == 0) st.tryno=0;
		else st.tryno+=incr;
		st.trystat=sts;
		(void)time(&st.trytime);
		fprintf(fp,"%lu %u %u\n",
			st.trytime,st.tryno,(unsigned)st.trystat);
		fclose(fp);
	}
	else
	{
		logerr("$cannot create status file for node %s",
			ascfnode(addr,0x1f));
	}
}