home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / ListSERV1_4.lha / ListSERV / source / RCS / main.c,v < prev    next >
Encoding:
Text File  |  1993-12-29  |  23.7 KB  |  935 lines

  1. head    1.9;
  2. branch    1.9.1;
  3. access;
  4. symbols;
  5. locks
  6.     simons:1.9.1.15
  7.     andy:1.9; strict;
  8. comment    @ * @;
  9.  
  10.  
  11. 1.9
  12. date    93.02.25.16.04.13;    author andy;    state Exp;
  13. branches
  14.     1.9.1.1;
  15. next    ;
  16.  
  17. 1.9.1.1
  18. date    93.12.26.00.42.01;    author simons;    state Exp;
  19. branches;
  20. next    1.9.1.2;
  21.  
  22. 1.9.1.2
  23. date    93.12.26.00.51.59;    author simons;    state Exp;
  24. branches;
  25. next    1.9.1.3;
  26.  
  27. 1.9.1.3
  28. date    93.12.26.00.53.53;    author simons;    state Exp;
  29. branches;
  30. next    1.9.1.4;
  31.  
  32. 1.9.1.4
  33. date    93.12.26.18.45.38;    author simons;    state Exp;
  34. branches;
  35. next    1.9.1.5;
  36.  
  37. 1.9.1.5
  38. date    93.12.26.19.35.55;    author simons;    state Exp;
  39. branches;
  40. next    1.9.1.6;
  41.  
  42. 1.9.1.6
  43. date    93.12.26.21.22.27;    author simons;    state Exp;
  44. branches;
  45. next    1.9.1.7;
  46.  
  47. 1.9.1.7
  48. date    93.12.27.17.24.01;    author simons;    state Exp;
  49. branches;
  50. next    1.9.1.8;
  51.  
  52. 1.9.1.8
  53. date    93.12.28.00.18.12;    author simons;    state Exp;
  54. branches;
  55. next    1.9.1.9;
  56.  
  57. 1.9.1.9
  58. date    93.12.28.17.00.52;    author simons;    state Exp;
  59. branches;
  60. next    1.9.1.10;
  61.  
  62. 1.9.1.10
  63. date    93.12.28.17.37.42;    author simons;    state Exp;
  64. branches;
  65. next    1.9.1.11;
  66.  
  67. 1.9.1.11
  68. date    93.12.28.21.57.37;    author simons;    state Exp;
  69. branches;
  70. next    1.9.1.12;
  71.  
  72. 1.9.1.12
  73. date    93.12.28.22.16.34;    author simons;    state Exp;
  74. branches;
  75. next    1.9.1.13;
  76.  
  77. 1.9.1.13
  78. date    93.12.29.06.24.47;    author simons;    state Exp;
  79. branches;
  80. next    1.9.1.14;
  81.  
  82. 1.9.1.14
  83. date    93.12.29.07.07.06;    author simons;    state Exp;
  84. branches;
  85. next    1.9.1.15;
  86.  
  87. 1.9.1.15
  88. date    93.12.29.07.26.54;    author simons;    state Exp;
  89. branches;
  90. next    ;
  91.  
  92.  
  93. desc
  94. @Original Unix-Listserv distribution.
  95. @
  96.  
  97.  
  98. 1.9
  99. log
  100. @checked in with -k by simons at 1993/12/26 00:08:53
  101. @
  102. text
  103. @#include "listserv.h"
  104.  
  105. static char rcsid[] = "$Header: /nfs/ucsd/local/src/mail/listserv/RCS/main.c,v 1.9 93/02/25 16:04:13 andy Exp Locker: andy $";
  106.  
  107. FILE *mailer;
  108. FILE *logfile;
  109.  
  110. main(argc,argv)
  111. int argc;
  112. char **argv;
  113.         {
  114.         char from[256];
  115.         char buf[BUFSIZ];
  116.         char grp[64];
  117.         char dat[64];
  118.         char *p;
  119.         int i;
  120.         int gotcommand = 0;
  121.         int outsider = 0;
  122.         int inheader;
  123.         int log;
  124.         int garbage = 0;
  125.  
  126.         /* gotta have some default if the From: line is missing */
  127.         strcpy(from, "ListServ");
  128.  
  129.         inheader = 1;
  130.         while (fgets(buf,BUFSIZ,stdin) != NULL)
  131.                 {
  132.                 /* drop trailing newline */
  133.                 while (buf[(i=strlen(buf)-1)] == '\n')
  134.                         buf[i] = '\0';
  135.  
  136.                 /* drop trailing blanks */
  137.                 p = buf + (strlen(buf) - 1);
  138.                 while (p && *p && p >= buf && isspace(*p))
  139.                         *p-- = '\0';
  140.  
  141.                 /* deblank beginning of line */
  142.                 p = buf;
  143.                 while (p && *p && isspace(*p))
  144.                         p++;
  145.                 if (p != buf)
  146.                         strcpy(buf, p);
  147.  
  148.                 if (strlen(buf) == 0)   /* blank line ends header */
  149.                         {
  150.                         inheader = 0;
  151.                         continue;
  152.                         }
  153.  
  154.                 /*
  155.                 get the From: line so we can return the answer
  156.  
  157.                 Note that we DON'T check that we're in the header when
  158.                 picking up the From: line; that's so that we'll take the
  159.                 last from line we encounter which makes it handle
  160.                 forwarded messages correctly.
  161.                 */
  162.                 if (strncasecmp(buf,"From: ",6) == 0)
  163.                         {
  164.                         strcpy(from, &buf[6]);
  165.                         cleanup(from, &outsider);
  166.                         printf("outsider = %d\n", outsider);
  167.                         continue;
  168.                         }
  169.                 if (strncasecmp(buf, "From: listserv", 14) == 0
  170.                 || strncasecmp(buf,
  171.                         "subject: re: your listserve request", 35) == 0)
  172.                         {
  173.                         printf("loop detected, flushing mail\n");
  174.                         exit(0);
  175.                         }
  176.  
  177.                 /*
  178.                 don't look for commands in the header
  179.                 */
  180.                 if (inheader)
  181.                         continue;
  182.  
  183.                 /* avoid mail loops - ignore requests from ourself! */
  184.                 if (!strncasecmp(from, "listserv", 8))
  185.                         {
  186.                         printf("I refuse to talk to myself.\n");
  187.                         exit(0);
  188.                         }
  189.  
  190.                 /* Throw away bounced mail */
  191.                 if (strstr(from, "daemon") != NULL)
  192.                         {
  193.                         printf("We don't do business with your type.\n");
  194.                         exit(0);
  195.                         }
  196.  
  197.                 /* force to lower case and scan for commands */
  198.                 p = buf;
  199.                 while (p && *p)
  200.                         {
  201.                         if (isupper(*p))
  202.                                 *p = tolower(*p);
  203.                         p++;
  204.                         }
  205.  
  206.                 /* log the request */
  207.                 log = open(LOGFILE, AFLAGS, AMODE);
  208.                 if (log == -1)
  209.                         perror(LOGFILE);
  210.                 else
  211.                         {
  212.                         logfile = fdopen(log, "a");
  213.                         if (logfile != NULL)
  214.                                 {
  215.                                 long clock = time(0);
  216.                                 strcpy(dat,ctime(&clock));
  217.                                 /* drop trailing newline */
  218.                                 while (dat[(i=strlen(dat)-1)] == '\n')
  219.                                         dat[i] = '\0';
  220.                                 printf("logfile: %s|%s|%s\n", dat, from, buf);
  221.                                 fprintf(logfile,"%s|%s|%s\n", dat, from, buf);
  222.                                 fflush(logfile);
  223.                                 close(log);
  224.                                 }
  225.                         else
  226.                                 perror(LOGFILE);
  227.                         }
  228.  
  229.                 if (!strncasecmp(buf, "list ",5)
  230.                 || !strncasecmp(buf, "delete-all ",11)
  231.                 || !strncasecmp(buf, "del-all ",8)
  232.                 || !strncasecmp(buf, "unsubscribe-all ",16)
  233.                 || !strncasecmp(buf, "unsub-all ",10)
  234.                 || !strcasecmp(buf, "list")
  235.                 || !strcasecmp(buf, "delete-all")
  236.                 || !strcasecmp(buf, "del-all")
  237.                 || !strcasecmp(buf, "unsubscribe-all")
  238.                 || !strcasecmp(buf, "unsub-all"))
  239.                         {
  240.                         gotcommand++;
  241.                         listsearch(from, buf);
  242.                         continue;
  243.                         }
  244.  
  245.                 if (!strncasecmp(buf,"add ", 4)
  246.                 || !strncasecmp(buf,"subscribe ", 10)
  247.                 || !strncasecmp(buf,"sub ",4))
  248.                         {
  249.                         gotcommand++;
  250.                         subscription(from,buf,1,outsider);
  251.                         continue;
  252.                         }
  253.  
  254.                 if (!strncasecmp(buf,"delete ", 7)
  255.                 || !strncasecmp(buf,"del ",4)
  256.                 || !strncasecmp(buf,"unsubscribe ", 12)
  257.                 || !strncasecmp(buf,"unsub ",6))
  258.                         {
  259.                         gotcommand++;
  260.                         subscription(from,buf,0,outsider);
  261.                         continue;
  262.                         }
  263.  
  264.                 if (!strcasecmp(buf,"index")
  265.                 || !strcasecmp(buf,"longindex"))
  266.                         {
  267.                         gotcommand++;
  268.                         sendindex(from,buf,!strcasecmp(buf,"longindex"),
  269.                                 outsider);
  270.                         continue;
  271.                         }
  272.  
  273.                 if (!strncasecmp(buf, "faq ", 4))
  274.                         {
  275.                         gotcommand++;
  276.                         sendfaq(from, buf, outsider);
  277.                         continue;
  278.                         }
  279.  
  280.                 if (!strcasecmp(buf, "faq"))
  281.                         {
  282.                         gotcommand++;
  283.                         faqindex(from, buf);
  284.                         continue;
  285.                         }
  286.  
  287.                 if (!strcasecmp(buf, "info"))
  288.                         {
  289.                         gotcommand++;
  290.                         infoindex(from, buf);
  291.                         continue;
  292.                         }
  293.  
  294.                 if (!strncasecmp(buf, "info ", 5)
  295.                 || !strncasecmp(buf, "get ",4))
  296.                         {
  297.                         gotcommand++;
  298.                         sendinfo(from, buf);
  299.                         continue;
  300.                         }
  301.  
  302.                 if (!strcasecmp(buf,"help"))
  303.                         {
  304.                         gotcommand++;
  305.                         sendhelp(from,buf);
  306.                         continue;
  307.                         }
  308.  
  309.                 if (!strncasecmp(buf,"help ",5))
  310.                         {
  311.                         gotcommand++;
  312.                         sscanf(buf,"%*s%s", grp);
  313.                         listhelp(from,grp,buf,outsider);
  314.                         continue;
  315.                         }
  316.                 /* Flush message if > 5 lines of garbage */
  317.                 if (++garbage > 5)
  318.                         {
  319.                         printf("Garbled message, flushing...\n");
  320.                         exit(0);
  321.                         }
  322.                 }
  323.         if (gotcommand == 0)
  324.                 sendhelp(from, "indecipherable");
  325.         exit(0);
  326.         }
  327.  
  328. callmailer(redirect, toaddr, request)
  329. char *redirect, *toaddr, *request;
  330.         {
  331.         char cbuf[BUFSIZ];
  332.  
  333.         printf("callmailer \"%s\",\"%s\",\"%s\"\n", redirect, toaddr, request);
  334.  
  335.         strcpy(cbuf, MAILER);
  336.         strcat(cbuf, " -f");
  337.         strcat(cbuf, LISTSERVMANAGER);
  338.         strcat(cbuf, " -F\"Mailing List Processor\"");
  339.         strcat(cbuf, " -t -oi");
  340.         strcat(cbuf, " "); strcat(cbuf, redirect);
  341.         mailer = popen(cbuf,"w");
  342.         printf("mailer popen '%s'\n", cbuf);
  343.         if (mailer == NULL)
  344.                 {
  345.                 perror(cbuf);
  346.                 exit(1);
  347.                 }
  348.         fprintf(mailer,"From: ");
  349.         fprintf(mailer, LISTSERVADDR);
  350.         fprintf(mailer, " (Mailing List Processor)\n");
  351.         fprintf(mailer,"To: %s\n", toaddr);
  352.         fprintf(mailer,"Subject: Re: your LISTSERV request \"%s\"\n", request);
  353.         fprintf(mailer,"\n");
  354.         }
  355.  
  356. mailcat(mfname,prefix)
  357. char *mfname, *prefix;
  358.         {
  359.         FILE *mf;
  360.         char buf[BUFSIZ];
  361.  
  362.         printf("mailcat \"%s\", \"%s\"\n", mfname, prefix);
  363.  
  364.         mf = fopen(mfname,"r");
  365.         if (mf == NULL)
  366.                 {
  367.                 perror(mfname);
  368.                 fprintf(mailer,"This should have been the contents of\n");
  369.                 fprintf(mailer,"file '%s' but it's missing!\n",mfname);
  370.                 return;
  371.                 }
  372.  
  373.         /* copy the message file into the mailer */
  374.         while (fgets(buf,BUFSIZ,mf) != NULL)
  375.                 {
  376.                 fputs(prefix,mailer);
  377.                 fputs(buf,mailer);
  378.                 }
  379.         fclose(mf);
  380.         return;
  381.         }
  382.  
  383. cleanup(from, outsider)
  384. char *from;
  385. int *outsider;
  386.         {
  387.         char *p, *q;
  388.  
  389.         printf("cleanup \"%s\"\n", from);
  390.  
  391.         while (p = index(from,'~'))
  392.                 *p = 'X';
  393.  
  394.         while (p = index(from,'|'))
  395.                 *p = 'X';
  396.  
  397.         /* elide stuff in parenthesis */
  398.         if (p = index(from,'('))
  399.                 {
  400.                 if ( (q=rindex(from,')')) == NULL)
  401.                         {
  402.                         /* zap the from line; it's invalid */
  403.                         *p = '\0';
  404.                         return;
  405.                         }
  406.                 strcpy(p, q+1);
  407.                 }
  408.  
  409.         if (p = index(from,'<'))
  410.                 {
  411.                 if ( (q=index(from,'>')) == NULL)
  412.                         {
  413.                         /* zap the from line; it's invalid */
  414.                         *p = '\0';
  415.                         return;
  416.                         }
  417.                 *q = '\0';
  418.                 strcpy(from, p+1);
  419.                 }
  420.  
  421.         p = from;
  422.  
  423.         /* drop trailing blanks */
  424.         p = from + (strlen(from) - 1);
  425.         while (p && *p && p >= from && isspace(*p))
  426.                 *p-- = '\0';
  427.  
  428.         /* 'outsider' indicates whether it's mail from a local user
  429.                 or not.  'subscribe' uses that to determine whether
  430.                 to acknowledge the existence of the list.  (local users
  431.                 may subscribe to anything with a .info file; others
  432.                 may only subscribe if there is a .pub file)
  433.         */
  434.  
  435.         if (index(from, '!') != NULL)   /* uucp sites are foreign */
  436.                 {
  437.                 *outsider = 1;
  438.                 return;
  439.                 }
  440.         if ((p = index(from, '@@')) == NULL)    /* on-machine user */
  441.                 {
  442.                 *outsider = 0;
  443.                 return;
  444.                 }
  445.  
  446.         if (strcasecmp(p+1, DOMAIN) == 0)
  447.                 {
  448.                 *outsider = 0;
  449.                 return;
  450.                 }
  451.         if ((p = index(p, '.')) == NULL)        /* in-domain user */
  452.                 {
  453.                 *outsider = 0;
  454.                 return;
  455.                 }
  456.         if (strncasecmp(p+1, DOMAIN,8) == 0)
  457.                 {
  458.                 *outsider = 0;
  459.                 return;
  460.                 }
  461.  
  462.         *outsider = 1;
  463.         return;
  464.         }
  465.  
  466. @
  467.  
  468.  
  469. 1.9.1.1
  470. log
  471. @Changed source code to compiler under SAS/C 6.50.
  472. @
  473. text
  474. @a1 1
  475. #include "protos.h"
  476. d3 1
  477. a3 1
  478. static char rcsid[] = "$Id$";
  479. d5 2
  480. a6 1
  481. FILE *mailer, *logfile;
  482. d8 1
  483. a8 1
  484. int main(argc,argv)
  485. d226 1
  486. a226 1
  487. void callmailer(redirect, toaddr, request)
  488. d234 1
  489. a234 1
  490.         strcat(cbuf, " -f ");
  491. d236 2
  492. a237 1
  493.         strcat(cbuf, " -R \"Mailing List Processor\"");
  494. d246 3
  495. d254 1
  496. a254 1
  497. void mailcat(mfname,prefix)
  498. d281 1
  499. a281 1
  500. void cleanup(from, outsider)
  501. @
  502.  
  503.  
  504. 1.9.1.2
  505. log
  506. @callmailer() now uses the redirect parameter as username.
  507. @
  508. text
  509. @d4 1
  510. a4 1
  511. static char rcsid[] = "$Id: main.c,v 1.9.1.1 1993/12/26 00:42:01 simons Exp simons $";
  512. d235 1
  513. a235 1
  514.         strcat(cbuf, (redirect) ? redirect : LISTSERVMANAGER);
  515. d237 1
  516. @
  517.  
  518.  
  519. 1.9.1.3
  520. log
  521. @Test for contents of >redirect< was wrong: In case we have to use the
  522. default, we get an empty string (""), not NULL.
  523. @
  524. text
  525. @d235 1
  526. a235 1
  527.         strcat(cbuf, (*redirect) ? redirect : LISTSERVMANAGER);
  528. @
  529.  
  530.  
  531. 1.9.1.4
  532. log
  533. @Added a short startup-message, containing the name of the program.
  534. @
  535. text
  536. @d4 1
  537. a4 1
  538. static char rcsid[] = "$Id: main.c,v 1.9.1.3 1993/12/26 00:53:53 simons Exp simons $";
  539. a22 2
  540.  
  541.         printf("ListSERV -- amiga version by Peter Simons <simons@@peti.GUN.de>\n");
  542. @
  543.  
  544.  
  545. 1.9.1.5
  546. log
  547. @Removed the complete local/non-local user determination, including
  548. all >outsider< parameters and the cleanup() routine.
  549. Changed UNIX-paths to conform with AmigaDOS.
  550. @
  551. text
  552. @d4 1
  553. a4 1
  554. static char rcsid[] = "$Id: main.c,v 1.9.1.4 1993/12/26 18:45:38 simons Exp simons $";
  555. d19 1
  556. d65 2
  557. d150 1
  558. a150 1
  559.                         subscription(from,buf,1);
  560. d160 1
  561. a160 1
  562.                         subscription(from,buf,0);
  563. d168 2
  564. a169 1
  565.                         sendindex(from,buf,!strcasecmp(buf,"longindex"));
  566. d176 1
  567. a176 1
  568.                         sendfaq(from, buf);
  569. d213 1
  570. a213 1
  571.                         listhelp(from, grp, buf);
  572. d275 83
  573. @
  574.  
  575.  
  576. 1.9.1.6
  577. log
  578. @Added filelocking mechanism.
  579. @
  580. text
  581. @d4 1
  582. a4 1
  583. static char rcsid[] = "$Id: main.c,v 1.9.1.5 1993/12/26 19:35:55 simons Exp simons $";
  584. a103 1
  585.                 LockFile(LOGFILE);
  586. a124 1
  587.                 UnLockFile(LOGFILE);
  588. a254 1
  589.         LockFile(mfname);
  590. a257 1
  591.                 UnLockFile(mfname);
  592. a270 1
  593.         UnLockFile(mfname);
  594. @
  595.  
  596.  
  597. 1.9.1.7
  598. log
  599. @Removed the 'INFO'-command--for the moment.
  600. @
  601. text
  602. @d4 1
  603. a4 1
  604. static char rcsid[] = "$Id: main.c,v 1.9.1.6 1993/12/26 21:22:27 simons Exp simons $";
  605. d185 15
  606. a199 16
  607. /*                if (!strcasecmp(buf, "info"))
  608.  *                       {
  609.  *                       gotcommand++;
  610.  *                       infoindex(from, buf);
  611.  *                       continue;
  612.  *
  613.  *                       }
  614.  *
  615.  *                if (!strncasecmp(buf, "info ", 5)
  616.  *                || !strncasecmp(buf, "get ",4))
  617.  *                        {
  618.  *                        gotcommand++;
  619.  *                        sendinfo(from, buf);
  620.  *                        continue;
  621.  *                        }
  622.  */
  623. @
  624.  
  625.  
  626. 1.9.1.8
  627. log
  628. @Changed the default user that is used in From-line to 'listserv' instead
  629. of postmaster, so people can simply reply to the mails they get.
  630. Added support for C='s bumprev.
  631. Added AmigaDOS version string and changes startupmessage.
  632. @
  633. text
  634. @a2 1
  635. #include "ListSERV_rev.h"
  636. d4 1
  637. a4 1
  638. #define STARTUP "Amiga " VERS " -- written by by Peter Simons <simons@@peti.GUN.de>\n"
  639. a5 3
  640. static char rcssid[] = "$Id: main.c,v 1.9.1.7 1993/12/27 17:24:01 simons Exp simons $";
  641. static char dosid[] = VERSTAG;
  642.  
  643. d23 1
  644. a23 1
  645.         printf(STARTUP);
  646. d236 1
  647. a236 1
  648.         strcat(cbuf, (*redirect) ? redirect : LISTSERVADDR);
  649. a246 1
  650.         fprintf(mailer,"X-ListSERV: Amiga " VERS " (" DATE ")\n");
  651. @
  652.  
  653.  
  654. 1.9.1.9
  655. log
  656. @Changed callmail(): The from-line will now always contain the address of
  657. the listserver. The redirect parameter is unused now.
  658. @
  659. text
  660. @d7 1
  661. a7 1
  662. static char rcssid[] = "$Id: main.c,v 1.9.1.8 1993/12/28 00:18:12 simons Exp simons $";
  663. d239 3
  664. a241 2
  665.         strcat(cbuf, " -f " LISTSERVADDR " -R \"Mailing List Processor\"");
  666.  
  667. @
  668.  
  669.  
  670. 1.9.1.10
  671. log
  672. @Changed callmailer(): Former redirect parameter is now called carboncopy
  673. and contains the address of one or more additional receipients.
  674. @
  675. text
  676. @d7 1
  677. a7 1
  678. static char rcssid[] = "$Id: main.c,v 1.9.1.9 1993/12/28 17:00:52 simons Exp simons $";
  679. d231 2
  680. a232 2
  681. void callmailer(carboncopy, toaddr, request)
  682. char *carboncopy, *toaddr, *request;
  683. d236 1
  684. a236 1
  685.         printf("callmailer \"%s\",\"%s\",\"%s\"\n", carboncopy, toaddr, request);
  686. d240 1
  687. a240 4
  688.         if (carboncopy && *carboncopy) {
  689.                 strcat(cbuf, " -c ");
  690.                 strcat(cbuf, carboncopy);
  691.         }
  692. @
  693.  
  694.  
  695. 1.9.1.11
  696. log
  697. @Changed X-ListSERV: field in the mailheaders to "Peti's Amiga ListSERV".
  698. @
  699. text
  700. @d7 1
  701. a7 1
  702. static char rcssid[] = "$Id: main.c,v 1.9.1.10 1993/12/28 17:37:42 simons Exp simons $";
  703. d253 1
  704. a253 1
  705.         fprintf(mailer,"X-ListSERV: Peti's Amiga " VERS " (" DATE ")\n");
  706. @
  707.  
  708.  
  709. 1.9.1.12
  710. log
  711. @Changed function declarations to ANSI-compliant style.
  712. Added automatic stack allocation when the provided stack is < 5k.
  713. @
  714. text
  715. @d7 1
  716. a7 1
  717. static char rcssid[] = "$Id: main.c,v 1.9.1.11 1993/12/28 21:57:37 simons Exp simons $";
  718. d12 4
  719. a15 7
  720. long __stack = 1024*5;  /* In case the stack is too small, allocate a
  721.                          * new one.             (SAS/C 6.3+)
  722.                          */
  723.  
  724. int main(int argc,
  725.          char **argv)
  726. {
  727. d231 3
  728. a233 4
  729. void callmailer(char *carboncopy,
  730.                 char *toaddr,
  731.                 char *request)
  732. {
  733. d257 3
  734. a259 3
  735. void mailcat(char *mfname,
  736.              char *prefix)
  737. {
  738. @
  739.  
  740.  
  741. 1.9.1.13
  742. log
  743. @Removed the strange internal string compare routines.
  744. @
  745. text
  746. @d7 1
  747. a7 1
  748. static char rcssid[] = "$Id: main.c,v 1.9.1.12 1993/12/28 22:16:34 simons Exp simons $";
  749. d68 1
  750. a68 1
  751.                 if (strnicmp(buf,"From: ",6) == 0)
  752. d73 2
  753. a74 2
  754.                 if (strnicmp(buf, "From: listserv", 14) == 0
  755.                 || strnicmp(buf,
  756. d88 1
  757. a88 1
  758.                 if (!strnicmp(from, "listserv", 8))
  759. d135 10
  760. a144 10
  761.                 if (!strnicmp(buf, "list ",5)
  762.                 || !strnicmp(buf, "delete-all ",11)
  763.                 || !strnicmp(buf, "del-all ",8)
  764.                 || !strnicmp(buf, "unsubscribe-all ",16)
  765.                 || !strnicmp(buf, "unsub-all ",10)
  766.                 || !stricmp(buf, "list")
  767.                 || !stricmp(buf, "delete-all")
  768.                 || !stricmp(buf, "del-all")
  769.                 || !stricmp(buf, "unsubscribe-all")
  770.                 || !stricmp(buf, "unsub-all"))
  771. d151 3
  772. a153 3
  773.                 if (!strnicmp(buf,"add ", 4)
  774.                 || !strnicmp(buf,"subscribe ", 10)
  775.                 || !strnicmp(buf,"sub ",4))
  776. d160 4
  777. a163 4
  778.                 if (!strnicmp(buf,"delete ", 7)
  779.                 || !strnicmp(buf,"del ",4)
  780.                 || !strnicmp(buf,"unsubscribe ", 12)
  781.                 || !strnicmp(buf,"unsub ",6))
  782. d170 2
  783. a171 2
  784.                 if (!stricmp(buf,"index")
  785.                 || !stricmp(buf,"longindex"))
  786. d174 1
  787. a174 1
  788.                         sendindex(from,buf,!stricmp(buf,"longindex"));
  789. d178 1
  790. a178 1
  791.                 if (!strnicmp(buf, "faq ", 4))
  792. d185 1
  793. a185 1
  794.                 if (!stricmp(buf, "faq"))
  795. d192 1
  796. a192 1
  797. /*                if (!stricmp(buf, "info"))
  798. d200 2
  799. a201 2
  800.  *                if (!strnicmp(buf, "info ", 5)
  801.  *                || !strnicmp(buf, "get ",4))
  802. d208 1
  803. a208 1
  804.                 if (!stricmp(buf,"help"))
  805. d215 1
  806. a215 1
  807.                 if (!strnicmp(buf,"help ",5))
  808. @
  809.  
  810.  
  811. 1.9.1.14
  812. log
  813. @Invented real address parsing with ParseAddress(), taken from my
  814. PGPSendMail.
  815. Changed a few comments, straightened some code.
  816. Removed lots of strange and useless header-parsing stuff. I really
  817. wonder why the original author converted all characters to lower-case
  818. and compared them with an case-independant routine afterwards...
  819. However, all this stuff is gone.
  820. Changed the Subject:-line to "ListSERV". Names are very important! :-)
  821. @
  822. text
  823. @d7 1
  824. a7 1
  825. static char rcssid[] = "$Id: main.c,v 1.9.1.13 1993/12/29 06:24:47 simons Exp simons $";
  826. d42 12
  827. a59 1
  828.  
  829. d61 1
  830. a61 7
  831.                  * get the From: line so we can return the answer
  832.                  *
  833.                  * Note that we DON'T check that we're in the header when
  834.                  * picking up the From: line; that's so that we'll take the
  835.                  * last from line we encounter which makes it handle
  836.                  * forwarded messages correctly.
  837.                  */
  838. d63 7
  839. a69 1
  840.                 if (!strnicmp(buf,"From: ",6)) {
  841. a70 1
  842.                         ParseAddress(from);
  843. d72 8
  844. a79 1
  845.                 }
  846. d81 3
  847. a83 1
  848.                 /* don't look for commands in the header */
  849. d95 1
  850. a95 1
  851.                 if (strstr(from, "daemon"))
  852. d101 1
  853. a101 1
  854.                 /* force to lower case and scan for commands
  855. a108 1
  856.                 */
  857. d192 16
  858. d234 3
  859. a236 1
  860. void callmailer(char *carboncopy, char *toaddr, char *request)
  861. d256 1
  862. a256 1
  863.         fprintf(mailer,"Subject: Re: your ListSERV request \"%s\"\n", request);
  864. d259 1
  865. a259 1
  866. }
  867. d261 2
  868. a262 1
  869. void mailcat(char *mfname, char *prefix)
  870. a288 28
  871. }
  872.  
  873.  
  874. void ParseAddress(char *line)
  875. {
  876.         int brackets, i, z;
  877.  
  878.         for (i = 0, z = 0, brackets = 0; line[i] != '\0'; i++) {
  879.                 if (line[i] == '(' && (i == 0 || isspace(line[i-1])))
  880.                         brackets = 1;
  881.                 if (line[i] == ')' && (line[i+1] == '\0' || isspace(line[i+1])))
  882.                         brackets = 0;
  883.                 if (line[i] == '<' && brackets == 0) {
  884.                         i++;
  885.                         while (1) {             /* Forever! */
  886.                                 if (line[i] == '>' && (line[i+1] == '\0' || isspace(line[i+1])))
  887.                                         break;
  888.                                 line[z++] = line[i++];
  889.                         }
  890.                         line[z] = '\0';
  891.                         break;
  892.                 }
  893.         }
  894.         if (z == 0) {   /* No <address> occured. */
  895.                 i = 0;
  896.                 while (!isspace(line[i]))
  897.                         i++;
  898.                 line[i] = '\0';
  899. a289 1
  900. }
  901. @
  902.  
  903.  
  904. 1.9.1.15
  905. log
  906. @Changed the username that is used to recognize bounced mail to
  907. "-daemon" to avoid confusion in case someone likes strange names. :-)
  908. The X-ListSERV:-field now doesn't contain the date of the current
  909. version anymore, will save some bandwidth--the number is sufficient.
  910. Added a usage text when started with "?" or "-h".
  911. @
  912. text
  913. @a5 1
  914. #define USAGE   "USAGE: ListSERV <mailfile\n"
  915. d7 1
  916. a7 1
  917. static char rcssid[] = "$Id: main.c,v 1.9.1.14 1993/12/29 07:07:06 simons Exp simons $";
  918. d16 2
  919. a17 1
  920. int main(int argc, char **argv)
  921. d23 1
  922. a30 5
  923.         if (argc == 2 && (!strcmp(argv[1], "?") ||
  924.                           !stricmp(argv[1], "-h"))) {
  925.                 printf(USAGE);
  926.                 return 0;
  927.         }
  928. d76 1
  929. a76 1
  930.                 if (strstr(from, "-daemon"))
  931. d221 1
  932. a221 1
  933.         fprintf(mailer,"X-ListSERV: Peti's Amiga " VERS "\n");
  934. @
  935.