2 * ircd-ratbox: A slightly useful ircd.
3 * m_olist.c: List channels. olist is an oper only command
4 * that shows channels regardless of modes. This
5 * is kinda evil, and might be morally wrong, but
6 * somebody will likely need it.
8 * Copyright (C) 2002 by the past and present ircd coders, and others.
9 * Copyright (C) 2004 ircd-ratbox Development Team
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 * $Id: m_olist.c 6 2005-09-10 01:02:21Z nenolod $
38 #include "irc_string.h"
43 #include "s_newconf.h"
44 #include "sprintf_irc.h"
46 static int mo_olist(struct Client
*, struct Client
*, int parc
, const char *parv
[]);
48 #ifndef STATIC_MODULES
50 struct Message olist_msgtab
= {
51 "OLIST", 0, 0, 0, MFLG_SLOW
,
52 {mg_unreg
, mg_not_oper
, mg_ignore
, mg_ignore
, mg_ignore
, {mo_olist
, 1}}
55 mapi_clist_av1 olist_clist
[] = { &olist_msgtab
, NULL
};
57 DECLARE_MODULE_AV1(okick
, NULL
, NULL
, olist_clist
, NULL
, NULL
, "$Revision: 6 $");
61 static void list_all_channels(struct Client
*source_p
);
62 static void list_named_channel(struct Client
*source_p
, const char *name
);
66 ** parv[0] = sender prefix
70 mo_olist(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
72 if(IsOperSpy(source_p
))
74 /* If no arg, do all channels *whee*, else just one channel */
75 if(parc
< 2 || EmptyString(parv
[1]))
77 report_operspy(source_p
, "LIST", NULL
);
78 list_all_channels(source_p
);
82 report_operspy(source_p
, "LIST", parv
[1]);
83 list_named_channel(source_p
, parv
[1]);
87 sendto_one(source_p
, form_str(RPL_LISTEND
), me
.name
, source_p
->name
);
94 * inputs - pointer to client requesting list
96 * side effects - list all channels to source_p
99 list_all_channels(struct Client
*source_p
)
101 struct Channel
*chptr
;
103 sendto_one(source_p
, form_str(RPL_LISTSTART
), me
.name
, source_p
->name
);
105 RB_DLINK_FOREACH(ptr
, global_channel_list
.head
)
109 sendto_one(source_p
, form_str(RPL_LIST
),
110 me
.name
, source_p
->name
, chptr
->chname
,
111 rb_dlink_list_length(&chptr
->members
),
112 chptr
->topic
== NULL
? "" : chptr
->topic
);
120 * inputs - pointer to client requesting list
122 * side effects - list all channels to source_p
125 list_named_channel(struct Client
*source_p
, const char *name
)
127 struct Channel
*chptr
;
129 char *n
= LOCAL_COPY(name
);
131 sendto_one(source_p
, form_str(RPL_LISTSTART
), me
.name
, source_p
->name
);
133 if((p
= strchr(n
, ',')))
138 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
139 form_str(ERR_NOSUCHCHANNEL
), n
);
143 if((chptr
= find_channel(n
)) == NULL
)
144 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
145 form_str(ERR_NOSUCHCHANNEL
), n
);
147 sendto_one(source_p
, form_str(RPL_LIST
), me
.name
, source_p
->name
,
148 chptr
->chname
, rb_dlink_list_length(&chptr
->members
),
149 chptr
->topic
? chptr
->topic
: "");