/[svn]/ircd-hybrid-8/modules/m_list.c
ViewVC logotype

Contents of /ircd-hybrid-8/modules/m_list.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1449 - (show annotations)
Tue Jun 26 18:17:03 2012 UTC (8 years ago) by michael
File MIME type: text/x-chdr
File size: 5081 byte(s)
- Merged m_away() and mo_away(). Also, /away is no longer time-limited.
- Same goes for /list

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
41
42 static void
43 do_list(struct Client *source_p, int parc, char *parv[])
44 {
45 struct ListTask *lt;
46 int no_masked_channels;
47
48 if (source_p->localClient->list_task != NULL)
49 {
50 free_list_task(source_p->localClient->list_task, source_p);
51 sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
52 return;
53 }
54
55 lt = MyMalloc(sizeof(struct ListTask));
56 lt->users_max = UINT_MAX;
57 lt->created_max = UINT_MAX;
58 lt->topicts_max = UINT_MAX;
59 source_p->localClient->list_task = lt;
60
61 no_masked_channels = 1;
62
63 if (parc > 1)
64 {
65 char *opt, *save = NULL;
66 dlink_list *list;
67 int i, errors = 0;
68
69 for (opt = strtoken(&save, parv[1], ","); opt != NULL;
70 opt = strtoken(&save, NULL, ","))
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': switch (*++opt)
86 {
87 case '<': if ((i = atoi(opt + 1)) >= 0)
88 lt->created_max = (unsigned int) (CurrentTime
89 - 60 * i);
90 else
91 errors = 1;
92 break;
93 case '>': if ((i = atoi(opt + 1)) >= 0)
94 lt->created_min = (unsigned int) (CurrentTime
95 - 60 * i);
96 else
97 errors = 1;
98 break;
99 default: errors = 1;
100 }
101 break;
102 case 'T':
103 case 't': switch (*++opt)
104 {
105 case '<': if ((i = atoi(opt + 1)) >= 0)
106 lt->topicts_min = (unsigned int) (CurrentTime
107 - 60 * i);
108 else
109 errors = 1;
110 break;
111 case '>': if ((i = atoi(opt + 1)) >= 0)
112 lt->topicts_max = (unsigned int) (CurrentTime
113 - 60 * i);
114 else
115 errors = 1;
116 break;
117 default: errors = 1;
118 }
119 break;
120 default: if (*opt == '!')
121 {
122 list = &lt->hide_mask;
123 opt++;
124 }
125 else list = &lt->show_mask;
126
127 if (has_wildcards(opt + !!IsChanPrefix(*opt)))
128 {
129 if (list == &lt->show_mask)
130 no_masked_channels = 0;
131 }
132 else if (!IsChanPrefix(*opt))
133 errors = 1;
134 if (!errors)
135 {
136 char *s;
137 DupString(s, opt);
138 dlinkAdd(s, make_dlink_node(), list);
139 }
140 }
141 if (errors)
142 {
143 free_list_task(lt, source_p);
144 sendto_one(source_p, form_str(ERR_LISTSYNTAX),
145 me.name, source_p->name);
146 return;
147 }
148 }
149
150
151 dlinkAdd(source_p, make_dlink_node(), &listing_client_list);
152
153 sendto_one(source_p, form_str(RPL_LISTSTART),
154 me.name, source_p->name);
155 safe_list_channels(source_p, lt, no_masked_channels &&
156 lt->show_mask.head != NULL);
157 }
158
159 /*
160 ** mo_list
161 ** parv[0] = sender prefix
162 ** parv[1] = channel
163 */
164 static void
165 m_list(struct Client *client_p, struct Client *source_p,
166 int parc, char *parv[])
167 {
168 do_list(source_p, parc, parv);
169 }
170
171 static struct Message list_msgtab = {
172 "LIST", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
173 { m_unregistered, m_list, m_ignore, m_ignore, m_list, m_ignore }
174 };
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 };

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28