ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_topic.c
Revision: 1751
Committed: Wed Jan 16 18:30:52 2013 UTC (12 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 4639 byte(s)
Log Message:
- Forward-port -r1750 [IMPORTANT: nick and topic lengths are now configurable
  via ircd.conf. A max_nick_length, as well as a max_topic_length configuration
  option can now be found in the serverinfo{} block]
- OpenSSL 0.9.8s and higher is now required in order to enable ssl support

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #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 michael 885 if (EmptyString(parv[1]))
66 adx 30 {
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 michael 895 if ((chptr = hash_find_channel(parv[1])) == NULL)
76 adx 30 {
77 michael 895 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 adx 30 {
89 michael 895 sendto_one(source_p, form_str(ERR_NOTONCHANNEL), from,
90     to, parv[1]);
91 michael 885 return;
92 adx 30 }
93    
94 michael 895 if (!(chptr->mode.mode & MODE_TOPICLIMIT) ||
95     has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
96 adx 30 {
97 michael 895 char topic_info[USERHOST_REPLYLEN];
98 michael 885
99 michael 1203 snprintf(topic_info, sizeof(topic_info), "%s!%s@%s", source_p->name,
100     source_p->username, source_p->host);
101 michael 1751 set_channel_topic(chptr, parv[2], topic_info, CurrentTime, !!MyClient(source_p));
102 adx 30
103 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
104 michael 895 ":%s TOPIC %s :%s",
105     ID(source_p), chptr->chname,
106 michael 1203 chptr->topic);
107 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
108 michael 895 ":%s TOPIC %s :%s",
109     source_p->name, chptr->chname,
110 michael 1203 chptr->topic);
111 michael 1011 sendto_channel_local(ALL_MEMBERS, 0,
112 michael 895 chptr, ":%s!%s@%s TOPIC %s :%s",
113     source_p->name,
114     source_p->username,
115     source_p->host,
116 michael 1203 chptr->chname, chptr->topic);
117 adx 30 }
118 michael 895 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 adx 30 {
126 michael 1203 if (chptr->topic[0] == '\0')
127 michael 895 sendto_one(source_p, form_str(RPL_NOTOPIC),
128     from, to, chptr->chname);
129 adx 30 else
130     {
131 michael 895 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 adx 30 }
139     }
140     else
141 michael 895 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
142     from, to, chptr->chname);
143 adx 30 }
144     }
145 michael 1230
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