ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_list.c
Revision: 1028
Committed: Sun Nov 8 13:03:38 2009 UTC (16 years, 11 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/modules/m_list.c
File size: 5538 byte(s)
Log Message:
- move ircd-hybrid-7.2 to trunk

File Contents

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

Properties

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