From: Gunnar Beutner Date: Tue, 6 Aug 2013 15:15:03 +0000 (+0200) Subject: Implement 'reason' provider for whowas search. X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/commitdiff_plain/8c50d8ebc3a9011299d39c4689b680022d876d98 Implement 'reason' provider for whowas search. --HG-- branch : shroudtrusts --- diff --git a/newsearch/Makefile b/newsearch/Makefile index 690e3508..58663674 100644 --- a/newsearch/Makefile +++ b/newsearch/Makefile @@ -6,7 +6,7 @@ LDFLAGS+=$(LIBPCRE) .PHONY: all clean distclean all: newsearch.so -NSCOMMANDS=ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.o ns-away.o ns-modes.o ns-nick.o ns-ident.o ns-regex.o ns-host.o ns-channel.o ns-lt.o ns-gt.o ns-timestamp.o ns-country.o ns-authname.o ns-ip.o ns-kill.o ns-gline.o ns-exists.o ns-services.o ns-size.o ns-name.o ns-topic.o ns-oppct.o ns-cumodecount.o ns-cumodepct.o ns-hostpct.o ns-authedpct.o ns-length.o ns-kick.o ns-authts.o ns-channels.o ns-server.o ns-authid.o ns-notice.o newsearch_ast.o ns-any.o ns-channeliter.o ns-var.o ns-all.o ns-cumodes.o ns-cidr.o ns-nickiter.o ns-ipv6.o ns-away.o ns-quit.o ns-killed.o ns-renamed.o ns-age.o ns-newnick.o +NSCOMMANDS=ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.o ns-away.o ns-modes.o ns-nick.o ns-ident.o ns-regex.o ns-host.o ns-channel.o ns-lt.o ns-gt.o ns-timestamp.o ns-country.o ns-authname.o ns-ip.o ns-kill.o ns-gline.o ns-exists.o ns-services.o ns-size.o ns-name.o ns-topic.o ns-oppct.o ns-cumodecount.o ns-cumodepct.o ns-hostpct.o ns-authedpct.o ns-length.o ns-kick.o ns-authts.o ns-channels.o ns-server.o ns-authid.o ns-notice.o newsearch_ast.o ns-any.o ns-channeliter.o ns-var.o ns-all.o ns-cumodes.o ns-cidr.o ns-nickiter.o ns-ipv6.o ns-away.o ns-quit.o ns-killed.o ns-renamed.o ns-age.o ns-newnick.o ns-reason.o newsearch.so: newsearch.o formats.o y.tab.o lex.yy.o parser.o ${NSCOMMANDS} diff --git a/newsearch/newsearch.c b/newsearch/newsearch.c index 782e59bf..c91ac9e9 100644 --- a/newsearch/newsearch.c +++ b/newsearch/newsearch.c @@ -218,6 +218,7 @@ void _init() { registersearchterm(reg_whowassearch, "renamed",renamed_parse, 0, "User changed nick"); registersearchterm(reg_whowassearch, "age",age_parse, 0, "Whowas record age in seconds"); registersearchterm(reg_whowassearch, "newnick",newnick_parse, 0, "New nick (for rename whowas records)"); + registersearchterm(reg_whowassearch, "reason",reason_parse, 0, "Quit/kill reason"); /* Channel operations */ registersearchterm(reg_chansearch, "exists",exists_parse, 0, "Returns if channel exists on network. Note: newserv may store data on empty channels"); /* channel only */ diff --git a/newsearch/newsearch.h b/newsearch/newsearch.h index 98c8ac06..67ebe116 100644 --- a/newsearch/newsearch.h +++ b/newsearch/newsearch.h @@ -148,6 +148,7 @@ struct searchNode *killed_parse(searchCtx *ctx, int argc, char **argv); struct searchNode *renamed_parse(searchCtx *ctx, int argc, char **argv); struct searchNode *age_parse(searchCtx *ctx, int argc, char **argv); struct searchNode *newnick_parse(searchCtx *ctx, int argc, char **argv); +struct searchNode *reason_parse(searchCtx *ctx, int argc, char **argv); /* Channel functions (various types) */ struct searchNode *exists_parse(searchCtx *ctx, int argc, char **argv); diff --git a/newsearch/ns-reason.c b/newsearch/ns-reason.c new file mode 100644 index 00000000..6a528825 --- /dev/null +++ b/newsearch/ns-reason.c @@ -0,0 +1,42 @@ +/* + * quit functionality + */ + +#include "newsearch.h" + +#include +#include + +void *reason_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); +void reason_free(searchCtx *ctx, struct searchNode *thenode); + +struct searchNode *reason_parse(searchCtx *ctx, int argc, char **argv) { + struct searchNode *thenode; + + if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) { + parseError = "malloc: could not allocate memory for this search."; + return NULL; + } + + thenode->returntype = RETURNTYPE_BOOL; + thenode->localdata = NULL; + thenode->exe = reason_exe; + thenode->free = reason_free; + + return thenode; +} + +void *reason_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { + nick *np = (nick *)theinput; + whowas *ww = (whowas *)np->next; + + if (ww->type != WHOWAS_RENAME) + return (void *)0; + + return (void *)ww->reason->content; +} + +void reason_free(searchCtx *ctx, struct searchNode *thenode) { + free(thenode); +} +