ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svsmode.c
Revision: 1230
Committed: Thu Sep 22 19:41:19 2011 UTC (13 years, 11 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_svsmode.c
File size: 5763 byte(s)
Log Message:
- cleanup module loader. Make module api more flexible

File Contents

# User Rev Content
1 michael 1159 /*
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 michael 1160 * \version $Id$
26 michael 1159 */
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    
44 michael 1221 /*! \brief SVSMODE command handler (called by services)
45 michael 1159 *
46     * \param client_p Pointer to allocated Client struct with physical connection
47     * to this server, i.e. with an open socket connected.
48     * \param source_p Pointer to allocated Client struct from which the message
49     * originally comes from. This can be a local or remote client.
50     * \param parc Integer holding the number of supplied arguments.
51     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
52     * pointers.
53     * \note Valid arguments for this command are:
54     * - parv[0] = sender prefix
55     * - parv[1] = nickname
56     * - parv[2] = TS (or mode, depending on svs version)
57     * - parv[3] = mode (or services id if old svs version)
58     * - parv[4] = optional arguement (services id)
59     */
60     static void
61     ms_svsmode(struct Client *client_p, struct Client *source_p,
62     int parc, char *parv[])
63     {
64     struct Client *target_p = NULL;
65     int what = MODE_ADD;
66     unsigned int flag = 0, setflags = 0;
67     char *m = NULL, *modes = NULL, *extarg = NULL;
68     time_t ts = 0;
69    
70 michael 1221 if (!HasFlag(source_p, FLAGS_SERVICE))
71 michael 1159 return;
72    
73     if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-')))
74     {
75     ts = atol(parv[2]);
76     modes = parv[3];
77     extarg = (parc > 4) ? parv[4] : NULL;
78     }
79     else
80     {
81     modes = parv[2];
82     extarg = (parc > 3) ? parv[3] : NULL;
83     }
84    
85     if ((target_p = find_person(client_p, parv[1])) == NULL)
86     return;
87    
88     if (ts && (ts != target_p->tsinfo))
89     return;
90    
91     setflags = target_p->umodes;
92    
93     for (m = modes; *m; ++m)
94     {
95     switch (*m)
96     {
97     case '+':
98     what = MODE_ADD;
99     break;
100     case '-':
101     what = MODE_DEL;
102     break;
103 michael 1163
104     case 'd':
105     if (extarg && IsDigit(*extarg))
106     target_p->servicestamp = strtoul(extarg, NULL, 0);
107     break;
108    
109 michael 1159 case 'o':
110 michael 1219 if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER))
111 michael 1159 {
112     ClearOper(target_p);
113     Count.oper--;
114    
115     if (MyConnect(target_p))
116     {
117     dlink_node *dm = NULL;
118    
119     detach_conf(target_p, OPER_TYPE);
120 michael 1219 ClrOFlag(target_p);
121 michael 1159 DelUMode(target_p, ConfigFileEntry.oper_only_umodes);
122    
123     if ((dm = dlinkFindDelete(&oper_list, target_p)) != NULL)
124     free_dlink_node(dm);
125     }
126     }
127    
128     break;
129    
130 michael 1163 case 'i':
131     if (what == MODE_ADD && !HasUMode(target_p, UMODE_INVISIBLE))
132     {
133     AddUMode(target_p, UMODE_INVISIBLE);
134     ++Count.invisi;
135     }
136    
137     if (what == MODE_DEL && HasUMode(target_p, UMODE_INVISIBLE))
138     {
139     DelUMode(target_p, UMODE_INVISIBLE);
140     --Count.invisi;
141     }
142    
143     break;
144    
145 michael 1159 case ' ':
146     case '\n':
147     case '\r':
148     case '\t':
149     break;
150     default:
151     if ((flag = user_modes[(unsigned char)*m]))
152     execute_callback(umode_cb, client_p, target_p, what, flag);
153     break;
154     }
155     }
156    
157     if (extarg)
158     {
159     sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
160     ":%s SVSMODE %s %lu %s %s", ID(source_p),
161     ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg);
162     sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
163     ":%s SVSMODE %s %lu %s %s", source_p->name,
164     target_p->name, (unsigned long)target_p->tsinfo, modes, extarg);
165     }
166     else
167     {
168     sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
169     ":%s SVSMODE %s %lu %s", ID(source_p),
170     ID(target_p), (unsigned long)target_p->tsinfo, modes);
171     sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
172     ":%s SVSMODE %s %lu %s", source_p->name,
173     target_p->name, (unsigned long)target_p->tsinfo, modes);
174     }
175    
176 michael 1161 if (MyConnect(target_p) && (setflags != target_p->umodes))
177 michael 1159 {
178     char modebuf[IRCD_BUFSIZE];
179    
180     send_umode(target_p, target_p, setflags, 0xffffffff, modebuf);
181     }
182     }
183 michael 1230
184     static struct Message svsmode_msgtab = {
185     "SVSMODE", 0, 0, 3, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0,
186     {m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, 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     .node = { NULL, NULL, NULL },
203     .name = NULL,
204     .version = "$Revision$",
205     .handle = NULL,
206     .modinit = module_init,
207     .modexit = module_exit,
208     .flags = 0
209     };

Properties

Name Value
svn:keywords Id Revision