]> jfr.im git - irc/quakenet/newserv.git/commitdiff
PARSER: Added "calls" field to allow tracking how many times each command is
authorsplidge <redacted>
Tue, 5 May 2009 14:01:01 +0000 (15:01 +0100)
committersplidge <redacted>
Tue, 5 May 2009 14:01:01 +0000 (15:01 +0100)
called.

Used this field to add partial "stats m" functionality to the IRC module (we
don't count bytes so bytes is always returned as 0).

irc/irc.c
irc/irc.h
nick/nickhandlers.c
parser/parser.c
parser/parser.h

index 4f3ae431271727eb00541c1f56d5ec06a545971f..932d067e2721b831950ca895a417635594e36db8 100644 (file)
--- a/irc/irc.c
+++ b/irc/irc.c
@@ -448,6 +448,7 @@ int parseline() {
       return 0;
     }
     for (;c!=NULL;c=c->next) {
+      c->calls++;
       if (((c->handler)("INIT",cargc-1,&cargv[1]))==CMD_LAST)
         return 0;
     }  
@@ -457,6 +458,7 @@ int parseline() {
       long numeric = strtol(cargv[1], NULL, 0);
       if((numeric >= MIN_NUMERIC) && (numeric <= MAX_NUMERIC)) {
         for(c=numericcommands[numeric];c;c=c->next) {
+          c->calls++;
           if (((c->handler)((void *)numeric,cargc,cargv))==CMD_LAST)
             return 0;
         }
@@ -467,6 +469,7 @@ int parseline() {
         return 0;
       }
       for (;c!=NULL;c=c->next) {
+        c->calls++;
         if (((c->handler)(cargv[0],cargc-2,cargv+2))==CMD_LAST)
           return 0;
       }
@@ -602,3 +605,13 @@ void ircstats(int hooknum, void *arg) {
     triggerhook(HOOK_CORE_STATSREPLY,buf);
   }
 }
+void stats_m(char *str1, char *str2) {
+  Command *cmds[500];
+  unsigned int c,i;
+  
+  c=getcommandlist(servercommands,cmds,500);
+  
+  for (i=0;i<c;i++) {
+    irc_send(":%s 212 %s %s %u 0", str1, str2, cmds[i]->command->content, cmds[i]->calls);
+  }
+}
index 90b35654dbf8a1e87be7d64fc662a6f779a4b716..9af90c4d140faec500628458dbc19541ffe85c4d 100644 (file)
--- a/irc/irc.h
+++ b/irc/irc.h
@@ -31,6 +31,7 @@ int deregisternumerichandler(const int numeric, CommandHandler handler);
 char *getmynumeric();
 time_t getnettime();
 void setnettime(time_t newtime);
+void stats_m(char *, char *);
 
 /* Functions from irchandlers.c */
 int handleping(void *sender, int cargc, char **cargv);
index 4f208a48c6983d258bad6fd779f2efa775356810..86c3590577d809dcb74637facfd6d660615430e8 100644 (file)
@@ -489,7 +489,10 @@ int handlestatsmsg(void *source, int cargc, char **cargv) {
   case 'P':
     irc_send(":%s 217 %s P none 0 :0x2000",fromstring,replytarget);
     break;
-    
+   
+  case 'm':
+    stats_m(fromstring, replytarget);
+    break; 
   }
 
   irc_send(":%s 219 %s %c :End of /STATS report",fromstring,replytarget,cargv[0][0]);
index 12e46c860c1acda238289a4537a557a2d1a8ec87..2a8147616d3be08dfeda268673148f467363627a 100644 (file)
@@ -130,6 +130,7 @@ Command *addcommandexttotree(CommandTree *ct, const char *cmdname, int level, in
   nc->handler=handler;
   nc->ext=NULL;
   nc->next=NULL;
+  nc->calls=0;
   nc->destroyext=NULL;
 
   if ((c=findcommandintree(ct,cmdname,1))!=NULL) {
index 794d968699de0d9f622b96c631ca15fcf2ddc288..870a9bf86c904b13c9afe87159998b80339024d6 100644 (file)
@@ -39,6 +39,7 @@ typedef struct Command {
   CommandHandler  handler;       /* Function to deal with the message */
   void           *ext;           /* Pointer to some arbitrary other data */
   DestroyExt      destroyext;    /* Function to destroy ->ext on destroycommandtree (if necessary) */
+  unsigned int    calls;         /* How many times this command has been called */
   struct Command *next;          /* Next handler chained onto this command */
 } Command;