ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svsmode.c
Revision: 6782
Committed: Sun Nov 15 18:49:32 2015 UTC (9 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 5450 byte(s)
Log Message:
- Use the %ju conversion specifier for time_t and get rid of these non-portable (unsigned long) casts; replace some uint64_t with uintmax_t

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1999 Bahamut development team.
5 * Copyright (c) 2011-2015 ircd-hybrid development team
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20 * USA
21 */
22
23 /*! \file m_svsmode.c
24 * \brief Includes required functions for processing the SVSMODE command.
25 * \version $Id$
26 */
27
28 #include "stdinc.h"
29 #include "client.h"
30 #include "ircd.h"
31 #include "send.h"
32 #include "channel_mode.h"
33 #include "parse.h"
34 #include "modules.h"
35 #include "irc_string.h"
36 #include "user.h"
37 #include "conf.h"
38
39
40 /*! \brief SVSMODE command handler
41 *
42 * \param source_p Pointer to allocated Client struct from which the message
43 * originally comes from. This can be a local or remote client.
44 * \param parc Integer holding the number of supplied arguments.
45 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
46 * pointers.
47 * \note Valid arguments for this command are:
48 * - parv[0] = command
49 * - parv[1] = nickname
50 * - parv[2] = TS
51 * - parv[3] = mode
52 * - parv[4] = optional argument (services account, vhost)
53 */
54 static int
55 ms_svsmode(struct Client *source_p, int parc, char *parv[])
56 {
57 const struct user_modes *tab = NULL;
58 struct Client *target_p = NULL;
59 int what = MODE_ADD;
60 unsigned int setmodes = 0;
61 const char *modes = NULL, *extarg = NULL;
62 time_t ts = 0;
63
64 if (!HasFlag(source_p, FLAGS_SERVICE))
65 return 0;
66
67 modes = parv[3];
68 extarg = (parc > 4) ? parv[4] : NULL;
69
70 if ((target_p = find_person(source_p, parv[1])) == NULL)
71 return 0;
72
73 ts = atol(parv[2]);
74 if (ts && (ts != target_p->tsinfo))
75 return 0;
76
77 setmodes = target_p->umodes;
78
79 for (const char *m = modes; *m; ++m)
80 {
81 switch (*m)
82 {
83 case '+':
84 what = MODE_ADD;
85 break;
86 case '-':
87 what = MODE_DEL;
88 break;
89
90 case 'd':
91 if (!EmptyString(extarg))
92 {
93 strlcpy(target_p->account, extarg, sizeof(target_p->account));
94 sendto_common_channels_local(target_p, 1, CAP_ACCOUNT_NOTIFY, 0, ":%s!%s@%s ACCOUNT %s",
95 target_p->name, target_p->username,
96 target_p->host, target_p->account);
97 }
98
99 break;
100
101 case 'x':
102 if (!EmptyString(extarg) && valid_hostname(extarg))
103 user_set_hostmask(target_p, extarg, what);
104 break;
105
106 case 'o':
107 if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER))
108 {
109 ClearOper(target_p);
110 --Count.oper;
111
112 if (MyConnect(target_p))
113 {
114 dlink_node *node = NULL;
115
116 detach_conf(target_p, CONF_OPER);
117 ClrOFlag(target_p);
118 DelUMode(target_p, ConfigGeneral.oper_only_umodes);
119
120 if ((node = dlinkFindDelete(&oper_list, target_p)))
121 free_dlink_node(node);
122 }
123 }
124
125 break;
126
127 case 'i':
128 if (what == MODE_ADD && !HasUMode(target_p, UMODE_INVISIBLE))
129 {
130 AddUMode(target_p, UMODE_INVISIBLE);
131 ++Count.invisi;
132 }
133 else if (what == MODE_DEL && HasUMode(target_p, UMODE_INVISIBLE))
134 {
135 DelUMode(target_p, UMODE_INVISIBLE);
136 --Count.invisi;
137 }
138
139 break;
140
141 case 'S': /* Only servers may set +S in a burst */
142 case 'W': /* Only servers may set +W in a burst */
143 break;
144
145 default:
146 if ((tab = umode_map[(unsigned char)*m]))
147 {
148 if (what == MODE_ADD)
149 AddUMode(target_p, tab->flag);
150 else
151 DelUMode(target_p, tab->flag);
152 }
153
154 break;
155 }
156 }
157
158 if (extarg)
159 sendto_server(source_p, 0, 0, ":%s SVSMODE %s %ju %s %s",
160 source_p->id,
161 target_p->id, target_p->tsinfo, modes, extarg);
162 else
163 sendto_server(source_p, 0, 0, ":%s SVSMODE %s %ju %s",
164 source_p->id,
165 target_p->id, target_p->tsinfo, modes);
166
167 if (MyConnect(target_p) && (setmodes != target_p->umodes))
168 {
169 char modebuf[IRCD_BUFSIZE] = "";
170
171 send_umode(target_p, target_p, setmodes, modebuf);
172 }
173
174 return 0;
175 }
176
177 static struct Message svsmode_msgtab =
178 {
179 .cmd = "SVSMODE",
180 .args_min = 4,
181 .args_max = MAXPARA,
182 .handlers[UNREGISTERED_HANDLER] = m_ignore,
183 .handlers[CLIENT_HANDLER] = m_ignore,
184 .handlers[SERVER_HANDLER] = ms_svsmode,
185 .handlers[ENCAP_HANDLER] = m_ignore,
186 .handlers[OPER_HANDLER] = m_ignore
187 };
188
189 static void
190 module_init(void)
191 {
192 mod_add_cmd(&svsmode_msgtab);
193 }
194
195 static void
196 module_exit(void)
197 {
198 mod_del_cmd(&svsmode_msgtab);
199 }
200
201 struct module module_entry =
202 {
203 .version = "$Revision$",
204 .modinit = module_init,
205 .modexit = module_exit,
206 };

Properties

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