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: 5015
Committed: Tue Dec 9 17:53:37 2014 UTC (9 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 4383 byte(s)
Log Message:
- Removed unused header includes:wq

File Contents

# User Rev Content
1 michael 3356 /*
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 michael 4564 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 michael 3356 * USA
20     */
21    
22     /*! \file m_bmask.c
23     * \brief Includes required functions for processing the BMASK command.
24 michael 3357 * \version $Id$
25 michael 3356 */
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 michael 3778 /*! \brief BMASK command handler
42 michael 3356 *
43 michael 3778 * \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 michael 3356 */
55     static int
56     ms_bmask(struct Client *source_p, int parc, char *parv[])
57     {
58 michael 3538 char modebuf[IRCD_BUFSIZE] = "";
59     char parabuf[IRCD_BUFSIZE] = "";
60     char banbuf[IRCD_BUFSIZE] = "";
61     struct Channel *chptr = NULL;
62 michael 3356 char *s, *t, *mbuf, *pbuf;
63     unsigned int mode_type = 0;
64 michael 3538 int mlen = 0, tlen = 0;
65 michael 3356 int modecount = 0;
66    
67     if ((chptr = hash_find_channel(parv[2])) == NULL)
68     return 0;
69    
70     /* TS is higher, drop it. */
71 michael 4817 if (atol(parv[1]) > chptr->creationtime)
72 michael 3356 return 0;
73    
74     switch (*parv[3])
75     {
76     case 'b':
77     mode_type = CHFL_BAN;
78     break;
79     case 'e':
80     mode_type = CHFL_EXCEPTION;
81     break;
82     case 'I':
83     mode_type = CHFL_INVEX;
84     break;
85     default:
86     return 0;
87     }
88    
89 michael 3538 strlcpy(banbuf, parv[4], sizeof(banbuf));
90 michael 3356 s = banbuf;
91    
92     mlen = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s +",
93     (IsHidden(source_p) || ConfigServerHide.hide_servers) ? me.name : source_p->name,
94 michael 4617 chptr->name);
95 michael 3356 mbuf = modebuf + mlen;
96     pbuf = parabuf;
97    
98     do
99     {
100     if ((t = strchr(s, ' ')))
101     *t++ = '\0';
102     tlen = strlen(s);
103    
104     /* I don't even want to begin parsing this.. */
105     if (tlen > MODEBUFLEN)
106     break;
107    
108     if (tlen && *s != ':' && add_id(source_p, chptr, s, mode_type))
109     {
110     /* this new one wont fit.. */
111     if (mbuf - modebuf + 2 + pbuf - parabuf + tlen > IRCD_BUFSIZE - 2 ||
112     modecount >= MAXMODEPARAMS)
113     {
114 michael 3538 *mbuf = *(pbuf - 1) = '\0';
115 michael 3356
116 michael 4794 sendto_channel_local(0, chptr, "%s %s", modebuf, parabuf);
117 michael 3356 mbuf = modebuf + mlen;
118     pbuf = parabuf;
119     modecount = 0;
120     }
121    
122 michael 3538 *mbuf++ = *parv[3];
123 michael 3356 pbuf += sprintf(pbuf, "%s ", s);
124 michael 3538 ++modecount;
125 michael 3356 }
126    
127     s = t;
128     } while (s);
129    
130     if (modecount)
131     {
132     *mbuf = *(pbuf - 1) = '\0';
133 michael 4794 sendto_channel_local(0, chptr, "%s %s", modebuf, parabuf);
134 michael 3356 }
135    
136 michael 4963 sendto_server(source_p, 0, 0, ":%s BMASK %lu %s %s :%s",
137 michael 4817 source_p->id, (unsigned long)chptr->creationtime, chptr->name,
138 michael 3356 parv[3], parv[4]);
139     return 0;
140     }
141    
142     static struct Message bmask_msgtab =
143     {
144 michael 4546 "BMASK", NULL, 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
145 michael 3356 { m_ignore, m_ignore, ms_bmask, m_ignore, m_ignore, m_ignore }
146     };
147    
148     static void
149     module_init(void)
150     {
151     mod_add_cmd(&bmask_msgtab);
152     }
153    
154     static void
155     module_exit(void)
156     {
157     mod_del_cmd(&bmask_msgtab);
158     }
159    
160     struct module module_entry =
161     {
162     .node = { NULL, NULL, NULL },
163     .name = NULL,
164 michael 3357 .version = "$Revision$",
165 michael 3356 .handle = NULL,
166     .modinit = module_init,
167     .modexit = module_exit,
168     .flags = MODULE_FLAG_CORE
169     };

Properties

Name Value
svn:keywords Id Revision