]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-ident.c
LUA: port luadb to dbapi2 to drop postgres dependency
[irc/quakenet/newserv.git] / newsearch / ns-ident.c
index 3d568a13671526f2316573196f953e75ec477860..825988cda2641f0bd309580d54b4db40f3bb26c4 100644 (file)
@@ -7,21 +7,17 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "../nick/nick.h"
+void *ident_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void ident_free(searchCtx *ctx, struct searchNode *thenode);
 
-void *ident_exe(struct searchNode *thenode, int type, void *theinput);
-void ident_free(struct searchNode *thenode);
-
-struct searchNode *ident_parse(int type, int argc, char **argv) {
+struct searchNode *ident_parse(searchCtx *ctx, int argc, char **argv) {
   struct searchNode *thenode;
 
-  if (type != SEARCHTYPE_NICK) {
-    parseError = "ident: this function is only valid for nick searches.";
+  if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
+    parseError = "malloc: could not allocate memory for this search.";
     return NULL;
   }
 
-  thenode=(struct searchNode *)malloc(sizeof (struct searchNode));
-
   thenode->returntype = RETURNTYPE_STRING;
   thenode->localdata = NULL;
   thenode->exe = ident_exe;
@@ -30,17 +26,13 @@ struct searchNode *ident_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *ident_exe(struct searchNode *thenode, int type, void *theinput) {
+void *ident_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
-  if (type != RETURNTYPE_STRING) {
-    return (void *)1;
-  }
-
   return np->ident;
 }
 
-void ident_free(struct searchNode *thenode) {
+void ident_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }