]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-hostmask.c
SearchCtx should contain 'type' - this is to make life easier when defining new searc...
[irc/quakenet/newserv.git] / newsearch / ns-hostmask.c
index 1ef9f74910e679ac6d1ae5b51c719eb26e6cbacf..ae4f5492a423ff3f853cc8f38d6936437757af1d 100644 (file)
 #include "../irc/irc_config.h"
 #include "../lib/irc_string.h"
 
-void *hostmask_exe(struct searchNode *thenode, int type, void *theinput);
-void *hostmask_exe_real(struct searchNode *thenode, int type, void *theinput);
-void hostmask_free(struct searchNode *thenode);
+void *hostmask_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void *hostmask_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void hostmask_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *hostmask_parse(int type, int argc, char **argv) {
+struct searchNode *hostmask_parse(searchCtx *ctx, int argc, char **argv) {
   struct searchNode *thenode;
 
-  if (type != SEARCHTYPE_NICK) {
+  if (ctx->type != SEARCHTYPE_NICK) {
     parseError = "hostmask: this function is only valid for nick searches.";
     return NULL;
   }
@@ -28,7 +28,7 @@ struct searchNode *hostmask_parse(int type, int argc, char **argv) {
   }
 
   thenode->returntype = RETURNTYPE_STRING;
-  if (!(thenode->localdata = (void *)malloc(HOSTLEN+USERLEN+NICKLEN+3))) {
+  if (!(thenode->localdata = (void *)malloc(HOSTLEN+USERLEN+NICKLEN+REALLEN+10))) {
     /* couldn't malloc() memory for thenode->localdata, so free thenode to avoid leakage */
     parseError = "malloc: could not allocate memory for this search.";
     free(thenode);
@@ -46,31 +46,23 @@ struct searchNode *hostmask_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *hostmask_exe(struct searchNode *thenode, int type, void *theinput) {
+void *hostmask_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
   char *buf = thenode->localdata;
 
-  if (type != RETURNTYPE_STRING) {
-    return (void *)1;
-  }
-
   return visiblehostmask(np, buf);
 }
 
-void *hostmask_exe_real(struct searchNode *thenode, int type, void *theinput) {
+void *hostmask_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
   char *buf = thenode->localdata;
 
-  if (type != RETURNTYPE_STRING) {
-    return (void *)1;
-  }
-
-  sprintf(buf,"%s!%s@%s",np->nick,np->ident,np->host->name->content);
+  sprintf(buf,"%s!%s@%s\r%s",np->nick,np->ident,np->host->name->content,np->realname->name->content);
 
   return buf;
 }
 
-void hostmask_free(struct searchNode *thenode) {
+void hostmask_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode->localdata);
   free(thenode);
 }