ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_tb.c
Revision: 69
Committed: Tue Oct 4 16:09:51 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 4369 byte(s)
Log Message:
- splitted ircd/libio, all headers connected with libio sources have been
  moved for internal use only. To use libio interface, include "libio.h"
  (which is already done in "stdinc.h")


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 "hash.h"
40     #include "s_serv.h"
41     #include "s_conf.h"
42    
43     static void ms_tb(struct Client *, struct Client *, int, char *[]);
44     static void set_topic(struct Client *, struct Channel *, time_t, char *, char *);
45    
46     struct Message tb_msgtab = {
47     "TB", 0, 0, 0, 0, MFLG_SLOW, 0,
48     {m_ignore, m_ignore, ms_tb, m_ignore, m_ignore, m_ignore}
49     };
50    
51     #ifndef STATIC_MODULES
52    
53     void
54     _modinit(void)
55     {
56     mod_add_cmd(&tb_msgtab);
57     add_capability("TB", CAP_TB, 1);
58     }
59    
60     void
61     _moddeinit(void)
62     {
63     mod_del_cmd(&tb_msgtab);
64     delete_capability("TB");
65     }
66    
67 knight 31 const char *_version = "$Revision$";
68 adx 30
69     #endif /* !STATIC_MODULES */
70    
71     /* ms_tb()
72     *
73     * parv[0] = sender prefix
74     * parv[1] = channel name
75     * parv[2] = topic timestamp
76     * parv[3] = topic setter OR topic itself if parc == 4
77     * parv[4] = topic itself if parc == 5
78     *
79     * Rewritten from original m_tburst
80     * set_topic() is from original m_tburst.c rewritten to use TB not TBURST
81     * - Dianora July 28 2005
82     */
83     #define tb_channel parv[1]
84     #define tb_topicts_str parv[2]
85    
86     static void
87     ms_tb(struct Client *client_p, struct Client *source_p,
88     int parc, char *parv[])
89     {
90     struct Channel *chptr;
91     time_t tb_topicts = atol(tb_topicts_str);
92     char *tb_whoset=NULL;
93     char *tb_topic=NULL;
94    
95     if ((chptr = hash_find_channel(tb_channel)) == NULL)
96     return;
97    
98     if (parc == 5)
99     {
100     tb_whoset = parv[3];
101     tb_topic = parv[4];
102     }
103     else
104     {
105     tb_whoset = source_p->name;
106     tb_topic = parv[3];
107     }
108    
109     if (chptr->topic != NULL)
110     {
111     if (tb_topicts < chptr->topic_time)
112     {
113     /* If the topics are the same (due to lag) ignore it */
114     if (strcmp(chptr->topic, tb_topic) == 0)
115     return;
116     }
117     else
118     return;
119     }
120     set_topic(source_p, chptr, tb_topicts, tb_whoset, tb_topic);
121     }
122    
123     /*
124     * set_topic
125     *
126     * inputs - source_p pointer
127     * - channel pointer
128     * - topicts to set
129     * - who to set as who doing the topic
130     * - topic
131     * output - none
132     * Side effects - simply propagates topic as needed
133     * little helper function, could be removed
134     */
135     static void
136     set_topic(struct Client *source_p, struct Channel *chptr,
137     time_t topicts, char *topicwho, char *topic)
138     {
139     set_channel_topic(chptr, topic, topicwho, topicts);
140    
141     sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s TOPIC %s :%s",
142     ConfigServerHide.hide_servers ? me.name : source_p->name,
143     chptr->chname, chptr->topic == NULL ? "" : chptr->topic);
144    
145     sendto_server(source_p, NULL, chptr, CAP_TB, NOCAPS, NOFLAGS,
146     ":%s TB %s %lu %s :%s",
147     me.name, chptr->chname,
148     (unsigned long)chptr->topic_time,
149     chptr->topic_info == NULL ? "" : chptr->topic_info,
150     chptr->topic == NULL ? "" : chptr->topic);
151     }

Properties

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