ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_tburst.c
Revision: 3294
Committed: Thu Apr 10 18:48:55 2014 UTC (11 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 4211 byte(s)
Log Message:
- doxygen

File Contents

# User Rev Content
1 michael 2820 /*
2     * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 michael 325 *
4 michael 2820 * Copyright (c) 2002-2014 ircd-hybrid development team
5 michael 325 *
6 michael 2820 * 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 michael 325 *
11 michael 2820 * 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 michael 325 *
16 michael 2820 * 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 michael 325 */
21    
22 michael 2820 /*! \file m_tburst.c
23     * \brief Includes required functions for processing the TBURST command.
24     * \version $Id$
25     */
26    
27 michael 325 #include "stdinc.h"
28     #include "client.h"
29     #include "ircd.h"
30     #include "send.h"
31     #include "modules.h"
32     #include "hash.h"
33     #include "s_serv.h"
34 michael 1309 #include "conf.h"
35 michael 1243 #include "parse.h"
36 michael 325
37    
38 michael 3294 /*! \brief TBURST command handler
39 michael 325 *
40 michael 3294 * \param source_p Pointer to allocated Client struct from which the message
41     * originally comes from. This can be a local or remote client.
42     * \param parc Integer holding the number of supplied arguments.
43     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
44     * pointers.
45     * \note Valid arguments for this command are:
46     * - parv[0] = command
47     * - parv[1] = channel timestamp
48     * - parv[2] = channel name
49     * - parv[3] = topic timestamp
50     * - parv[4] = topic setter
51     * - parv[5] = topic
52 michael 325 */
53 michael 2820 static int
54 michael 3156 ms_tburst(struct Client *source_p, int parc, char *parv[])
55 michael 325 {
56     struct Channel *chptr = NULL;
57 michael 336 int accept_remote = 0;
58     time_t remote_channel_ts = atol(parv[1]);
59     time_t remote_topic_ts = atol(parv[3]);
60 michael 1486 const char *topic = parv[5];
61     const char *setby = parv[4];
62 michael 325
63 michael 336 /*
64     * Do NOT test parv[5] for an empty string and return if true!
65     * parv[5] CAN be an empty string, i.e. if the other side wants
66     * to unset our topic. Don't forget: an empty topic is also a
67     * valid topic.
68     */
69    
70    
71 michael 325 if ((chptr = hash_find_channel(parv[2])) == NULL)
72 michael 2820 return 0;
73 michael 325
74 michael 336 /*
75     * The logic for accepting and rejecting channel topics was
76     * always a bit hairy, so now we got exactly 2 cases where
77     * we would accept a bursted topic
78     *
79     * Case 1:
80     * The TS of the remote channel is older than ours
81     * Case 2:
82     * The TS of the remote channel is equal to ours AND
83     * the TS of the remote topic is newer than ours
84 michael 325 */
85 michael 1485 if (HasFlag(source_p, FLAGS_SERVICE))
86 michael 336 accept_remote = 1;
87 michael 1485 else if (remote_channel_ts < chptr->channelts)
88     accept_remote = 1;
89 michael 336 else if (remote_channel_ts == chptr->channelts)
90     if (remote_topic_ts > chptr->topic_time)
91     accept_remote = 1;
92    
93     if (accept_remote)
94     {
95 michael 1487 int topic_differs = strncmp(chptr->topic, topic, sizeof(chptr->topic) - 1);
96 michael 1615 int hidden_server = (ConfigServerHide.hide_servers || IsHidden(source_p));
97 michael 1487
98 michael 3232 set_channel_topic(chptr, topic, setby, remote_topic_ts, 0);
99 michael 336
100 michael 3135 sendto_server(source_p, CAP_TBURST, NOCAPS,
101 michael 1615 ":%s TBURST %s %s %s %s :%s",
102 michael 3186 source_p->id, parv[1], parv[2], parv[3], setby, topic);
103 michael 1615
104 michael 1487 if (topic_differs)
105 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s TOPIC %s :%s",
106 michael 1615 hidden_server ? me.name : source_p->name,
107 michael 1203 chptr->chname, chptr->topic);
108 michael 336 }
109 michael 2820
110     return 0;
111 michael 325 }
112    
113 michael 2820 static struct Message tburst_msgtab =
114     {
115 michael 1486 "TBURST", 0, 0, 6, MAXPARA, MFLG_SLOW, 0,
116 michael 1230 { m_ignore, m_ignore, ms_tburst, m_ignore, m_ignore, m_ignore }
117     };
118    
119 michael 325 static void
120 michael 1230 module_init(void)
121 michael 325 {
122 michael 1230 mod_add_cmd(&tburst_msgtab);
123     add_capability("TBURST", CAP_TBURST, 1);
124     }
125 michael 325
126 michael 1230 static void
127     module_exit(void)
128     {
129     mod_del_cmd(&tburst_msgtab);
130     delete_capability("TBURST");
131 michael 325 }
132 michael 1230
133 michael 2820 struct module module_entry =
134     {
135 michael 1230 .node = { NULL, NULL, NULL },
136     .name = NULL,
137     .version = "$Revision$",
138     .handle = NULL,
139     .modinit = module_init,
140     .modexit = module_exit,
141     .flags = 0
142     };

Properties

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