]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* modules/m_operspy.c |
2 | * Copyright (C) 2003-2005 ircd-ratbox development team | |
3 | * Copyright (C) 2003 Lee Hardy <lee@leeh.co.uk> | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions are | |
7 | * met: | |
8 | * | |
9 | * 1.Redistributions of source code must retain the above copyright notice, | |
10 | * this list of conditions and the following disclaimer. | |
11 | * 2.Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3.The name of the author may not be used to endorse or promote products | |
15 | * derived from this software without specific prior written permission. | |
16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
20 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | |
212380e3 AC |
28 | */ |
29 | ||
30 | #include "stdinc.h" | |
212380e3 AC |
31 | #include "send.h" |
32 | #include "channel.h" | |
33 | #include "client.h" | |
9b8e9eb3 | 34 | #include "defaults.h" |
212380e3 AC |
35 | #include "ircd.h" |
36 | #include "numeric.h" | |
212380e3 AC |
37 | #include "s_serv.h" |
38 | #include "hash.h" | |
39 | #include "msg.h" | |
40 | #include "parse.h" | |
41 | #include "modules.h" | |
77d3d2db | 42 | #include "logger.h" |
212380e3 | 43 | |
eeabf33a EM |
44 | static const char operspy_desc[] = |
45 | "Provides the operspy facility for viewing normally private data"; | |
46 | ||
3c7d6fcc | 47 | static void ms_operspy(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, |
eeabf33a | 48 | int parc, const char *parv[]); |
212380e3 AC |
49 | |
50 | struct Message operspy_msgtab = { | |
7baa37a9 | 51 | "OPERSPY", 0, 0, 0, 0, |
212380e3 AC |
52 | {mg_ignore, mg_ignore, mg_ignore, mg_ignore, {ms_operspy, 2}, mg_ignore} |
53 | }; | |
54 | ||
55 | mapi_clist_av1 operspy_clist[] = { &operspy_msgtab, NULL }; | |
1fe7d608 | 56 | |
1fe7d608 | 57 | DECLARE_MODULE_AV2(operspy, NULL, NULL, operspy_clist, NULL, NULL, NULL, NULL, operspy_desc); |
212380e3 AC |
58 | |
59 | /* ms_operspy() | |
60 | * | |
61 | * parv[1] - operspy command | |
62 | * parv[2] - optional params | |
63 | */ | |
3c7d6fcc | 64 | static void |
428ca87b | 65 | ms_operspy(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, |
212380e3 AC |
66 | int parc, const char *parv[]) |
67 | { | |
68 | static char buffer[BUFSIZE]; | |
69 | char *ptr; | |
70 | int cur_len = 0; | |
71 | int len, i; | |
72 | ||
73 | if(parc < 4) | |
74 | { | |
75 | report_operspy(source_p, parv[1], | |
76 | parc < 3 ? NULL : parv[2]); | |
77 | } | |
78 | /* buffer all remaining into one param */ | |
79 | else | |
80 | { | |
81 | ptr = buffer; | |
82 | cur_len = 0; | |
83 | ||
84 | for(i = 2; i < parc; i++) | |
85 | { | |
86 | len = strlen(parv[i]) + 1; | |
87 | ||
88 | if((size_t)(cur_len + len) >= sizeof(buffer)) | |
3c7d6fcc | 89 | return; |
212380e3 | 90 | |
5203cba5 | 91 | snprintf(ptr, sizeof(buffer) - cur_len, "%s ", |
212380e3 AC |
92 | parv[i]); |
93 | ptr += len; | |
94 | cur_len += len; | |
95 | } | |
96 | ||
97 | report_operspy(source_p, parv[1], buffer); | |
98 | } | |
212380e3 | 99 | } |