ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_invite.c
Revision: 1483
Committed: Wed Jul 25 19:15:48 2012 UTC (11 years, 8 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_invite.c
File size: 5223 byte(s)
Log Message:
- Made Client::away a fixed-size array at the expense of a somewhat higher
  memory consumption

File Contents

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

Properties

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