ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_bmask.c
Revision: 7330
Committed: Fri Feb 19 17:50:13 2016 UTC (10 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 4539 byte(s)
Log Message:
- Now that we got time_t to work nicely on openbsd with snprintf's conversion specifiers,
  we ran into a similiar issue on Raspbian/ARMv7's time_t which is of signed 32 bit and
  doesn't cope at all with %j. Instead of doing tricks, get rid of time_t everywhere and
  forever and use uintmax_t instead which has at least a 'standardized' conversion specifier
  associated with it.

File Contents

# User Rev Content
1 michael 3356 /*
2     * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3     *
4 michael 7006 * Copyright (c) 1997-2016 ircd-hybrid development team
5 michael 3356 *
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 4565 * 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 3777 /*! \brief BMASK command handler
42 michael 3356 *
43 michael 3777 * \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 3537 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 3537 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 7330 if (strtoumax(parv[1], NULL, 10) > 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 3537 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 4618 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 michael 5756 /* add_id can modify 's' */
111     tlen = strlen(s);
112    
113 michael 3356 /* this new one wont fit.. */
114     if (mbuf - modebuf + 2 + pbuf - parabuf + tlen > IRCD_BUFSIZE - 2 ||
115     modecount >= MAXMODEPARAMS)
116     {
117 michael 3537 *mbuf = *(pbuf - 1) = '\0';
118 michael 3356
119 michael 6759 sendto_channel_local(NULL, chptr, 0, 0, 0, "%s %s", modebuf, parabuf);
120 michael 3356 mbuf = modebuf + mlen;
121     pbuf = parabuf;
122     modecount = 0;
123     }
124    
125 michael 3537 *mbuf++ = *parv[3];
126 michael 3356 pbuf += sprintf(pbuf, "%s ", s);
127 michael 3537 ++modecount;
128 michael 3356 }
129    
130     s = t;
131     } while (s);
132    
133     if (modecount)
134     {
135     *mbuf = *(pbuf - 1) = '\0';
136 michael 6759 sendto_channel_local(NULL, chptr, 0, 0, 0, "%s %s", modebuf, parabuf);
137 michael 3356 }
138    
139 michael 6782 sendto_server(source_p, 0, 0, ":%s BMASK %ju %s %s :%s",
140     source_p->id, chptr->creationtime, chptr->name,
141 michael 3356 parv[3], parv[4]);
142     return 0;
143     }
144    
145     static struct Message bmask_msgtab =
146     {
147 michael 5881 .cmd = "BMASK",
148     .args_min = 5,
149     .args_max = MAXPARA,
150     .handlers[UNREGISTERED_HANDLER] = m_ignore,
151     .handlers[CLIENT_HANDLER] = m_ignore,
152     .handlers[SERVER_HANDLER] = ms_bmask,
153     .handlers[ENCAP_HANDLER] = m_ignore,
154     .handlers[OPER_HANDLER] = m_ignore
155 michael 3356 };
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 michael 3357 .version = "$Revision$",
172 michael 3356 .modinit = module_init,
173     .modexit = module_exit,
174     .flags = MODULE_FLAG_CORE
175     };

Properties

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