]> jfr.im git - irc/quakenet/newserv.git/blobdiff - versionscan/versionscan.c
CHANSERV: fix issue where chanserv_relay doesn't wait for db to be loaded before...
[irc/quakenet/newserv.git] / versionscan / versionscan.c
index 4e59460ff559b191c2c5c5f58ec06ea26405acf3..3931ba948f1c9c65e60d2e5eedf1934641def0bc 100644 (file)
@@ -1,4 +1,8 @@
 #include "versionscan.h"
+#include "../lib/version.h"
+#include "../glines/glines.h"
+
+MODULE_VERSION("")
 
 CommandTree* versionscan_commands;
 nick* versionscan_nick;
@@ -14,11 +18,16 @@ unsigned long gcount=0;
 schedule *vsconnect;
 
 void versionscan_addstat(char* reply) {
+  unsigned int replylen;
+  unsigned long replycrc;
   vsstatistic* v, *pv;
-
-  pv=0;
+  
+  replylen = strlen(reply);
+  replycrc = crc32i(reply);
+  
+  pv=NULL;
   for (v=vsstats; v; v=v->next) {
-    if (!ircd_strcmp(v->reply, reply)) {
+    if (v->replylen==replylen && v->replycrc==replycrc) {
       v->count++;
       return;
     }
@@ -26,17 +35,21 @@ void versionscan_addstat(char* reply) {
   }
   if (!pv) {
     vsstats=(vsstatistic*)malloc(sizeof(vsstatistic));
-    vsstats->reply=(char*)malloc(strlen(reply)+1);
+    vsstats->reply=(char*)malloc(replylen + 1);
     strcpy(vsstats->reply, reply);
+    vsstats->replylen = replylen;
+    vsstats->replycrc = replycrc;
     vsstats->count=1;
-    vsstats->next=0;
+    vsstats->next=NULL;
   }
   else {
     pv->next=(vsstatistic*)malloc(sizeof(vsstatistic));
-    pv->next->reply=(char*)malloc(strlen(reply)+1);
+    pv->next->reply=(char*)malloc(replylen + 1);
     strcpy(pv->next->reply, reply);
+    pv->next->replylen = replylen;
+    pv->next->replycrc = replycrc;
     pv->next->count=1;
-    pv->next->next=0;
+    pv->next->next=NULL;
   }
 }
 
@@ -632,12 +645,12 @@ int versionscan_statsdump(void* sender, int cargc, char** cargv) {
     sendnoticetouser(versionscan_nick, np, "No statistics are available unless STATISTICS mode of operation is enabled.");
     return CMD_ERROR;
   }
-  if (!(fout=fopen("versionscanstats","w"))) {
+  if (!(fout=fopen("data/versionscanstats","w"))) {
     sendnoticetouser(versionscan_nick, np, "Unable to open save file.");
     return CMD_ERROR;
   }
   for (v=vsstats; v; v=v->next) {
-    fprintf(fout, "%s [%lu]\n", v->reply, v->count);
+    fprintf(fout, "%lu:%s\n", v->count, v->reply);
     rlimit++;
   }
   fclose(fout);
@@ -752,19 +765,19 @@ void versionscan_handler(nick* me, int type, void** args) {
           hcount++;
           switch (v->action) {
           case VS_WARN:
-            sendnoticetouser(versionscan_nick, sender, v->data);
+            sendnoticetouser(versionscan_nick, sender, "%s", v->data);
             wcount++;
             break;
           case VS_KILL:
-            killuser(versionscan_nick, sender, v->data);
+            killuser(versionscan_nick, sender, "%s", v->data);
             kcount++;
             break;
           case VS_GLUSER:
-            irc_send("%s GL * +*!%s@%s 3600 :%s\r\n", mynumeric->content, sender->ident, sender->host->name->content, v->data);
+            glinebynick(sender, 3600, v->data, GLINE_ALWAYS_USER, "versionscan");
             gcount++;
             break;
           case VS_GLHOST:
-            irc_send("%s GL * +*!*@%s 3600 :%s\r\n", mynumeric->content, sender->host->name->content, v->data);
+            glinebynick(sender, 3600, v->data, 0, "versionscan");
             gcount++;
             break;
           default: