ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_lljoin.c
Revision: 69
Committed: Tue Oct 4 16:09:51 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 5022 byte(s)
Log Message:
- splitted ircd/libio, all headers connected with libio sources have been
  moved for internal use only. To use libio interface, include "libio.h"
  (which is already done in "stdinc.h")


File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_lljoin.c: Joins a user on a lazy-link to 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     #include "channel.h"
27     #include "channel_mode.h"
28     #include "client.h"
29     #include "hash.h"
30     #include "common.h"
31     #include "ircd.h"
32     #include "numeric.h"
33     #include "s_serv.h"
34     #include "s_conf.h"
35     #include "send.h"
36     #include "handlers.h"
37     #include "msg.h"
38     #include "parse.h"
39     #include "modules.h"
40    
41    
42     static void ms_lljoin(struct Client *,struct Client *,int,char **);
43    
44     struct Message lljoin_msgtab = {
45     "LLJOIN", 0, 0, 3, 0, MFLG_SLOW | MFLG_UNREG, 0L,
46     {m_unregistered, m_ignore, ms_lljoin, m_ignore, m_ignore, m_ignore}
47     };
48     #ifndef STATIC_MODULES
49    
50     void
51     _modinit(void)
52     {
53     mod_add_cmd(&lljoin_msgtab);
54     }
55    
56     void
57     _moddeinit(void)
58     {
59     mod_del_cmd(&lljoin_msgtab);
60     }
61    
62 knight 31 const char *_version = "$Revision$";
63 adx 30 #endif
64     /*
65     * m_lljoin
66     * parv[0] = sender prefix
67     * parv[1] = channel
68     * parv[2] = nick ("!nick" == cjoin)
69     * parv[3] = key (optional)
70     *
71     * If a lljoin is received, from our uplink, join
72     * the requested client to the given channel, or ignore it
73     * if there is an error.
74     *
75     * Ok, the way this works. Leaf client tries to join a channel,
76     * it doesn't exist so the join does a cburst request on behalf of the
77     * client, and aborts that join. The cburst sjoin's the channel if it
78     * exists on the hub, and sends back an LLJOIN to the leaf. Thats where
79     * this is now..
80     *
81     */
82     static void
83     ms_lljoin(struct Client *client_p, struct Client *source_p,
84     int parc, char *parv[])
85     {
86     char *chname = NULL;
87     char *nick = NULL;
88     char *key = NULL;
89     int flags;
90     int i;
91     struct Client *target_p;
92     struct Channel *chptr;
93    
94     if (uplink && !IsCapable(uplink,CAP_LL))
95     {
96     sendto_realops_flags(UMODE_ALL, L_ALL,
97     "*** LLJOIN requested from non LL server %s",
98     client_p->name);
99     return;
100     }
101    
102     chname = parv[1];
103     if(chname == NULL)
104     return;
105    
106     nick = parv[2];
107     if(nick == NULL)
108     return;
109    
110     if (parc >3)
111     key = parv[3];
112    
113     flags = 0;
114    
115     target_p = find_person(client_p, nick);
116    
117     if (!target_p)
118     return;
119    
120     if (!MyClient(target_p))
121     return;
122    
123     chptr = get_or_create_channel(target_p, chname, NULL);
124     flags = CHFL_CHANOP;
125    
126     if(!chptr)
127     return;
128    
129     if (dlink_list_length(&chptr->members) == 0)
130     flags = CHFL_CHANOP;
131     else
132     flags = 0;
133    
134     /* XXX in m_join.c :( */
135     /* check_spambot_warning(target_p, chname); */
136    
137     /* They _could_ join a channel twice due to lag */
138     if(chptr)
139     {
140     if (IsMember(target_p, chptr)) /* already a member, ignore this */
141     return;
142     }
143     else
144     {
145     sendto_one(target_p, form_str(ERR_UNAVAILRESOURCE),
146     me.name, nick, chptr->chname);
147     return;
148     }
149    
150     if ((i = can_join(target_p, chptr, key)))
151     {
152     sendto_one(target_p, form_str(i),
153     me.name, nick, chptr->chname);
154     return;
155     }
156    
157     if ((dlink_list_length(&target_p->channel) >= ConfigChannel.max_chans_per_user) &&
158     (!IsOper(target_p) || (dlink_list_length(&target_p->channel) >=
159     ConfigChannel.max_chans_per_user*3)))
160     {
161     sendto_one(target_p, form_str(ERR_TOOMANYCHANNELS),
162     me.name, nick, chptr->chname );
163     return;
164     }
165    
166     if (flags == CHFL_CHANOP)
167     {
168     chptr->channelts = CurrentTime;
169    
170     sendto_one(uplink,
171     ":%s SJOIN %lu %s + :@%s",
172     me.name,
173     (unsigned long) chptr->channelts,
174     chptr->chname,
175     nick);
176     }
177    
178     sendto_one(uplink,
179     ":%s SJOIN %lu %s + :%s",
180     me.name,
181     (unsigned long) chptr->channelts,
182     chptr->chname,
183     nick);
184    
185     add_user_to_channel(chptr, target_p, flags, YES);
186    
187     sendto_channel_local(ALL_MEMBERS, NO, chptr,
188     ":%s!%s@%s JOIN :%s",
189     target_p->name,
190     target_p->username,
191     target_p->host,
192     chptr->chname);
193    
194     if (flags & CHFL_CHANOP)
195     {
196     chptr->mode.mode |= MODE_TOPICLIMIT;
197     chptr->mode.mode |= MODE_NOPRIVMSGS;
198    
199     sendto_channel_local(ALL_MEMBERS, NO, chptr,
200     ":%s MODE %s +nt",
201     me.name, chptr->chname);
202     sendto_one(uplink,
203     ":%s MODE %s +nt",
204     me.name, chptr->chname);
205     }
206    
207     channel_member_names(target_p, chptr, 1);
208     }

Properties

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