]> jfr.im git - irc/rqf/shadowircd.git/blame - modules/m_operspy.c
Update TODO
[irc/rqf/shadowircd.git] / modules / m_operspy.c
CommitLineData
212380e3 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.
28 *
29 * $Id: m_operspy.c 254 2005-09-21 23:35:12Z nenolod $
30 */
31
32#include "stdinc.h"
212380e3 33#include "send.h"
34#include "channel.h"
35#include "client.h"
36#include "common.h"
37#include "config.h"
38#include "ircd.h"
39#include "numeric.h"
212380e3 40#include "s_serv.h"
41#include "hash.h"
42#include "msg.h"
43#include "parse.h"
44#include "modules.h"
212380e3 45
46static int ms_operspy(struct Client *client_p, struct Client *source_p,
47 int parc, const char *parv[]);
48
49struct Message operspy_msgtab = {
50 "OPERSPY", 0, 0, 0, MFLG_SLOW,
51 {mg_ignore, mg_ignore, mg_ignore, mg_ignore, {ms_operspy, 2}, mg_ignore}
52};
53
54mapi_clist_av1 operspy_clist[] = { &operspy_msgtab, NULL };
55DECLARE_MODULE_AV1(operspy, NULL, NULL, operspy_clist, NULL, NULL, "$Revision: 254 $");
56
57/* ms_operspy()
58 *
59 * parv[1] - operspy command
60 * parv[2] - optional params
61 */
62static int
63ms_operspy(struct Client *client_p, struct Client *source_p,
64 int parc, const char *parv[])
65{
66 static char buffer[BUFSIZE];
67 char *ptr;
68 int cur_len = 0;
69 int len, i;
70
71 if(parc < 4)
72 {
73 report_operspy(source_p, parv[1],
74 parc < 3 ? NULL : parv[2]);
75 }
76 /* buffer all remaining into one param */
77 else
78 {
79 ptr = buffer;
80 cur_len = 0;
81
82 for(i = 2; i < parc; i++)
83 {
84 len = strlen(parv[i]) + 1;
85
86 if((size_t)(cur_len + len) >= sizeof(buffer))
87 return 0;
88
581fa5c4 89 rb_snprintf(ptr, sizeof(buffer) - cur_len, "%s ",
212380e3 90 parv[i]);
91 ptr += len;
92 cur_len += len;
93 }
94
95 report_operspy(source_p, parv[1], buffer);
96 }
97
98 return 0;
99}
100