CtdlLocalHost() to detect aliases for the local host. Used in SMTP listener.
$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 <S>ystem configuration <I>nternet in the client (unfinished)
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
+
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; i<config_lines; ++i) {
+ extract_token(buf, inetcfg, i, '\n');
+ extract_token(host, buf, 0, '|');
+ extract_token(type, buf, 1, '|');
+ if ( (!strcasecmp(type, "localhost"))
+ && (!strcasecmp(fqdn, host))) return(1);
+ }
+
+ return(0);
+}
+
+
+
+
+
+
/*
* Return 0 if a given string fuzzy-matches a Citadel user account
process_rfc822_addr(source, user, node, name);
/* Map the FQDN to a Citadel node name
- * FIX ... we have to check for all known aliases for the local
- * system, and also handle gateway domains, etc. etc.
+ * FIX ... we have to check for gateway domains
*/
- if (!strcasecmp(node, config.c_fqdn)) {
+ if (CtdlLocalHost(node)) {
strcpy(node, config.c_nodename);
}
struct CtdlMessage *convert_internet_message(char *rfc822);
+int CtdlLocalHost(char *fqdn);
+
+extern char *inetcfg;
/* $Id$
*
* This module handles the loading/saving and maintenance of the
- * system's Internet configuration.
+ * system's Internet configuration. It's not an optional component; I
+ * wrote it as a module merely to keep things as clean and loosely coupled
+ * as possible.
*/
#include "sysdep.h"
#include "genstamp.h"
#include "domain.h"
+void inetcfg_setTo(struct CtdlMessage *msg) {
+ char *conf;
+ char buf[256];
+
+ if (msg->cm_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
strlen(INTERNETCFG) )) ) {
/* Bingo! The user is changing configs.
*/
- lprintf(9, "Internet configuration changed FIX\n");
+ inetcfg_setTo(msg);
}
ptr = strchr((char *)ptr, '\n');
}
+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 */
char *Dynamic_Module_Init(void)
{
CtdlRegisterMessageHook(inetcfg_aftersave, EVT_AFTERSAVE);
+ inetcfg_init();
return "$Id$";
}