]> jfr.im git - solanum.git/blobdiff - modules/m_stats.c
ircd: implement EXTENDCHANS, based on ircd-seven (with some improvements from chatircd)
[solanum.git] / modules / m_stats.c
index 44c2e15c57f8fb669f99b9acbfbd6d9962264642..a59d604b99c86cb492401bf907f280dbae65d401 100644 (file)
@@ -48,6 +48,7 @@
 #include "hash.h"
 #include "reject.h"
 #include "whowas.h"
+#include "irc_radixtree.h"
 
 static int m_stats (struct Client *, struct Client *, int, const char **);
 
@@ -271,10 +272,20 @@ stats_delay(struct Client *source_p)
        }
 }
 
+static void
+stats_hash_cb(const char *buf, void *client_p)
+{
+       sendto_one_numeric(client_p, RPL_STATSDEBUG, "B :%s", buf);
+}
+
 static void
 stats_hash(struct Client *source_p)
 {
-       hash_stats(source_p);
+       sendto_one_numeric(source_p, RPL_STATSDEBUG, "B :%-30s %-15s %-10s %-10s %-10s %-10s",
+               "NAME", "TYPE", "OBJECTS", "DEPTH SUM", "AVG DEPTH", "MAX DEPTH");
+
+       irc_dictionary_stats_walk(stats_hash_cb, source_p);
+       irc_radixtree_stats_walk(stats_hash_cb, source_p);
 }
 
 static void
@@ -621,6 +632,43 @@ stats_tklines(struct Client *source_p)
        }
 }
 
+/* report_Klines()
+ *
+ * inputs       - Client to report to, mask
+ * outputs      -
+ * side effects - Reports configured K-lines to client_p.
+ */
+static void
+report_Klines(struct Client *source_p)
+{
+       char *host, *pass, *user, *oper_reason;
+       struct AddressRec *arec;
+       struct ConfItem *aconf = NULL;
+       int i;
+
+       for (i = 0; i < ATABLE_SIZE; i++)
+       {
+               for (arec = atable[i]; arec; arec = arec->next)
+               {
+                       if(arec->type == CONF_KILL)
+                       {
+                               aconf = arec->aconf;
+
+                               /* its a tempkline, theyre reported elsewhere */
+                               if(aconf->flags & CONF_FLAGS_TEMPORARY)
+                                       continue;
+
+                               get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason);
+                               sendto_one_numeric(source_p, RPL_STATSKLINE,
+                                                  form_str(RPL_STATSKLINE),
+                                                  'K', host, user, pass,
+                                                  oper_reason ? "|" : "",
+                                                  oper_reason ? oper_reason : "");
+                       }
+               }
+       }
+}
+
 static void
 stats_klines(struct Client *source_p)
 {
@@ -781,6 +829,7 @@ static void
 stats_tresv(struct Client *source_p)
 {
        struct ConfItem *aconf;
+       struct irc_radixtree_iteration_state state;
        rb_dlink_node *ptr;
        int i;
 
@@ -793,15 +842,13 @@ stats_tresv(struct Client *source_p)
                                        'q', aconf->port, aconf->host, aconf->passwd);
        }
 
-       HASH_WALK(i, R_MAX, ptr, resvTable)
+       IRC_RADIXTREE_FOREACH(aconf, &state, resv_tree)
        {
-               aconf = ptr->data;
                if(aconf->hold)
                        sendto_one_numeric(source_p, RPL_STATSQLINE,
                                        form_str(RPL_STATSQLINE),
                                        'q', aconf->port, aconf->host, aconf->passwd);
        }
-       HASH_WALK_END
 }
 
 
@@ -809,6 +856,7 @@ static void
 stats_resv(struct Client *source_p)
 {
        struct ConfItem *aconf;
+       struct irc_radixtree_iteration_state state;
        rb_dlink_node *ptr;
        int i;
 
@@ -821,15 +869,13 @@ stats_resv(struct Client *source_p)
                                        'Q', aconf->port, aconf->host, aconf->passwd);
        }
 
-       HASH_WALK(i, R_MAX, ptr, resvTable)
+       IRC_RADIXTREE_FOREACH(aconf, &state, resv_tree)
        {
-               aconf = ptr->data;
                if(!aconf->hold)
                        sendto_one_numeric(source_p, RPL_STATSQLINE,
                                        form_str(RPL_STATSQLINE),
                                        'Q', aconf->port, aconf->host, aconf->passwd);
        }
-       HASH_WALK_END
 }
 
 static void
@@ -1007,6 +1053,7 @@ static struct shared_flags shared_flagtable[] =
        { SHARED_TDLINE,        'd' },
        { SHARED_PDLINE,        'D' },
        { SHARED_UNDLINE,       'E' },
+       { SHARED_GRANT,         'G' },
        { 0,                    '\0'}
 };