/[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 30 - (hide annotations)
Sun Oct 2 20:03:27 2005 UTC (15 years, 8 months ago) by adx
File MIME type: text/x-chdr
File size: 4742 byte(s)
- imported sources
- can be moved later according to the directory/branching scheme,
  but we need the svn up

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     * $Id: m_part.c,v 1.80 2005/09/24 12:38:38 michael Exp $
23     */
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     const char *_version = "$Revision: 1.80 $";
66     #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     char *name, char *reason)
80     {
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     ((can_send_part(ms, chptr, source_p) > 0 &&
107     (source_p->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
108     < CurrentTime))))
109     {
110     sendto_server(client_p, NULL, chptr, CAP_TS6, NOCAPS, NOFLAGS,
111     ":%s PART %s :%s", ID(source_p), chptr->chname,
112     reason);
113     sendto_server(client_p, NULL, chptr, NOCAPS, CAP_TS6, NOFLAGS,
114     ":%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     sendto_server(client_p, NULL, chptr, CAP_TS6, NOCAPS, NOFLAGS,
123     ":%s PART %s", ID(source_p), chptr->chname);
124     sendto_server(client_p, NULL, chptr, NOCAPS, CAP_TS6, NOFLAGS,
125     ":%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     char *p, *name;
145     char reason[KICKLEN + 1];
146    
147     if (IsServer(source_p))
148     return;
149    
150     if (*parv[1] == '\0')
151     {
152     sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
153     me.name, source_p->name, "PART");
154     return;
155     }
156    
157     reason[0] = '\0';
158    
159     if (parc > 2)
160     strlcpy(reason, parv[2], sizeof(reason));
161    
162     name = strtoken(&p, parv[1], ",");
163    
164     /* Finish the flood grace period... */
165     if (MyClient(source_p) && !IsFloodDone(source_p))
166     flood_endgrace(source_p);
167    
168     while (name)
169     {
170     part_one_client(client_p, source_p, name, reason);
171     name = strtoken(&p, NULL, ",");
172     }
173     }

Properties

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

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