ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_bmask.c
Revision: 9101
Committed: Wed Jan 1 09:58:45 2020 UTC (6 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 4655 byte(s)
Log Message:
- Bump copyright years everywhere

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2020 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 void
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 *channel = NULL;
62 char *s, *t, *mbuf, *pbuf;
63 dlink_list *list = NULL;
64 int mlen = 0, tlen = 0;
65 int modecount = 0;
66 unsigned int flags = 0;
67
68 if ((channel = hash_find_channel(parv[2])) == NULL)
69 return;
70
71 /* TS is higher, drop it. */
72 if (strtoumax(parv[1], NULL, 10) > channel->creation_time)
73 return;
74
75 switch (*parv[3])
76 {
77 case 'b':
78 list = &channel->banlist;
79 break;
80 case 'e':
81 list = &channel->exceptlist;
82 break;
83 case 'I':
84 list = &channel->invexlist;
85 break;
86 default:
87 return;
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 channel->name);
96 mbuf = modebuf + mlen;
97 pbuf = parabuf;
98
99 if (HasCMode(channel, 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, channel, s, list) == true)
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, channel, 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, channel, 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, channel->creation_time, channel->name,
145 parv[3], parv[4]);
146 }
147
148 static struct Message bmask_msgtab =
149 {
150 .cmd = "BMASK",
151 .args_min = 5,
152 .args_max = MAXPARA,
153 .handlers[UNREGISTERED_HANDLER] = m_ignore,
154 .handlers[CLIENT_HANDLER] = m_ignore,
155 .handlers[SERVER_HANDLER] = ms_bmask,
156 .handlers[ENCAP_HANDLER] = m_ignore,
157 .handlers[OPER_HANDLER] = m_ignore
158 };
159
160 static void
161 module_init(void)
162 {
163 mod_add_cmd(&bmask_msgtab);
164 }
165
166 static void
167 module_exit(void)
168 {
169 mod_del_cmd(&bmask_msgtab);
170 }
171
172 struct module module_entry =
173 {
174 .version = "$Revision$",
175 .modinit = module_init,
176 .modexit = module_exit,
177 .is_core = true
178 };

Properties

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