From 5b1236258555cdd61892324ef62964faf703b41d Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 3 Feb 2000 03:57:35 +0000 Subject: [PATCH] * Formalized the 'Internet Configuration' logistics. Added new API call CtdlLocalHost() to detect aliases for the local host. Used in SMTP listener. --- citadel/ChangeLog | 5 ++++ citadel/internet_addressing.c | 38 +++++++++++++++++++++++++++--- citadel/internet_addressing.h | 3 +++ citadel/serv_inetcfg.c | 44 +++++++++++++++++++++++++++++++++-- 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 3f808d62c..27fcd2024 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 1.455 2000/02/03 03:57:35 ajc +* Formalized the 'Internet Configuration' logistics. Added new API call + CtdlLocalHost() to detect aliases for the local host. Used in SMTP listener. + Revision 1.454 2000/01/31 02:13:05 ajc * <.A>ide ystem configuration nternet in the client (unfinished) @@ -1596,3 +1600,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 365a1ec9f..16e242333 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -38,6 +38,39 @@ struct trynamebuf { char buffer2[256]; }; +char *inetcfg = NULL; + + + +/* + * Return nonzero if the supplied name is an alias for this host. + */ +int CtdlLocalHost(char *fqdn) { + int config_lines; + int i; + char buf[256]; + char host[256], type[256]; + + if (!strcasecmp(fqdn, config.c_fqdn)) return(1); + if (inetcfg == NULL) return(0); + + config_lines = num_tokens(inetcfg, '\n'); + for (i=0; icm_fields['M']==NULL) return; + conf = strdoop(msg->cm_fields['M']); + + if (conf != NULL) { + do { + extract_token(buf, conf, 0, '\n'); + strcpy(conf, &conf[strlen(buf)+1]); + } while ( (strlen(conf)>0) && (strlen(buf)>0) ); + + if (inetcfg != NULL) phree(inetcfg); + inetcfg = conf; + } +} + /* * This handler detects changes being made to the system's Internet @@ -61,7 +81,7 @@ int inetcfg_aftersave(struct CtdlMessage *msg) { strlen(INTERNETCFG) )) ) { /* Bingo! The user is changing configs. */ - lprintf(9, "Internet configuration changed FIX\n"); + inetcfg_setTo(msg); } ptr = strchr((char *)ptr, '\n'); @@ -72,6 +92,25 @@ int inetcfg_aftersave(struct CtdlMessage *msg) { } +void inetcfg_init_backend(long msgnum) { + struct CtdlMessage *msg; + + msg = CtdlFetchMessage(msgnum); + if (msg != NULL) { + inetcfg_setTo(msg); + CtdlFreeMessage(msg); + } +} + + +void inetcfg_init(void) { + if (getroom(&CC->quickroom, SYSCONFIGROOM) != 0) return; + CtdlForEachMessage(MSGS_LAST, 1, INTERNETCFG, NULL, + inetcfg_init_backend); +} + + + /*****************************************************************************/ /* MODULE INITIALIZATION STUFF */ @@ -81,6 +120,7 @@ int inetcfg_aftersave(struct CtdlMessage *msg) { char *Dynamic_Module_Init(void) { CtdlRegisterMessageHook(inetcfg_aftersave, EVT_AFTERSAVE); + inetcfg_init(); return "$Id$"; } -- 2.30.2