Annotation of 42BSD/usr.bin/uucp/subdir.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.