]> jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-country.c
added LISP style kill/gline functionality
[irc/quakenet/newserv.git] / newsearch / ns-country.c
1 /*
2 * COUNTRY functionality
3 */
4
5 #include "newsearch.h"
6
7 #include <stdio.h>
8 #include <stdlib.h>
9
10 #include "../irc/irc_config.h"
11 #include "../lib/irc_string.h"
12
13 void *country_exe(struct searchNode *thenode, int type, void *theinput);
14 void *country_exe_real(struct searchNode *thenode, int type, void *theinput);
15 void country_free(struct searchNode *thenode);
16
17 int ext;
18
19 struct searchNode *country_parse(int type, int argc, char **argv) {
20 struct searchNode *thenode;
21
22 if (type != SEARCHTYPE_NICK) {
23 parseError = "country: this function is only valid for nick searches.";
24 return NULL;
25 }
26
27 ext = findnickext("geoip");
28 if(ext == -1) {
29 parseError = "country: Geoip module not loaded.";
30 return NULL;
31 }
32
33
34 thenode=(struct searchNode *)malloc(sizeof (struct searchNode));
35
36 thenode->returntype = RETURNTYPE_INT;
37 thenode->localdata = NULL;
38 thenode->exe = country_exe;
39 thenode->free = country_free;
40
41 return thenode;
42 }
43
44 void *country_exe(struct searchNode *thenode, int type, void *theinput) {
45 nick *np = (nick *)theinput;
46
47 if (type != RETURNTYPE_INT)
48 return (void *)1;
49
50 return (void *)np->exts[ext];
51 }
52
53 void country_free(struct searchNode *thenode) {
54 free(thenode);
55 }