X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/5a0247f12b0397d42e6ba09bc6f23ee82ebb44d0..8855bb48b449ed06cfd3ce528b3c0a77c37cb24b:/newsearch/ns-hostmask.c diff --git a/newsearch/ns-hostmask.c b/newsearch/ns-hostmask.c index 85dd9c07..caa66e08 100644 --- a/newsearch/ns-hostmask.c +++ b/newsearch/ns-hostmask.c @@ -11,11 +11,36 @@ #include "../lib/irc_string.h" void *hostmask_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); -void *hostmask_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput); +void *hostmask_exe_rn(searchCtx *ctx, struct searchNode *thenode, void *theinput); +void *hostmask_exe_rh(searchCtx *ctx, struct searchNode *thenode, void *theinput); +void *hostmask_exe_rn_rh(searchCtx *ctx, struct searchNode *thenode, void *theinput); void hostmask_free(searchCtx *ctx, struct searchNode *thenode); struct searchNode *hostmask_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; + int realhost = 0, realname = 0, i, error = 0; + + for(i=0;ifree(ctx, convsn); + + if(error) { + parseError = "bad argument: use realhost and/or realname"; + return NULL; + } + } if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) { parseError = "malloc: could not allocate memory for this search."; @@ -29,13 +54,20 @@ struct searchNode *hostmask_parse(searchCtx *ctx, int argc, char **argv) { free(thenode); return NULL; } - thenode->exe = hostmask_exe; thenode->free = hostmask_free; - /* Allow "hostmask real" to match realhost */ - - if (argc>0 && !ircd_strcmp(argv[0],"real")) { - thenode->exe = hostmask_exe_real; + if(realname) { + if(realhost) { + thenode->exe = hostmask_exe_rn_rh; + } else { + thenode->exe = hostmask_exe_rn; + } + } else { + if(realhost) { + thenode->exe = hostmask_exe_rh; + } else { + thenode->exe = hostmask_exe; + } } return thenode; @@ -48,7 +80,16 @@ void *hostmask_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { return visiblehostmask(np, buf); } -void *hostmask_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput) { +void *hostmask_exe_rh(searchCtx *ctx, struct searchNode *thenode, void *theinput) { + nick *np = (nick *)theinput; + char *buf = thenode->localdata; + + sprintf(buf,"%s!%s@%s",np->nick,np->ident,np->host->name->content); + + return buf; +} + +void *hostmask_exe_rn_rh(searchCtx *ctx, struct searchNode *thenode, void *theinput) { nick *np = (nick *)theinput; char *buf = thenode->localdata; @@ -57,6 +98,15 @@ void *hostmask_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinp return buf; } +void *hostmask_exe_rn(searchCtx *ctx, struct searchNode *thenode, void *theinput) { + nick *np = (nick *)theinput; + char *buf = thenode->localdata; + + sprintf(buf,"%s\r%s",visiblehostmask(np, buf),np->realname->name->content); + + return buf; +} + void hostmask_free(searchCtx *ctx, struct searchNode *thenode) { free(thenode->localdata); free(thenode);