]> jfr.im git - irc/quakenet/newserv.git/blame - newsearch/ns-country.c
Add jupe support
[irc/quakenet/newserv.git] / newsearch / ns-country.c
CommitLineData
c433958f
CP
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
14void *country_exe(struct searchNode *thenode, int type, void *theinput);
15void *country_exe_real(struct searchNode *thenode, int type, void *theinput);
16void country_free(struct searchNode *thenode);
17
18int ext;
19
20struct 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
45void *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
54void country_free(struct searchNode *thenode) {
55 free(thenode);
56}