]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/usercmds/suspenduserlist.c
TRUSTS: require sqlite
[irc/quakenet/newserv.git] / chanserv / usercmds / suspenduserlist.c
1 /* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: suspenduserlist
5 * CMDLEVEL: QCMD_HELPER
6 * CMDARGS: 1
7 * CMDDESC: Lists suspended/locked users.
8 * CMDFUNC: csu_dosuspenduserlist
9 * CMDPROTO: int csu_dosuspenduserlist(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: suspenduserlist <username or pattern>
11 * CMDHELP: Displays all suspend users with usernames matching the specified pattern,
12 * CMDHELP: or the single user with the specified username.
13 */
14
15 #include "../chanserv.h"
16 #include "../../lib/irc_string.h"
17 #include <stdio.h>
18 #include <string.h>
19
20 int csu_dosuspenduserlist(void *source, int cargc, char **cargv) {
21 nick *sender=source;
22 reguser *rup=getreguserfromnick(sender);
23 reguser *dbrup, *trup;
24 int i, seewhom;
25 unsigned int count=0;
26 char buf[TIMELEN], buf2[TIMELEN], *bywhom;
27 time_t now=time(NULL);
28
29 if (!rup)
30 return CMD_ERROR;
31
32 if (cargc < 1) {
33 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "suspenduserlist");
34 return CMD_ERROR;
35 }
36
37 seewhom = cs_privcheck(QPRIV_VIEWSUSPENDEDBY, sender);
38 if(!seewhom)
39 bywhom = "(hidden)";
40
41 /* @TIMELEN */
42 chanservstdmessage(sender, QM_SUSPENDUSERLISTHEADER);
43 for (i=0;i<REGUSERHASHSIZE;i++) {
44 for (dbrup=regusernicktable[i]; dbrup; dbrup=dbrup->nextbyname) {
45 if (!UHasSuspension(dbrup))
46 continue;
47
48 if (!match(cargv[0], dbrup->username)) {
49 char suspendtype[100];
50
51 if (UIsDelayedGline(dbrup))
52 strcpy(suspendtype, "delayed gline");
53 else if (UIsGline(dbrup))
54 strcpy(suspendtype, "instant gline");
55 else if (UIsSuspended(dbrup))
56 strcpy(suspendtype, "suspended");
57 else
58 strcpy(suspendtype, "not used");
59
60 if(seewhom) {
61 trup=findreguserbyID(dbrup->suspendby);
62 if (trup)
63 bywhom=trup->username;
64 else
65 bywhom="(unknown)";
66 }
67
68 if (dbrup->suspendexp)
69 q9strftime(buf,sizeof(buf),dbrup->suspendexp);
70
71 q9strftime(buf2,sizeof(buf2),dbrup->suspendtime);
72
73 count++;
74
75 /* @TIMELEN */
76 chanservsendmessage(sender, "%-15s %-13s %-15s %-19s %-19s %s", dbrup->username, suspendtype, bywhom, buf2, (dbrup->suspendexp)?((now >= dbrup->suspendexp)?"next auth":buf):"never", dbrup->suspendreason?dbrup->suspendreason->content:"(none)");
77 if (count >= 2000) {
78 chanservstdmessage(sender, QM_TOOMANYRESULTS, 2000, "users");
79 return CMD_ERROR;
80 }
81 }
82 }
83 }
84 chanservstdmessage(sender, QM_RESULTCOUNT, count, "user", (count==1)?"":"s");
85
86 return CMD_OK;
87 }