* Configuration for spam filter
authorArt Cancro <ajc@citadel.org>
Mon, 10 Jun 2002 22:25:25 +0000 (22:25 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 10 Jun 2002 22:25:25 +0000 (22:25 +0000)
citadel/ChangeLog
citadel/internet_addressing.c
citadel/internet_addressing.h
citadel/serv_inetcfg.c

index ff1bd4cd9f5b83e58c9d084566b70177e525facc..f84eefc588ba3efcce999c29690258339d89181f 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 591.38  2002/06/10 22:25:25  ajc
+ * Configuration for spam filter
+
  Revision 591.37  2002/06/09 23:59:38  ajc
  * Started working on the spam filter
 
@@ -3700,3 +3703,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 93337b3b166fa006461fdd179f5d62fa1bd6198e..6c1be48e1efe3680947a61f3367b089a87a92f4b 100644 (file)
@@ -61,7 +61,7 @@ struct trynamebuf {
 };
 
 char *inetcfg = NULL;
-
+struct spamstrings_t *spamstrings = NULL;
 
 
 /*
index 42b7c5bd11ef40100d3897816ec3cc3d2474dad7..314b2e90e7e77c871d2a79f99fa174d727dc9efc 100644 (file)
@@ -36,3 +36,12 @@ enum {
 };
 
 extern DLEXP char *inetcfg;
+
+
+struct spamstrings_t {
+       struct spamstrings_t *next;
+       char *string;
+};
+
+extern DLEXP struct spamstrings_t *spamstrings;
+
index 658bdce55b70a68571fa5dfb2336a3c3c0394d55..cb11d8322eebccab53d153eb6282a3dc666b532e 100644 (file)
 #include "genstamp.h"
 #include "domain.h"
 
+
+
+
 void inetcfg_setTo(struct CtdlMessage *msg) {
        char *conf;
        char buf[SIZ];
-
+       
        if (msg->cm_fields['M']==NULL) return;
        conf = strdoop(msg->cm_fields['M']);
 
@@ -68,6 +71,37 @@ void inetcfg_setTo(struct CtdlMessage *msg) {
 }
 
 
+void spamstrings_setTo(struct CtdlMessage *msg) {
+       char buf[SIZ];
+       char *conf;
+       struct spamstrings_t *sptr;
+       int i, n;
+
+       /* Clear out the existing list */
+       while (spamstrings != NULL) {
+               sptr = spamstrings;
+               spamstrings = spamstrings->next;
+               phree(sptr->string);
+               phree(sptr);
+       }
+
+       /* Read in the new list */
+       if (msg->cm_fields['M']==NULL) return;
+       conf = strdoop(msg->cm_fields['M']);
+       if (conf == NULL) return;
+
+       n = num_tokens(conf, '\n');
+       for (i=0; i<n; ++i) {
+               extract_token(buf, conf, i, '\n');
+               sptr = mallok(sizeof(struct spamstrings_t));
+               sptr->string = strdoop(buf);
+               sptr->next = spamstrings;
+               spamstrings = sptr;
+       }
+
+}
+
+
 /*
  * This handler detects changes being made to the system's Internet
  * configuration.
@@ -91,9 +125,11 @@ int inetcfg_aftersave(struct CtdlMessage *msg) {
                if (!strncasecmp(ptr, "Content-type: ", 14)) {
                        if (!strncasecmp(&ptr[14], INTERNETCFG,
                           strlen(INTERNETCFG))) {
-                               /* Bingo!  The user is changing configs.
-                               */
-                               inetcfg_setTo(msg);
+                               inetcfg_setTo(msg);     /* changing configs */
+                       }
+                       if (!strncasecmp(&ptr[14], SPAMSTRINGS,
+                          strlen(INTERNETCFG))) {
+                               spamstrings_setTo(msg); /* changing configs */
                        }
                }
 
@@ -116,10 +152,23 @@ void inetcfg_init_backend(long msgnum, void *userdata) {
 }
 
 
+void spamstrings_init_backend(long msgnum, void *userdata) {
+       struct CtdlMessage *msg;
+
+               msg = CtdlFetchMessage(msgnum);
+               if (msg != NULL) {
+               spamstrings_setTo(msg);
+                       CtdlFreeMessage(msg);
+       }
+}
+
+
 void inetcfg_init(void) {
        if (getroom(&CC->quickroom, SYSCONFIGROOM) != 0) return;
        CtdlForEachMessage(MSGS_LAST, 1, INTERNETCFG, NULL,
                inetcfg_init_backend, NULL);
+       CtdlForEachMessage(MSGS_LAST, 1, SPAMSTRINGS, NULL,
+               spamstrings_init_backend, NULL);
 }