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