]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-country.c
TRUSTS: require sqlite
[irc/quakenet/newserv.git] / newsearch / ns-country.c
index 3608156fba3d4c887721b5b27da1e9a66b2c0003..3f8588270be54d0ea6d4b5857909208d0baa4c32 100644 (file)
@@ -17,16 +17,12 @@ void country_free(searchCtx *ctx, struct searchNode *thenode);
 
 int ext;
 
-struct searchNode *country_parse(searchCtx *ctx, 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 <country 2 character ISO code>";
     return NULL;
@@ -39,7 +35,17 @@ struct searchNode *country_parse(searchCtx *ctx, 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;