ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_part.c
Revision: 1029
Committed: Sun Nov 8 13:10:50 2009 UTC (16 years, 11 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.3/modules/core/m_part.c
File size: 4610 byte(s)
Log Message:
- branch off trunk to create 7.3 branch

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_part.c: Parts a user from a channel.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #include "handlers.h"
28     #include "channel.h"
29     #include "channel_mode.h"
30     #include "client.h"
31     #include "common.h"
32     #include "hash.h"
33     #include "irc_string.h"
34     #include "ircd.h"
35     #include "numeric.h"
36     #include "send.h"
37     #include "s_serv.h"
38     #include "msg.h"
39     #include "parse.h"
40     #include "modules.h"
41     #include "s_conf.h"
42     #include "packet.h"
43    
44     static void m_part(struct Client *, struct Client *, int, char *[]);
45    
46     struct Message part_msgtab = {
47     "PART", 0, 0, 2, 0, MFLG_SLOW, 0,
48     { m_unregistered, m_part, m_part, m_ignore, m_part, m_ignore }
49     };
50    
51     #ifndef STATIC_MODULES
52     void
53     _modinit(void)
54     {
55     mod_add_cmd(&part_msgtab);
56     }
57    
58     void
59     _moddeinit(void)
60     {
61     mod_del_cmd(&part_msgtab);
62     }
63    
64 knight 31 const char *_version = "$Revision$";
65 adx 30 #endif
66    
67    
68     /* part_one_client()
69     *
70     * inputs - pointer to server
71     * - pointer to source client to remove
72     * - char pointer of name of channel to remove from
73     * output - none
74     * side effects - remove ONE client given the channel name
75     */
76     static void
77     part_one_client(struct Client *client_p, struct Client *source_p,
78 michael 885 const char *name, const char *reason)
79 adx 30 {
80     struct Channel *chptr = NULL;
81     struct Membership *ms = NULL;
82    
83     if ((chptr = hash_find_channel(name)) == NULL)
84     {
85     sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
86     me.name, source_p->name, name);
87     return;
88     }
89    
90     if ((ms = find_channel_link(source_p, chptr)) == NULL)
91     {
92     sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
93     me.name, source_p->name, name);
94     return;
95     }
96    
97     if (MyConnect(source_p) && !IsOper(source_p))
98     check_spambot_warning(source_p, NULL);
99    
100     /*
101     * Remove user from the old channel (if any)
102     * only allow /part reasons in -m chans
103     */
104     if (reason[0] && (!MyConnect(source_p) ||
105 michael 454 ((can_send(chptr, source_p, ms) &&
106 adx 30 (source_p->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
107     < CurrentTime))))
108     {
109 michael 885 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
110 adx 30 ":%s PART %s :%s", ID(source_p), chptr->chname,
111     reason);
112 michael 885 sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
113 adx 30 ":%s PART %s :%s", source_p->name, chptr->chname,
114     reason);
115     sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s PART %s :%s",
116     source_p->name, source_p->username,
117     source_p->host, chptr->chname, reason);
118     }
119     else
120     {
121 michael 885 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
122 adx 30 ":%s PART %s", ID(source_p), chptr->chname);
123 michael 885 sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
124 adx 30 ":%s PART %s", source_p->name, chptr->chname);
125     sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s PART %s",
126     source_p->name, source_p->username,
127     source_p->host, chptr->chname);
128     }
129    
130     remove_user_from_channel(ms);
131     }
132    
133     /*
134     ** m_part
135     ** parv[0] = sender prefix
136     ** parv[1] = channel
137     ** parv[2] = reason
138     */
139     static void
140     m_part(struct Client *client_p, struct Client *source_p,
141     int parc, char *parv[])
142     {
143 michael 875 char *p = NULL, *name = NULL;
144 michael 885 char reason[KICKLEN + 1] = { '\0' };
145 adx 30
146     if (IsServer(source_p))
147     return;
148    
149 michael 885 if (EmptyString(parv[1]))
150 adx 30 {
151     sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
152     me.name, source_p->name, "PART");
153     return;
154     }
155    
156     if (parc > 2)
157     strlcpy(reason, parv[2], sizeof(reason));
158    
159     /* Finish the flood grace period... */
160     if (MyClient(source_p) && !IsFloodDone(source_p))
161     flood_endgrace(source_p);
162    
163 michael 885 for (name = strtoken(&p, parv[1], ","); name;
164     name = strtoken(&p, NULL, ","))
165 adx 30 part_one_client(client_p, source_p, name, reason);
166     }

Properties

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