]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_inetcfg.c
* Renamed "dynloader" to "serv_extensions" globally. We don't want people
[citadel.git] / citadel / serv_inetcfg.c
index bedcd965d01e320a2bb90fe489be08bb822c86cd..f585866c2b6f1d3c4da5eed60d33fd0cf77ca436 100644 (file)
 #include <pwd.h>
 #include <errno.h>
 #include <sys/types.h>
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
 #include <sys/wait.h>
 #include <string.h>
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include <time.h>
 #include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
-#include "dynloader.h"
+#include "serv_extensions.h"
 #include "room_ops.h"
 #include "user_ops.h"
 #include "policy.h"
 #include "genstamp.h"
 #include "domain.h"
 
+
+
+
 void inetcfg_setTo(struct CtdlMessage *msg) {
        char *conf;
-       char buf[256];
-
+       char buf[SIZ];
+       
        if (msg->cm_fields['M']==NULL) return;
        conf = strdoop(msg->cm_fields['M']);
 
@@ -58,6 +71,39 @@ void inetcfg_setTo(struct CtdlMessage *msg) {
 }
 
 
+#ifdef ___NOT_CURRENTLY_IN_USE___
+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;
+       }
+
+}
+#endif
+
+
 /*
  * This handler detects changes being made to the system's Internet
  * configuration.
@@ -78,12 +124,17 @@ int inetcfg_aftersave(struct CtdlMessage *msg) {
                linelen = strcspn(ptr, "\n");
                if (linelen == 0) return(0);    /* end of headers */    
                
-               if ( (!strncasecmp(ptr, "Content-type: ", 14))
-                  && (!strncasecmp(&ptr[14], INTERNETCFG,
-                  strlen(INTERNETCFG) )) ) {
-                       /* Bingo!  The user is changing configs.
-                        */
-                       inetcfg_setTo(msg);
+               if (!strncasecmp(ptr, "Content-type: ", 14)) {
+                       if (!strncasecmp(&ptr[14], INTERNETCFG,
+                          strlen(INTERNETCFG))) {
+                               inetcfg_setTo(msg);     /* changing configs */
+                       }
+#ifdef ___NOT_CURRENTLY_IN_USE___
+                       if (!strncasecmp(&ptr[14], SPAMSTRINGS,
+                          strlen(INTERNETCFG))) {
+                               spamstrings_setTo(msg); /* changing configs */
+                       }
+#endif
                }
 
                ptr = strchr((char *)ptr, '\n');
@@ -105,10 +156,27 @@ void inetcfg_init_backend(long msgnum, void *userdata) {
 }
 
 
+#ifdef ___NOT_CURRENTLY_IN_USE___
+void spamstrings_init_backend(long msgnum, void *userdata) {
+       struct CtdlMessage *msg;
+
+               msg = CtdlFetchMessage(msgnum);
+               if (msg != NULL) {
+               spamstrings_setTo(msg);
+                       CtdlFreeMessage(msg);
+       }
+}
+#endif
+
+
 void inetcfg_init(void) {
        if (getroom(&CC->quickroom, SYSCONFIGROOM) != 0) return;
-       CtdlForEachMessage(MSGS_LAST, 1, (-127), INTERNETCFG, NULL,
+       CtdlForEachMessage(MSGS_LAST, 1, INTERNETCFG, NULL,
                inetcfg_init_backend, NULL);
+/*
+       CtdlForEachMessage(MSGS_LAST, 1, SPAMSTRINGS, NULL,
+               spamstrings_init_backend, NULL);
+ */
 }
 
 
@@ -119,7 +187,7 @@ void inetcfg_init(void) {
 /*****************************************************************************/
 
 
-char *Dynamic_Module_Init(void)
+char *serv_inetcfg_init(void)
 {
        CtdlRegisterMessageHook(inetcfg_aftersave, EVT_AFTERSAVE);
        inetcfg_init();