ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_tb.c
Revision: 33
Committed: Sun Oct 2 20:50:00 2005 UTC (20 years, 10 months ago) by knight
Content type: text/x-csrc
File size: 4387 byte(s)
Log Message:
- svn:keywords

File Contents

# User Rev Content
1 adx 30 /* contrib/m_tburst.c
2     * Copyright (C) 2002, 2003, 2004, 2005 Hybrid Development Team
3     *
4     * Redistribution and use in source and binary forms, with or without
5     * modification, are permitted provided that the following conditions are
6     * met:
7     *
8     * 1.Redistributions of source code must retain the above copyright notice,
9     * this list of conditions and the following disclaimer.
10     * 2.Redistributions in binary form must reproduce the above copyright
11     * notice, this list of conditions and the following disclaimer in the
12     * documentation and/or other materials provided with the distribution.
13     * 3.The name of the author may not be used to endorse or promote products
14     * derived from this software without specific prior written permission.
15     *
16     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18     * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19     * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20     * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21     * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22     * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24     * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25     * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26     * POSSIBILITY OF SUCH DAMAGE.
27     *
28 knight 31 * $Id$
29 adx 30 */
30    
31     #include "stdinc.h"
32     #include "handlers.h"
33     #include "client.h"
34     #include "common.h"
35     #include "ircd.h"
36     #include "send.h"
37     #include "msg.h"
38     #include "modules.h"
39     #include "hook.h"
40     #include "hash.h"
41     #include "s_serv.h"
42     #include "s_conf.h"
43    
44     static void ms_tb(struct Client *, struct Client *, int, char *[]);
45     static void set_topic(struct Client *, struct Channel *, time_t, char *, char *);
46    
47     struct Message tb_msgtab = {
48     "TB", 0, 0, 0, 0, MFLG_SLOW, 0,
49     {m_ignore, m_ignore, ms_tb, m_ignore, m_ignore, m_ignore}
50     };
51    
52     #ifndef STATIC_MODULES
53    
54     void
55     _modinit(void)
56     {
57     mod_add_cmd(&tb_msgtab);
58     add_capability("TB", CAP_TB, 1);
59     }
60    
61     void
62     _moddeinit(void)
63     {
64     mod_del_cmd(&tb_msgtab);
65     delete_capability("TB");
66     }
67    
68 knight 31 const char *_version = "$Revision$";
69 adx 30
70     #endif /* !STATIC_MODULES */
71    
72     /* ms_tb()
73     *
74     * parv[0] = sender prefix
75     * parv[1] = channel name
76     * parv[2] = topic timestamp
77     * parv[3] = topic setter OR topic itself if parc == 4
78     * parv[4] = topic itself if parc == 5
79     *
80     * Rewritten from original m_tburst
81     * set_topic() is from original m_tburst.c rewritten to use TB not TBURST
82     * - Dianora July 28 2005
83     */
84     #define tb_channel parv[1]
85     #define tb_topicts_str parv[2]
86    
87     static void
88     ms_tb(struct Client *client_p, struct Client *source_p,
89     int parc, char *parv[])
90     {
91     struct Channel *chptr;
92     time_t tb_topicts = atol(tb_topicts_str);
93     char *tb_whoset=NULL;
94     char *tb_topic=NULL;
95    
96     if ((chptr = hash_find_channel(tb_channel)) == NULL)
97     return;
98    
99     if (parc == 5)
100     {
101     tb_whoset = parv[3];
102     tb_topic = parv[4];
103     }
104     else
105     {
106     tb_whoset = source_p->name;
107     tb_topic = parv[3];
108     }
109    
110     if (chptr->topic != NULL)
111     {
112     if (tb_topicts < chptr->topic_time)
113     {
114     /* If the topics are the same (due to lag) ignore it */
115     if (strcmp(chptr->topic, tb_topic) == 0)
116     return;
117     }
118     else
119     return;
120     }
121     set_topic(source_p, chptr, tb_topicts, tb_whoset, tb_topic);
122     }
123    
124     /*
125     * set_topic
126     *
127     * inputs - source_p pointer
128     * - channel pointer
129     * - topicts to set
130     * - who to set as who doing the topic
131     * - topic
132     * output - none
133     * Side effects - simply propagates topic as needed
134     * little helper function, could be removed
135     */
136     static void
137     set_topic(struct Client *source_p, struct Channel *chptr,
138     time_t topicts, char *topicwho, char *topic)
139     {
140     set_channel_topic(chptr, topic, topicwho, topicts);
141    
142     sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s TOPIC %s :%s",
143     ConfigServerHide.hide_servers ? me.name : source_p->name,
144     chptr->chname, chptr->topic == NULL ? "" : chptr->topic);
145    
146     sendto_server(source_p, NULL, chptr, CAP_TB, NOCAPS, NOFLAGS,
147     ":%s TB %s %lu %s :%s",
148     me.name, chptr->chname,
149     (unsigned long)chptr->topic_time,
150     chptr->topic_info == NULL ? "" : chptr->topic_info,
151     chptr->topic == NULL ? "" : chptr->topic);
152     }

Properties

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