ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_list.c
Revision: 1592
Committed: Sat Oct 27 21:02:32 2012 UTC (12 years, 10 months ago) by michael
Content type: text/x-csrc
File size: 5081 byte(s)
Log Message:
- Second time's the charm? Moving svnroot/ircd-hybrid-8 to
  svnroot/ircd-hybrid/trunk

File Contents

# User Rev Content
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    
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 michael 885 if (source_p->localClient->list_task != NULL)
49 adx 30 {
50 michael 885 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 adx 30 }
54    
55 michael 885 lt = MyMalloc(sizeof(struct ListTask));
56 adx 30 lt->users_max = UINT_MAX;
57     lt->created_max = UINT_MAX;
58     lt->topicts_max = UINT_MAX;
59 michael 885 source_p->localClient->list_task = lt;
60    
61 adx 30 no_masked_channels = 1;
62    
63     if (parc > 1)
64     {
65 michael 968 char *opt, *save = NULL;
66 adx 30 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 michael 1121 lt->users_max = (unsigned int) i - 1;
75 adx 30 else
76 michael 1121 errors = 1;
77     break;
78 adx 30 case '>': if ((i = atoi(opt + 1)) >= 0)
79 michael 1121 lt->users_min = (unsigned int) i + 1;
80     else
81     errors = 1;
82     break;
83 adx 30 case '-': break;
84     case 'C':
85 michael 1121 case 'c': switch (*++opt)
86     {
87 adx 30 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 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 adx 30 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     };

Properties

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