]> Pileus Git - ~andy/fetchmail/commitdiff
Can specify multiple spam-blocks now.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 20 Jul 1998 17:48:01 +0000 (17:48 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 20 Jul 1998 17:48:01 +0000 (17:48 -0000)
svn path=/trunk/; revision=1997

NEWS
conf.c
driver.c
fetchmail.c
fetchmail.h
fetchmail.man
options.c
rcfile_y.y

diff --git a/NEWS b/NEWS
index d3e5228616d7d24ea1af36dc2f8134b89cdb02da..4fd34e5954bc8b39d3d6d496a68a0d1a7a4f9a4c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ fetchmail-4.5.3 ():
   of run, and then only if they'll actually be needed later for multidrop
   checking or fetching Kerberos tickets.  This change eliminates many
   gethostbyname calls.
+* It's now possible to specify multiple spam-block responses as a list.
 * 1.1 version of fetchmailconf.
 
 Note: the DNS-usage change might conceivably break your configuration
diff --git a/conf.c b/conf.c
index 7a4b7b4be42d94f27f28a0e172e15d15b0d101df..b98ac1d06366d07ed8aa99803b132391117052b7 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -270,7 +270,14 @@ void dump_config(struct runctl *runp, struct query *querylist)
        numdump("expunge", ctl->expunge);
        listdump("smtphunt", ctl->smtphunt);
        stringdump("smtpaddress", ctl->smtpaddress);
-       numdump("antispam", ctl->antispam);
+       fprintf(stdout, "'antispam':[");
+       for (idp = ctl->antispam; idp; idp = idp->next)
+       {
+           fprintf(stdout, "%d", idp->val.status.num);
+           if (idp->next)
+               fputs(", ", stdout);
+       }
+       fputs("],\n", stdout);
        listdump("mailboxes", ctl->mailboxes);
 
        indent('}');
index a6c79b05dafe7b31143b230c5ef3b33edbc0ca4f..425ffd5fea19ac550330520f561cac5246dd981b 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -1193,7 +1193,7 @@ int num;          /* index of message */
        {
            int smtperr = atoi(smtp_response);
 
-           if (smtperr == ctl->antispam)
+           if (str_find(&ctl->antispam, smtperr))
            {
                /*
                 * SMTP listener explicitly refuses to deliver mail
index 63ad9999b5e45d42eb555dcfd305b6ef9d03ab8c..f495d16b410d41d753d5b6fad9265848686266ce 100644 (file)
@@ -678,6 +678,7 @@ static void optmerge(struct query *h2, struct query *h1, int force)
     LIST_MERGE(h2->localnames, h1->localnames);
     LIST_MERGE(h2->mailboxes, h1->mailboxes);
     LIST_MERGE(h2->smtphunt, h1->smtphunt);
+    LIST_MERGE(h2->antispam, h1->antispam);
 #undef LIST_MERGE
 
 #define FLAG_MERGE(fld) if (force ? !!h1->fld : !h2->fld) h2->fld = h1->fld
@@ -711,7 +712,6 @@ static void optmerge(struct query *h2, struct query *h1, int force)
     FLAG_MERGE(password);
     FLAG_MERGE(mda);
     FLAG_MERGE(smtpaddress);
-    FLAG_MERGE(antispam);
     FLAG_MERGE(preconnect);
 
     FLAG_MERGE(keep);
@@ -739,7 +739,7 @@ static int load_params(int argc, char **argv, int optind)
     memset(&def_opts, '\0', sizeof(struct query));
     def_opts.smtp_socket = -1;
     def_opts.smtpaddress = (char *)0;
-    def_opts.antispam = 571;
+    save_str(&def_opts.antispam, (char *)NULL, 0)->val.status.num = 571;
 
     def_opts.server.protocol = P_AUTO;
     def_opts.server.timeout = CLIENT_TIMEOUT;
@@ -1297,10 +1297,19 @@ void dump_params (struct runctl *runp, struct query *querylist, flag implicit)
                printf("  Host part of MAIL FROM line will be %s\n",
                       ctl->smtpaddress);
        }
-       if (ctl->server.protocol != P_ETRN) {
-               if (ctl->antispam != -1)
-                   printf("  Listener SMTP reponse %d will be treated as a spam block\n",
+       if (ctl->server.protocol != P_ETRN)
+       {
+               if (ctl->antispam != (struct idlist *)NULL)
+               {
+                   struct idlist *idp;
+
+                   printf("  Recognized listener spam block responses are:",
                           ctl->antispam);
+                   for (idp = ctl->antispam; idp; idp = 
+idp->next)
+                       printf(" %d", idp->val.status.num);
+                   printf("\n");
+               }
                else if (outlevel == O_VERBOSE)
                    printf("  Spam-blocking disabled\n");
        }
index cfb729a718ab690e3696955b06f04e38d0a0a27a..acbf14fc6d89fdeb8a7130bc4da47675a5c8343f 100644 (file)
@@ -174,7 +174,7 @@ struct query
     struct idlist *smtphunt;   /* list of SMTP hosts to try forwarding to */
     char *smtphost;            /* actual SMTP host to point to */
     char *smtpaddress;         /* address we want to force in the delivery messages */ 
-    int        antispam;               /* listener's antispam response */
+    struct idlist *antispam;   /* list of listener's antispam response */
     char *mda;                 /* local MDA to pass mail to */
     char *preconnect;          /* pre-connection command to execute */
     char *postconnect;         /* post-connection command to execute */
index ed24bdc915d403e627d55841cb98886385c92d60..56000f6d9702be0c06e7a81414706ad0da467500 100644 (file)
@@ -231,11 +231,12 @@ Specify the domain to be put in RCPT TO lines shipped to SMTP. The
 name of the SMTP server (as specified by --smtphost, or defaulted to
 "localhost") is used when this is not specified.
 .TP
-.B \-Z nnn, --antispam nnn
+.B \-Z nnn, --antispam nnn[,nnn[,nnn...]]
 (Keyword: antispam) 
-Specifies the numeric SMTP error that is to be interpreted as a
-spam-block response from the listener.  A value of -1 disables
-this option.
+Specifies the list of numeric SMTP errors that are to be interpreted
+as a spam-block response from the listener.  A value of -1 disables
+this option.  For the command-line option, the list values should
+be comma-separated.
 .TP
 .B \-m, \--mda
 (Keyword: mda)
@@ -927,7 +928,7 @@ smtpaddress -D      T{
 Specify the domain to be put in RCPT TO lines
 T}
 antispam       -Z      T{
-Specify what SMTP return is interpreted as a spam-policy block
+Specify what SMTP returns are interpreted as spam-policy blocks
 T}
 mda            -m      T{
 Specify MDA for local delivery
index 892e0f3e30061c83b7bf020ee243bc86017a05d3..94595e30f481c2620addd7578eead9e826262f66 100644 (file)
--- a/options.c
+++ b/options.c
@@ -426,8 +426,16 @@ struct query *ctl; /* option record to be initialized */
            break;
        case 'Z':
        case LA_ANTISPAM:
-           c = xatoi(optarg, &errflag);
-           ctl->antispam = NUM_VALUE(c);
+           strcpy(buf, optarg);
+           cp = strtok(buf, ",");
+           do {
+               struct idlist   *idp = save_str(&ctl->antispam, NULL, 0);;
+
+               idp->val.status.num = atoi(cp);
+           } while
+               ((cp = strtok((char *)NULL, ",")));
+           free(buf);
+           break;
        case 'b':
        case LA_BATCHLIMIT:
            c = xatoi(optarg, &errflag);
@@ -543,7 +551,7 @@ struct query *ctl;  /* option record to be initialized */
 #endif /* NET_SECURITY */
        fputs("  -S, --smtphost    set SMTP forwarding host\n", stderr);
        fputs("  -D, --smtpaddress set SMTP delivery domain to use\n", stderr);
-       fputs("  -Z, --antispam,   set antispam response value\n", stderr);
+       fputs("  -Z, --antispam,   set antispam response values\n", stderr);
        fputs("  -b, --batchlimit  set batch limit for SMTP connections\n", stderr);
        fputs("  -B, --fetchlimit  set fetch limit for server connections\n", stderr);
        fputs("  -e, --expunge     set max deletions between expunges\n", stderr);
index d6930b2a2be9217e79a225b36cf5c8c601639709..d3af58b36aaa912bdbac1e715a8155d28ecb0714 100644 (file)
@@ -261,6 +261,18 @@ smtp_list  : STRING                {save_str(&current.smtphunt, $1,TRUE);}
                | smtp_list STRING      {save_str(&current.smtphunt, $2,TRUE);}
                ;
 
+num_list       : NUMBER                {
+                                           struct idlist *id;
+                                           id=save_str(&current.antispam,0,0);
+                                           id->val.status.num = $1;
+                                       }
+               | num_list NUMBER       {
+                                           struct idlist *id;
+                                           id=save_str(&current.antispam,0,0);
+                                           id->val.status.num = $2;
+                                       }
+               ;
+
 user_option    : TO localnames HERE
                | TO localnames
                | IS localnames HERE
@@ -271,7 +283,7 @@ user_option : TO localnames HERE
                | FOLDER folder_list
                | SMTPHOST smtp_list
                | SMTPADDRESS STRING    {current.smtpaddress = xstrdup($2);}
-               | SPAMRESPONSE NUMBER   {current.antispam = $2;}
+               | SPAMRESPONSE num_list
                | MDA STRING            {current.mda        = xstrdup($2);}
                | PRECONNECT STRING     {current.preconnect = xstrdup($2);}
                | POSTCONNECT STRING    {current.postconnect = xstrdup($2);}