]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/usercmds/listflags.c
5f805c89be0bb1352377ffa8592ee83116d76ddc
[irc/quakenet/newserv.git] / chanserv / usercmds / listflags.c
1 /* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: listflags
5 * CMDLEVEL: QCMD_OPER
6 * CMDARGS: 1
7 * CMDDESC: List users with the specified user flags.
8 * CMDFUNC: csu_dolistflags
9 * CMDPROTO: int csu_dolistflags(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: listflags <flags>
11 * CMDHELP: Shows a list of all users with the specified user flags.
12 */
13
14 #include "../chanserv.h"
15 #include "../../lib/irc_string.h"
16 #include <stdio.h>
17 #include <string.h>
18
19 int csu_dolistflags(void *source, int cargc, char **cargv) {
20 nick *sender=source;
21 reguser *rup=getreguserfromnick(sender);
22 reguser *dbrup;
23 flag_t matchflags = 0;
24 char *ch;
25 int i, j;
26 unsigned int count=0;
27
28 if (!rup)
29 return CMD_ERROR;
30
31 if (cargc < 1) {
32 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "listflags");
33 return CMD_ERROR;
34 }
35
36 ch=cargv[0][0]=='+'?cargv[0]+1:cargv[0];
37
38 for (i=0; ch[i]; i++) {
39 for (j = 0; ruflags[j].flagchar; j++) {
40 if (ruflags[j].flagchar == ch[i]) {
41 matchflags|=ruflags[j].flagbit;
42 break;
43 }
44 }
45 }
46
47 chanservstdmessage(sender, QM_LISTFLAGSHEADER);
48 for (i=0;i<REGUSERHASHSIZE;i++) {
49 for (dbrup=regusernicktable[i]; dbrup; dbrup=dbrup->nextbyname) {
50 if ((dbrup->flags & matchflags) == matchflags) {
51 chanservsendmessage(sender, "%-15s %-17s %-10s %-30s %s", dbrup->username, printflags(dbrup->flags, ruflags),
52 UHasSuspension(dbrup)?"yes":"no", dbrup->email?dbrup->email->content:"none set",
53 dbrup->lastuserhost?dbrup->lastuserhost->content:"none");
54 count++;
55 if (count >= 2000) {
56 chanservstdmessage(sender, QM_TOOMANYRESULTS, 2000, "users");
57 return CMD_ERROR;
58 }
59 }
60 }
61 }
62 chanservstdmessage(sender, QM_RESULTCOUNT, count, "user", (count==1)?"":"s");
63
64 return CMD_OK;
65 }