|
|
1.1 root 1: #ifndef lint
2: static char sccsid[] = "@(#)subdir.c 5.5 (Berkeley) 2/24/88";
3: #endif
4:
5: #include "uucp.h"
6:
7: /*LINTLIBRARY*/
8:
9: /*
10: * By Tom Truscott, March 1983
11: *
12: * Prefix table.
13: * If a prefix is "abc", for example,
14: * then any file Spool/abc... is mapped to Spool/abc/abc... .
15: * The first prefix found is used, so D.foo should preceed D. in table.
16: *
17: * Each prefix must be a subdirectory of Spool, owned by uucp!
18: * Remember: use cron to uuclean these directories daily,
19: * and check them manually every now and then. Beware complacency!
20: */
21:
22: static char *dprefix[] = {
23: DLocalX, /* Outbound 'xqt' request files */
24: DLocal, /* Outbound data files */
25: "D.", /* Other "D." files (remember the "."!) */
26: "C.", /* "C." subdirectory */
27: "X.", /* "X." subdirectory */
28: "TM.", /* Temporaries for inbound files */
29: 0
30: };
31:
32: /*
33: * filename mapping kludges to put uucp work files in other directories.
34: */
35:
36: #define BUFLEN 50
37:
38: static char fn1[BUFLEN], fn2[BUFLEN]; /* remapped filename areas */
39: static int inspool; /* true iff working dir is Spool */
40:
41: /*
42: * return (possibly) remapped string s
43: */
44: char *
45: subfile(as)
46: char *as;
47: {
48: register char *s, **p;
49: register int n;
50: static char *tptr = NULL;
51:
52: /* Alternate buffers so "link(subfile(a), subfile(b))" works */
53: if (tptr != fn1)
54: tptr = fn1;
55: else
56: tptr = fn2;
57:
58: s = as;
59: tptr[0] = '\0';
60:
61: /* if s begins with Spool/, copy that to tptr and advance s */
62: if (strncmp(s, Spool, n = strlen(Spool)) == 0 && s[n] == '/') {
63: if (!inspool) {
64: strcpy(tptr, Spool);
65: strcat(tptr, "/");
66: }
67: s += n + 1;
68: }
69: else
70: if (!inspool)
71: return as;
72:
73: /* look for first prefix which matches, and make subdirectory */
74: for (p = &dprefix[0]; *p; p++) {
75: if (strncmp(s, *p, n = strlen(*p))==0 && s[n] && s[n] != '/') {
76: strcat(tptr, *p);
77: strcat(tptr, "/");
78: strcat(tptr, s);
79: return tptr;
80: }
81: }
82: return as;
83: }
84:
85: /*
86: * save away filename
87: */
88: subchdir(s)
89: register char *s;
90: {
91: inspool = (strcmp(s, Spool) == 0);
92: return chdir(s);
93: }
94:
95: /*
96: * return possibly corrected directory for searching
97: */
98: static char xdir[BUFSIZ];
99: char *
100: subdir(d, pre)
101: register char *d, pre;
102: {
103: if (strcmp(d, Spool) == 0)
104: if (pre == CMDPRE)
105: return CMDSDIR;
106: else if (pre == XQTPRE) {
107: if (xdir[0] == '\0')
108: sprintf(xdir,"%s/X.",Spool);
109: return xdir;
110:
111: }
112: return d;
113: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.