Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / motd.c
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);