ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_list.c
Revision: 8673
Committed: Sat Nov 24 14:33:53 2018 UTC (7 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 5638 byte(s)
Log Message:
- m_list.c: rename 'errors' variable

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2018 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_list.c
23 * \brief Includes required functions for processing the LIST command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "irc_string.h"
32 #include "ircd.h"
33 #include "numeric.h"
34 #include "send.h"
35 #include "parse.h"
36 #include "modules.h"
37 #include "user.h"
38 #include "memory.h"
39 #include "isupport.h"
40
41
42 static void
43 do_list(struct Client *source_p, char *arg)
44 {
45 bool no_masked_channels = true;
46
47 if (source_p->connection->list_task)
48 {
49 free_list_task(source_p);
50 sendto_one_numeric(source_p, &me, RPL_LISTEND);
51 return;
52 }
53
54 struct ListTask *lt = xcalloc(sizeof(*lt));
55 lt->users_max = UINT_MAX;
56 lt->created_max = UINT_MAX;
57 lt->topicts_max = UINT_MAX;
58 source_p->connection->list_task = lt;
59 dlinkAdd(source_p, &lt->node, &listing_client_list);
60
61 if (!EmptyString(arg))
62 {
63 dlink_list *list = NULL;
64 char *opt, *save = NULL;
65 bool error = false;
66 int i = 0;
67
68 for (opt = strtok_r(arg, ",", &save); opt;
69 opt = strtok_r(NULL, ",", &save))
70 {
71 switch (*opt)
72 {
73 case '<':
74 if ((i = atoi(opt + 1)) > 0)
75 lt->users_max = (unsigned int)i - 1;
76 else
77 error = true;
78 break;
79 case '>':
80 if ((i = atoi(opt + 1)) >= 0)
81 lt->users_min = (unsigned int)i + 1;
82 else
83 error = true;
84 break;
85 case 'C':
86 case 'c':
87 switch (*++opt)
88 {
89 case '<':
90 if ((i = atoi(opt + 1)) >= 0)
91 lt->created_max = (unsigned int)(CurrentTime - 60 * i);
92 else
93 error = true;
94 break;
95 case '>':
96 if ((i = atoi(opt + 1)) >= 0)
97 lt->created_min = (unsigned int)(CurrentTime - 60 * i);
98 else
99 error = true;
100 break;
101 default:
102 error = true;
103 }
104
105 break;
106
107 case 'T':
108 case 't':
109 switch (*++opt)
110 {
111 case '<':
112 if ((i = atoi(opt + 1)) >= 0)
113 lt->topicts_min = (unsigned int)(CurrentTime - 60 * i);
114 else
115 error = true;
116 break;
117 case '>':
118 if ((i = atoi(opt + 1)) >= 0)
119 lt->topicts_max = (unsigned int)(CurrentTime - 60 * i);
120 else
121 error = true;
122 break;
123 case ':':
124 if (strlcpy(lt->topic, opt + 1, sizeof(lt->topic)) == 0)
125 error = true;
126 break;
127 default:
128 error = true;
129 }
130
131 break;
132
133 default:
134 if (*opt == '!')
135 {
136 list = &lt->hide_mask;
137 opt++;
138 }
139 else
140 list = &lt->show_mask;
141
142 if (has_wildcards(opt + !!IsChanPrefix(*opt)))
143 {
144 if (list == &lt->show_mask)
145 no_masked_channels = false;
146 }
147 else if (!IsChanPrefix(*opt))
148 error = true;
149
150 if (error == false)
151 dlinkAdd(xstrdup(opt), make_dlink_node(), list);
152 }
153 }
154
155 if (error == true)
156 {
157 free_list_task(source_p);
158 sendto_one_numeric(source_p, &me, ERR_LISTSYNTAX);
159 return;
160 }
161 }
162
163 sendto_one_numeric(source_p, &me, RPL_LISTSTART);
164 safe_list_channels(source_p, no_masked_channels && lt->show_mask.head != NULL);
165 }
166
167 /*! \brief LIST command handler
168 *
169 * \param source_p Pointer to allocated Client struct from which the message
170 * originally comes from. This can be a local or remote client.
171 * \param parc Integer holding the number of supplied arguments.
172 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
173 * pointers.
174 * \note Valid arguments for this command are:
175 * - parv[0] = command
176 * - parv[1] = channel name/list options
177 */
178 static int
179 m_list(struct Client *source_p, int parc, char *parv[])
180 {
181 do_list(source_p, parv[1]);
182 return 0;
183 }
184
185 static struct Message list_msgtab =
186 {
187 .cmd = "LIST",
188 .args_max = MAXPARA,
189 .handlers[UNREGISTERED_HANDLER] = m_unregistered,
190 .handlers[CLIENT_HANDLER] = m_list,
191 .handlers[SERVER_HANDLER] = m_ignore,
192 .handlers[ENCAP_HANDLER] = m_ignore,
193 .handlers[OPER_HANDLER] = m_list
194 };
195
196 static void
197 module_init(void)
198 {
199 mod_add_cmd(&list_msgtab);
200 isupport_add("ELIST", "CMNTU", -1);
201 isupport_add("SAFELIST", NULL, -1);
202 }
203
204 static void
205 module_exit(void)
206 {
207 mod_del_cmd(&list_msgtab);
208 isupport_delete("ELIST");
209 isupport_delete("SAFELIST");
210 }
211
212 struct module module_entry =
213 {
214 .version = "$Revision$",
215 .modinit = module_init,
216 .modexit = module_exit,
217 };

Properties

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