ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_topic.c
Revision: 1243
Committed: Fri Sep 30 10:47:53 2011 UTC (13 years, 10 months ago) by michael
Content type: text/x-csrc
File size: 4631 byte(s)
Log Message:
- move content of msg.h, ircd_handler.h and handlers.h into parse.h and
  remove headers accordingly
- killed common.h
- remove m_killhost.c and m_flags.c from contrib/
- sort out unused header includes here and there

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_topic.c: Sets a channel topic.
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 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "list.h"
27 #include "channel.h"
28 #include "channel_mode.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "irc_string.h"
32 #include "sprintf_irc.h"
33 #include "ircd.h"
34 #include "numeric.h"
35 #include "send.h"
36 #include "s_serv.h"
37 #include "parse.h"
38 #include "modules.h"
39 #include "packet.h"
40
41
42 /* m_topic()
43 * parv[0] = sender prefix
44 * parv[1] = channel name
45 * parv[2] = new topic, if setting topic
46 */
47 static void
48 m_topic(struct Client *client_p, struct Client *source_p,
49 int parc, char *parv[])
50 {
51 struct Channel *chptr = NULL;
52 const char *from, *to;
53
54 if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
55 {
56 from = me.id;
57 to = source_p->id;
58 }
59 else
60 {
61 from = me.name;
62 to = source_p->name;
63 }
64
65 if (EmptyString(parv[1]))
66 {
67 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
68 from, to, "TOPIC");
69 return;
70 }
71
72 if (MyClient(source_p) && !IsFloodDone(source_p))
73 flood_endgrace(source_p);
74
75 if ((chptr = hash_find_channel(parv[1])) == NULL)
76 {
77 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
78 from, to, parv[1]);
79 return;
80 }
81
82 /* setting topic */
83 if (parc > 2)
84 {
85 struct Membership *ms;
86
87 if ((ms = find_channel_link(source_p, chptr)) == NULL)
88 {
89 sendto_one(source_p, form_str(ERR_NOTONCHANNEL), from,
90 to, parv[1]);
91 return;
92 }
93
94 if (!(chptr->mode.mode & MODE_TOPICLIMIT) ||
95 has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
96 {
97 char topic_info[USERHOST_REPLYLEN];
98
99 snprintf(topic_info, sizeof(topic_info), "%s!%s@%s", source_p->name,
100 source_p->username, source_p->host);
101 set_channel_topic(chptr, parv[2], topic_info, CurrentTime);
102
103 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
104 ":%s TOPIC %s :%s",
105 ID(source_p), chptr->chname,
106 chptr->topic);
107 sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
108 ":%s TOPIC %s :%s",
109 source_p->name, chptr->chname,
110 chptr->topic);
111 sendto_channel_local(ALL_MEMBERS, 0,
112 chptr, ":%s!%s@%s TOPIC %s :%s",
113 source_p->name,
114 source_p->username,
115 source_p->host,
116 chptr->chname, chptr->topic);
117 }
118 else
119 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
120 from, to, chptr->chname);
121 }
122 else /* only asking for topic */
123 {
124 if (!SecretChannel(chptr) || IsMember(source_p, chptr))
125 {
126 if (chptr->topic[0] == '\0')
127 sendto_one(source_p, form_str(RPL_NOTOPIC),
128 from, to, chptr->chname);
129 else
130 {
131 sendto_one(source_p, form_str(RPL_TOPIC),
132 from, to,
133 chptr->chname, chptr->topic);
134 sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
135 from, to, chptr->chname,
136 chptr->topic_info,
137 chptr->topic_time);
138 }
139 }
140 else
141 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
142 from, to, chptr->chname);
143 }
144 }
145
146 static struct Message topic_msgtab = {
147 "TOPIC", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
148 {m_unregistered, m_topic, m_topic, m_ignore, m_topic, m_ignore}
149 };
150
151 static void
152 module_init(void)
153 {
154 mod_add_cmd(&topic_msgtab);
155 }
156
157 static void
158 module_exit(void)
159 {
160 mod_del_cmd(&topic_msgtab);
161 }
162
163 struct module module_entry = {
164 .node = { NULL, NULL, NULL },
165 .name = NULL,
166 .version = "$Revision$",
167 .handle = NULL,
168 .modinit = module_init,
169 .modexit = module_exit,
170 .flags = 0
171 };

Properties

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