ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.1.x/modules/m_list.c
Revision: 2905
Committed: Wed Jan 22 20:44:34 2014 UTC (10 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 5329 byte(s)
Log Message:
- m_list.c: style cleanups

File Contents

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

Properties

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