- The big forward port. I probably broke lots of stuff, so please look over any
[ircu2.10.12-pk.git] / ircd / motd.c
index 393d1ee4c1d2768ce6ed243c75e1aa57027724a9..a2634b966c4ca1482e0ed25330adf70039c9a820 100644 (file)
@@ -41,6 +41,7 @@
 #include "s_conf.h"
 #include "s_debug.h"
 #include "s_user.h"
+#include "s_stats.h"
 #include "send.h"
 
 #include <assert.h>
@@ -63,6 +64,7 @@ motd_create(const char *hostmask, const char *path, int maxcount)
 {
   struct Motd* tmp;
   int type = MOTD_UNIVERSAL;
+  const char *s;
   
   assert(0 != path);
   
@@ -371,7 +373,7 @@ motd_clear(void)
 
 /* This is called to report T-lines */
 void
-motd_report(struct Client *to)
+motd_report(struct Client *to, struct StatDesc *sd, int stat, char *param)
 {
   struct Motd *ptr;
 
@@ -379,3 +381,49 @@ motd_report(struct Client *to)
     send_reply(to, SND_EXPLICIT | RPL_STATSTLINE, "T %s %s",
                ptr->hostmask, ptr->path);
 }
+
+void
+motd_memory_count(struct Client *cptr)
+{
+  struct Motd *ptr;
+  struct MotdCache *cache;
+  unsigned int mt = 0,   /* motd count */
+               mtm = 0,  /* memory consumed by motd */
+               mtc = 0,  /* motd cache count */
+               mtcm = 0, /* memory consumed by motd cache */
+               mtf = 0;  /* motd free list count */
+  if (MotdList.local)
+  {
+    mt++;
+    mtm += sizeof(struct Motd);
+    mtm += MotdList.local->path ? (strlen(MotdList.local->path) + 1) : 0;
+  }
+
+  if (MotdList.remote) 
+  {
+    mt++;
+    mtm += sizeof(struct Motd);
+    mtm += MotdList.remote->path ? (strlen(MotdList.remote->path) + 1) : 0;
+  }
+
+  for (ptr = MotdList.other; ptr; ptr = ptr->next)
+  {
+    mt++;
+    mtm += sizeof(struct Motd);
+    mtm += ptr->path ? (strlen(ptr->path) + 1) : 0;
+  }
+
+  for (cache = MotdList.cachelist; cache; cache = cache->next)
+  {
+    mtc++;
+    mtcm += sizeof(struct MotdCache) + (MOTD_LINESIZE * (cache->count - 1));
+  }
+
+  if (MotdList.freelist)
+    for (ptr = MotdList.freelist; ptr; ptr = ptr->next)
+      mtf++;
+
+  send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG,
+             ":Motds %d(%zu) Cache %d(%zu) Free %d(%zu)",
+             mt, mtm, mtc, mtcm, mtf, (mtf * sizeof(struct Motd)));
+}