ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/core/m_part.c
Revision: 69
Committed: Tue Oct 4 16:09:51 2005 UTC (18 years, 6 months ago) by adx
Content type: text/x-csrc
File size: 4624 byte(s)
Log Message:
- splitted ircd/libio, all headers connected with libio sources have been
  moved for internal use only. To use libio interface, include "libio.h"
  (which is already done in "stdinc.h")


File Contents

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

Properties

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