# 2.11BSD#431 - /usr/src/usr.bin/uucp/subdir.c

##### Functions

    subchdir          X
    subdir            X
    subfile           X

##### Macros

    BUFLEN            X

       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

subchdir defined in line 88; used 7 times

- in /usr/src/usr.bin/uucp/cico.c line 196
- in /usr/src/usr.bin/uucp/uucp.c line 104
- in /usr/src/usr.bin/uucp/uuq.c line 114
- in /usr/src/usr.bin/uucp/uux.c line 142
- in /usr/src/usr.bin/uucp/uuxqt.c line 105, 305, 331

subdir defined in line 98; used 7 times

- in /usr/src/usr.bin/uucp/anlwrk.c line 122-123(2)
- in /usr/src/usr.bin/uucp/gnsys.c line 46
- in /usr/src/usr.bin/uucp/uucp.h line 395
- in /usr/src/usr.bin/uucp/uupoll.c line 64
- in /usr/src/usr.bin/uucp/uuq.c line 164, 196

subfile defined in line 44; used 66 times

- in /usr/src/usr.bin/uucp/anlwrk.c line 57, 63-64(2), 83
- in /usr/src/usr.bin/uucp/anyread.c line 19
- in /usr/src/usr.bin/uucp/chkpth.c line 213, 223-224(2)
- in /usr/src/usr.bin/uucp/cico.c line 380
- in /usr/src/usr.bin/uucp/cntrl.c line 218-223(2), 263, 483, 520, 585, 629, 902, 917
- in /usr/src/usr.bin/uucp/cpmv.c line 25-28(2), 36, 62-70(5)
- in /usr/src/usr.bin/uucp/expfile.c line 68
- in /usr/src/usr.bin/uucp/mailst.c line 30
- in /usr/src/usr.bin/uucp/uucp.c line 234-239(2), 301, 421, 440
- in /usr/src/usr.bin/uucp/uucp.h line 395
- in /usr/src/usr.bin/uucp/uuq.c line 258-259(2), 270, 282-284(2), 290, 316, 348
- in /usr/src/usr.bin/uucp/uux.c line 297(2), 437, 460, 480
- in /usr/src/usr.bin/uucp/uuxqt.c line 197, 336, 348, 356, 362-364(2), 438-446(5), 470, 480, 502, 511, 530, 540, 699, 705

#### Defined variables

dprefix defined in line 22; used 1 times

- in line 74

fn1 defined in line 38; used 2 times

- in line 53-54(2)

fn2 defined in line 38; used 1 times

- in line 56

inspool defined in line 39; used 3 times

- in line 63, 70, 91

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: 524 |