]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Implement 'reason' provider for whowas search.
authorGunnar Beutner <redacted>
Tue, 6 Aug 2013 15:15:03 +0000 (17:15 +0200)
committerGunnar Beutner <redacted>
Tue, 6 Aug 2013 15:15:03 +0000 (17:15 +0200)
--HG--
branch : shroudtrusts

newsearch/Makefile
newsearch/newsearch.c
newsearch/newsearch.h
newsearch/ns-reason.c [new file with mode: 0644]

index 690e35088062e3bf4f5374ac99b0f54a1739af8c..5866367492cd37683abf40c5f7987f8153c71cd2 100644 (file)
@@ -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}
 
index 782e59bf0a3271c9a06035df775b3a1e477fef18..c91ac9e9c630d346b9c9a3c3e477664034e3842c 100644 (file)
@@ -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 */
index 98c8ac060db87fd7cc72257af585910bb82ab9cf..67ebe1165249b322a556004276fd95fbbed64f43 100644 (file)
@@ -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 (file)
index 0000000..6a52882
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * quit functionality
+ */
+
+#include "newsearch.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+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);
+}
+