X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/7839f73a60770f2e3d8bc97ff1c3d709985a7203..f28b61f26dec986fb87602b5c75ad812b8297d85:/newsearch/formats.c diff --git a/newsearch/formats.c b/newsearch/formats.c index c00ac8ad..edc0ebce 100644 --- a/newsearch/formats.c +++ b/newsearch/formats.c @@ -9,15 +9,14 @@ #include "../lib/splitline.h" #include "../lib/version.h" -void printnick(nick *sender, nick *np) { +void printnick(searchCtx *ctx, nick *sender, nick *np) { char hostbuf[HOSTLEN+NICKLEN+USERLEN+4]; - controlreply(sender,"%s [%s] (%s) (%s)",visiblehostmask(np,hostbuf), - IPtostr(np->p_ipaddr), printflags(np->umodes, umodeflags), np->realname->name->content); + ctx->reply(sender,"%s [%s] (%s) (%s)",visiblehostmask(np,hostbuf), + IPtostr(np->ipaddress), printflags(np->umodes, umodeflags), np->realname->name->content); } -void printnick_channels(nick *sender, nick *np) { - char hostbuf[HOSTLEN+NICKLEN+USERLEN+4]; +void printnick_channels(searchCtx *ctx, nick *sender, nick *np) { char chanlistbuf[512]; unsigned int bufpos=0, overflow=0; channel **cs, *cp; @@ -25,7 +24,7 @@ void printnick_channels(nick *sender, nick *np) { unsigned long *lp; /* Include the default format too */ - printnick(sender,np); + printnick(ctx, sender,np); /* Now add the channels.. */ cs=(channel **)(np->channels->content); @@ -51,13 +50,13 @@ void printnick_channels(nick *sender, nick *np) { } if (!bufpos) { - controlreply(sender," Not an any channels."); + ctx->reply(sender," Not an any channels."); } else { - controlreply(sender," On channel%s: %s%s",np->channels->cursi>1?"s":"", chanlistbuf, overflow?"[...]":""); + ctx->reply(sender," On channel%s: %s%s",np->channels->cursi>1?"s":"", chanlistbuf, overflow?"[...]":""); } } -void printchannel(nick *sender, chanindex *cip) { +void printchannel(searchCtx *ctx, nick *sender, chanindex *cip) { /* shamelessly stolen from (now defunct) chansearch.c */ int i; int op,voice,peon; @@ -70,7 +69,7 @@ void printchannel(nick *sender, chanindex *cip) { marker=nexthostmarker(); if (cip->channel==NULL) { - controlreply(sender,"[ Channel currently empty ] %s",cip->name->content); + ctx->reply(sender,"[ Channel currently empty ] %s",cip->name->content); } else { cuhp=cip->channel->users; for (i=0;ihashsize;i++) { @@ -96,21 +95,21 @@ void printchannel(nick *sender, chanindex *cip) { } } } - controlreply(sender,"[ %4dU %4d@ %4d+ %4d %4d* %4dk %4dH ] %s (%s)",cuhp->totalusers,op,voice,peon,oper, + ctx->reply(sender,"[ %4dU %4d@ %4d+ %4d %4d* %4dk %4dH ] %s (%s)",cuhp->totalusers,op,voice,peon,oper, service,hosts,cip->name->content, printflags(cip->channel->flags, cmodeflags)); } } -void printchannel_topic(nick *sender, chanindex *cip) { +void printchannel_topic(searchCtx *ctx, nick *sender, chanindex *cip) { if (cip->channel==NULL) { - controlreply(sender,"[ empty ] %-30s",cip->name->content); + ctx->reply(sender,"[ empty ] %-30s",cip->name->content); } else { - controlreply(sender,"[%4u users] %s (%s)",cip->channel->users->totalusers,cip->name->content,cip->channel->topic?cip->channel->topic->content:"no topic"); + ctx->reply(sender,"[%4u users] %s (%s)",cip->channel->users->totalusers,cip->name->content,cip->channel->topic?cip->channel->topic->content:"no topic"); } } -void printchannel_services(nick *sender, chanindex *cip) { +void printchannel_services(searchCtx *ctx, nick *sender, chanindex *cip) { int i; chanuserhash *cuhp; char servlist[300]; @@ -119,7 +118,7 @@ void printchannel_services(nick *sender, chanindex *cip) { int servs=0; if (cip->channel==NULL) { - controlreply(sender,"%-30s empty",cip->name->content); + ctx->reply(sender,"%-30s empty",cip->name->content); } else { cuhp=cip->channel->users; for (i=0;ihashsize;i++) { @@ -142,8 +141,16 @@ void printchannel_services(nick *sender, chanindex *cip) { } } - controlreply(sender,"%-30s %5d user%c %2d service%c %s%s%s",cip->name->content,cuhp->totalusers, + ctx->reply(sender,"%-30s %5d user%c %2d service%c %s%s%s",cip->name->content,cuhp->totalusers, cuhp->totalusers>1?'s':' ',servs,(servs==1)?' ':'s',servs?"(":"",slpos?servlist:"",servs?")":""); } } +void printuser(searchCtx *ctx, nick *sender, authname *aup) { + ctx->reply(sender,"%d", aup->userid); +} + +void printwhowas(searchCtx *ctx, nick *sender, whowas *ww) { + ctx->reply(sender,"%s", whowas_format(ww)); + ctx->reply(sender,"%s", whowas_formatchannels(ww)); +}