ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_list.c
Revision: 3109
Committed: Thu Mar 6 19:25:12 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 5227 byte(s)
Log Message:
- Applied Adam's sendto_one_numeric() changes

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
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 michael 2820 /*! \file m_list.c
23     * \brief Includes required functions for processing the LIST command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28 michael 1011 #include "list.h"
29 adx 30 #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 michael 1309 #include "conf.h"
37 adx 30 #include "s_serv.h"
38     #include "send.h"
39     #include "parse.h"
40     #include "modules.h"
41     #include "s_user.h"
42 michael 1666 #include "memory.h"
43 adx 30
44    
45     static void
46     do_list(struct Client *source_p, int parc, char *parv[])
47     {
48 michael 1896 struct ListTask *lt = NULL;
49     int no_masked_channels = 1;
50 adx 30
51 michael 2904 if (source_p->localClient->list_task)
52 adx 30 {
53 michael 885 free_list_task(source_p->localClient->list_task, source_p);
54 michael 3109 sendto_one_numeric(source_p, &me, RPL_LISTEND);
55 michael 885 return;
56 adx 30 }
57    
58 michael 885 lt = MyMalloc(sizeof(struct ListTask));
59 adx 30 lt->users_max = UINT_MAX;
60     lt->created_max = UINT_MAX;
61     lt->topicts_max = UINT_MAX;
62 michael 885 source_p->localClient->list_task = lt;
63    
64 michael 1896 if (parc > 1 && !EmptyString(parv[1]))
65 adx 30 {
66 michael 968 char *opt, *save = NULL;
67 michael 1896 dlink_list *list = NULL;
68     int i = 0, errors = 0;
69 adx 30
70 michael 2904 for (opt = strtoken(&save, parv[1], ","); opt;
71     opt = strtoken(&save, NULL, ","))
72 michael 2224 {
73 adx 30 switch (*opt)
74     {
75 michael 2904 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 adx 30 case '-': break;
88     case 'C':
89 michael 2224 case 'c':
90     switch (*++opt)
91     {
92     case '<':
93     if ((i = atoi(opt + 1)) >= 0)
94 michael 2904 lt->created_max = (unsigned int)(CurrentTime - 60 * i);
95 michael 2224 else
96     errors = 1;
97     break;
98     case '>':
99     if ((i = atoi(opt + 1)) >= 0)
100 michael 2904 lt->created_min = (unsigned int)(CurrentTime - 60 * i);
101 michael 2224 else
102     errors = 1;
103     break;
104     default:
105     errors = 1;
106     }
107 adx 30
108 michael 2224 break;
109    
110     case 'T':
111     case 't':
112     switch (*++opt)
113     {
114     case '<':
115     if ((i = atoi(opt + 1)) >= 0)
116 michael 2904 lt->topicts_min = (unsigned int)(CurrentTime - 60 * i);
117 michael 2224 else
118     errors = 1;
119     break;
120     case '>':
121     if ((i = atoi(opt + 1)) >= 0)
122 michael 2904 lt->topicts_max = (unsigned int)(CurrentTime - 60 * i);
123 michael 2224 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 michael 2904
149 michael 2224 if (!errors)
150 michael 2904 dlinkAdd(xstrdup(opt), make_dlink_node(), list);
151 adx 30 }
152 michael 2224 }
153    
154 adx 30 if (errors)
155     {
156     free_list_task(lt, source_p);
157 michael 3109 sendto_one_numeric(source_p, &me, ERR_LISTSYNTAX);
158 adx 30 return;
159     }
160     }
161    
162 michael 885 dlinkAdd(source_p, make_dlink_node(), &listing_client_list);
163    
164 michael 3109 sendto_one_numeric(source_p, &me, RPL_LISTSTART);
165 adx 30 safe_list_channels(source_p, lt, no_masked_channels &&
166 michael 896 lt->show_mask.head != NULL);
167 adx 30 }
168    
169     /*
170     ** mo_list
171 michael 3096 ** parv[0] = command
172 adx 30 ** parv[1] = channel
173     */
174 michael 2820 static int
175 michael 1449 m_list(struct Client *client_p, struct Client *source_p,
176 adx 30 int parc, char *parv[])
177     {
178     do_list(source_p, parc, parv);
179 michael 2820 return 0;
180 adx 30 }
181 michael 1230
182 michael 2820 static struct Message list_msgtab =
183     {
184 michael 1230 "LIST", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
185 michael 1449 { m_unregistered, m_list, m_ignore, m_ignore, m_list, m_ignore }
186 michael 1230 };
187    
188     static void
189     module_init(void)
190     {
191     mod_add_cmd(&list_msgtab);
192     add_isupport("ELIST", "CMNTU", -1);
193     add_isupport("SAFELIST", NULL, -1);
194     }
195    
196     static void
197     module_exit(void)
198     {
199     mod_del_cmd(&list_msgtab);
200     delete_isupport("ELIST");
201     delete_isupport("SAFELIST");
202     }
203    
204 michael 2820 struct module module_entry =
205     {
206 michael 1230 .node = { NULL, NULL, NULL },
207     .name = NULL,
208     .version = "$Revision$",
209     .handle = NULL,
210     .modinit = module_init,
211     .modexit = module_exit,
212     .flags = 0
213     };

Properties

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