]>
Commit | Line | Data |
---|---|---|
1 | #include "trusts_newsearch.h" | |
2 | #include "../newsearch/newsearch.h" | |
3 | ||
4 | static void tsnsmessagewrapper(nick *np, char *format, ...) { | |
5 | char buf[1024]; | |
6 | va_list ap; | |
7 | ||
8 | va_start(ap, format); | |
9 | vsnprintf(buf, sizeof(buf), format, ap); | |
10 | va_end(ap); | |
11 | ||
12 | controlreply(np, "%s", buf); | |
13 | } | |
14 | ||
15 | static void tsnswallwrapper(int level, char *format, ...) { | |
16 | char buf[1024]; | |
17 | va_list ap; | |
18 | ||
19 | va_start(ap, format); | |
20 | vsnprintf(buf, sizeof(buf), format, ap); | |
21 | va_end(ap); | |
22 | ||
23 | controlwall(NO_OPER, level, "%s", buf); | |
24 | } | |
25 | ||
26 | int tsns_dotrustlist(void *source, int cargc, char **cargv) { | |
27 | searchASTExpr tree; | |
28 | searchASTExpr nodes[2]; | |
29 | ||
30 | if(cargc < 1) { | |
31 | controlreply(source,"Syntax: trustlist <#groupid>"); | |
32 | return CMD_ERROR; | |
33 | } | |
34 | ||
35 | if(cargv[0][0]== '#'){ | |
36 | tree = NSASTNode(eq_parse, NSASTNode(tsns_tgid_parse), NSASTLiteral(&cargv[0][1])); | |
37 | } else { | |
38 | tree = NSASTNode(eq_parse, NSASTNode(tsns_tgid_parse), NSASTLiteral(cargv[0])); | |
39 | } | |
40 | ||
41 | // nodes[0] = NSASTNode(tsns_tgid_parse); | |
42 | // nodes[1] = cargv[0]; | |
43 | // tree = | |
44 | // NSASTManualNode(eq_parse, 2, nodes | |
45 | // ); | |
46 | return ast_tgsearch(&tree, tsnsmessagewrapper , source, tsnswallwrapper, printtgfull, NULL, NULL, 1); | |
47 | } | |
48 | ||
49 | int tsns_dotrustdenylist(void *source, int cargc, char **cargv) { | |
50 | searchASTExpr tree; | |
51 | ||
52 | tree = NSASTNode(gt_parse, NSASTNode(tsns_tbid_parse), NSASTLiteral("0")); | |
53 | ||
54 | if(cargc == 1){ /* just assume -private */ | |
55 | return ast_nodesearch(&tree, tsnsmessagewrapper , source, tsnswallwrapper, printtrust_blockprivate, NULL, NULL, 500); | |
56 | } else { | |
57 | return ast_nodesearch(&tree, tsnsmessagewrapper , source, tsnswallwrapper, printtrust_block, NULL, NULL, 500); | |
58 | } | |
59 | } |