X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/fa14012da55d8fa4b8d79b164ada9c354aeefbc9..3e1b768066a16c4b899b9cbdd7911be883151a05:/newsearch/ns-country.c diff --git a/newsearch/ns-country.c b/newsearch/ns-country.c index 1a237e10..3f858827 100644 --- a/newsearch/ns-country.c +++ b/newsearch/ns-country.c @@ -12,21 +12,17 @@ #include "../geoip/geoip.h" #include "../core/modules.h" -void *country_exe(struct searchNode *thenode, void *theinput); -void country_free(struct searchNode *thenode); +void *country_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); +void country_free(searchCtx *ctx, struct searchNode *thenode); int ext; -struct searchNode *country_parse(int type, int argc, char **argv) { - struct searchNode *thenode; +struct searchNode *country_parse(searchCtx *ctx, int argc, char **argv) { + struct searchNode *thenode, *countrysn; GeoIP_LookupCode l; long target; - - if (type != SEARCHTYPE_NICK) { - parseError = "country: this function is only valid for nick searches."; - return NULL; - } - + char *p; + if (argc<1) { parseError = "country: usage: country "; return NULL; @@ -39,7 +35,17 @@ struct searchNode *country_parse(int type, int argc, char **argv) { } l = ndlsym("geoip", "geoip_lookupcode"); - target = l(argv[0]); + if(!l) { + parseError = "unable to lookup geoip function pointer"; + return NULL; + } + + if (!(countrysn=argtoconststr("country", ctx, argv[0], &p))) + return NULL; + + target = l(p); + countrysn->free(ctx, countrysn); + if(target == -1) { parseError = "country: invalid country."; return NULL; @@ -58,7 +64,7 @@ struct searchNode *country_parse(int type, int argc, char **argv) { return thenode; } -void *country_exe(struct searchNode *thenode, void *theinput) { +void *country_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { nick *np = (nick *)theinput; long country = (long)thenode->localdata, rc = (long)np->exts[ext]; @@ -68,6 +74,6 @@ void *country_exe(struct searchNode *thenode, void *theinput) { return (void *)0; } -void country_free(struct searchNode *thenode) { +void country_free(searchCtx *ctx, struct searchNode *thenode) { free(thenode); }