]> jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-country.c
Newsearch overhauled.
[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, void *theinput);
14 void country_free(struct searchNode *thenode);
15
16 int ext;
17
18 struct searchNode *country_parse(int type, int argc, char **argv) {
19 struct searchNode *thenode;
20
21 if (type != SEARCHTYPE_NICK) {
22 parseError = "country: this function is only valid for nick searches.";
23 return NULL;
24 }
25
26 ext = findnickext("geoip");
27 if(ext == -1) {
28 parseError = "country: Geoip module not loaded.";
29 return NULL;
30 }
31
32
33 if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
34 parseError = "malloc: could not allocate memory for this search.";
35 return NULL;
36 }
37
38 thenode->returntype = RETURNTYPE_INT;
39 thenode->localdata = NULL;
40 thenode->exe = country_exe;
41 thenode->free = country_free;
42
43 return thenode;
44 }
45
46 void *country_exe(struct searchNode *thenode, void *theinput) {
47 nick *np = (nick *)theinput;
48
49 return (void *)np->exts[ext];
50 }
51
52 void country_free(struct searchNode *thenode) {
53 free(thenode);
54 }