ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svsmode.c
Revision: 5347
Committed: Sun Jan 11 12:42:20 2015 UTC (11 years, 8 months ago) by michael
Content type: text/x-csrc
File size: 5115 byte(s)
Log Message:
- Update copyright years

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 struct Client *target_p = NULL;
58 int what = MODE_ADD;
59 unsigned int flag = 0, setmodes = 0;
60 const char *modes = NULL, *extarg = NULL;
61 time_t ts = 0;
62
63 if (!HasFlag(source_p, FLAGS_SERVICE))
64 return 0;
65
66 ts = atol(parv[2]);
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 if (ts && (ts != target_p->tsinfo))
74 return 0;
75
76 setmodes = target_p->umodes;
77
78 for (const char *m = modes; *m; ++m)
79 {
80 switch (*m)
81 {
82 case '+':
83 what = MODE_ADD;
84 break;
85 case '-':
86 what = MODE_DEL;
87 break;
88
89 case 'd':
90 if (!EmptyString(extarg))
91 strlcpy(target_p->account, extarg, sizeof(target_p->account));
92 break;
93
94 case 'x':
95 if (!EmptyString(extarg) && valid_hostname(extarg))
96 user_set_hostmask(target_p, extarg, what);
97 break;
98
99 case 'o':
100 if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER))
101 {
102 ClearOper(target_p);
103 --Count.oper;
104
105 if (MyConnect(target_p))
106 {
107 dlink_node *node = NULL;
108
109 detach_conf(target_p, CONF_OPER);
110 ClrOFlag(target_p);
111 DelUMode(target_p, ConfigGeneral.oper_only_umodes);
112
113 if ((node = dlinkFindDelete(&oper_list, target_p)))
114 free_dlink_node(node);
115 }
116 }
117
118 break;
119
120 case 'i':
121 if (what == MODE_ADD && !HasUMode(target_p, UMODE_INVISIBLE))
122 {
123 AddUMode(target_p, UMODE_INVISIBLE);
124 ++Count.invisi;
125 }
126
127 if (what == MODE_DEL && HasUMode(target_p, UMODE_INVISIBLE))
128 {
129 DelUMode(target_p, UMODE_INVISIBLE);
130 --Count.invisi;
131 }
132
133 break;
134
135 case 'S': /* Only servers may set +S in a burst */
136 case 'W': /* Only servers may set +W in a burst */
137 break;
138
139 default:
140 if ((flag = user_modes[(unsigned char)*m]))
141 {
142 if (what == MODE_ADD)
143 AddUMode(target_p, flag);
144 else
145 DelUMode(target_p, flag);
146 }
147
148 break;
149 }
150 }
151
152 if (extarg)
153 sendto_server(source_p, 0, 0, ":%s SVSMODE %s %lu %s %s",
154 source_p->id,
155 target_p->id, (unsigned long)target_p->tsinfo, modes, extarg);
156 else
157 sendto_server(source_p, 0, 0, ":%s SVSMODE %s %lu %s",
158 source_p->id,
159 target_p->id, (unsigned long)target_p->tsinfo, modes);
160
161 if (MyConnect(target_p) && (setmodes != target_p->umodes))
162 {
163 char modebuf[IRCD_BUFSIZE] = "";
164
165 send_umode(target_p, target_p, setmodes, modebuf);
166 }
167
168 return 0;
169 }
170
171 static struct Message svsmode_msgtab =
172 {
173 "SVSMODE", NULL, 0, 0, 4, MAXPARA, MFLG_SLOW, 0,
174 { m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore }
175 };
176
177 static void
178 module_init(void)
179 {
180 mod_add_cmd(&svsmode_msgtab);
181 }
182
183 static void
184 module_exit(void)
185 {
186 mod_del_cmd(&svsmode_msgtab);
187 }
188
189 struct module module_entry =
190 {
191 .node = { NULL, NULL, NULL },
192 .name = NULL,
193 .version = "$Revision$",
194 .handle = NULL,
195 .modinit = module_init,
196 .modexit = module_exit,
197 .flags = 0
198 };

Properties

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