ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svsmode.c
Revision: 1219
Committed: Sun Sep 18 09:02:38 2011 UTC (15 years ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_svsmode.c
File size: 5673 byte(s)
Log Message:
- Start cleaning up macros in client.h. Replace several ClientHasSomeCoolFlag()
with simple HasFlag/HasUMode macros.

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 *
4 * Copyright (C) 1999 by the Bahamut Development Team.
5 * Copyright (C) 2011 by the 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
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 "handlers.h"
30 #include "client.h"
31 #include "ircd.h"
32 #include "numeric.h"
33 #include "s_conf.h"
34 #include "s_serv.h"
35 #include "send.h"
36 #include "channel_mode.h"
37 #include "msg.h"
38 #include "parse.h"
39 #include "modules.h"
40 #include "irc_string.h"
41 #include "s_user.h"
42
43 static void ms_svsmode(struct Client *, struct Client *, int, char *[]);
44
45 struct Message svsmode_msgtab = {
46 "SVSMODE", 0, 0, 3, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0,
47 {m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore}
48 };
49
50 const char *_version = "$Revision$";
51
52 void
53 _modinit(void)
54 {
55 mod_add_cmd(&svsmode_msgtab);
56 }
57
58 void
59 _moddeinit(void)
60 {
61 mod_del_cmd(&svsmode_msgtab);
62 }
63
64
65 /*! \brief SVSMODE command handler (called by servers or services)
66 *
67 * \param client_p Pointer to allocated Client struct with physical connection
68 * to this server, i.e. with an open socket connected.
69 * \param source_p Pointer to allocated Client struct from which the message
70 * originally comes from. This can be a local or remote client.
71 * \param parc Integer holding the number of supplied arguments.
72 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
73 * pointers.
74 * \note Valid arguments for this command are:
75 * - parv[0] = sender prefix
76 * - parv[1] = nickname
77 * - parv[2] = TS (or mode, depending on svs version)
78 * - parv[3] = mode (or services id if old svs version)
79 * - parv[4] = optional arguement (services id)
80 */
81 static void
82 ms_svsmode(struct Client *client_p, struct Client *source_p,
83 int parc, char *parv[])
84 {
85 struct Client *target_p = NULL;
86 int what = MODE_ADD;
87 unsigned int flag = 0, setflags = 0;
88 char *m = NULL, *modes = NULL, *extarg = NULL;
89 time_t ts = 0;
90
91 if (!HasFlag(source_p, FLAGS_SERVICE) || (parc < 3))
92 return;
93
94 if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-')))
95 {
96 ts = atol(parv[2]);
97 modes = parv[3];
98 extarg = (parc > 4) ? parv[4] : NULL;
99 }
100 else
101 {
102 modes = parv[2];
103 extarg = (parc > 3) ? parv[3] : NULL;
104 }
105
106 if ((target_p = find_person(client_p, parv[1])) == NULL)
107 return;
108
109 if (ts && (ts != target_p->tsinfo))
110 return;
111
112 setflags = target_p->umodes;
113
114 for (m = modes; *m; ++m)
115 {
116 switch (*m)
117 {
118 case '+':
119 what = MODE_ADD;
120 break;
121 case '-':
122 what = MODE_DEL;
123 break;
124
125 case 'd':
126 if (extarg && IsDigit(*extarg))
127 target_p->servicestamp = strtoul(extarg, NULL, 0);
128 break;
129
130 case 'o':
131 if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER))
132 {
133 ClearOper(target_p);
134 Count.oper--;
135
136 if (MyConnect(target_p))
137 {
138 dlink_node *dm = NULL;
139
140 detach_conf(target_p, OPER_TYPE);
141 ClrOFlag(target_p);
142 DelUMode(target_p, ConfigFileEntry.oper_only_umodes);
143
144 if ((dm = dlinkFindDelete(&oper_list, target_p)) != NULL)
145 free_dlink_node(dm);
146 }
147 }
148
149 break;
150
151 case 'i':
152 if (what == MODE_ADD && !HasUMode(target_p, UMODE_INVISIBLE))
153 {
154 AddUMode(target_p, UMODE_INVISIBLE);
155 ++Count.invisi;
156 }
157
158 if (what == MODE_DEL && HasUMode(target_p, UMODE_INVISIBLE))
159 {
160 DelUMode(target_p, UMODE_INVISIBLE);
161 --Count.invisi;
162 }
163
164 break;
165
166 case ' ':
167 case '\n':
168 case '\r':
169 case '\t':
170 break;
171 default:
172 if ((flag = user_modes[(unsigned char)*m]))
173 execute_callback(umode_cb, client_p, target_p, what, flag);
174 break;
175 }
176 }
177
178 if (extarg)
179 {
180 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
181 ":%s SVSMODE %s %lu %s %s", ID(source_p),
182 ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg);
183 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
184 ":%s SVSMODE %s %lu %s %s", source_p->name,
185 target_p->name, (unsigned long)target_p->tsinfo, modes, extarg);
186 }
187 else
188 {
189 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
190 ":%s SVSMODE %s %lu %s", ID(source_p),
191 ID(target_p), (unsigned long)target_p->tsinfo, modes);
192 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
193 ":%s SVSMODE %s %lu %s", source_p->name,
194 target_p->name, (unsigned long)target_p->tsinfo, modes);
195 }
196
197 if (MyConnect(target_p) && (setflags != target_p->umodes))
198 {
199 char modebuf[IRCD_BUFSIZE];
200
201 send_umode(target_p, target_p, setflags, 0xffffffff, modebuf);
202 }
203 }

Properties

Name Value
svn:keywords Id Revision