ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_invite.c
Revision: 1832
Committed: Fri Apr 19 19:16:09 2013 UTC (12 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 4516 byte(s)
Log Message:
- Made all numeric defines use the actual string instead of the numeric value
  which allows to use gcc's printf format attribute
- Remove current message locale implementation

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #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 michael 1309 #include "conf.h"
36 adx 30 #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 michael 885 if (EmptyString(parv[2]))
61 adx 30 {
62 michael 1832 sendto_one(source_p, ERR_NEEDMOREPARAMS,
63 adx 30 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 michael 1832 sendto_one(source_p, ERR_NOSUCHNICK,
73 adx 30 me.name, source_p->name, parv[1]);
74     return;
75     }
76    
77     if ((chptr = hash_find_channel(parv[2])) == NULL)
78     {
79 michael 1832 sendto_one(source_p, ERR_NOSUCHCHANNEL,
80 adx 30 me.name, source_p->name, parv[2]);
81     return;
82     }
83    
84 michael 322 if (MyConnect(source_p) && (ms = find_channel_link(source_p, chptr)) == NULL)
85 adx 30 {
86 michael 1832 sendto_one(source_p, ERR_NOTONCHANNEL,
87 adx 30 me.name, source_p->name, chptr->chname);
88     return;
89     }
90    
91 michael 1477 if (MyConnect(source_p) && !has_member_flags(ms, CHFL_CHANOP))
92 adx 30 {
93 michael 1832 sendto_one(source_p, ERR_CHANOPRIVSNEEDED,
94 michael 1477 me.name, source_p->name, chptr->chname);
95     return;
96 adx 30 }
97    
98     if (IsMember(target_p, chptr))
99     {
100 michael 1832 sendto_one(source_p, ERR_USERONCHANNEL,
101 adx 30 me.name, source_p->name, target_p->name, chptr->chname);
102     return;
103     }
104    
105     if (MyConnect(source_p))
106     {
107 michael 1832 sendto_one(source_p, RPL_INVITING, me.name,
108 adx 30 source_p->name, target_p->name, chptr->chname);
109    
110 michael 1483 if (target_p->away[0])
111 michael 1832 sendto_one(source_p, RPL_AWAY,
112 adx 30 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 michael 1721 sendto_channel_butone(NULL, &me, chptr, CHFL_CHANOP,
129     "NOTICE @%s :%s is inviting %s to %s.",
130     chptr->chname, source_p->name,
131     target_p->name, chptr->chname);
132 michael 1479
133 adx 30 /* Add the invite if channel is +i */
134     add_invite(chptr, target_p);
135     }
136     }
137     else if (target_p->from != client_p)
138     sendto_one(target_p, ":%s INVITE %s %s %lu",
139     ID_or_name(source_p, target_p->from),
140     ID_or_name(target_p, target_p->from),
141     chptr->chname, (unsigned long)chptr->channelts);
142     }
143 michael 1230
144     static struct Message invite_msgtab = {
145     "INVITE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
146     { m_unregistered, m_invite, m_invite, m_ignore, m_invite, m_ignore }
147     };
148    
149     static void
150     module_init(void)
151     {
152     mod_add_cmd(&invite_msgtab);
153     }
154    
155     static void
156     module_exit(void)
157     {
158     mod_del_cmd(&invite_msgtab);
159     }
160    
161     struct module module_entry = {
162     .node = { NULL, NULL, NULL },
163     .name = NULL,
164     .version = "$Revision$",
165     .handle = NULL,
166     .modinit = module_init,
167     .modexit = module_exit,
168     .flags = 0
169     };

Properties

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