3 * This module handles the loading/saving and maintenance of the
4 * system's Internet configuration. It's not an optional component; I
5 * wrote it as a module merely to keep things as clean and loosely coupled
17 #include <sys/types.h>
25 #include "sysdep_decls.h"
26 #include "citserver.h"
29 #include "dynloader.h"
36 #include "internet_addressing.h"
40 void inetcfg_setTo(struct CtdlMessage *msg) {
44 if (msg->cm_fields['M']==NULL) return;
45 conf = strdoop(msg->cm_fields['M']);
49 extract_token(buf, conf, 0, '\n');
50 strcpy(conf, &conf[strlen(buf)+1]);
51 } while ( (strlen(conf)>0) && (strlen(buf)>0) );
53 if (inetcfg != NULL) phree(inetcfg);
60 * This handler detects changes being made to the system's Internet
63 int inetcfg_aftersave(struct CtdlMessage *msg) {
67 /* If this isn't the configuration room, or if this isn't a MIME
68 * message, don't bother.
70 if (strcasecmp(msg->cm_fields['O'], SYSCONFIGROOM)) return(0);
71 if (msg->cm_format_type != 4) return(0);
73 ptr = msg->cm_fields['M'];
76 linelen = strcspn(ptr, "\n");
77 if (linelen == 0) return(0); /* end of headers */
79 if ( (!strncasecmp(ptr, "Content-type: ", 14))
80 && (!strncasecmp(&ptr[14], INTERNETCFG,
81 strlen(INTERNETCFG) )) ) {
82 /* Bingo! The user is changing configs.
87 ptr = strchr((char *)ptr, '\n');
88 if (ptr != NULL) ++ptr;
95 void inetcfg_init_backend(long msgnum) {
96 struct CtdlMessage *msg;
98 msg = CtdlFetchMessage(msgnum);
101 CtdlFreeMessage(msg);
106 void inetcfg_init(void) {
107 if (getroom(&CC->quickroom, SYSCONFIGROOM) != 0) return;
108 CtdlForEachMessage(MSGS_LAST, 1, INTERNETCFG, NULL,
109 inetcfg_init_backend);
115 /*****************************************************************************/
116 /* MODULE INITIALIZATION STUFF */
117 /*****************************************************************************/
120 char *Dynamic_Module_Init(void)
122 CtdlRegisterMessageHook(inetcfg_aftersave, EVT_AFTERSAVE);