]> jfr.im git - solanum.git/blobdiff - modules/m_stats.c
Get rid of ^M.
[solanum.git] / modules / m_stats.c
index f7c2c93690fee79269215f3fbb57f1bd528b0b1d..7d9abc9fe276ec76ec866ae7c2bbabad492c446d 100644 (file)
@@ -25,7 +25,6 @@
  */
 
 #include "stdinc.h"
-#include "tools.h"             /* rb_dlink_node/rb_dlink_list */
 #include "class.h"             /* report_classes */
 #include "client.h"            /* Client */
 #include "common.h"            /* TRUE/FALSE */
 #include "numeric.h"           /* ERR_xxx */
 #include "scache.h"            /* list_scache */
 #include "send.h"              /* sendto_one */
-#include "commio.h"            /* highest_fd */
 #include "s_conf.h"            /* ConfItem */
 #include "s_serv.h"            /* hunt_server */
 #include "s_stats.h"           /* tstats */
 #include "s_user.h"            /* show_opers */
-#include "event.h"             /* events */
 #include "blacklist.h"         /* dnsbl stuff */
-#include "linebuf.h"
 #include "parse.h"
 #include "modules.h"
 #include "hook.h"
@@ -122,7 +118,7 @@ static void stats_memory(struct Client *);
 static void stats_servlinks(struct Client *);
 static void stats_ltrace(struct Client *, int, const char **);
 static void stats_ziplinks(struct Client *);
-
+static void stats_comm(struct Client *);
 /* This table contains the possible stats items, in order:
  * stats letter,  function to call, operonly? adminonly?
  * case only matters in the stats letter column.. -- fl_
@@ -139,8 +135,8 @@ static struct StatsStruct stats_cmd_table[] = {
        {'D', stats_deny,               1, 0, },
        {'e', stats_exempt,             1, 0, },
        {'E', stats_events,             1, 1, },
-       {'f', rb_dump,          1, 1, },
-       {'F', rb_dump,          1, 1, },
+       {'f', stats_comm,               1, 1, },
+       {'F', stats_comm,               1, 1, },
        {'g', stats_pending_glines,     1, 0, },
        {'G', stats_glines,             1, 0, },
        {'h', stats_hubleaf,            0, 0, },
@@ -199,7 +195,7 @@ m_stats(struct Client *client_p, struct Client *source_p, int parc, const char *
        if(MyClient(source_p) && !IsOper(source_p))
        {
                /* Check the user is actually allowed to do /stats, and isnt flooding */
-               if((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
+               if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
                {
                        /* safe enough to give this on a local connect only */
                        sendto_one(source_p, form_str(RPL_LOAD2HI),
@@ -209,7 +205,7 @@ m_stats(struct Client *client_p, struct Client *source_p, int parc, const char *
                        return 0;
                }
                else
-                       last_used = CurrentTime;
+                       last_used = rb_current_time();
        }
 
        if(hunt_server (client_p, source_p, ":%s STATS %s :%s", 2, parc, parv) != HUNTED_ISME)
@@ -447,10 +443,17 @@ stats_exempt(struct Client *source_p)
        }}
 
 
+static void
+stats_events_cb(char *str, void *ptr)
+{
+       sendto_one_numeric(ptr, RPL_STATSDEBUG, "E :%s", str);
+}
+
 static void
 stats_events (struct Client *source_p)
 {
-       show_events (source_p);
+       rb_dump_events(stats_events_cb, source_p);
+       send_pop_queue(source_p);
 }
 
 /* stats_pending_glines()
@@ -891,7 +894,7 @@ stats_usage (struct Client *source_p)
        if(0 == secs)
                secs = 1;
 
-       rup = (CurrentTime - startup_time) * hzz;
+       rup = (rb_current_time() - startup_time) * hzz;
        if(0 == rup)
                rup = 1;
   
@@ -932,7 +935,7 @@ stats_uptime (struct Client *source_p)
 {
        time_t now;
 
-       now = CurrentTime - startup_time;
+       now = rb_current_time() - startup_time;
        sendto_one_numeric(source_p, RPL_STATSUPTIME, 
                           form_str (RPL_STATSUPTIME),
                           now / 86400, (now / 3600) % 24, 
@@ -1046,7 +1049,7 @@ stats_servers (struct Client *source_p)
                target_p = ptr->data;
 
                j++;
-               seconds = CurrentTime - target_p->localClient->firsttime;
+               seconds = rb_current_time() - target_p->localClient->firsttime;
 
                days = (int) (seconds / 86400);
                seconds %= 86400;
@@ -1060,8 +1063,8 @@ stats_servers (struct Client *source_p)
                                   "Connected: %d day%s, %d:%02d:%02d",
                                   target_p->name,
                                   (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
-                                  (int) (CurrentTime - target_p->localClient->lasttime),
-                                  (int) linebuf_len (&target_p->localClient->buf_sendq),
+                                  (int) (rb_current_time() - target_p->localClient->lasttime),
+                                  (int) rb_linebuf_len (&target_p->localClient->buf_sendq),
                                   days, (days == 1) ? "" : "s", hours, minutes, 
                                   (int) seconds);
        }
@@ -1186,14 +1189,14 @@ stats_servlinks (struct Client *source_p)
                sendto_one(source_p, Sformat,
                        get_id(&me, source_p), RPL_STATSLINKINFO, get_id(source_p, source_p),
                        get_server_name(target_p, SHOW_IP),
-                       (int) linebuf_len (&target_p->localClient->buf_sendq),
+                       (int) rb_linebuf_len (&target_p->localClient->buf_sendq),
                        (int) target_p->localClient->sendM,
                        (int) target_p->localClient->sendK,
                        (int) target_p->localClient->receiveM,
                        (int) target_p->localClient->receiveK,
-                       CurrentTime - target_p->localClient->firsttime,
-                       (CurrentTime > target_p->localClient->lasttime) ? 
-                        (CurrentTime - target_p->localClient->lasttime) : 0,
+                       rb_current_time() - target_p->localClient->firsttime,
+                       (rb_current_time() > target_p->localClient->lasttime) ? 
+                        (rb_current_time() - target_p->localClient->lasttime) : 0,
                        IsOper (source_p) ? show_capabilities (target_p) : "TS");
        }
 
@@ -1207,7 +1210,7 @@ stats_servlinks (struct Client *source_p)
                           "? :Recv total : %7.2f %s",
                           _GMKv (receiveK), _GMKs (receiveK));
 
-       uptime = (CurrentTime - startup_time);
+       uptime = (rb_current_time() - startup_time);
 
        sendto_one_numeric(source_p, RPL_STATSDEBUG,
                           "? :Server send: %7.2f %s (%4.1f K/s)",
@@ -1339,14 +1342,14 @@ stats_l_client(struct Client *source_p, struct Client *target_p,
        {
                sendto_one_numeric(source_p, RPL_STATSLINKINFO, Lformat,
                                get_server_name(target_p, SHOW_IP),
-                               (int) linebuf_len(&target_p->localClient->buf_sendq),
+                               (int) rb_linebuf_len(&target_p->localClient->buf_sendq),
                                (int) target_p->localClient->sendM,
                                (int) target_p->localClient->sendK,
                                (int) target_p->localClient->receiveM,
                                (int) target_p->localClient->receiveK,
-                               CurrentTime - target_p->localClient->firsttime,
-                               (CurrentTime > target_p->localClient->lasttime) ? 
-                                (CurrentTime - target_p->localClient->lasttime) : 0,
+                               rb_current_time() - target_p->localClient->firsttime,
+                               (rb_current_time() > target_p->localClient->lasttime) ? 
+                                (rb_current_time() - target_p->localClient->lasttime) : 0,
                                IsOper(source_p) ? show_capabilities(target_p) : "-");
        }
 
@@ -1358,18 +1361,32 @@ stats_l_client(struct Client *source_p, struct Client *target_p,
                                     get_client_name(target_p, SHOW_IP) :
                                     get_client_name(target_p, HIDE_IP)) :
                                    get_client_name(target_p, MASK_IP),
-                                   (int) linebuf_len(&target_p->localClient->buf_sendq),
+                                   (int) rb_linebuf_len(&target_p->localClient->buf_sendq),
                                    (int) target_p->localClient->sendM,
                                    (int) target_p->localClient->sendK,
                                    (int) target_p->localClient->receiveM,
                                    (int) target_p->localClient->receiveK,
-                                   CurrentTime - target_p->localClient->firsttime,
-                                   (CurrentTime > target_p->localClient->lasttime) ? 
-                                    (CurrentTime - target_p->localClient->lasttime) : 0,
+                                   rb_current_time() - target_p->localClient->firsttime,
+                                   (rb_current_time() > target_p->localClient->lasttime) ? 
+                                    (rb_current_time() - target_p->localClient->lasttime) : 0,
                                    "-");
        }
 }
 
+static void
+rb_dump_fd_callback(int fd, const char *desc, void *data)
+{
+       struct Client *source_p = data;
+       sendto_one_numeric(source_p, RPL_STATSDEBUG, "F :fd %-3d desc '%s'", fd, desc);
+}
+
+static void
+stats_comm(struct Client *source_p)
+{
+       rb_dump_fd(rb_dump_fd_callback, source_p);
+       send_pop_queue(source_p);
+}
+
 /*
  * stats_spy
  *