From 7935ab0b35d3d2bbe54e3eb523323ad3d4288663 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 10 Jun 2002 22:25:25 +0000 Subject: [PATCH] * Configuration for spam filter --- citadel/ChangeLog | 4 +++ citadel/internet_addressing.c | 2 +- citadel/internet_addressing.h | 9 ++++++ citadel/serv_inetcfg.c | 57 ++++++++++++++++++++++++++++++++--- 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index ff1bd4cd9..f84eefc58 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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 Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 93337b3b1..6c1be48e1 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -61,7 +61,7 @@ struct trynamebuf { }; char *inetcfg = NULL; - +struct spamstrings_t *spamstrings = NULL; /* diff --git a/citadel/internet_addressing.h b/citadel/internet_addressing.h index 42b7c5bd1..314b2e90e 100644 --- a/citadel/internet_addressing.h +++ b/citadel/internet_addressing.h @@ -36,3 +36,12 @@ enum { }; extern DLEXP char *inetcfg; + + +struct spamstrings_t { + struct spamstrings_t *next; + char *string; +}; + +extern DLEXP struct spamstrings_t *spamstrings; + diff --git a/citadel/serv_inetcfg.c b/citadel/serv_inetcfg.c index 658bdce55..cb11d8322 100644 --- a/citadel/serv_inetcfg.c +++ b/citadel/serv_inetcfg.c @@ -49,10 +49,13 @@ #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; istring = 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); } -- 2.30.2