ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_ojoin.c
Revision: 405
Committed: Tue Feb 7 19:38:35 2006 UTC (20 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 4789 byte(s)
Log Message:
- Removed now unused llflags parameter from sendto_server()


File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_ojoin.c: Allows opers join channels with @%+ modes
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 "handlers.h"
27     #include "channel.h"
28     #include "client.h"
29     #include "ircd.h"
30     #include "numeric.h"
31     #include "send.h"
32     #include "hash.h"
33     #include "msg.h"
34     #include "s_serv.h"
35     #include "modules.h"
36     #include "channel_mode.h"
37     #include "common.h"
38    
39     static void mo_ojoin(struct Client *, struct Client *, int, char *[]);
40    
41     struct Message ojoin_msgtab = {
42     "OJOIN", 0, 0, 2, 0, MFLG_SLOW, 0,
43     { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_ojoin, m_ignore }
44     };
45    
46     #ifndef STATIC_MODULES
47     void
48     _modinit(void)
49     {
50     mod_add_cmd(&ojoin_msgtab);
51     }
52    
53     void
54     _moddeinit(void)
55     {
56     mod_del_cmd(&ojoin_msgtab);
57     }
58    
59 knight 31 const char *_version = "$Revision$";
60 adx 30 #endif
61    
62     /* mo_ojoin()
63     * parv[0] = sender prefix
64     * parv[1] = channels separated by commas
65     */
66     static void
67     mo_ojoin(struct Client *client_p, struct Client *source_p,
68     int parc, char *parv[])
69     {
70     struct Channel *chptr = NULL;
71     const char *prefix = "";
72     char modeletter = '\0';
73     char *name = parv[1];
74     char *t = NULL;
75     unsigned int flags = 0;
76 adx 355 dlink_node *ptr;
77 adx 30
78     /* admins only */
79     if (!IsAdmin(source_p))
80     {
81     sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
82     me.name, source_p->name);
83     return;
84     }
85    
86     for (name = strtoken(&t, name, ","); name;
87     name = strtoken(&t, NULL, ","))
88     {
89     switch (*name)
90     {
91     case '@':
92     prefix = "@";
93     flags = CHFL_CHANOP;
94     modeletter = 'o';
95     ++name;
96     break;
97     #ifdef HALFOPS
98     case '%':
99     prefix = "%";
100     flags = CHFL_HALFOP;
101     modeletter = 'h';
102     ++name;
103     break;
104     #endif
105     case '+':
106     prefix = "+";
107     flags = CHFL_VOICE;
108     modeletter = 'v';
109     ++name;
110     break;
111     case '#':
112     case '&':
113     prefix = "";
114     flags = 0;
115     modeletter = '\0';
116     break;
117    
118     default:
119     sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
120     me.name, source_p->name, name);
121     continue;
122     }
123    
124     /* Error checking here */
125     if ((chptr = hash_find_channel(name)) == NULL)
126     {
127     sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
128     me.name, source_p->name, name);
129     }
130     else if (IsMember(source_p, chptr))
131     {
132     sendto_one(source_p, ":%s NOTICE %s :Please part %s before using OJOIN",
133     me.name, source_p->name, name);
134     }
135     else
136     {
137     add_user_to_channel(chptr, source_p, flags, NO);
138    
139     if (chptr->chname[0] == '#')
140 michael 405 {
141 adx 355 DLINK_FOREACH(ptr, serv_list.head)
142     {
143     struct Client *serv_p = ptr->data;
144     if (IsDead(serv_p))
145     continue;
146 adx 30
147 michael 405 sendto_one(serv_p, ":%s SJOIN %lu %s + :%s%s", ID_or_name(&me, serv_p),
148     (unsigned long)chptr->channelts, chptr->chname,
149     (*prefix == '%' && !IsCapable(serv_p, CAP_HOPS)) ?
150     "@" : prefix, ID_or_name(source_p, serv_p));
151 adx 355 }
152 michael 405 }
153 adx 355
154 adx 30 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s JOIN %s",
155     source_p->name, source_p->username,
156     source_p->host,
157     chptr->chname);
158    
159     if (modeletter != '\0')
160     sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s +%c %s",
161     me.name, chptr->chname, modeletter, source_p->name);
162    
163     /* send the topic... */
164     if (chptr->topic != NULL)
165     {
166     sendto_one(source_p, form_str(RPL_TOPIC),
167     me.name, source_p->name, chptr->chname,
168     chptr->topic);
169     sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
170     me.name, source_p->name, chptr->chname,
171     chptr->topic_info, chptr->topic_time);
172     }
173    
174     source_p->localClient->last_join_time = CurrentTime;
175     channel_member_names(source_p, chptr, 1);
176     }
177     }
178     }

Properties

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