ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_topic.c
Revision: 3135
Committed: Mon Mar 10 21:11:25 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 5411 byte(s)
Log Message:
- Server now no longer accepts TS5 links

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
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 michael 2820 /*! \file m_topic.c
23     * \brief Includes required functions for processing the TOPIC command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28 michael 1011 #include "list.h"
29 adx 30 #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 "s_serv.h"
38     #include "parse.h"
39     #include "modules.h"
40     #include "packet.h"
41    
42    
43     /* m_topic()
44 michael 3096 * parv[0] = command
45 adx 30 * parv[1] = channel name
46     * parv[2] = new topic, if setting topic
47     */
48 michael 2820 static int
49 adx 30 m_topic(struct Client *client_p, struct Client *source_p,
50     int parc, char *parv[])
51     {
52     struct Channel *chptr = NULL;
53    
54 michael 885 if (EmptyString(parv[1]))
55 adx 30 {
56 michael 3109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "TOPIC");
57 michael 2820 return 0;
58 adx 30 }
59    
60 michael 1799 if (!IsFloodDone(source_p))
61 adx 30 flood_endgrace(source_p);
62    
63 michael 895 if ((chptr = hash_find_channel(parv[1])) == NULL)
64 adx 30 {
65 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[1]);
66 michael 2820 return 0;
67 michael 895 }
68    
69     /* setting topic */
70     if (parc > 2)
71     {
72 michael 2520 const struct Membership *ms = NULL;
73 michael 895
74     if ((ms = find_channel_link(source_p, chptr)) == NULL)
75 adx 30 {
76 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, parv[1]);
77 michael 2820 return 0;
78 adx 30 }
79    
80 michael 895 if (!(chptr->mode.mode & MODE_TOPICLIMIT) ||
81     has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
82 adx 30 {
83 michael 2820 char topic_info[USERHOST_REPLYLEN];
84 michael 885
85 michael 1203 snprintf(topic_info, sizeof(topic_info), "%s!%s@%s", source_p->name,
86     source_p->username, source_p->host);
87 michael 1799 set_channel_topic(chptr, parv[2], topic_info, CurrentTime, 1);
88 adx 30
89 michael 3135 sendto_server(client_p, NOCAPS, NOCAPS, ":%s TOPIC %s :%s",
90 michael 895 ID(source_p), chptr->chname,
91 michael 1203 chptr->topic);
92 michael 1011 sendto_channel_local(ALL_MEMBERS, 0,
93 michael 895 chptr, ":%s!%s@%s TOPIC %s :%s",
94     source_p->name,
95     source_p->username,
96     source_p->host,
97 michael 1203 chptr->chname, chptr->topic);
98 adx 30 }
99 michael 895 else
100 michael 3109 sendto_one_numeric(source_p, &me, ERR_CHANOPRIVSNEEDED, chptr->chname);
101 michael 895 }
102     else /* only asking for topic */
103     {
104     if (!SecretChannel(chptr) || IsMember(source_p, chptr))
105 adx 30 {
106 michael 1203 if (chptr->topic[0] == '\0')
107 michael 3109 sendto_one_numeric(source_p, &me, RPL_NOTOPIC, chptr->chname);
108 adx 30 else
109     {
110 michael 3109 sendto_one_numeric(source_p, &me, RPL_TOPIC,
111     chptr->chname, chptr->topic);
112     sendto_one_numeric(source_p, &me, RPL_TOPICWHOTIME, chptr->chname,
113     chptr->topic_info,
114     chptr->topic_time);
115 adx 30 }
116     }
117     else
118 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, chptr->chname);
119 adx 30 }
120 michael 2820
121     return 0;
122 adx 30 }
123 michael 1230
124 michael 2820 static int
125 michael 1799 ms_topic(struct Client *client_p, struct Client *source_p,
126     int parc, char *parv[])
127     {
128     struct Channel *chptr = NULL;
129     char topic_info[USERHOST_REPLYLEN];
130    
131     if (EmptyString(parv[1]))
132     {
133 michael 3109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "TOPIC");
134 michael 2820 return 0;
135 michael 1799 }
136    
137     if ((chptr = hash_find_channel(parv[1])) == NULL)
138     {
139 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[1]);
140 michael 2820 return 0;
141 michael 1799 }
142    
143     if (!IsClient(source_p))
144     strlcpy(topic_info, source_p->name, sizeof(topic_info));
145     else
146     snprintf(topic_info, sizeof(topic_info), "%s!%s@%s", source_p->name,
147     source_p->username, source_p->host);
148     set_channel_topic(chptr, parv[2], topic_info, CurrentTime, 0);
149    
150 michael 3135 sendto_server(client_p, NOCAPS, NOCAPS, ":%s TOPIC %s :%s",
151 michael 1799 ID(source_p), chptr->chname,
152     chptr->topic);
153    
154     if (!IsClient(source_p))
155     sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s TOPIC %s :%s",
156     source_p->name,
157     chptr->chname, chptr->topic);
158    
159     else
160     sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s TOPIC %s :%s",
161     source_p->name,
162     source_p->username,
163     source_p->host,
164     chptr->chname, chptr->topic);
165 michael 2820 return 0;
166 michael 1799 }
167    
168    
169 michael 2820 static struct Message topic_msgtab =
170     {
171 michael 1230 "TOPIC", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
172 michael 2820 { m_unregistered, m_topic, ms_topic, m_ignore, m_topic, m_ignore }
173 michael 1230 };
174    
175     static void
176     module_init(void)
177     {
178     mod_add_cmd(&topic_msgtab);
179     }
180    
181     static void
182     module_exit(void)
183     {
184     mod_del_cmd(&topic_msgtab);
185     }
186    
187 michael 2820 struct module module_entry =
188     {
189 michael 1230 .node = { NULL, NULL, NULL },
190     .name = NULL,
191     .version = "$Revision$",
192     .handle = NULL,
193     .modinit = module_init,
194     .modexit = module_exit,
195     .flags = 0
196     };

Properties

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