Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Tue, 28 Nov 2000 18:30:23 +0000 (18:30 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Tue, 28 Nov 2000 18:30:23 +0000 (18:30 +0000)
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
ircd/ircd.c
ircd/motd.c

index af3ddb372602cc42e2d80a7248f364e48fa85b8e..dc1ad39979ec344a7cefe7d000f1a86eec3ea39a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-11-28  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * 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  <klmitch@mit.edu>
 
        * ircd/s_stats.c: comment out report_motd_list and include a
index 7fcf5b43661b2b9ad12e20ddc143d3758b9d8b8d..9b9e780c099882cf72170e3935b9ac9fb7163f66 100644 (file)
@@ -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);
index e4be1c28762e1585c2cc244ef69469b1c877046b..503b530ffbb5f7295e8aaa4298aeb48862fe63f0 100644 (file)
@@ -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);