]>
Commit | Line | Data |
---|---|---|
c96aa815 P |
1 | /* oper commands for the splitlist */ |
2 | ||
3 | #include "../lib/irc_string.h" | |
4 | #include "../irc/irc.h" | |
5 | #include "../splitlist/splitlist.h" | |
6 | #include "../control/control.h" | |
7f32dbdf P |
7 | #include "../lib/version.h" |
8 | ||
9 | MODULE_VERSION(""); | |
c96aa815 P |
10 | |
11 | int spcmd_splitlist(void *source, int cargc, char **cargv); | |
12 | int spcmd_splitdel(void *source, int cargc, char **cargv); | |
13 | ||
14 | void _init(void) { | |
cc3fea75 | 15 | registercontrolhelpcmd("splitlist", NO_STAFF, 0, &spcmd_splitlist, "Usage: splitlist\nLists servers currently split from the netowkr"); |
c96aa815 P |
16 | registercontrolcmd("splitdel", 10, 1, &spcmd_splitdel); |
17 | } | |
18 | ||
19 | void _fini(void) { | |
20 | deregistercontrolcmd("splitlist", &spcmd_splitlist); | |
21 | deregistercontrolcmd("splitdel", &spcmd_splitdel); | |
22 | } | |
23 | ||
24 | /* todo: add RELINK status */ | |
25 | int spcmd_splitlist(void *source, int cargc, char **cargv) { | |
26 | nick *np = (nick*)source; | |
27 | int i; | |
28 | splitserver srv; | |
29 | ||
30 | if (splitlist.cursi == 0) { | |
31 | controlreply(np, "There currently aren't any registered splits."); | |
32 | ||
33 | return CMD_OK; | |
34 | } | |
35 | ||
36 | controlreply(np, "Server Status Split for"); | |
37 | ||
38 | for (i = 0; i < splitlist.cursi; i++) { | |
39 | srv = ((splitserver*)splitlist.content)[i]; | |
40 | ||
41 | controlreply(np, "%s M.I.A. %s", srv.name->content, longtoduration(getnettime() - srv.ts, 1)); | |
42 | } | |
43 | ||
44 | controlreply(np, "--- End of splitlist"); | |
45 | ||
46 | return CMD_OK; | |
47 | } | |
48 | ||
49 | int spcmd_splitdel(void *source, int cargc, char **cargv) { | |
50 | nick *np = (nick*)source; | |
51 | int i, count; | |
52 | splitserver srv; | |
53 | ||
54 | if (cargc < 1) { | |
55 | controlreply(np, "Syntax: splitdel <pattern>"); | |
56 | ||
57 | return CMD_ERROR; | |
58 | } | |
59 | ||
60 | count = 0; | |
61 | ||
62 | for (i = splitlist.cursi - 1; i >= 0; i--) { | |
63 | srv = ((splitserver*)splitlist.content)[i]; | |
64 | ||
65 | if (match2strings(cargv[0], srv.name->content)) { | |
66 | sp_deletesplit(srv.name->content); /* inefficient .. but it doesn't matter */ | |
67 | count++; | |
68 | } | |
69 | } | |
70 | ||
71 | controlreply(np, "%d %s deleted.", count, count != 1 ? "splits" : "split"); | |
72 | ||
73 | return CMD_OK; | |
74 | } |