BSD 4_4 release
[unix-history] / usr / src / usr.bin / uucp / libuu / subdir.c
index 7d92358..9cfac8d 100644 (file)
@@ -1,8 +1,20 @@
+/*-
+ * Copyright (c) 1985, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This module is believed to contain source code proprietary to AT&T.
+ * Use and redistribution is subject to the Berkeley Software License
+ * Agreement and your Software Agreement with AT&T (Western Electric).
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)subdir.c   5.2 (Berkeley) %G%";
-#endif
+static char sccsid[] = "@(#)subdir.c   8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
 
 #include "uucp.h"
 
 #include "uucp.h"
+
+/*LINTLIBRARY*/
+
 /*
  * By Tom Truscott, March 1983
  *
 /*
  * By Tom Truscott, March 1983
  *
@@ -13,10 +25,10 @@ static char sccsid[] = "@(#)subdir.c        5.2 (Berkeley) %G%";
  *
  * Each prefix must be a subdirectory of Spool, owned by uucp!
  * Remember: use cron to uuclean these directories daily,
  *
  * Each prefix must be a subdirectory of Spool, owned by uucp!
  * Remember: use cron to uuclean these directories daily,
- * and check them manual every now and then.  Beware complacency!
+ * and check them manually every now and then.  Beware complacency!
  */
 
  */
 
-static char *prefix[] = {
+static char *dprefix[] = {
        DLocalX,        /* Outbound 'xqt' request files */
        DLocal,         /* Outbound data files */
        "D.",           /* Other "D." files (remember the "."!) */
        DLocalX,        /* Outbound 'xqt' request files */
        DLocal,         /* Outbound data files */
        "D.",           /* Other "D." files (remember the "."!) */
@@ -65,18 +77,18 @@ char *as;
        }
        else
                if (!inspool)
        }
        else
                if (!inspool)
-                       return(as);
+                       return as;
 
        /* look for first prefix which matches, and make subdirectory */
 
        /* look for first prefix which matches, and make subdirectory */
-       for (p = &prefix[0]; *p; p++) {
+       for (p = &dprefix[0]; *p; p++) {
                if (strncmp(s, *p, n = strlen(*p))==0 && s[n] && s[n] != '/') {
                        strcat(tptr, *p);
                        strcat(tptr, "/");
                        strcat(tptr, s);
                if (strncmp(s, *p, n = strlen(*p))==0 && s[n] && s[n] != '/') {
                        strcat(tptr, *p);
                        strcat(tptr, "/");
                        strcat(tptr, s);
-                       return(tptr);
+                       return tptr;
                }
        }
                }
        }
-       return(as);
+       return as;
 }
 
 /*
 }
 
 /*
@@ -86,20 +98,25 @@ subchdir(s)
 register char *s;
 {
        inspool = (strcmp(s, Spool) == 0);
 register char *s;
 {
        inspool = (strcmp(s, Spool) == 0);
-       return(chdir(s));
+       return chdir(s);
 }
 
 /*
  * return possibly corrected directory for searching
  */
 }
 
 /*
  * return possibly corrected directory for searching
  */
+static char xdir[BUFSIZ];
 char *
 subdir(d, pre)
 register char *d, pre;
 {
        if (strcmp(d, Spool) == 0)
                if (pre == CMDPRE)
 char *
 subdir(d, pre)
 register char *d, pre;
 {
        if (strcmp(d, Spool) == 0)
                if (pre == CMDPRE)
-                       return(CMDSDIR);
-               else if (pre == XQTPRE)
-                       return(XEQTDIR);
-       return(d);
+                       return CMDSDIR;
+               else if (pre == XQTPRE) {
+                       if (xdir[0] == '\0')
+                               sprintf(xdir,"%s/X.",Spool);
+                       return xdir;
+
+               }
+       return d;
 }
 }