ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_list.c
Revision: 896
Committed: Sat Nov 3 08:54:09 2007 UTC (17 years, 9 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/modules/m_list.c
File size: 5547 byte(s)
Log Message:
- Killed s_stats.c

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_list.c: List channel given or all channels.
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     #include "tools.h"
27     #include "handlers.h"
28     #include "channel.h"
29     #include "channel_mode.h"
30     #include "client.h"
31     #include "hash.h"
32     #include "irc_string.h"
33     #include "ircd.h"
34     #include "numeric.h"
35     #include "s_conf.h"
36     #include "s_serv.h"
37     #include "send.h"
38     #include "list.h"
39     #include "msg.h"
40     #include "parse.h"
41     #include "modules.h"
42     #include "s_user.h"
43    
44 michael 896 static void m_list(struct Client *, struct Client *, int, char *[]);
45     static void mo_list(struct Client *, struct Client *, int, char *[]);
46 adx 30
47     struct Message list_msgtab = {
48     "LIST", 0, 0, 0, 0, MFLG_SLOW, 0,
49 michael 885 {m_unregistered, m_list, m_ignore, m_ignore, mo_list, m_ignore}
50 adx 30 };
51    
52     #ifndef STATIC_MODULES
53     void
54     _modinit(void)
55     {
56     mod_add_cmd(&list_msgtab);
57     add_isupport("ELIST", "CMNTU", -1);
58     add_isupport("SAFELIST", NULL, -1);
59     }
60    
61     void
62     _moddeinit(void)
63     {
64     mod_del_cmd(&list_msgtab);
65     delete_isupport("ELIST");
66     delete_isupport("SAFELIST");
67     }
68    
69 knight 31 const char *_version = "$Revision$";
70 adx 30 #endif
71    
72     static int
73     has_wildcards(const char *s)
74     {
75     char c;
76    
77     while ((c = *s++))
78     if (IsMWildChar(c))
79     return 1;
80    
81     return 0;
82     }
83    
84     static void
85     do_list(struct Client *source_p, int parc, char *parv[])
86     {
87     struct ListTask *lt;
88     int no_masked_channels;
89    
90 michael 885 if (source_p->localClient->list_task != NULL)
91 adx 30 {
92 michael 885 free_list_task(source_p->localClient->list_task, source_p);
93     sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
94     return;
95 adx 30 }
96    
97 michael 885 lt = MyMalloc(sizeof(struct ListTask));
98 adx 30 lt->users_max = UINT_MAX;
99     lt->created_max = UINT_MAX;
100     lt->topicts_max = UINT_MAX;
101 michael 885 source_p->localClient->list_task = lt;
102    
103 adx 30 no_masked_channels = 1;
104    
105     if (parc > 1)
106     {
107     char *opt, *save;
108     dlink_list *list;
109     int i, errors = 0;
110    
111     for (opt = strtoken(&save, parv[1], ","); opt != NULL;
112     opt = strtoken(&save, NULL, ","))
113     switch (*opt)
114     {
115     case '<': if ((i = atoi(opt + 1)) > 0)
116     lt->users_max = (unsigned int) i - 1;
117     else
118     errors = 1;
119     break;
120     case '>': if ((i = atoi(opt + 1)) >= 0)
121     lt->users_min = (unsigned int) i + 1;
122     else
123     errors = 1;
124     break;
125     case '-': break;
126     case 'C':
127     case 'c': switch (*++opt)
128     {
129     case '<': if ((i = atoi(opt + 1)) >= 0)
130     lt->created_max = (unsigned int) (CurrentTime
131     - 60 * i);
132     else
133     errors = 1;
134     break;
135     case '>': if ((i = atoi(opt + 1)) >= 0)
136     lt->created_min = (unsigned int) (CurrentTime
137     - 60 * i);
138     else
139     errors = 1;
140     break;
141     default: errors = 1;
142     }
143     break;
144     case 'T':
145     case 't': switch (*++opt)
146     {
147     case '<': if ((i = atoi(opt + 1)) >= 0)
148     lt->topicts_min = (unsigned int) (CurrentTime
149     - 60 * i);
150     else
151     errors = 1;
152     break;
153     case '>': if ((i = atoi(opt + 1)) >= 0)
154     lt->topicts_max = (unsigned int) (CurrentTime
155     - 60 * i);
156     else
157     errors = 1;
158     break;
159     default: errors = 1;
160     }
161     break;
162     default: if (*opt == '!')
163     {
164     list = &lt->hide_mask;
165     opt++;
166     }
167     else list = &lt->show_mask;
168    
169     if (has_wildcards(opt + !!IsChanPrefix(*opt)))
170     {
171     if (list == &lt->show_mask)
172     no_masked_channels = 0;
173     }
174     else if (!IsChanPrefix(*opt))
175     errors = 1;
176     if (!errors)
177     {
178     char *s;
179     DupString(s, opt);
180     dlinkAdd(s, make_dlink_node(), list);
181     }
182     }
183     if (errors)
184     {
185     free_list_task(lt, source_p);
186     sendto_one(source_p, form_str(ERR_LISTSYNTAX),
187 michael 896 me.name, source_p->name);
188 adx 30 return;
189     }
190     }
191    
192    
193 michael 885 dlinkAdd(source_p, make_dlink_node(), &listing_client_list);
194    
195 adx 30 sendto_one(source_p, form_str(RPL_LISTSTART),
196 michael 896 me.name, source_p->name);
197 adx 30 safe_list_channels(source_p, lt, no_masked_channels &&
198 michael 896 lt->show_mask.head != NULL);
199 adx 30 }
200    
201     /*
202     ** m_list
203     ** parv[0] = sender prefix
204     ** parv[1] = channel
205     */
206     static void
207     m_list(struct Client *client_p, struct Client *source_p,
208     int parc, char *parv[])
209     {
210     static time_t last_used = 0;
211    
212     if (((last_used + ConfigFileEntry.pace_wait) > CurrentTime))
213     {
214     sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,parv[0]);
215     return;
216     }
217    
218 michael 885 last_used = CurrentTime;
219 adx 30
220     do_list(source_p, parc, parv);
221     }
222    
223     /*
224     ** mo_list
225     ** parv[0] = sender prefix
226     ** parv[1] = channel
227     */
228     static void
229     mo_list(struct Client *client_p, struct Client *source_p,
230     int parc, char *parv[])
231     {
232     do_list(source_p, parc, parv);
233     }

Properties

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