]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/formats.c
5 #include "../irc/irc_config.h"
6 #include "../lib/irc_string.h"
7 #include "../parser/parser.h"
8 #include "../control/control.h"
9 #include "../lib/splitline.h"
10 #include "../lib/version.h"
12 void printnick(searchCtx
*ctx
, nick
*sender
, nick
*np
) {
13 char hostbuf
[HOSTLEN
+NICKLEN
+USERLEN
+4];
15 ctx
->reply(sender
,"%s [%s] (%s) (%s)",visiblehostmask(np
,hostbuf
),
16 IPtostr(np
->p_ipaddr
), printflags(np
->umodes
, umodeflags
), np
->realname
->name
->content
);
19 void printnick_channels(searchCtx
*ctx
, nick
*sender
, nick
*np
) {
20 char chanlistbuf
[512];
21 unsigned int bufpos
=0, overflow
=0;
26 /* Include the default format too */
27 printnick(ctx
, sender
,np
);
29 /* Now add the channels.. */
30 cs
=(channel
**)(np
->channels
->content
);
31 for (i
=0;i
<np
->channels
->cursi
;i
++) {
34 if (!(lp
=getnumerichandlefromchanhash(cp
->users
,np
->numeric
)))
35 /* "Impossible" error case - nick not on this channel */
38 if (bufpos
+ cp
->index
->name
->length
> 400) {
43 if (*lp
& CUMODE_OP
) {
44 chanlistbuf
[bufpos
++]='@';
45 } else if (*lp
& CUMODE_VOICE
) {
46 chanlistbuf
[bufpos
++]='+';
49 bufpos
+=sprintf(chanlistbuf
+bufpos
,"%s ",cp
->index
->name
->content
);
53 ctx
->reply(sender
," Not an any channels.");
55 ctx
->reply(sender
," On channel%s: %s%s",np
->channels
->cursi
>1?"s":"", chanlistbuf
, overflow
?"[...]":"");
59 void printchannel(searchCtx
*ctx
, nick
*sender
, chanindex
*cip
) {
60 /* shamelessly stolen from (now defunct) chansearch.c */
63 int oper
,service
,hosts
;
68 op
=voice
=peon
=oper
=service
=hosts
=0;
69 marker
=nexthostmarker();
71 if (cip
->channel
==NULL
) {
72 ctx
->reply(sender
,"[ Channel currently empty ] %s",cip
->name
->content
);
74 cuhp
=cip
->channel
->users
;
75 for (i
=0;i
<cuhp
->hashsize
;i
++) {
76 if (cuhp
->content
[i
]!=nouser
) {
77 if (cuhp
->content
[i
]&CUMODE_OP
) {
79 } else if (cuhp
->content
[i
]&CUMODE_VOICE
) {
84 if ((np
=getnickbynumeric(cuhp
->content
[i
]&CU_NUMERICMASK
))!=NULL
) {
91 if (np
->host
->marker
!=marker
) {
92 np
->host
->marker
=marker
;
98 ctx
->reply(sender
,"[ %4dU %4d@ %4d+ %4d %4d* %4dk %4dH ] %s (%s)",cuhp
->totalusers
,op
,voice
,peon
,oper
,
99 service
,hosts
,cip
->name
->content
, printflags(cip
->channel
->flags
, cmodeflags
));
104 void printchannel_topic(searchCtx
*ctx
, nick
*sender
, chanindex
*cip
) {
105 if (cip
->channel
==NULL
) {
106 ctx
->reply(sender
,"[ empty ] %-30s",cip
->name
->content
);
108 ctx
->reply(sender
,"[%4u users] %s (%s)",cip
->channel
->users
->totalusers
,cip
->name
->content
,cip
->channel
->topic
?cip
->channel
->topic
->content
:"no topic");
112 void printchannel_services(searchCtx
*ctx
, nick
*sender
, chanindex
*cip
) {
116 int slpos
=0,slfull
=0;
120 if (cip
->channel
==NULL
) {
121 ctx
->reply(sender
,"%-30s empty",cip
->name
->content
);
123 cuhp
=cip
->channel
->users
;
124 for (i
=0;i
<cuhp
->hashsize
;i
++) {
125 if (cuhp
->content
[i
]!=nouser
) {
126 if ((np
=getnickbynumeric(cuhp
->content
[i
]&CU_NUMERICMASK
))) {
131 slpos
+=sprintf(&servlist
[slpos
],", ");
133 slpos
+=sprintf(&servlist
[slpos
],"%s",np
->nick
);
135 sprintf(&servlist
[slpos
],", ...");
144 ctx
->reply(sender
,"%-30s %5d user%c %2d service%c %s%s%s",cip
->name
->content
,cuhp
->totalusers
,
145 cuhp
->totalusers
>1?'s':' ',servs
,(servs
==1)?' ':'s',servs
?"(":"",slpos
?servlist
:"",servs
?")":"");
149 void printuser(searchCtx
*ctx
, nick
*sender
, authname
*aup
) {
150 ctx
->reply(sender
,"%d", aup
->userid
);