]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/newsearch/formats.c
Merge.
[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 #include "../../lib/stringbuf.h"
7
8 void printchannel_qusers(searchCtx *ctx, nick *sender, chanindex *cip) {
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])) {
15 ctx->reply(sender,"[ - not registered - ] %s",cip->name->content);
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
33 ctx->reply(sender,"[%4dn %4dm %4do %4dv %4dk %4db - %4d total ] %s",own,mas,op,voi,kno,ban,tot,cip->name->content);
34 }
35
36
37 void printnick_auth(searchCtx *ctx, nick *sender, nick *np) {
38 struct reguser *rup;
39
40 if (!(rup=getreguserfromnick(np))) {
41 ctx->reply(sender,"%s (not authed)",np->nick);
42 } else {
43 ctx->reply(sender,"%s (%s/%u) (%s) (%s)",np->nick,rup->username,rup->ID,
44 rup->email ? rup->email->content : "no email",
45 rup->comment ? rup->comment->content : "no comment" );
46 }
47 }
48
49 void printnick_authchans(searchCtx *ctx, nick *sender, nick *np) {
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
57 printnick_auth(ctx, sender,np);
58
59 if (!(rup=getreguserfromnick(np)))
60 return;
61
62 if (!rup->knownon) {
63 ctx->reply(sender, " (no channels)");
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) {
82 ctx->reply(sender," %s", thebuf);
83 bufpos=0;
84 }
85 bufpos+=sprintf(thebuf+bufpos,"%s ",buf2);
86 }
87 if (bufpos)
88 ctx->reply(sender," %s", thebuf);
89 }
90 }
91
92 void printauth(searchCtx *ctx, nick *sender, authname *anp) {
93 reguser *rup;
94 char *la;
95 /* StringBuf b;
96 char output[1024];
97 nick *tnp;
98 int space = 0;
99 */
100
101 if (!(rup=anp->exts[chanservaext]))
102 return;
103
104 /*
105 output[0] = '\0';
106
107 b.capacity = sizeof(output);
108 b.len = 0;
109 b.buf = output;
110
111 for(tnp=anp->nicks;tnp;tnp=tnp->next) {
112 if(space)
113 sbaddchar(&b, ' ');
114 space = 1;
115 sbaddstr(&b, tnp->nick);
116 }
117 sbterminate(&b);
118
119 ctx->reply(sender, " %s%s%s%s", rup->username, *output?" (":"", output, *output?")":"");
120 */
121
122 if (rup->lastauth) {
123 char timebuf[20];
124 strftime(timebuf, 15, "%d/%m/%y %H:%M", gmtime(&(rup->lastauth)));
125 la = timebuf;
126 } else {
127 la = "(never)";
128 }
129
130 ctx->reply(sender, "%-15s %-10s %-30s %-15s %s", rup->username, UHasSuspension(rup)?"yes":"no", rup->email?rup->email->content:"(no email)", la, rup->lastuserhost?rup->lastuserhost->content:"(no last host)");
131 }