/[svn]/branches/newio/modules/core/m_part.c
ViewVC logotype

Contents of /branches/newio/modules/core/m_part.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2415 - (show annotations)
Sun Jul 21 14:33:22 2013 UTC (6 years, 11 months ago) by michael
File MIME type: text/x-chdr
File size: 4540 byte(s)
- ioengine changes as of 21JUL13

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

Properties

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

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