home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / UUCP_Blars.lzh / uumailclean.c < prev    next >
C/C++ Source or Header  |  1991-03-10  |  17KB  |  759 lines

  1. /*
  2.  * uumailclean  -  this program searches through the uucp spool directory
  3.  * looking for mail files.  Files which have been around for longer than
  4.  * "failtime" hours will be returned to the sender.  If a file has been
  5.  * around longer than "warntime" hours, then a warning message is sent (once)
  6.  * to the sender. 
  7.  *
  8.  * Originally Written by Jim Crammond  <jim@cs.hw.ac.uk> 3/86
  9.  * Hacked to death by Rick Adams <rick@seismo.css.gov> 5/87 
  10.  * Released to comp.sources.unix 6/88
  11.  * Ported to OS-9/68000 by Wolfgang Ocker <weo@recco>  9/88
  12.  * Released to sub.os9 9/88
  13.  *
  14.  * This program contains no ATT code and may be freely used on sites without a
  15.  * source license. 
  16.  */
  17.  
  18. /*
  19.  * OS-9/68000 BETA RELEASE!!!
  20.  *
  21.  * Pls send comments, suggestions or bug reports (including diffs) to
  22.  *            weo@recco.chi.sub.org
  23.  */
  24.  
  25. #include <stdio.h>
  26. #include <types.h>
  27. #include <sys/stat.h>
  28. #include <ctype.h>
  29. #include <direct.h>
  30. #include <dir.h>
  31. #include <modes.h>
  32.  
  33. #define TRUE  1
  34. #define FALSE 0
  35.  
  36. extern int errno;
  37.  
  38. #define STRCMP(a,b)  ((*(a) != *(b)) ? (*(a)-*(b)) : strcmp((a)+1, (b)+1))
  39. #define STRNCMP(a,b,n)  ((*(a) != *(b)) ? (*(a)-*(b)) : strncmp(a, b, n))
  40.  
  41. long Now;
  42.  
  43. /* Various UUCP specific defines */
  44. #define CMDPRE  'C'
  45. #define MAXBASENAME  15
  46. #define SYSNSIZE  (6)  /* system name length */
  47. #define FILENAMELEN  (MAXBASENAME + 1 + 2)  /* uucp filename length */
  48. #define DEBUG(level, format, param) if (Debug >= level) fprintf(stderr, format, param); else
  49.  
  50. #define SENDMAIL   "smail"
  51. #define BLKSIZE    ((BUFSIZ/(FILENAMELEN)) - 1)
  52.  
  53.  
  54. # define Csubfile(x)  x
  55. # define Dsubfile(x)  x
  56. # define Xsubfile(x)  x
  57.  
  58. #include <strings.h>
  59.  
  60. void checkfiles();
  61. void fail();
  62. void warn();
  63. void print_message();
  64. void usage();
  65.  
  66. extern char *info_str();
  67.  
  68. struct flist {
  69.   char fname[BLKSIZE][FILENAMELEN];
  70.   int nused;
  71.   struct flist *next;
  72. };
  73.  
  74. struct flist warnlist;
  75. FILE         *warnfp;
  76.  
  77. char *Spool = "/h0/SPOOL/UUCP";
  78. char _Spool[120];
  79. char myuucpname[FILENAMELEN];
  80.  
  81. #define WARNFILE ".LOG/warnlist.mail"
  82.  
  83. int warntime = 24 * 3;    /* default hours before sending a warning */
  84. int failtime = 24 * 14;    /* default hours before returning the mail */
  85.  
  86. int Debug = 0;
  87. int nflag = 0;
  88.  
  89. void usage();
  90.  
  91. /*
  92.  * m a i n
  93.  */
  94. main(argc, argv)
  95.   char **argv;
  96. {
  97.   int  c;
  98.   int  i, j;
  99.   char *cp;
  100.  
  101.   if ((cp = info_str("UUCP.SPOOL", _Spool, sizeof(_Spool))) != NULL)
  102.     Spool = cp;
  103.  
  104.   for (i = 1; i < argc; i++)
  105.     if (argv[i][0] == '-')
  106.       for (j = 1; j < strlen(argv[i]); j++)
  107.         switch (tolower(argv[i][j])) {
  108.           case '?':
  109.             usage();
  110.             exit(1);
  111.           case 's':
  112.             Spool = argv[i] + j + (argv[i][j+1] == '=' ? 2 : 1);
  113.             j = strlen(argv[i]);
  114.             break;
  115.           case 'f':
  116.             failtime = atoi(argv[i] + j +
  117.                             (argv[i][j+1] == '=' ? 2 : 1));
  118.             j = strlen(argv[i]);
  119.             break;
  120.           case 'w':
  121.             warntime = atoi(argv[i] + j +
  122.                             (argv[i][j+1] == '=' ? 2 : 1));
  123.             j = strlen(argv[i]);
  124.             break;
  125.           case 'x':
  126.             Debug = atoi(argv[i] + j +
  127.                          (argv[i][j+1] == '=' ? 2 : 1));
  128.             j = strlen(argv[i]);
  129.             break;
  130.           case 'h':
  131.             strncpy(myuucpname,
  132.                     argv[i] + j + (argv[i][j+1] == '=' ? 2 : 1), 
  133.                     FILENAMELEN);
  134.             j = strlen(argv[i]);
  135.             break;
  136.           case 'n':
  137.             nflag = TRUE;
  138.             break;
  139.         }
  140.  
  141.   if (myuucpname[0] == '\0') {
  142.     register char *p;
  143.  
  144.     if (gethostname(myuucpname, FILENAMELEN) == NULL)
  145.       exit(_errmsg(1, "Can't determine hostname"));
  146.  
  147.     p = index(myuucpname, '.');
  148.     if (p)
  149.       *p = '\0';
  150.   }
  151.  
  152.   setuid(getmuid());
  153.  
  154.   if (chdir(Spool) < 0)
  155.     exit(_errmsg(errno, "Can't change to spooldirectory"));
  156.  
  157.   init_warnedlist(WARNFILE);
  158.  
  159.   checkfiles(".");
  160.   exit(0);
  161. }
  162.  
  163.  
  164. /*
  165.  * c h e c k f i l e s
  166.  *
  167.  * scan a directory looking for "old" control files. For each
  168.  * one found, call fail or warn as appropriate. 
  169.  */
  170. void checkfiles(dir)
  171.   char *dir;
  172. {
  173.   register DIR *dirp;
  174.   register struct direct *dentp;
  175.   struct stat stbuf;
  176.   int hours;
  177.   int clen;
  178.  
  179.   (void) time(&Now);
  180.  
  181.   DEBUG(5, "checkfiles(%s)\n", dir);
  182.  
  183.   if ((dirp = opendir(dir)) == NULL) {
  184.     _errmsg(errno, "directory unreadable");
  185.     return;
  186.   }
  187.  
  188.   while ((dentp = readdir(dirp)) != NULL) {
  189.     if (dentp->d_name[0] != CMDPRE)
  190.       continue;
  191.  
  192.     clen = strlen(dentp->d_name) - 4;
  193.     if ((clen > 0) && (STRCMP("POLL", &dentp->d_name[clen]) == 0))
  194.       continue;
  195.  
  196.     DEBUG(9, "stat %s\n", dentp->d_name);
  197.     if (stat(Csubfile(dentp->d_name), &stbuf) == -1) {
  198.       if (Debug >= 4)
  199.         _errmsg(errno, "stat failed: %s\n", Csubfile(dentp->d_name));
  200.       continue;
  201.     }
  202.     if ((stbuf.st_mode & S_IFMT) == S_IFDIR)
  203.       continue;
  204.  
  205.     hours = (int) (Now - stbuf.st_mtime) / 3600;
  206.     DEBUG(9, "%d hours old\n", hours);
  207.     if (hours >= failtime)
  208.       fail(dentp->d_name, hours);
  209.     else
  210.       if (hours >= warntime)
  211.         warn(dentp->d_name, hours);
  212.   }
  213. }
  214.  
  215.  
  216. /*
  217.  * f a i l
  218.  *
  219.  * send a failure message to the sender and delete the mail. 
  220.  */
  221. void fail(cmdfile, hours)
  222.   char *cmdfile;
  223.   int  hours;
  224. {
  225.   char          dfile[FILENAMELEN], xfile[FILENAMELEN];
  226.   char          host[FILENAMELEN];
  227.   register char *from, **to;
  228.   char          *sender(), **recipients();
  229.   FILE          *out, *popen();
  230.   char          cmd[BUFSIZ];
  231.  
  232.  
  233.   DEBUG(4, "fail called on %s\n", cmdfile);
  234.   if (getfnames(cmdfile, dfile, xfile) < 0)
  235.     return;
  236.  
  237.   if (xfile[0] == '\0' || (to = recipients(xfile)) == NULL)
  238.     return;
  239.   if (dfile[0] == '\0' || (from = sender(dfile)) == NULL)
  240.     return;
  241.  
  242.   strcpy(host, &cmdfile[2]);
  243.   host[strlen(cmdfile) - SYSNSIZE] = '\0';
  244.  
  245. /*  sprintf(cmd, "%s -t", SENDMAIL);*/
  246.   sprintf(cmd, "%s -R %s", SENDMAIL, from);
  247.   DEBUG(1, "Failed: From: %s\n\tTo:", from);
  248.  
  249.   if (nflag) {
  250.     out = stdout;
  251.     fflush(stderr);
  252.     printf("\nFile: %s\n", cmdfile);
  253.   }
  254.   else
  255.     out = popen(cmd, "w");
  256.  
  257.   fprintf(out, "From: MAILER-DAEMON\nSubject: Failed Mail\nTo: %s\n\n",
  258.                from);
  259.   fprintf(out, "After %d days (%d hours), your message to the following people:\n\n",
  260.                hours / 24, hours);
  261.  
  262.   /* put out recipents */
  263.   while (*to) {
  264.     DEBUG(1, " %s!", host);
  265.     DEBUG(1, "%s", *to);
  266.     fprintf(out, "\t%s  (host=%s)\n", *to, host);
  267.     to++;
  268.   }
  269.   DEBUG(1, "\n", 0);
  270.  
  271.   fprintf(out, "\ncould not be delivered.\n\n");
  272.   fprintf(out, "   ----- Unsent message follows -----   \n");
  273.  
  274.   /* print all of the message */
  275.   print_message(dfile, out, 0);
  276.  
  277.   if (nflag)
  278.     return;
  279.   pclose(out);
  280.  
  281.   (void) unlink(Csubfile(cmdfile));
  282.   (void) unlink(Dsubfile(dfile));
  283.   (void) unlink(Dsubfile(xfile));
  284. }
  285.  
  286. /*
  287.  * w a r n
  288.  *
  289.  * send a warning message to the sender and add the control file to
  290.  * the list of files for which warnings have been sent. 
  291.  */
  292. void warn(cmdfile, hours)
  293.   char *cmdfile;
  294.   int  hours;
  295. {
  296.   char dfile[FILENAMELEN], xfile[FILENAMELEN];
  297.   char host[FILENAMELEN];
  298.   char *from, **to;
  299.   char *sender(), **recipients();
  300.   FILE *out, *popen();
  301.   char cmd[BUFSIZ];
  302.  
  303.   if (in_warnedlist(cmdfile))
  304.     return;
  305.  
  306.   DEBUG(4, "warn called on %s\n", cmdfile);
  307.   if (getfnames(cmdfile, dfile, xfile) < 0) {
  308.     DEBUG(5, "getfnames(%s) failed\n", cmdfile);
  309.     return;
  310.   }
  311.  
  312.   if ((to = recipients(xfile)) == NULL || (from = sender(dfile)) == NULL)
  313.     return;
  314.  
  315.   strcpy(host, &cmdfile[2]);
  316.   host[strlen(cmdfile) - SYSNSIZE] = '\0';
  317.  
  318.   sprintf(cmd, "%s -R %s", SENDMAIL, from);
  319.   DEBUG(1, "Warning: From: %s\n\tTo:", from);
  320.   if (nflag) {
  321.     out = stdout;
  322.     fflush(stderr);
  323.     printf("\nFile: %s\n", cmdfile);
  324.   }
  325.   else
  326.     out = popen(cmd, "w");
  327.  
  328.   fprintf(out, "From: MAILER-DAEMON\nSubject: Waiting Mail\nTo: %s\n\n",
  329.                from);
  330.   fprintf(out, "After %d days (%d hours), your message to the following people:\n\n",
  331.                hours / 24, hours);
  332.  
  333.   /* put out recipents */
  334.   while (*to) {
  335.     DEBUG(1, " %s!", host);
  336.     DEBUG(1, "%s", *to);
  337.     fprintf(out, "\t%s  (host=%s)\n", *to, host);
  338.     to++;
  339.   }
  340.   DEBUG(1, "\n", 0);
  341.  
  342.   fprintf(out, "\nhas not yet been delivered. Attempts to deliver the message will\n");
  343.   fprintf(out, "continue for %d more days. No further action is required by you.\n\n", (failtime - hours) / 24);
  344.   fprintf(out, "   ----- Queued message begins -----   \n");
  345.  
  346.   /* print a summary of the message */
  347.   print_message(dfile, out, 1);
  348.   if (nflag)
  349.     return;
  350.  
  351.   pclose(out);
  352.  
  353.   fprintf(warnfp, "%s\n", cmdfile);
  354. }
  355.  
  356. /*
  357.  * g e t f n a m e s
  358.  *
  359.  * read the control file to find the data and execute files
  360.  * which contain the message and list of recipients. dfile is set to the
  361.  * datafile, xfile to the execute file. 
  362.  */
  363. getfnames(cmdfile, dfile, xfile)
  364.   char *cmdfile;
  365.   char *dfile;
  366.   char *xfile;
  367. {
  368.   register FILE *fp;
  369.   register char *s, *d;
  370.   register int  n;
  371.   char          buf[BUFSIZ];
  372.  
  373.   DEBUG(5, "getfnames(%s) called\n", cmdfile);
  374.  
  375.   if ((fp = fopen(Csubfile(cmdfile), "r")) == NULL) {
  376.     _errmsg(errno, "Can't open %s\n", Csubfile(cmdfile));
  377.     return(-1);
  378.   }
  379.   if (fgets(buf, BUFSIZ, fp) == NULL) {
  380.     DEBUG(7, "fgets dfile %s failed\n", cmdfile);
  381.     fclose(fp);
  382.     return(-1);
  383.   }
  384.  
  385.   s = buf;
  386.   d = dfile;
  387.   while (*s != '\0' && *s++ != ' ') ;    /* skip first argument */
  388.  
  389.   n = FILENAMELEN - 1;
  390.  
  391.   do {
  392.     *d++ = *s;
  393.   } while (*s != '\0' && *s != ' ' && *s++ != '\n' && --n);
  394.  
  395.   d[-1] = '\0';
  396.   DEBUG(5, "dfile set to %s\n", dfile);
  397.  
  398.   if (fgets(buf, BUFSIZ, fp) == NULL) {
  399.     DEBUG(7, "fgets xfile %s failed\n", cmdfile);
  400.     fclose(fp);
  401.     return(-1);
  402.   }
  403.  
  404.   s = buf;
  405.   d = xfile;
  406.   while (*s != '\0' && *s++ != ' ') ;    /* skip first argument */
  407.  
  408.   n = FILENAMELEN - 1;
  409.   do {
  410.     *d++ = *s;
  411.   } while (*s != '\0' && *s != ' ' && *s++ != '\n' && --n);
  412.  
  413.   d[-1] = '\0';
  414.   DEBUG(5, "xfile set to %s\n", xfile);
  415.  
  416.   fclose(fp);
  417.   return(0);
  418. }
  419.  
  420. /*
  421.  * r e c i p i e n t s
  422.  *
  423.  * returns a list of recipients that the mail was intended for,
  424.  * or NULL if the execute file is not a mail file. 
  425.  */
  426. char **recipients(xfile)
  427.   char *xfile;
  428. {
  429.   static char   rbuf[BUFSIZ];
  430.   static char   *tobuf[BUFSIZ*2];  /* see uuxqt */
  431.   register FILE *fp;
  432.   register char *p, **t;
  433.  
  434.   DEBUG(7, "recipients(%s)\n", xfile);
  435.   if ((fp = fopen(Dsubfile(xfile), "r")) == NULL) {
  436.     _errmsg(errno, "can't open %s\n", Dsubfile(xfile));
  437.     return(NULL);
  438.   }
  439.  
  440.   while (fgets(rbuf, BUFSIZ, fp) != NULL) {
  441.     if (rbuf[0] == 'C' && STRNCMP(rbuf, "C rmail ", 8) == 0) {
  442.  
  443.       /* turn into an array of addresses */
  444.       for (p = &rbuf[8], t = tobuf; *p;) {
  445.         while (*p == ' ' || *p == '\n')
  446.           *p++ = '\0';
  447.         *t = p;
  448.         while (*p && *p != ' ' && *p != '\n')
  449.           p++;
  450.         if (*t != p)
  451.           t++;
  452.       }
  453.       *t = NULL;
  454.       fclose(fp);
  455.       return(tobuf);
  456.     }
  457.   }
  458.  
  459.   fclose(fp);
  460.   return(NULL);
  461. }
  462.  
  463. char *badnames[] = {
  464.   "daemon",
  465.   "/dev/null",
  466.   "mailer",
  467.   "postmaster",
  468.   "netlib",
  469.   "netlibd",
  470.   "listserv",
  471.   "uucp",
  472.   "news",
  473.   "usenet",
  474.   0
  475. };
  476.  
  477. char *badsuffix[] = {
  478.   "archive",
  479.   "daemon",
  480.   "sender",
  481.   "mailer",
  482.   "relay",
  483.   "request",
  484.   "reply",
  485.   "server",
  486.   0
  487. };
  488.  
  489. /*
  490.  * s e n d e r
  491.  * 
  492.  * returns the sender address from the uucp from line, or NULL if
  493.  * not found. 
  494.  */
  495. char *sender(dfile)
  496.   char *dfile;
  497. {
  498.   static char   buf[BUFSIZ];
  499.   char          username[BUFSIZ];
  500.   register char *senderof, *cp, **bname;
  501.   register FILE *fp;
  502.  
  503.   DEBUG(7, "sender(%s)\n", dfile);
  504.   if ((fp = fopen(Dsubfile(dfile), "r")) == NULL) {
  505.     _errmsg(errno, "Can't open %s\n", Dsubfile(dfile));
  506.     return(NULL);
  507.   }
  508.  
  509.   if (fgets(buf, BUFSIZ, fp) == NULL)
  510.     return(NULL);
  511.   fclose(fp);
  512.  
  513.   senderof = index(buf, ' ');
  514.   if (senderof++ == '\0')
  515.     return(NULL);
  516.   cp = index(senderof, ' ');
  517.   if(cp != NULL)
  518.     *cp = '\0';
  519.  
  520.   /* pick of the username */
  521.   cp = rindex(senderof, '!');  /* try uucp style */
  522.   if (cp != NULL)
  523.     strcpy(username, cp+1);
  524.   else {                      /* try arpa style */
  525.     cp = index(senderof, '@');
  526.     if (cp == NULL)
  527.       return(senderof);
  528.     strcpy(username, senderof);
  529.     cp  = index(username, '@');
  530.     *cp = '\0';
  531.   }
  532.  
  533.   /* lower case username so get case independent strcmp */
  534.   cp = username;
  535.   do {
  536.     if (isupper(*cp))
  537.       *cp = tolower(*cp);
  538.   } while (*cp++ != '\0');
  539.  
  540.   DEBUG(7,"checking username \"%s\"\n", username);
  541.  
  542.   /* some lists begin with info- */
  543.  
  544.   if (STRNCMP(username, "info-", 5) == 0) {
  545.     DEBUG(7, "Not warning %s\n", senderof);
  546.     return(NULL);
  547.   }
  548.  
  549.   cp = rindex(username, '-');
  550.   if (cp++ == NULL) {
  551.     bname = badnames;
  552.     cp = username;
  553.   }
  554.   else
  555.     bname = badsuffix;
  556.  
  557.  
  558.   while (*bname != NULL) {
  559.     DEBUG(9, "\tcomparing against %s\n", *bname);
  560.     if (STRCMP(*bname, cp) == 0) {
  561.       DEBUG(7, "Not warning %s\n", senderof);
  562.       return(NULL);
  563.     }
  564.     bname++;
  565.   }
  566.  
  567.   return(senderof);
  568. }
  569.  
  570. /*
  571.  * p r i n t _ m e s s a g e
  572.  *
  573.  * print the message in "dfile" on the stream "outp". If
  574.  * the edited flag is set, then only print some interesting headers and the
  575.  * first few lines of the body. 
  576.  */
  577. void print_message(dfile, outp, edited)
  578.   char          *dfile;
  579.   register FILE *outp;
  580.   int           edited;
  581. {
  582.   register FILE *dfp;
  583.   char          buf[BUFSIZ];
  584.   int           iflg, linecount;
  585.  
  586.   if ((dfp = fopen(Dsubfile(dfile), "r")) == NULL)
  587.     return;
  588.  
  589.   /* skip unix from line */
  590.   fgets(buf, BUFSIZ, dfp);
  591.  
  592.   /* print header */
  593.   iflg = 0;
  594.   while (fgets(buf, BUFSIZ, dfp) != NULL && buf[0] != '\n') {
  595.     if (edited) {
  596.       if (buf[0] == '\t' || buf[0] == ' ') {
  597.         if (iflg)
  598.           fputs(buf, outp);
  599.         continue;
  600.       }
  601.       if (!interested(buf)) {
  602.         iflg = 0;
  603.         continue;
  604.       }
  605.       iflg = 1;
  606.     }
  607.     fputs(buf, outp);
  608.   }
  609.   putc('\n', outp);
  610.  
  611.   /* print body */
  612.   linecount = 0;
  613.   while (fgets(buf, BUFSIZ, dfp) != NULL) {
  614.     if (edited && ++linecount > 5) {
  615.       fprintf(outp, ".....\n");
  616.       break;
  617.     }
  618.     fputs(buf, outp);
  619.   }
  620.   fclose(dfp);
  621. }
  622.  
  623. static char *headers[] = {
  624.   "From:",
  625.   "Date:",
  626.   "To:",
  627.   "Cc:",
  628.   "Subject:",
  629.   0
  630. };
  631.  
  632. /*
  633.  * i n t e r e s t e d
  634.  *
  635.  * determine whether "hdr" is considered interesting and thus
  636.  * should be printed in edited mode. 
  637.  */
  638. interested(hdr)
  639.   char *hdr;
  640. {
  641.   register char **hp = headers;
  642.  
  643.   while (*hp) {
  644.     if (STRNCMP(hdr, *hp, strlen(*hp)) == 0)
  645.       return(1);
  646.     hp++;
  647.   }
  648.   return(0);
  649. }
  650.  
  651. /*
  652.  * i n i t _ w a r n e d l i s t
  653.  *
  654.  * Initialise list of files for which warning messages have already been
  655.  * sent. This involves reading the warnfile into a table, removing files
  656.  * which no longer exist (i.e. been sent or deleted), and writing this out
  657.  * again. 
  658.  */
  659. init_warnedlist(warnfile)
  660. char *warnfile;
  661. {
  662.   register struct flist *wp;
  663.   register char *p;
  664.   register int i;
  665.   char warned[FILENAMELEN];
  666.  
  667.   wp = &warnlist;
  668.   wp->next = NULL;
  669.   wp->nused = 0;
  670.  
  671.   if ((warnfp = fopen(warnfile, "r")) != NULL) {
  672.     while (fgets(warned, FILENAMELEN, warnfp) != NULL) {
  673.       if(warned[0] == '\n')
  674.           continue;
  675.       if ((p = index(warned, '\n')) != NULL)
  676.         *p = '\0';
  677.  
  678.       if (access(Csubfile(warned), S_IREAD) == 0) {
  679.         if (wp->nused >= BLKSIZE) {
  680.           wp->next = (struct flist *) malloc(sizeof(warnlist));
  681.           wp = wp->next;
  682.           wp->next = (struct flist *) NULL;
  683.           wp->nused = 0;
  684.         }
  685.         strcpy(wp->fname[wp->nused], warned);
  686.         wp->nused++;
  687.       }
  688.     }
  689.     fclose(warnfp);
  690.   }
  691.   /*
  692.    * Rewrite warnedlist removing files that no longer exist. Could be
  693.    * really paranoid here and create a temporary file first, rather
  694.    * than overwrite; in case of crashed 
  695.    */
  696.   if ((warnfp = fopen(warnfile, "w")) != NULL) {
  697.     wp = &warnlist;
  698.     while (wp) {
  699.       for (i = 0; i < wp->nused; i++)
  700.         fprintf(warnfp, "%s\n", wp->fname[i]);
  701.       wp = wp->next;
  702.     }
  703.     fflush(warnfp);
  704.   }
  705. }
  706.  
  707. /*
  708.  * i n _ w a r n e d l i s t
  709.  *
  710.  * Determine whether the given filename is in the warn list. Returns 1 if
  711.  * found, 0 otherwise. 
  712.  * 
  713.  * This should really use some clever hashing scheme, but the cpu
  714.  * time spent traversing this list is only 1% of total.
  715.  */
  716. in_warnedlist(file)
  717.   register char *file;
  718. {
  719.   register struct flist *wp = &warnlist;
  720.   register int i;
  721.  
  722.   while (wp) {
  723.     for (i = 0; i < wp->nused; i++) {
  724.       if (STRCMP(file, wp->fname[i]) == 0)
  725.         return(1);
  726.     }
  727.     wp = wp->next;
  728.   }
  729.   return(0);
  730. }
  731.  
  732. char DLocalX[FILENAMELEN], DLocal[FILENAMELEN];
  733.  
  734. static char *dprefix[] = {
  735.   DLocalX,  /* Outbound 'xqt' request files */
  736.   DLocal,    /* Outbound data files */
  737.   "D.",    /* Other "D." files (remember the "."!) */
  738.   "C.",    /* "C." subdirectory */
  739.   "X.",    /* "X." subdirectory */
  740.   "TM.",    /* Temporaries for inbound files */
  741.   0
  742. };
  743.  
  744. /*
  745.  * u s a g e
  746.  */
  747. void usage()
  748. {
  749.   fputs("Syntax: uumailclean [<opts>]\n", stderr);
  750.   fputs("Function: warn/delete very old mails\n", stderr);
  751.   fputs("Options:\n", stderr);
  752.   fputs("      -s=<path>      spool directory\n", stderr);
  753.   fputs("      -f=<time>      fail time [hours]\n", stderr);
  754.   fputs("      -w=<time>      warn time [hours]\n", stderr);
  755.   fputs("      -x=<level>     debug level\n", stderr);
  756.   fputs("      -h=<hostname>  host name\n", stderr);
  757.   fputs("      -n             only display, no actions\n", stderr);
  758. }
  759.