]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-country.c
2 * COUNTRY functionality
10 #include "../irc/irc_config.h"
11 #include "../lib/irc_string.h"
12 #include "../geoip/geoip.h"
13 #include "../core/modules.h"
15 void *country_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
16 void country_free(searchCtx
*ctx
, struct searchNode
*thenode
);
20 struct searchNode
*country_parse(searchCtx
*ctx
, int argc
, char **argv
) {
21 struct searchNode
*thenode
;
26 parseError
= "country: usage: country <country 2 character ISO code>";
30 ext
= findnickext("geoip");
32 parseError
= "country: Geoip module not loaded.";
36 l
= ndlsym("geoip", "geoip_lookupcode");
39 parseError
= "country: invalid country.";
43 if (!(thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
)))) {
44 parseError
= "malloc: could not allocate memory for this search.";
48 thenode
->returntype
= RETURNTYPE_BOOL
;
49 thenode
->localdata
= (void *)target
;
50 thenode
->exe
= country_exe
;
51 thenode
->free
= country_free
;
56 void *country_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
57 nick
*np
= (nick
*)theinput
;
58 long country
= (long)thenode
->localdata
, rc
= (long)np
->exts
[ext
];
66 void country_free(searchCtx
*ctx
, struct searchNode
*thenode
) {