]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-ip.c
sync R from D back into this branch
[irc/quakenet/newserv.git] / newsearch / ns-ip.c
index 7886ec6b229ab54abad605dae1b2ac3867223cf0..a96f7f1d7c44c1699a804e80f4db9a48b590e129 100644 (file)
@@ -7,12 +7,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "../nick/nick.h"
+void *ip_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void ip_free(searchCtx *ctx, struct searchNode *thenode);
 
-void *ip_exe(struct searchNode *thenode, int type, void *theinput);
-void ip_free(struct searchNode *thenode);
-
-struct searchNode *ip_parse(int type, int argc, char **argv) {
+struct searchNode *ip_parse(searchCtx *ctx, int type, int argc, char **argv) {
   struct searchNode *thenode;
 
   if (type != SEARCHTYPE_NICK) {
@@ -20,7 +18,10 @@ struct searchNode *ip_parse(int type, int argc, char **argv) {
     return NULL;
   }
 
-  thenode=(struct searchNode *)malloc(sizeof (struct searchNode));
+  if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
+    parseError = "malloc: could not allocate memory for this search.";
+    return NULL;
+  }
 
   thenode->returntype = RETURNTYPE_STRING;
   thenode->localdata = NULL;
@@ -30,17 +31,13 @@ struct searchNode *ip_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *ip_exe(struct searchNode *thenode, int type, void *theinput) {
+void *ip_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
-  if (type != RETURNTYPE_STRING) {
-    return (void *)1;
-  }
-
-  return IPtostr(np->p_ipaddr);
+  return (void *)IPtostr(np->p_ipaddr);
 }
 
-void ip_free(struct searchNode *thenode) {
+void ip_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }