X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/74620ebafeb4a94b61a3747e39d27a4ec7a9fe5a..40814391c7b017da05d4daa2895093e5099801c7:/newsearch/ns-host.c diff --git a/newsearch/ns-host.c b/newsearch/ns-host.c index aa3cfff2..ab919d84 100644 --- a/newsearch/ns-host.c +++ b/newsearch/ns-host.c @@ -10,18 +10,14 @@ #include "../irc/irc_config.h" #include "../lib/irc_string.h" -void *host_exe(struct searchNode *thenode, void *theinput); -void *host_exe_real(struct searchNode *thenode, void *theinput); -void host_free(struct searchNode *thenode); - -struct searchNode *host_parse(int type, int argc, char **argv) { - struct searchNode *thenode; - - if (type != SEARCHTYPE_NICK) { - parseError = "host: this function is only valid for nick searches."; - return NULL; - } - +void *host_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); +void *host_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput); +void host_free(searchCtx *ctx, struct searchNode *thenode); + +struct searchNode *host_parse(searchCtx *ctx, int argc, char **argv) { + struct searchNode *thenode, *argsn; + char *p; + if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) { parseError = "malloc: could not allocate memory for this search."; return NULL; @@ -37,16 +33,23 @@ struct searchNode *host_parse(int type, int argc, char **argv) { thenode->exe = host_exe; thenode->free = host_free; - /* Allow "host real" to match realhost */ - - if (argc>0 && !ircd_strcmp(argv[0],"real")) { - thenode->exe = host_exe_real; + if (argc>0) { + if (!(argsn=argtoconststr("host", ctx, argv[0], &p))) { + free(thenode); + return NULL; + } + + /* Allow "host real" to match realhost */ + if (!ircd_strcmp(p,"real")) + thenode->exe = host_exe_real; + + argsn->free(ctx, argsn); } return thenode; } -void *host_exe(struct searchNode *thenode, void *theinput) { +void *host_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { nick *np = (nick *)theinput; char *buf = thenode->localdata; @@ -60,13 +63,13 @@ void *host_exe(struct searchNode *thenode, void *theinput) { } } -void *host_exe_real(struct searchNode *thenode, void *theinput) { +void *host_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput) { nick *np = (nick *)theinput; return np->host->name->content; } -void host_free(struct searchNode *thenode) { +void host_free(searchCtx *ctx, struct searchNode *thenode) { free(thenode->localdata); free(thenode); }