ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_list.c
Revision: 2224
Committed: Wed Jun 12 18:10:43 2013 UTC (13 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 5382 byte(s)
Log Message:
- white-space commit/style corrections

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 "channel.h"
28 #include "channel_mode.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "irc_string.h"
32 #include "ircd.h"
33 #include "numeric.h"
34 #include "conf.h"
35 #include "s_serv.h"
36 #include "send.h"
37 #include "parse.h"
38 #include "modules.h"
39 #include "s_user.h"
40 #include "memory.h"
41
42
43 static void
44 do_list(struct Client *source_p, int parc, char *parv[])
45 {
46 struct ListTask *lt = NULL;
47 int no_masked_channels = 1;
48
49 if (source_p->localClient->list_task != NULL)
50 {
51 free_list_task(source_p->localClient->list_task, source_p);
52 sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
53 return;
54 }
55
56 lt = MyMalloc(sizeof(struct ListTask));
57 lt->users_max = UINT_MAX;
58 lt->created_max = UINT_MAX;
59 lt->topicts_max = UINT_MAX;
60 source_p->localClient->list_task = lt;
61
62 if (parc > 1 && !EmptyString(parv[1]))
63 {
64 char *opt, *save = NULL;
65 dlink_list *list = NULL;
66 int i = 0, errors = 0;
67
68 for (opt = strtoken(&save, parv[1], ","); opt != NULL;
69 opt = strtoken(&save, NULL, ","))
70 {
71 switch (*opt)
72 {
73 case '<': if ((i = atoi(opt + 1)) > 0)
74 lt->users_max = (unsigned int) i - 1;
75 else
76 errors = 1;
77 break;
78 case '>': if ((i = atoi(opt + 1)) >= 0)
79 lt->users_min = (unsigned int) i + 1;
80 else
81 errors = 1;
82 break;
83 case '-': break;
84 case 'C':
85 case 'c':
86 switch (*++opt)
87 {
88 case '<':
89 if ((i = atoi(opt + 1)) >= 0)
90 lt->created_max = (unsigned int) (CurrentTime - 60 * i);
91 else
92 errors = 1;
93 break;
94 case '>':
95 if ((i = atoi(opt + 1)) >= 0)
96 lt->created_min = (unsigned int) (CurrentTime - 60 * i);
97 else
98 errors = 1;
99 break;
100 default:
101 errors = 1;
102 }
103
104 break;
105
106 case 'T':
107 case 't':
108 switch (*++opt)
109 {
110 case '<':
111 if ((i = atoi(opt + 1)) >= 0)
112 lt->topicts_min = (unsigned int) (CurrentTime - 60 * i);
113 else
114 errors = 1;
115 break;
116 case '>':
117 if ((i = atoi(opt + 1)) >= 0)
118 lt->topicts_max = (unsigned int) (CurrentTime - 60 * i);
119 else
120 errors = 1;
121 break;
122 default:
123 errors = 1;
124 }
125
126 break;
127
128 default:
129 if (*opt == '!')
130 {
131 list = &lt->hide_mask;
132 opt++;
133 }
134 else
135 list = &lt->show_mask;
136
137 if (has_wildcards(opt + !!IsChanPrefix(*opt)))
138 {
139 if (list == &lt->show_mask)
140 no_masked_channels = 0;
141 }
142 else if (!IsChanPrefix(*opt))
143 errors = 1;
144 if (!errors)
145 {
146 char *s = xstrdup(opt);
147
148 dlinkAdd(s, make_dlink_node(), list);
149 }
150 }
151 }
152
153 if (errors)
154 {
155 free_list_task(lt, source_p);
156 sendto_one(source_p, form_str(ERR_LISTSYNTAX),
157 me.name, source_p->name);
158 return;
159 }
160 }
161
162 dlinkAdd(source_p, make_dlink_node(), &listing_client_list);
163
164 sendto_one(source_p, form_str(RPL_LISTSTART),
165 me.name, source_p->name);
166 safe_list_channels(source_p, lt, no_masked_channels &&
167 lt->show_mask.head != NULL);
168 }
169
170 /*
171 ** mo_list
172 ** parv[0] = sender prefix
173 ** parv[1] = channel
174 */
175 static void
176 m_list(struct Client *client_p, struct Client *source_p,
177 int parc, char *parv[])
178 {
179 do_list(source_p, parc, parv);
180 }
181
182 static struct Message list_msgtab = {
183 "LIST", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
184 { m_unregistered, m_list, m_ignore, m_ignore, m_list, m_ignore }
185 };
186
187 static void
188 module_init(void)
189 {
190 mod_add_cmd(&list_msgtab);
191 add_isupport("ELIST", "CMNTU", -1);
192 add_isupport("SAFELIST", NULL, -1);
193 }
194
195 static void
196 module_exit(void)
197 {
198 mod_del_cmd(&list_msgtab);
199 delete_isupport("ELIST");
200 delete_isupport("SAFELIST");
201 }
202
203 struct module module_entry = {
204 .node = { NULL, NULL, NULL },
205 .name = NULL,
206 .version = "$Revision$",
207 .handle = NULL,
208 .modinit = module_init,
209 .modexit = module_exit,
210 .flags = 0
211 };

Properties

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