]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Add country to nicksearch
authorChris Porter <redacted>
Sun, 19 Mar 2006 12:47:00 +0000 (12:47 +0000)
committerChris Porter <redacted>
Sun, 19 Mar 2006 12:47:00 +0000 (12:47 +0000)
newsearch/Makefile
newsearch/newsearch.c
newsearch/newsearch.h
newsearch/ns-country.c [new file with mode: 0644]

index 5d511bc06d30656e54249961414ca8278e21516b..242f125a2911f03c453d91e802f6809cdc697771 100644 (file)
@@ -2,5 +2,5 @@
 .PHONY: all
 all: newsearch.so
 
-newsearch.so: newsearch.o ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.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
+newsearch.so: newsearch.o ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.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
        ld -shared -Bdynamic $(LIBPCRE) -o $@ $^
index 85ff1072dfc8db77b4a4640271664df3b34bda47..bb502dc8db2610d55a2a1d3d056d62dd63d9a55f 100644 (file)
@@ -47,6 +47,7 @@ void _init() {
   registersearchterm("host",host_parse);
   registersearchterm("channel",channel_parse);
   registersearchterm("timestamp",timestamp_parse);
+  registersearchterm("country",country_parse);
 
   /* Nickname / channel operations */
   registersearchterm("modes",modes_parse);
index 1519dd4e65310cb88938d5af79a49b0ab0609bf5..0afdf820983ae9dac378cc4db104c8f7683f1ccb 100644 (file)
@@ -32,6 +32,7 @@ struct searchNode *ident_parse(int type, int argc, char **argv);
 struct searchNode *host_parse(int type, int argc, char **argv);
 struct searchNode *channel_parse(int type, int argc, char **argv);
 struct searchNode *timestamp_parse(int type, int argc, char **argv);
+struct searchNode *country_parse(int type, int argc, char **argv);
 
 
 struct searchNode *search_parse(int type, char *input);
diff --git a/newsearch/ns-country.c b/newsearch/ns-country.c
new file mode 100644 (file)
index 0000000..eeba0f3
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * COUNTRY functionality
+ */
+
+#include "newsearch.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "../irc/irc_config.h"
+#include "../nick/nick.h"
+#include "../lib/irc_string.h"
+
+void *country_exe(struct searchNode *thenode, int type, void *theinput);
+void *country_exe_real(struct searchNode *thenode, int type, void *theinput);
+void country_free(struct searchNode *thenode);
+
+int ext;
+
+struct searchNode *country_parse(int type, int argc, char **argv) {
+  struct searchNode *thenode;
+
+  if (type != SEARCHTYPE_NICK) {
+    parseError = "country: this function is only valid for nick searches.";
+    return NULL;
+  }
+
+  ext = findnickext("geoip");
+  if(ext == -1) {
+    parseError = "country: Geoip module not loaded.";
+    return NULL;
+  }
+  
+
+  thenode=(struct searchNode *)malloc(sizeof (struct searchNode));
+
+  thenode->returntype = RETURNTYPE_INT;
+  thenode->localdata = NULL;
+  thenode->exe = country_exe;
+  thenode->free = country_free;
+
+  return thenode;
+}
+
+void *country_exe(struct searchNode *thenode, int type, void *theinput) {
+  nick *np = (nick *)theinput;
+
+  if (type != RETURNTYPE_INT)
+    return (void *)1;
+
+  return (void *)np->exts[ext];
+}
+
+void country_free(struct searchNode *thenode) {
+  free(thenode);
+}