ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_tburst.c
Revision: 3186
Committed: Thu Mar 20 18:09:34 2014 UTC (12 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 3813 byte(s)
Log Message:
- Get rid of the ID() macro

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2002-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_tburst.c
23 * \brief Includes required functions for processing the TBURST command.
24 * \version $Id$
25 */
26
27 #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 #include "conf.h"
35 #include "parse.h"
36
37
38 /* ms_tburst()
39 *
40 * parv[0] = command
41 * parv[1] = channel timestamp
42 * parv[2] = channel
43 * parv[3] = topic timestamp
44 * parv[4] = topic setter
45 * parv[5] = topic
46 */
47 static int
48 ms_tburst(struct Client *source_p, int parc, char *parv[])
49 {
50 struct Channel *chptr = NULL;
51 int accept_remote = 0;
52 time_t remote_channel_ts = atol(parv[1]);
53 time_t remote_topic_ts = atol(parv[3]);
54 const char *topic = parv[5];
55 const char *setby = parv[4];
56
57 /*
58 * Do NOT test parv[5] for an empty string and return if true!
59 * parv[5] CAN be an empty string, i.e. if the other side wants
60 * to unset our topic. Don't forget: an empty topic is also a
61 * valid topic.
62 */
63
64
65 if ((chptr = hash_find_channel(parv[2])) == NULL)
66 return 0;
67
68 /*
69 * The logic for accepting and rejecting channel topics was
70 * always a bit hairy, so now we got exactly 2 cases where
71 * we would accept a bursted topic
72 *
73 * Case 1:
74 * The TS of the remote channel is older than ours
75 * Case 2:
76 * The TS of the remote channel is equal to ours AND
77 * the TS of the remote topic is newer than ours
78 */
79 if (HasFlag(source_p, FLAGS_SERVICE))
80 accept_remote = 1;
81 else if (remote_channel_ts < chptr->channelts)
82 accept_remote = 1;
83 else if (remote_channel_ts == chptr->channelts)
84 if (remote_topic_ts > chptr->topic_time)
85 accept_remote = 1;
86
87 if (accept_remote)
88 {
89 int topic_differs = strncmp(chptr->topic, topic, sizeof(chptr->topic) - 1);
90 int hidden_server = (ConfigServerHide.hide_servers || IsHidden(source_p));
91
92 set_channel_topic(chptr, topic, setby, remote_topic_ts, !!MyClient(source_p));
93
94 sendto_server(source_p, CAP_TBURST, NOCAPS,
95 ":%s TBURST %s %s %s %s :%s",
96 source_p->id, parv[1], parv[2], parv[3], setby, topic);
97
98 if (topic_differs)
99 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s TOPIC %s :%s",
100 hidden_server ? me.name : source_p->name,
101 chptr->chname, chptr->topic);
102 }
103
104 return 0;
105 }
106
107 static struct Message tburst_msgtab =
108 {
109 "TBURST", 0, 0, 6, MAXPARA, MFLG_SLOW, 0,
110 { m_ignore, m_ignore, ms_tburst, m_ignore, m_ignore, m_ignore }
111 };
112
113 static void
114 module_init(void)
115 {
116 mod_add_cmd(&tburst_msgtab);
117 add_capability("TBURST", CAP_TBURST, 1);
118 }
119
120 static void
121 module_exit(void)
122 {
123 mod_del_cmd(&tburst_msgtab);
124 delete_capability("TBURST");
125 }
126
127 struct module module_entry =
128 {
129 .node = { NULL, NULL, NULL },
130 .name = NULL,
131 .version = "$Revision$",
132 .handle = NULL,
133 .modinit = module_init,
134 .modexit = module_exit,
135 .flags = 0
136 };

Properties

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