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