ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_invite.c
Revision: 2888
Committed: Tue Jan 21 17:47:11 2014 UTC (10 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 4661 byte(s)
Log Message:
- Fixed improper use of the ID_or_name macro in several places

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-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_invite.c
23 * \brief Includes required functions for processing the INVITE command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #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 #include "conf.h"
38 #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 static int
52 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 return 0;
61
62 if (EmptyString(parv[2]))
63 {
64 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
65 me.name, source_p->name, "INVITE");
66 return 0;
67 }
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 sendto_one(source_p, form_str(ERR_NOSUCHNICK),
75 me.name, source_p->name, parv[1]);
76 return 0;
77 }
78
79 if ((chptr = hash_find_channel(parv[2])) == NULL)
80 {
81 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
82 me.name, source_p->name, parv[2]);
83 return 0;
84 }
85
86 if (MyConnect(source_p) && (ms = find_channel_link(source_p, chptr)) == NULL)
87 {
88 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
89 me.name, source_p->name, chptr->chname);
90 return 0;
91 }
92
93 if (MyConnect(source_p) && !has_member_flags(ms, CHFL_CHANOP))
94 {
95 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
96 me.name, source_p->name, chptr->chname);
97 return 0;
98 }
99
100 if (IsMember(target_p, chptr))
101 {
102 sendto_one(source_p, form_str(ERR_USERONCHANNEL), me.name,
103 source_p->name, target_p->name, chptr->chname);
104 return 0;
105 }
106
107 if (MyConnect(source_p))
108 {
109 sendto_one(source_p, form_str(RPL_INVITING), me.name,
110 source_p->name, target_p->name, chptr->chname);
111
112 if (target_p->away[0])
113 sendto_one(source_p, form_str(RPL_AWAY),
114 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 return 0;
120
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 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
135 /* 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),
142 ID_or_name(target_p, target_p),
143 chptr->chname, (unsigned long)chptr->channelts);
144 return 0;
145 }
146
147 static struct Message invite_msgtab =
148 {
149 "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 struct module module_entry =
166 {
167 .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