X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/850bf0cfc1f89d21ebc74cabe01a5e8b11fbd7b3..8dc0685213ead3f8896c83cadc130143ccc4d181:/src/log.c diff --git a/src/log.c b/src/log.c index 07587ef..ef531ee 100644 --- a/src/log.c +++ b/src/log.c @@ -3,7 +3,7 @@ * * This file is part of x3. * - * srvx is free software; you can redistribute it and/or modify + * x3 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. @@ -541,7 +541,7 @@ log_audit(struct log_type *type, enum log_severity sev, struct userNode *user, s /* remove old elements from the linked list */ while (type->log_count > type->max_count) log_type_free_oldest(type); - while (type->log_oldest && (type->log_oldest->time + type->max_age < (unsigned long)now)) + while (type->log_oldest && (type->log_oldest->time + (time_t)type->max_age < now)) log_type_free_oldest(type); if (type->log_oldest) type->log_oldest->prev = 0; @@ -602,7 +602,7 @@ log_module(struct log_type *type, enum log_severity sev, const char *format, ... fprintf(stderr, "%s: %s\n", log_severity_names[sev], msgbuf); } if (sev == LOG_FATAL) { - assert(0 && "fatal message logged"); + //assert(0 && "fatal message logged"); _exit(1); } } @@ -1049,19 +1049,24 @@ void SyncLog(char *fmt,...) int parselog(char *LogLine, struct userNode *user, struct chanNode *cptr, char *chan, char *nuh, char *command, char *rest) { - const char *info; - - char serv[NICKLEN+1]; - - char* mychan; - char* mynuh; + struct svccmd *svccmd; + struct svccmd *cmd; + struct service *service; + const char *info; + char serv[NICKLEN+1]; + char buf[MAXLEN]; + char myservc[MAXLEN]; + char* mychan; + char* mynuh; char* mycommand; - char* myrest; - char* datestr; - char* mywho; - char* myserv; + char* myrest; + char* datestr; + char* mywho; + char *myserv; char* myserva; - char* mychana; + char* mychana; + unsigned int pos; + int p = 0; datestr = (char *) mysep(&LogLine, "]"); mywho = (char *) mysep(&LogLine, " "); @@ -1100,15 +1105,75 @@ int parselog(char *LogLine, struct userNode *user, struct chanNode *cptr, char * if (!myserv) myserv = ""; + else + strcpy(myservc, myserv); + if (!strcmp(myserv, info)) { if (!IsOper(user)) return 0; - sprintf(serv, "(%s)", info); - } else + else { + if ((service = service_find(myserv))) { + if (!(cmd = dict_find(service->commands, mycommand, NULL))) + return 0; + + if (!(svccmd = svccmd_resolve_name(cmd, mycommand))) + return 0; + + pos = snprintf(buf, sizeof(buf), "%s.%s", svccmd->command->parent->name, svccmd->command->name); + + if (svccmd->alias.used) { + buf[pos++] = ' '; + unsplit_string((char**)svccmd->alias.list+1, svccmd->alias.used-1, buf+pos); + } + } + } + + if (!(strcmp(buf+0, "OpServ.OP"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.DEOP"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.VOICE"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.DEVOICE"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.KICK"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.KICKBAN"))) + p = 1; + + if (!(strcmp(buf+0, "OpServ.OPALL"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.DEOPALL"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.VOICEALL"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.DEVOICEALL"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.KICKALL"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.KICKBANALL"))) + p = 1; + + + if (!(strcmp(buf+0, "OpServ.INVITE"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.INVITEME"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.CLEARBANS"))) + p = 1; + if (!(strcmp(buf+0, "OpServ.CLEARMODES"))) + p = 1; + + if (p == 1) + send_message(user, chanserv, "LAST_RESULTS", datestr, myserv, mynuh, mycommand, myrest); + + p = 0; + } else { sprintf(serv, "%s", ""); + send_message(user, chanserv, "LAST_RESULTS", datestr, serv, mynuh, mycommand, myrest); + } - send_message(user, chanserv, "LAST_RESULTS", datestr, serv, mynuh, mycommand, myrest); return 1; }