]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/newsearch/formats.c
Added some things to chanserv_newsearch.
[irc/quakenet/newserv.git] / chanserv / newsearch / formats.c
1 #include <stdio.h>
2
3 #include "../chanserv.h"
4 #include "../../newsearch/newsearch.h"
5 #include "../../control/control.h"
6
7 void printchannel_qusers(nick *sender, chanindex *cip) {
8 regchanuser *rcup;
9 regchan *rcp;
10 int i;
11 int own=0,mas=0,op=0,voi=0,kno=0,ban=0,tot=0;
12
13 if (!(rcp=cip->exts[chanservext])) {
14 controlreply(sender,"[ - not registered - ] %s",cip->name->content);
15 return;
16 }
17
18 for (i=0;i<REGCHANUSERHASHSIZE;i++) {
19 for (rcup=rcp->regusers[i];rcup;rcup=rcup->nextbychan) {
20 tot++;
21
22 if (CUIsOwner(rcup)) own++; else
23 if (CUIsMaster(rcup)) mas++; else
24 if (CUIsOp(rcup)) op++; else
25 if (CUIsVoice(rcup)) voi++; else
26 if (CUIsKnown(rcup)) kno++;
27
28 if (CUIsBanned(rcup)) ban++;
29 }
30 }
31
32 controlreply(sender,"[%4dn %4dm %4do %4dv %4dk %4db - %4d total ] %s",own,mas,op,voi,kno,ban,tot,cip->name->content);
33 }
34
35
36 void printnick_auth(nick *sender, nick *np) {
37 struct reguser *rup;
38
39 if (!(rup=getreguserfromnick(np))) {
40 controlreply(sender,"%s (not authed)",np->nick);
41 } else {
42 controlreply(sender,"%s (%s/%u) (%s) (%s)",np->nick,rup->username,rup->ID,
43 rup->email ? rup->email->content : "no email",
44 rup->comment ? rup->comment->content : "no comment" );
45 }
46 }
47
48 void printnick_authchans(nick *sender, nick *np) {
49 struct reguser *rup;
50 struct regchanuser *rcup;
51 char thebuf[1024];
52 char buf2[512];
53 unsigned int bufpos=0, buf2len;
54 unsigned char ch;
55
56 printnick_auth(sender,np);
57
58 if (!(rup=getreguserfromnick(np)))
59 return;
60
61 if (!rup->knownon) {
62 controlreply(sender, " (no channels)");
63 } else {
64 for (rcup=rup->knownon;rcup;rcup=rcup->nextbyuser) {
65 if (CUIsOwner(rcup))
66 ch='*';
67 else if (CUHasMasterPriv(rcup))
68 ch='&';
69 else if (CUHasOpPriv(rcup))
70 ch='@';
71 else if (CUHasVoicePriv(rcup))
72 ch='+';
73 else if (CUKnown(rcup))
74 ch=' ';
75 else
76 ch='!';
77
78 buf2len=sprintf(buf2,"%c%s",ch,rcup->chan->index->name->content);
79
80 if (buf2len+bufpos > 400) {
81 controlreply(sender," %s", thebuf);
82 bufpos=0;
83 }
84 bufpos+=sprintf(thebuf+bufpos,"%s ",buf2);
85 }
86 if (bufpos)
87 controlreply(sender," %s", thebuf);
88 }
89 }