]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/suspendchanlist.c
suspendtime is now set where you'd expect, and displayed too
[irc/quakenet/newserv.git] / chanserv / chancmds / suspendchanlist.c
1 /* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: suspendchanlist
5 * CMDLEVEL: QCMD_HELPER
6 * CMDARGS: 1
7 * CMDDESC: Lists suspended channels.
8 * CMDFUNC: csc_dosuspendchanlist
9 * CMDPROTO: int csc_dosuspendchanlist(void *source, int cargc, char **cargv);
10 */
11
12 #include "../chanserv.h"
13 #include "../../nick/nick.h"
14 #include "../../lib/flags.h"
15 #include "../../lib/irc_string.h"
16 #include "../../channel/channel.h"
17 #include "../../parser/parser.h"
18 #include "../../irc/irc.h"
19 #include "../../localuser/localuserchannel.h"
20 #include <string.h>
21 #include <stdio.h>
22
23 int csc_dosuspendchanlist(void *source, int cargc, char **cargv) {
24 nick *sender=source;
25 reguser *rup=getreguserfromnick(sender);
26 chanindex *cip;
27 regchan *rcp;
28 int i;
29 char *bywhom, buf[200];
30 unsigned int count=0;
31 struct tm *tmp;
32 if (!rup)
33 return CMD_ERROR;
34
35 if (cargc < 1) {
36 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "suspendchanlist");
37 return CMD_ERROR;
38 }
39
40 chanservstdmessage(sender, QM_SUSPENDCHANLISTHEADER);
41 for (i=0; i<CHANNELHASHSIZE; i++) {
42 for (cip=chantable[i]; cip; cip=cip->next) {
43 if (!(rcp=(regchan*)cip->exts[chanservext]))
44 continue;
45
46 if (!CIsSuspended(rcp))
47 continue;
48
49 if ((rcp->suspendby != rup->ID) && match(cargv[0], cip->name->content))
50 continue;
51
52 if (rcp->suspendby == rup->ID)
53 bywhom=rup->username;
54 else {
55 reguser *trup=findreguserbyID(rcp->suspendby);
56 if (trup)
57 bywhom=trup->username;
58 else
59 bywhom="unknown";
60 }
61 count++;
62
63 tmp=gmtime(&(rcp->suspendtime));
64 strftime(buf,15,"%d/%m/%y %H:%M",tmp);
65
66 chanservsendmessage(sender, "%-30s %-15s %-15s %s", cip->name->content, bywhom, buf, rcp->suspendreason->content);
67 if (count >= 2000) {
68 chanservstdmessage(sender, QM_TOOMANYRESULTS, 2000, "channels");
69 return CMD_ERROR;
70 }
71 }
72 }
73 chanservstdmessage(sender, QM_RESULTCOUNT, count, "channel", (count==1)?"":"s");
74
75 return CMD_OK;
76 }