ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/core/m_part.c
Revision: 1230
Committed: Thu Sep 22 19:41:19 2011 UTC (15 years ago) by michael
Content type: text/x-csrc
File size: 4734 byte(s)
Log Message:
- cleanup module loader. Make module api more flexible

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

Properties

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