|
|
1.1 root 1: #include <stdio.h>
2: #define GFLIST "forwardlist"
3: #define LFLIST "forwardlist.lo"
4:
5: /* imported */
6: extern char *upaspath();
7:
8: static checkfile();
9:
10: /*
11: * Return nonzero if forwarding is allowed to the system
12: * named in the string at "cp". If we can't read the file
13: * which contains the systems, assume blanket forwarding.
14: */
15: okrmt(cp)
16: char *cp;
17: {
18: /* always accept the null string */
19: if (*cp == '\0')
20: return 1;
21:
22: /* try both general and local forwardlists */
23: switch (checkfile(cp, GFLIST)) {
24: case -1:
25: return checkfile(cp, LFLIST);
26: case 0:
27: return checkfile(cp, LFLIST) == 1;
28: }
29: return 1;
30: }
31:
32: static
33: checkfile(cp, file)
34: char *cp;
35: char *file;
36: {
37: register FILE *fp;
38: char buf[20];
39:
40: /* try to open the file; allow forwarding on failure */
41: fp = fopen (upaspath(file), "r");
42: if (fp == NULL)
43: return -1;
44:
45: /* one iteration per system name in the file */
46: while (fgets (buf, sizeof buf, fp) != NULL) {
47: buf[strlen(buf)-1] = '\0';
48: if (strcmp (buf, cp) == 0) {
49: /* found it, allow forwarding */
50: fclose (fp);
51: return 1;
52: }
53: }
54:
55: /* didn't find it, prohibit forwarding */
56: fclose (fp);
57: return 0;
58: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.