ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_topic.c
Revision: 3220
Committed: Thu Mar 27 17:49:38 2014 UTC (12 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 5350 byte(s)
Log Message:
- m_topic.c:m_topic(): use chptr->chname when reporting ERR_NOTONCHANNEL

File Contents

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

Properties

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