1: #ifndef lint
   2: static char sccsid[] = "@(#)subdir.c	5.4 (Berkeley) 6/23/85";
   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: char *
  99: subdir(d, pre)
 100: register char *d, pre;
 101: {
 102:     if (strcmp(d, Spool) == 0)
 103:         if (pre == CMDPRE)
 104:             return CMDSDIR;
 105:         else if (pre == XQTPRE)
 106:             return XEQTDIR;
 107:     return d;
 108: }

Defined functions

Defined variables

dprefix defined in line 22; used 1 times
  • in line 74
fn1 defined in line 38; used 2 times
fn2 defined in line 38; used 1 times
  • in line 56
inspool defined in line 39; used 3 times
sccsid defined in line 2; never used

Defined macros

BUFLEN defined in line 36; used 2 times
  • in line 38(2)
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2517
Valid CSS Valid XHTML 1.0 Strict