/[svn]/ircd-hybrid/modules/core/m_part.c
ViewVC logotype

Annotation of /ircd-hybrid/modules/core/m_part.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 885 - (hide annotations)
Wed Oct 31 18:09:24 2007 UTC (13 years, 7 months ago) by michael
Original Path: ircd-hybrid-7.2/modules/core/m_part.c
File MIME type: text/x-chdr
File size: 4629 byte(s)
- Removed LazyLinks in 7.2 to stop people from asking why we keep
  broken code for half a decade. LL will be implemented in a smarter
  fashion in due time

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

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28