ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svspart.c
Revision: 3331
Committed: Wed Apr 16 15:29:40 2014 UTC (11 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 5180 byte(s)
Log Message:
- Fixed inconsistent style in some places

File Contents

# User Rev Content
1 michael 3327 /*
2     * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3     *
4     * Copyright (c) 2014 ircd-hybrid development team
5     *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19     * USA
20     */
21    
22     /*! \file m_svspart.c
23     * \brief Includes required functions for processing the SVSPART command.
24 michael 3328 * \version $Id$
25 michael 3327 */
26    
27     #include "stdinc.h"
28     #include "list.h"
29     #include "channel.h"
30     #include "client.h"
31     #include "hash.h"
32     #include "irc_string.h"
33     #include "ircd.h"
34     #include "numeric.h"
35     #include "send.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 *target_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_numeric(target_p, &me, ERR_NOSUCHCHANNEL, name);
59     return;
60     }
61    
62     if ((ms = find_channel_link(target_p, chptr)) == NULL)
63     {
64     sendto_one_numeric(target_p, &me, ERR_NOTONCHANNEL, chptr->chname);
65     return;
66     }
67    
68     /*
69     * Remove user from the old channel (if any)
70     * only allow /part reasons in -m chans
71     */
72     if (*reason && (!MyConnect(target_p) ||
73     ((can_send(chptr, target_p, ms, reason) &&
74     (target_p->localClient->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
75     < CurrentTime))))
76     {
77     sendto_server(target_p, NOCAPS, NOCAPS, ":%s PART %s :%s",
78     target_p->id, chptr->chname, reason);
79     sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s PART %s :%s",
80     target_p->name, target_p->username,
81     target_p->host, chptr->chname, reason);
82     }
83     else
84     {
85     sendto_server(target_p, NOCAPS, NOCAPS, ":%s PART %s",
86     target_p->id, chptr->chname);
87     sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s PART %s",
88     target_p->name, target_p->username,
89     target_p->host, chptr->chname);
90     }
91    
92     remove_user_from_channel(ms);
93     }
94    
95     /*! \brief SVSPART command handler
96     *
97     * \param source_p Pointer to allocated Client struct from which the message
98     * originally comes from. This can be a local or remote client.
99     * \param parc Integer holding the number of supplied arguments.
100     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
101     * pointers.
102     * \note Valid arguments for this command are:
103     * - parv[0] = command
104     * - parv[1] = nickname
105     * - parv[2] = channel name
106     * - parv[3] = part message
107     */
108     static int
109     ms_svspart(struct Client *source_p, int parc, char *parv[])
110     {
111     struct Client *target_p = NULL;
112     char *p = NULL, *name = NULL;
113     char reason[KICKLEN + 1] = "";
114    
115     if (!HasFlag(source_p, FLAGS_SERVICE))
116     return 0;
117    
118     if (EmptyString(parv[2]))
119     return 0;
120    
121     if ((target_p = find_person(source_p, parv[1])) == NULL)
122     return 0;
123    
124     if (target_p->from == source_p->from)
125     {
126     sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
127 michael 3331 "Received wrong-direction SVSPART "
128 michael 3327 "for %s (behind %s) from %s",
129     target_p->name, source_p->from->name,
130     get_client_name(source_p, HIDE_IP));
131     return 0;
132     }
133    
134     if (!MyConnect(target_p))
135     {
136     if (parc == 3)
137     sendto_one(target_p, ":%s SVSPART %s %s", source_p->id,
138     target_p->id, parv[2]);
139     else
140 michael 3329 sendto_one(target_p, ":%s SVSPART %s %s :%s", source_p->id,
141 michael 3327 target_p->id, parv[2], parv[3]);
142     return 0;
143     }
144    
145     if (parc > 3 && !EmptyString(parv[3]))
146     strlcpy(reason, parv[3], sizeof(reason));
147    
148     for (name = strtoken(&p, parv[2], ","); name;
149     name = strtoken(&p, NULL, ","))
150     part_one_client(target_p, name, reason);
151     return 0;
152     }
153    
154     static struct Message svspart_msgtab =
155     {
156     "SVSPART", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
157     { m_unregistered, m_ignore, ms_svspart, m_ignore, m_ignore, m_ignore }
158     };
159    
160     static void
161     module_init(void)
162     {
163     mod_add_cmd(&svspart_msgtab);
164     }
165    
166     static void
167     module_exit(void)
168     {
169     mod_del_cmd(&svspart_msgtab);
170     }
171    
172     struct module module_entry =
173     {
174     .node = { NULL, NULL, NULL },
175     .name = NULL,
176 michael 3328 .version = "$Revision$",
177 michael 3327 .handle = NULL,
178     .modinit = module_init,
179     .modexit = module_exit,
180     .flags = 0
181     };

Properties

Name Value
svn:keywords Id Revision