#include "versionscan.h"
+#include "../lib/version.h"
+#include "../glines/glines.h"
+
+MODULE_VERSION("")
CommandTree* versionscan_commands;
nick* versionscan_nick;
schedule *vsconnect;
void versionscan_addstat(char* reply) {
+ unsigned int replylen;
+ unsigned long replycrc;
vsstatistic* v, *pv;
-
- pv=0;
+
+ replylen = strlen(reply);
+ replycrc = irc_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;
}
}
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;
}
}
vsauths=pv->next;
free(pv);
}
+ break;
}
prevv=pv;
}
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);
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: