113670Ssam #ifndef lint 2*17838Sralph static char sccsid[] = "@(#)subdir.c 5.2 (Berkeley) 01/22/85"; 313670Ssam #endif 413670Ssam 513670Ssam #include "uucp.h" 613670Ssam /* 713670Ssam * By Tom Truscott, March 1983 813670Ssam * 913670Ssam * Prefix table. 1013670Ssam * If a prefix is "abc", for example, 1113670Ssam * then any file Spool/abc... is mapped to Spool/abc/abc... . 1213670Ssam * The first prefix found is used, so D.foo should preceed D. in table. 1313670Ssam * 1413670Ssam * Each prefix must be a subdirectory of Spool, owned by uucp! 1513670Ssam * Remember: use cron to uuclean these directories daily, 1613670Ssam * and check them manual every now and then. Beware complacency! 1713670Ssam */ 1813670Ssam 1913670Ssam static char *prefix[] = { 2013670Ssam DLocalX, /* Outbound 'xqt' request files */ 2113670Ssam DLocal, /* Outbound data files */ 2213670Ssam "D.", /* Other "D." files (remember the "."!) */ 2313670Ssam "C.", /* "C." subdirectory */ 2413670Ssam "X.", /* "X." subdirectory */ 2513670Ssam "TM.", /* Temporaries for inbound files */ 2613670Ssam 0 2713670Ssam }; 2813670Ssam 2913670Ssam /* 3013670Ssam * filename mapping kludges to put uucp work files in other directories. 3113670Ssam */ 3213670Ssam 3313670Ssam #define BUFLEN 50 3413670Ssam 3513670Ssam static char fn1[BUFLEN], fn2[BUFLEN]; /* remapped filename areas */ 3613670Ssam static int inspool; /* true iff working dir is Spool */ 3713670Ssam 3813670Ssam /* 3913670Ssam * return (possibly) remapped string s 4013670Ssam */ 4113670Ssam char * 42*17838Sralph subfile(as) 4313670Ssam char *as; 4413670Ssam { 4513670Ssam register char *s, **p; 4613670Ssam register int n; 4713670Ssam static char *tptr = NULL; 4813670Ssam 4913670Ssam /* Alternate buffers so "link(subfile(a), subfile(b))" works */ 5013670Ssam if (tptr != fn1) 5113670Ssam tptr = fn1; 5213670Ssam else 5313670Ssam tptr = fn2; 5413670Ssam 5513670Ssam s = as; 5613670Ssam tptr[0] = '\0'; 5713670Ssam 5813670Ssam /* if s begins with Spool/, copy that to tptr and advance s */ 5913670Ssam if (strncmp(s, Spool, n = strlen(Spool)) == 0 && s[n] == '/') { 6013670Ssam if (!inspool) { 6113670Ssam strcpy(tptr, Spool); 6213670Ssam strcat(tptr, "/"); 6313670Ssam } 6413670Ssam s += n + 1; 6513670Ssam } 6613670Ssam else 6713670Ssam if (!inspool) 6813670Ssam return(as); 6913670Ssam 7013670Ssam /* look for first prefix which matches, and make subdirectory */ 7113670Ssam for (p = &prefix[0]; *p; p++) { 7213670Ssam if (strncmp(s, *p, n = strlen(*p))==0 && s[n] && s[n] != '/') { 7313670Ssam strcat(tptr, *p); 7413670Ssam strcat(tptr, "/"); 7513670Ssam strcat(tptr, s); 7613670Ssam return(tptr); 7713670Ssam } 7813670Ssam } 7913670Ssam return(as); 8013670Ssam } 8113670Ssam 8213670Ssam /* 8313670Ssam * save away filename 8413670Ssam */ 85*17838Sralph subchdir(s) 8613670Ssam register char *s; 8713670Ssam { 8813670Ssam inspool = (strcmp(s, Spool) == 0); 8913670Ssam return(chdir(s)); 9013670Ssam } 9113670Ssam 9213670Ssam /* 9313670Ssam * return possibly corrected directory for searching 9413670Ssam */ 9513670Ssam char * 96*17838Sralph subdir(d, pre) 9713670Ssam register char *d, pre; 9813670Ssam { 9913670Ssam if (strcmp(d, Spool) == 0) 10013670Ssam if (pre == CMDPRE) 101*17838Sralph return(CMDSDIR); 10213670Ssam else if (pre == XQTPRE) 103*17838Sralph return(XEQTDIR); 10413670Ssam return(d); 10513670Ssam } 106