ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/contrib/m_force.c
Revision: 1474
Committed: Sun Jul 22 14:44:07 2012 UTC (14 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 9978 byte(s)
Log Message:
- removed &localchannels

File Contents

# User Rev Content
1 adx 30 /* contrib/m_force.c
2     * Copyright (C) 2002, 2003, 2004, 2005 Hybrid Development Team
3     *
4     * Redistribution and use in source and binary forms, with or without
5     * modification, are permitted provided that the following conditions are
6     * met:
7     *
8     * 1.Redistributions of source code must retain the above copyright notice,
9     * this list of conditions and the following disclaimer.
10     * 2.Redistributions in binary form must reproduce the above copyright
11     * notice, this list of conditions and the following disclaimer in the
12     * documentation and/or other materials provided with the distribution.
13     * 3.The name of the author may not be used to endorse or promote products
14     * derived from this software without specific prior written permission.
15     *
16     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18     * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19     * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20     * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21     * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22     * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24     * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25     * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26     * POSSIBILITY OF SUCH DAMAGE.
27     *
28 knight 31 * $Id$
29 adx 30 */
30    
31     #include "stdinc.h"
32     #include "client.h"
33     #include "ircd.h"
34     #include "irc_string.h"
35     #include "numeric.h"
36     #include "fdlist.h"
37     #include "hash.h"
38     #include "s_bsd.h"
39 michael 1309 #include "conf.h"
40 adx 30 #include "s_serv.h"
41     #include "send.h"
42     #include "parse.h"
43     #include "modules.h"
44     #include "channel.h"
45     #include "channel_mode.h"
46    
47    
48     /* m_forcejoin()
49     * parv[0] = sender prefix
50     * parv[1] = user to force
51     * parv[2] = channel to force them into
52     */
53     static void
54     mo_forcejoin(struct Client *client_p, struct Client *source_p,
55     int parc, char *parv[])
56     {
57     struct Client *target_p = NULL;
58     struct Channel *chptr = NULL;
59     unsigned int type = 0;
60     char mode = '\0';
61     char sjmode = '\0';
62     char *newch = NULL;
63 michael 632 dlink_node *ptr = NULL;
64 adx 30
65 michael 1219 if (!HasUMode(source_p, UMODE_ADMIN))
66 adx 30 {
67     sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
68     me.name, source_p->name);
69     return;
70     }
71    
72 michael 1169 if ((target_p = hash_find_client(parv[1])) == NULL || !IsClient(target_p))
73 adx 30 {
74     sendto_one(source_p, form_str(ERR_NOSUCHNICK),
75     me.name, source_p->name, parv[1]);
76     return;
77     }
78    
79     if (!MyConnect(target_p))
80     {
81     if (target_p->from != client_p)
82     {
83     if (IsCapable(target_p->from, CAP_ENCAP))
84     sendto_one(target_p, ":%s ENCAP %s FORCEJOIN %s %s",
85     source_p->name, target_p->from->name,
86     target_p->name, parv[2]);
87     else
88     sendto_one(target_p, ":%s FORCEJOIN %s %s",
89     source_p->name, target_p->name, parv[2]);
90     }
91    
92     return;
93     }
94    
95     /* select our modes from parv[2] if they exist... (chanop)*/
96     switch (*parv[2])
97     {
98     case '@':
99     type = CHFL_CHANOP;
100     mode = 'o';
101     sjmode = '@';
102     parv[2]++;
103     break;
104     #ifdef HALFOPS
105     case '%':
106     type = CHFL_HALFOP;
107     mode = 'h';
108     sjmode = '%';
109     parv[2]++;
110     break;
111     #endif
112     case '+':
113     type = CHFL_VOICE;
114     mode = 'v';
115     sjmode = '+';
116     parv[2]++;
117     break;
118     default:
119     type = 0;
120     mode = sjmode = '\0'; /* make sure sjmode is 0. sjoin depends on it */
121     break;
122     }
123    
124     if ((chptr = hash_find_channel(parv[2])) != NULL)
125     {
126     if (IsMember(target_p, chptr))
127     {
128     sendto_one(source_p, ":%s NOTICE %s :*** Notice -- %s is already in %s",
129     me.name, source_p->name, target_p->name, chptr->chname);
130     return;
131     }
132    
133 michael 1243 add_user_to_channel(chptr, target_p, type, 0);
134 adx 30
135 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s JOIN :%s",
136 adx 30 target_p->name, target_p->username,
137     target_p->host, chptr->chname);
138    
139     if (sjmode)
140 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s +%c %s",
141 adx 30 me.name, chptr->chname, mode, target_p->name);
142    
143     if (chptr->chname[0] == '#')
144     {
145     if (sjmode)
146 michael 632 {
147 adx 356 DLINK_FOREACH (ptr, serv_list.head)
148     {
149     struct Client *serv_p = ptr->data;
150     if (serv_p == target_p->from || IsDead(serv_p))
151     continue;
152    
153     sendto_one(serv_p, ":%s SJOIN %lu %s + :%c%s",
154     ID_or_name(&me, serv_p), (unsigned long)chptr->channelts,
155     chptr->chname, (sjmode == '%' &&
156     !IsCapable(serv_p, CAP_HOPS)) ? '@' : sjmode,
157     ID_or_name(target_p, serv_p));
158     }
159 michael 632 }
160 adx 30 else
161     {
162 michael 1474 sendto_server(target_p, CAP_TS6, NOCAPS,
163 adx 30 ":%s SJOIN %lu %s + :%s",
164     me.id, (unsigned long)chptr->channelts,
165     chptr->chname, target_p->id);
166 michael 1474 sendto_server(target_p, NOCAPS, CAP_TS6,
167 adx 30 ":%s SJOIN %lu %s + :%s",
168     me.name, (unsigned long)chptr->channelts,
169     chptr->chname, target_p->name);
170     }
171     }
172    
173 michael 1203 if (chptr->topic[0])
174 adx 30 {
175     sendto_one(target_p, form_str(RPL_TOPIC),
176     me.name, target_p->name,
177     chptr->chname, chptr->topic);
178     sendto_one(target_p, form_str(RPL_TOPICWHOTIME),
179 michael 690 me.name, target_p->name, chptr->chname,
180 adx 30 chptr->topic_info, chptr->topic_time);
181     }
182    
183     target_p->localClient->last_join_time = CurrentTime;
184     channel_member_names(target_p, chptr, 1);
185     }
186     else
187     {
188     newch = parv[2];
189    
190 michael 632 if (!check_channel_name(newch, 1))
191 adx 30 {
192     sendto_one(source_p, form_str(ERR_BADCHANNAME),
193     me.name, source_p->name, newch);
194     return;
195     }
196    
197 michael 632 chptr = make_channel(newch);
198 michael 1243 add_user_to_channel(chptr, target_p, CHFL_CHANOP, 0);
199 adx 30
200 michael 1474 sendto_server(target_p, CAP_TS6, NOCAPS,
201     ":%s SJOIN %lu %s +nt :@%s",
202     me.id, (unsigned long)chptr->channelts,
203     chptr->chname, ID(target_p));
204     sendto_server(target_p, NOCAPS, CAP_TS6,
205     ":%s SJOIN %lu %s +nt :@%s",
206     me.name, (unsigned long)chptr->channelts,
207     chptr->chname, target_p->name);
208 adx 30
209 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s JOIN :%s",
210 adx 30 target_p->name, target_p->username,
211     target_p->host, chptr->chname);
212    
213     chptr->mode.mode |= MODE_TOPICLIMIT | MODE_NOPRIVMSGS;
214    
215 michael 1268 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s +nt",
216 adx 30 me.name, chptr->chname);
217    
218     target_p->localClient->last_join_time = CurrentTime;
219     channel_member_names(target_p, chptr, 1);
220    
221     /* we do this to let the oper know that a channel was created, this will be
222     * seen from the server handling the command instead of the server that
223     * the oper is on.
224     */
225     sendto_one(source_p, ":%s NOTICE %s :*** Notice -- Creating channel %s",
226     me.name, source_p->name, chptr->chname);
227     }
228     }
229    
230     static void
231     mo_forcepart(struct Client *client_p, struct Client *source_p,
232     int parc, char *parv[])
233     {
234     struct Client *target_p = NULL;
235     struct Channel *chptr = NULL;
236     struct Membership *member = NULL;
237    
238 michael 1219 if (!HasUMode(source_p, UMODE_ADMIN))
239 adx 30 {
240     sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
241     me.name, source_p->name);
242     return;
243     }
244    
245     /* if target_p == NULL then let the oper know */
246 michael 1169 if ((target_p = hash_find_client(parv[1])) == NULL || !IsClient(target_p))
247 adx 30 {
248     sendto_one(source_p, form_str(ERR_NOSUCHNICK),
249     me.name, source_p->name, parv[1]);
250     return;
251     }
252    
253     if (!MyConnect(target_p))
254     {
255     if (target_p->from != client_p)
256     {
257     if (IsCapable(target_p->from, CAP_ENCAP))
258     sendto_one(target_p, ":%s ENCAP %s FORCEPART %s %s",
259     source_p->name, target_p->from->name,
260     target_p->name, parv[2]);
261     else
262     sendto_one(target_p, ":%s FORCEPART %s %s",
263     source_p->name, target_p->name, parv[2]);
264     }
265    
266     return;
267     }
268    
269     if ((chptr = hash_find_channel(parv[2])) == NULL)
270     {
271     sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
272     me.name, source_p->name, parv[2]);
273     return;
274     }
275    
276     if ((member = find_channel_link(target_p, chptr)) == NULL)
277     {
278     sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
279     me.name, source_p->name, chptr->chname, target_p->name);
280     return;
281     }
282    
283 michael 1474 sendto_server(target_p, CAP_TS6, NOCAPS,
284     ":%s PART %s :%s", ID(target_p),
285     chptr->chname, target_p->name);
286     sendto_server(target_p, NOCAPS, CAP_TS6,
287     ":%s PART %s :%s", target_p->name,
288     chptr->chname, target_p->name);
289 adx 30
290 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s PART %s :%s",
291 adx 30 target_p->name, target_p->username,
292     target_p->host, chptr->chname,
293     target_p->name);
294     remove_user_from_channel(member);
295     }
296 michael 1268
297     static struct Message forcejoin_msgtab = {
298     "FORCEJOIN", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
299     { m_ignore, m_not_oper, mo_forcejoin, mo_forcejoin, mo_forcejoin, m_ignore }
300     };
301    
302     static struct Message forcepart_msgtab = {
303     "FORCEPART", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
304     { m_ignore, m_not_oper, mo_forcepart, mo_forcepart, mo_forcepart, m_ignore }
305     };
306    
307     static void
308     module_init(void)
309     {
310     mod_add_cmd(&forcejoin_msgtab);
311     mod_add_cmd(&forcepart_msgtab);
312     }
313    
314     static void
315     module_exit(void)
316     {
317     mod_del_cmd(&forcejoin_msgtab);
318     mod_del_cmd(&forcepart_msgtab);
319     }
320    
321     struct module module_entry = {
322     .node = { NULL, NULL, NULL },
323     .name = NULL,
324     .version = "$Revision$",
325     .handle = NULL,
326     .modinit = module_init,
327     .modexit = module_exit,
328     .flags = 0
329     };

Properties

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