From d4c9e3fc087c935d65a9e11b81b84f23c5d1e949 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Tue, 28 Nov 2000 18:30:23 +0000 Subject: [PATCH] Author: Kev Log message: Fixed the bugs I found in the motd routines; these should now be working. Someone should consider adding freelist stuff here. Testing done: most of what I outlined in the previous commit Status: stable Testing needed: double-check for possible memory leaks git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@315 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 10 ++++++++++ ircd/ircd.c | 4 ++-- ircd/motd.c | 21 ++++++++++++++------- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index af3ddb3..dc1ad39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-11-28 Kevin L. Mitchell + + * ircd/motd.c: we were setting type to MOTD_CLASS unconditionally, + which was of course stupid; switched to using switch/case in + initialization in motd_create(); zero the MotdList.other pointer + from motd_clear() + + * ircd/ircd.c (main): motd_init() has to come before init_conf(), + or we overwrite init_conf()'s hard work with respect to T-lines + 2000-11-27 Kevin L. Mitchell * ircd/s_stats.c: comment out report_motd_list and include a diff --git a/ircd/ircd.c b/ircd/ircd.c index 7fcf5b4..9b9e780 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -654,6 +654,8 @@ int main(int argc, char **argv) { init_resolver(); + motd_init(); + if (!init_conf()) { ircd_log(L_CRIT, "Failed to read configuration file %s", configfile); return 7; @@ -663,8 +665,6 @@ int main(int argc, char **argv) { uping_init(); - motd_init(); - CurrentTime = time(NULL); SetMe(&me); diff --git a/ircd/motd.c b/ircd/motd.c index e4be1c2..503b530 100644 --- a/ircd/motd.c +++ b/ircd/motd.c @@ -57,21 +57,19 @@ static struct Motd * motd_create(const char *hostmask, const char *path, int maxcount) { struct Motd* tmp; - int class = -1; int type = MOTD_UNIVERSAL; const char* s; assert(0 != path); if (hostmask) { /* figure out if it's a class or hostmask */ + type = MOTD_CLASS; /* all digits, convert to class */ + for (s = hostmask; *s; s++) if (!IsDigit(*s)) { /* not a digit, not a class... */ type = MOTD_HOSTMASK; break; } - - type = MOTD_CLASS; /* all digits, convert to class */ - class = atoi(hostmask); } /* allocate memory and initialize the structure */ @@ -79,10 +77,17 @@ motd_create(const char *hostmask, const char *path, int maxcount) tmp->next = 0; tmp->type = type; - if (type == MOTD_HOSTMASK) + + switch (type) { + case MOTD_HOSTMASK: DupString(tmp->id.hostmask, hostmask); - else if (type == MOTD_CLASS) - tmp->id.class = class; + break; + + case MOTD_CLASS: + tmp->id.class = atoi(hostmask); + break; + } + DupString(tmp->path, path); tmp->maxcount = maxcount; tmp->cache = 0; @@ -320,6 +325,8 @@ motd_clear(void) motd_destroy(ptr); } + MotdList.other = 0; + /* now recache local and remote MOTDs */ motd_cache(MotdList.local); motd_cache(MotdList.remote); -- 2.20.1