]>
Commit | Line | Data |
---|---|---|
524d28f9 CP |
1 | #include <stdio.h> |
2 | ||
b2b36016 | 3 | #include "../chanserv.h" |
4 | #include "../../newsearch/newsearch.h" | |
5 | #include "../../control/control.h" | |
6d349eb0 | 6 | #include "../../lib/stringbuf.h" |
b2b36016 | 7 | |
b888ae09 | 8 | void printchannel_qusers(searchCtx *ctx, nick *sender, chanindex *cip) { |
bbef4b5d | 9 | regchanuser *rcup; |
10 | regchan *rcp; | |
11 | int i; | |
12 | int own=0,mas=0,op=0,voi=0,kno=0,ban=0,tot=0; | |
13 | ||
14 | if (!(rcp=cip->exts[chanservext])) { | |
b888ae09 | 15 | ctx->reply(sender,"[ - not registered - ] %s",cip->name->content); |
bbef4b5d | 16 | return; |
17 | } | |
18 | ||
19 | for (i=0;i<REGCHANUSERHASHSIZE;i++) { | |
20 | for (rcup=rcp->regusers[i];rcup;rcup=rcup->nextbychan) { | |
21 | tot++; | |
22 | ||
23 | if (CUIsOwner(rcup)) own++; else | |
24 | if (CUIsMaster(rcup)) mas++; else | |
25 | if (CUIsOp(rcup)) op++; else | |
26 | if (CUIsVoice(rcup)) voi++; else | |
27 | if (CUIsKnown(rcup)) kno++; | |
28 | ||
29 | if (CUIsBanned(rcup)) ban++; | |
30 | } | |
31 | } | |
32 | ||
b888ae09 | 33 | ctx->reply(sender,"[%4dn %4dm %4do %4dv %4dk %4db - %4d total ] %s",own,mas,op,voi,kno,ban,tot,cip->name->content); |
bbef4b5d | 34 | } |
35 | ||
36 | ||
b888ae09 | 37 | void printnick_auth(searchCtx *ctx, nick *sender, nick *np) { |
b2b36016 | 38 | struct reguser *rup; |
39 | ||
40 | if (!(rup=getreguserfromnick(np))) { | |
b888ae09 | 41 | ctx->reply(sender,"%s (not authed)",np->nick); |
b2b36016 | 42 | } else { |
b888ae09 | 43 | ctx->reply(sender,"%s (%s/%u) (%s) (%s)",np->nick,rup->username,rup->ID, |
b2b36016 | 44 | rup->email ? rup->email->content : "no email", |
45 | rup->comment ? rup->comment->content : "no comment" ); | |
46 | } | |
47 | } | |
48 | ||
b888ae09 | 49 | void printnick_authchans(searchCtx *ctx, nick *sender, nick *np) { |
b2b36016 | 50 | struct reguser *rup; |
51 | struct regchanuser *rcup; | |
52 | char thebuf[1024]; | |
53 | char buf2[512]; | |
54 | unsigned int bufpos=0, buf2len; | |
55 | unsigned char ch; | |
56 | ||
b888ae09 | 57 | printnick_auth(ctx, sender,np); |
b2b36016 | 58 | |
59 | if (!(rup=getreguserfromnick(np))) | |
60 | return; | |
61 | ||
62 | if (!rup->knownon) { | |
b888ae09 | 63 | ctx->reply(sender, " (no channels)"); |
b2b36016 | 64 | } else { |
65 | for (rcup=rup->knownon;rcup;rcup=rcup->nextbyuser) { | |
66 | if (CUIsOwner(rcup)) | |
67 | ch='*'; | |
68 | else if (CUHasMasterPriv(rcup)) | |
69 | ch='&'; | |
70 | else if (CUHasOpPriv(rcup)) | |
71 | ch='@'; | |
72 | else if (CUHasVoicePriv(rcup)) | |
73 | ch='+'; | |
74 | else if (CUKnown(rcup)) | |
75 | ch=' '; | |
76 | else | |
77 | ch='!'; | |
78 | ||
79 | buf2len=sprintf(buf2,"%c%s",ch,rcup->chan->index->name->content); | |
80 | ||
81 | if (buf2len+bufpos > 400) { | |
b888ae09 | 82 | ctx->reply(sender," %s", thebuf); |
b2b36016 | 83 | bufpos=0; |
84 | } | |
85 | bufpos+=sprintf(thebuf+bufpos,"%s ",buf2); | |
86 | } | |
87 | if (bufpos) | |
b888ae09 | 88 | ctx->reply(sender," %s", thebuf); |
b2b36016 | 89 | } |
90 | } | |
6d349eb0 CP |
91 | |
92 | void printauth(searchCtx *ctx, nick *sender, authname *anp) { | |
93 | reguser *rup; | |
94 | StringBuf b; | |
95 | char output[1024]; | |
96 | nick *tnp; | |
97 | int space = 0; | |
98 | ||
99 | if (!(rup=anp->exts[chanservaext])) | |
100 | return; | |
101 | ||
102 | output[0] = '\0'; | |
103 | ||
104 | b.capacity = sizeof(output); | |
105 | b.len = 0; | |
106 | b.buf = output; | |
107 | ||
108 | for(tnp=anp->nicks;tnp;tnp=tnp->next) { | |
109 | if(space) | |
110 | sbaddchar(&b, ' '); | |
111 | space = 1; | |
112 | sbaddstr(&b, tnp->nick); | |
113 | } | |
114 | sbterminate(&b); | |
115 | ||
116 | ctx->reply(sender, " %s%s%s%s", rup->username, *output?" (":"", output, *output?")":""); | |
117 | ctx->reply(sender, " %-10s %-30s %s", UHasSuspension(rup)?"yes":"no", rup->email?rup->email->content:"(no email)", rup->lastuserhost?rup->lastuserhost->content:"(no last host)"); | |
118 | } |