/[svn]/ircd-hybrid/branches/8.2.x/modules/core/m_bmask.c
ViewVC logotype

Contents of /ircd-hybrid/branches/8.2.x/modules/core/m_bmask.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8280 - (show annotations)
Tue Feb 20 19:30:33 2018 UTC (4 years, 9 months ago) by michael
File MIME type: text/x-chdr
File size: 4653 byte(s)
- Update copyright years

1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2018 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_bmask.c
23 * \brief Includes required functions for processing the BMASK command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "channel.h"
30 #include "channel_mode.h"
31 #include "client.h"
32 #include "hash.h"
33 #include "irc_string.h"
34 #include "ircd.h"
35 #include "conf.h"
36 #include "send.h"
37 #include "parse.h"
38 #include "modules.h"
39
40
41 /*! \brief BMASK command handler
42 *
43 * \param source_p Pointer to allocated Client struct from which the message
44 * originally comes from. This can be a local or remote client.
45 * \param parc Integer holding the number of supplied arguments.
46 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
47 * pointers.
48 * \note Valid arguments for this command are:
49 * - parv[0] = command
50 * - parv[1] = timestamp
51 * - parv[2] = channel name
52 * - parv[3] = type of ban to add ('b' 'I' or 'e')
53 * - parv[4] = space delimited list of masks to add
54 */
55 static int
56 ms_bmask(struct Client *source_p, int parc, char *parv[])
57 {
58 char modebuf[IRCD_BUFSIZE] = "";
59 char parabuf[IRCD_BUFSIZE] = "";
60 char banbuf[IRCD_BUFSIZE] = "";
61 struct Channel *chptr = NULL;
62 char *s, *t, *mbuf, *pbuf;
63 unsigned int mode_type = 0;
64 int mlen = 0, tlen = 0;
65 int modecount = 0;
66 unsigned int flags = 0;
67
68 if ((chptr = hash_find_channel(parv[2])) == NULL)
69 return 0;
70
71 /* TS is higher, drop it. */
72 if (strtoumax(parv[1], NULL, 10) > chptr->creationtime)
73 return 0;
74
75 switch (*parv[3])
76 {
77 case 'b':
78 mode_type = CHFL_BAN;
79 break;
80 case 'e':
81 mode_type = CHFL_EXCEPTION;
82 break;
83 case 'I':
84 mode_type = CHFL_INVEX;
85 break;
86 default:
87 return 0;
88 }
89
90 strlcpy(banbuf, parv[4], sizeof(banbuf));
91 s = banbuf;
92
93 mlen = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s +",
94 (IsHidden(source_p) || ConfigServerHide.hide_servers) ? me.name : source_p->name,
95 chptr->name);
96 mbuf = modebuf + mlen;
97 pbuf = parabuf;
98
99 if (HasCMode(chptr, MODE_HIDEBMASKS))
100 flags = CHFL_CHANOP | CHFL_HALFOP;
101
102 do
103 {
104 if ((t = strchr(s, ' ')))
105 *t++ = '\0';
106 tlen = strlen(s);
107
108 /* I don't even want to begin parsing this.. */
109 if (tlen > MODEBUFLEN)
110 break;
111
112 if (tlen && *s != ':' && add_id(source_p, chptr, s, mode_type))
113 {
114 /* add_id can modify 's' */
115 tlen = strlen(s);
116
117 /* this new one wont fit.. */
118 if (mbuf - modebuf + 2 + pbuf - parabuf + tlen > IRCD_BUFSIZE - 2 ||
119 modecount >= MAXMODEPARAMS)
120 {
121 *mbuf = *(pbuf - 1) = '\0';
122
123 sendto_channel_local(NULL, chptr, flags, 0, 0, "%s %s", modebuf, parabuf);
124 mbuf = modebuf + mlen;
125 pbuf = parabuf;
126 modecount = 0;
127 }
128
129 *mbuf++ = *parv[3];
130 pbuf += sprintf(pbuf, "%s ", s);
131 ++modecount;
132 }
133
134 s = t;
135 } while (s);
136
137 if (modecount)
138 {
139 *mbuf = *(pbuf - 1) = '\0';
140 sendto_channel_local(NULL, chptr, flags, 0, 0, "%s %s", modebuf, parabuf);
141 }
142
143 sendto_server(source_p, 0, 0, ":%s BMASK %ju %s %s :%s",
144 source_p->id, chptr->creationtime, chptr->name,
145 parv[3], parv[4]);
146 return 0;
147 }
148
149 static struct Message bmask_msgtab =
150 {
151 .cmd = "BMASK",
152 .args_min = 5,
153 .args_max = MAXPARA,
154 .handlers[UNREGISTERED_HANDLER] = m_ignore,
155 .handlers[CLIENT_HANDLER] = m_ignore,
156 .handlers[SERVER_HANDLER] = ms_bmask,
157 .handlers[ENCAP_HANDLER] = m_ignore,
158 .handlers[OPER_HANDLER] = m_ignore
159 };
160
161 static void
162 module_init(void)
163 {
164 mod_add_cmd(&bmask_msgtab);
165 }
166
167 static void
168 module_exit(void)
169 {
170 mod_del_cmd(&bmask_msgtab);
171 }
172
173 struct module module_entry =
174 {
175 .version = "$Revision$",
176 .modinit = module_init,
177 .modexit = module_exit,
178 .flags = MODULE_FLAG_CORE
179 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28