]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: unbanmask | |
5 | * CMDLEVEL: QCMD_AUTHED | |
6 | * CMDARGS: 2 | |
7 | * CMDDESC: Removes bans matching a particular mask from a channel. | |
8 | * CMDFUNC: csc_dounbanmask | |
9 | * CMDPROTO: int csc_dounbanmask(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_dounbanmask(void *source, int cargc, char **cargv) { | |
24 | nick *sender=source; | |
25 | chanindex *cip; | |
26 | regban **rbh, *rbp; | |
27 | chanban **cbh, *cbp; | |
28 | regchan *rcp; | |
29 | chanban *theban; | |
30 | modechanges changes; | |
31 | char *banstr; | |
32 | ||
33 | if (cargc<2) { | |
34 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "unbanmask"); | |
35 | return CMD_ERROR; | |
36 | } | |
37 | ||
38 | if (!(cip=cs_checkaccess(sender, cargv[0], CA_OPPRIV, NULL, "unbanmask", 0, 0))) | |
39 | return CMD_ERROR; | |
40 | ||
41 | rcp=cip->exts[chanservext]; | |
42 | theban=makeban(cargv[1]); | |
43 | ||
44 | if (cip->channel) | |
45 | localsetmodeinit(&changes, cip->channel, chanservnick); | |
46 | ||
47 | for (rbh=&(rcp->bans); *rbh; ) { | |
48 | rbp=*rbh; | |
49 | if (banoverlap(theban, rbp->cbp)) { | |
50 | banstr=bantostring(rbp->cbp); | |
51 | /* Check perms and remove */ | |
52 | if (!cs_checkaccess(sender, NULL, CA_MASTERPRIV, cip, NULL, 0, 1)) { | |
53 | chanservstdmessage(sender, QM_NOTREMOVEDPERMBAN, banstr, cip->name->content); | |
54 | rbh=&(rbp->next); | |
55 | } else { | |
56 | chanservstdmessage(sender, QM_REMOVEDPERMBAN, banstr, cip->name->content); | |
57 | if (cip->channel) | |
58 | localdosetmode_ban(&changes, banstr, MCB_DEL); | |
59 | /* Remove from database */ | |
60 | csdb_deleteban(rbp); | |
61 | /* Remove from list */ | |
62 | (*rbh)=rbp->next; | |
63 | /* Free ban/string and update setby refcount, and free actual regban */ | |
64 | freesstring(rbp->reason); | |
65 | freechanban(rbp->cbp); | |
66 | freeregban(rbp); | |
67 | } | |
68 | } else { | |
69 | rbh=&(rbp->next); | |
70 | } | |
71 | } | |
72 | ||
73 | if (cip->channel) { | |
74 | for (cbh=&(cip->channel->bans); *cbh; ) { | |
75 | cbp=*cbh; | |
76 | if (banoverlap(theban, cbp)) { | |
77 | /* Remove */ | |
78 | banstr=bantostring(cbp); | |
79 | chanservstdmessage(sender, QM_REMOVEDCHANBAN, banstr, cip->name->content); | |
80 | localdosetmode_ban(&changes, banstr, MCB_DEL); | |
81 | } else { | |
82 | cbh=&(cbp->next); | |
83 | } | |
84 | } | |
85 | localsetmodeflush(&changes,1); | |
86 | } | |
87 | ||
88 | ||
89 | chanservstdmessage(sender, QM_DONE); | |
90 | return CMD_OK; | |
91 | } |