]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-authname.c
CHANSERV: better batcher error handling for expired accounts/accounts with no email.
[irc/quakenet/newserv.git] / newsearch / ns-authname.c
index 8c11c3b6cc680224e3af568074b0850fa60a5d0f..f1e299b383f48d77bc1f049bbd228cf938e2b49d 100644 (file)
@@ -7,21 +7,17 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "../nick/nick.h"
+void *authname_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void authname_free(searchCtx *ctx, struct searchNode *thenode);
 
-void *authname_exe(struct searchNode *thenode, int type, void *theinput);
-void authname_free(struct searchNode *thenode);
-
-struct searchNode *authname_parse(int type, int argc, char **argv) {
+struct searchNode *authname_parse(searchCtx *ctx, int argc, char **argv) {
   struct searchNode *thenode;
 
-  if (type != SEARCHTYPE_NICK) {
-    parseError = "authname: 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 = authname_exe;
@@ -30,21 +26,17 @@ struct searchNode *authname_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *authname_exe(struct searchNode *thenode, int type, void *theinput) {
+void *authname_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
 
-  if (type != RETURNTYPE_STRING) {
-    return (void *)1;
-  }
-
   if (IsAccount(np))
     return np->authname;
   else
-    return "[NULL]";
+    return ""; /* will cast to a FALSE */
 
 }
 
-void authname_free(struct searchNode *thenode) {
+void authname_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }