ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.1.x/modules/m_invite.c
Revision: 2821
Committed: Wed Jan 15 23:12:35 2014 UTC (12 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 4673 byte(s)
Log Message:
- Clean up all files in modules/ (fixed indentation, removed whitespaces/tabs)
- Fixed copyright years
- Made module handlers int type for later use

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2821 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2821 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
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 michael 2821 /*! \file m_invite.c
23     * \brief Includes required functions for processing the INVITE command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28 michael 1011 #include "list.h"
29 adx 30 #include "channel.h"
30     #include "channel_mode.h"
31     #include "client.h"
32     #include "hash.h"
33     #include "irc_string.h"
34     #include "ircd.h"
35     #include "numeric.h"
36     #include "send.h"
37 michael 1309 #include "conf.h"
38 adx 30 #include "s_serv.h"
39     #include "parse.h"
40     #include "modules.h"
41     #include "packet.h"
42    
43    
44     /*
45     ** m_invite
46     ** parv[0] - sender prefix
47     ** parv[1] - user to invite
48     ** parv[2] - channel name
49     ** parv[3] - invite timestamp
50     */
51 michael 2821 static int
52 adx 30 m_invite(struct Client *client_p, struct Client *source_p,
53     int parc, char *parv[])
54     {
55     struct Client *target_p = NULL;
56     struct Channel *chptr = NULL;
57     struct Membership *ms = NULL;
58    
59     if (IsServer(source_p))
60 michael 2821 return 0;
61 adx 30
62 michael 885 if (EmptyString(parv[2]))
63 adx 30 {
64 michael 1834 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
65 adx 30 me.name, source_p->name, "INVITE");
66 michael 2821 return 0;
67 adx 30 }
68    
69     if (MyClient(source_p) && !IsFloodDone(source_p))
70     flood_endgrace(source_p);
71    
72     if ((target_p = find_person(client_p, parv[1])) == NULL)
73     {
74 michael 1834 sendto_one(source_p, form_str(ERR_NOSUCHNICK),
75 adx 30 me.name, source_p->name, parv[1]);
76 michael 2821 return 0;
77 adx 30 }
78    
79     if ((chptr = hash_find_channel(parv[2])) == NULL)
80     {
81 michael 1834 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
82 adx 30 me.name, source_p->name, parv[2]);
83 michael 2821 return 0;
84 adx 30 }
85    
86 michael 322 if (MyConnect(source_p) && (ms = find_channel_link(source_p, chptr)) == NULL)
87 adx 30 {
88 michael 1834 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
89 adx 30 me.name, source_p->name, chptr->chname);
90 michael 2821 return 0;
91 adx 30 }
92    
93 michael 1477 if (MyConnect(source_p) && !has_member_flags(ms, CHFL_CHANOP))
94 adx 30 {
95 michael 1834 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
96 michael 1477 me.name, source_p->name, chptr->chname);
97 michael 2821 return 0;
98 adx 30 }
99    
100     if (IsMember(target_p, chptr))
101     {
102 michael 2821 sendto_one(source_p, form_str(ERR_USERONCHANNEL), me.name,
103     source_p->name, target_p->name, chptr->chname);
104     return 0;
105 adx 30 }
106    
107     if (MyConnect(source_p))
108     {
109 michael 1834 sendto_one(source_p, form_str(RPL_INVITING), me.name,
110 adx 30 source_p->name, target_p->name, chptr->chname);
111    
112 michael 1483 if (target_p->away[0])
113 michael 1834 sendto_one(source_p, form_str(RPL_AWAY),
114 adx 30 me.name, source_p->name, target_p->name,
115     target_p->away);
116     }
117     else if (parc > 3 && IsDigit(*parv[3]))
118     if (atoi(parv[3]) > chptr->channelts)
119 michael 2821 return 0;
120 adx 30
121     if (MyConnect(target_p))
122     {
123     sendto_one(target_p, ":%s!%s@%s INVITE %s :%s",
124     source_p->name, source_p->username,
125     source_p->host,
126     target_p->name, chptr->chname);
127    
128     if (chptr->mode.mode & MODE_INVITEONLY)
129     {
130 michael 1721 sendto_channel_butone(NULL, &me, chptr, CHFL_CHANOP,
131     "NOTICE @%s :%s is inviting %s to %s.",
132     chptr->chname, source_p->name,
133     target_p->name, chptr->chname);
134 michael 1479
135 adx 30 /* Add the invite if channel is +i */
136     add_invite(chptr, target_p);
137     }
138     }
139     else if (target_p->from != client_p)
140     sendto_one(target_p, ":%s INVITE %s %s %lu",
141     ID_or_name(source_p, target_p->from),
142     ID_or_name(target_p, target_p->from),
143     chptr->chname, (unsigned long)chptr->channelts);
144 michael 2821 return 0;
145 adx 30 }
146 michael 1230
147 michael 2821 static struct Message invite_msgtab =
148     {
149 michael 1230 "INVITE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
150     { m_unregistered, m_invite, m_invite, m_ignore, m_invite, m_ignore }
151     };
152    
153     static void
154     module_init(void)
155     {
156     mod_add_cmd(&invite_msgtab);
157     }
158    
159     static void
160     module_exit(void)
161     {
162     mod_del_cmd(&invite_msgtab);
163     }
164    
165 michael 2821 struct module module_entry =
166     {
167 michael 1230 .node = { NULL, NULL, NULL },
168     .name = NULL,
169     .version = "$Revision$",
170     .handle = NULL,
171     .modinit = module_init,
172     .modexit = module_exit,
173     .flags = 0
174     };

Properties

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