ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/core/m_bmask.c
Revision: 3377
Committed: Thu Apr 24 16:15:51 2014 UTC (9 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 4299 byte(s)
Log Message:
- Create 8.2.x branch

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2014 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
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 "numeric.h"
36 #include "user.h"
37 #include "conf.h"
38 #include "server.h"
39 #include "send.h"
40 #include "parse.h"
41 #include "modules.h"
42 #include "packet.h"
43
44
45 /*
46 * ms_bmask()
47 *
48 * inputs - parv[0] = command
49 * parv[1] = TS
50 * parv[2] = channel name
51 * parv[3] = type of ban to add ('b' 'I' or 'e')
52 * parv[4] = space delimited list of masks to add
53 * outputs - none
54 * side effects - propagates unchanged bmask line to servers
55 */
56 static int
57 ms_bmask(struct Client *source_p, int parc, char *parv[])
58 {
59 char modebuf[IRCD_BUFSIZE];
60 char parabuf[IRCD_BUFSIZE];
61 char banbuf[IRCD_BUFSIZE];
62 struct Channel *chptr;
63 char *s, *t, *mbuf, *pbuf;
64 unsigned int mode_type = 0;
65 int mlen, tlen;
66 int modecount = 0;
67
68 if ((chptr = hash_find_channel(parv[2])) == NULL)
69 return 0;
70
71 /* TS is higher, drop it. */
72 if (atol(parv[1]) > chptr->channelts)
73 return 0;
74
75 switch (*parv[3])
76 {
77 case 'b':
78 mode_type = CHFL_BAN;
79 break;
80
81 case 'e':
82 mode_type = CHFL_EXCEPTION;
83 break;
84
85 case 'I':
86 mode_type = CHFL_INVEX;
87 break;
88
89 /* maybe we should just blindly propagate this? */
90 default:
91 return 0;
92 }
93
94 parabuf[0] = '\0';
95 s = banbuf;
96 strlcpy(s, parv[4], sizeof(banbuf));
97
98 /* only need to construct one buffer, for non-ts6 servers */
99 mlen = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s +",
100 (IsHidden(source_p) || ConfigServerHide.hide_servers) ? me.name : source_p->name,
101 chptr->chname);
102 mbuf = modebuf + mlen;
103 pbuf = parabuf;
104
105 do
106 {
107 if ((t = strchr(s, ' ')))
108 *t++ = '\0';
109 tlen = strlen(s);
110
111 /* I don't even want to begin parsing this.. */
112 if (tlen > MODEBUFLEN)
113 break;
114
115 if (tlen && *s != ':' && add_id(source_p, chptr, s, mode_type))
116 {
117 /* this new one wont fit.. */
118 if (mbuf - modebuf + 2 + pbuf - parabuf + tlen > IRCD_BUFSIZE - 2 ||
119 modecount >= MAXMODEPARAMS)
120 {
121 *mbuf = '\0';
122 *(pbuf - 1) = '\0';
123
124 sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s",
125 modebuf, parabuf);
126 mbuf = modebuf + mlen;
127 pbuf = parabuf;
128 modecount = 0;
129 }
130
131 *mbuf++ = parv[3][0];
132 pbuf += sprintf(pbuf, "%s ", s);
133 modecount++;
134 }
135
136 s = t;
137 } while (s);
138
139 if (modecount)
140 {
141 *mbuf = *(pbuf - 1) = '\0';
142 sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s", modebuf, parabuf);
143 }
144
145 sendto_server(source_p, NOCAPS, NOCAPS, ":%s BMASK %lu %s %s :%s",
146 source_p->id, (unsigned long)chptr->channelts, chptr->chname,
147 parv[3], parv[4]);
148 return 0;
149 }
150
151 static struct Message bmask_msgtab =
152 {
153 "BMASK", 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
154 { m_ignore, m_ignore, ms_bmask, m_ignore, m_ignore, m_ignore }
155 };
156
157 static void
158 module_init(void)
159 {
160 mod_add_cmd(&bmask_msgtab);
161 }
162
163 static void
164 module_exit(void)
165 {
166 mod_del_cmd(&bmask_msgtab);
167 }
168
169 struct module module_entry =
170 {
171 .node = { NULL, NULL, NULL },
172 .name = NULL,
173 .version = "$Revision$",
174 .handle = NULL,
175 .modinit = module_init,
176 .modexit = module_exit,
177 .flags = MODULE_FLAG_CORE
178 };

Properties

Name Value
svn:keywords Id Revision