| 23 |
|
*/ |
| 24 |
|
|
| 25 |
|
#include "stdinc.h" |
| 26 |
< |
#include "tools.h" |
| 27 |
< |
#include "handlers.h" |
| 26 |
> |
#include "list.h" |
| 27 |
|
#include "channel.h" |
| 28 |
|
#include "channel_mode.h" |
| 29 |
|
#include "client.h" |
| 31 |
|
#include "irc_string.h" |
| 32 |
|
#include "ircd.h" |
| 33 |
|
#include "numeric.h" |
| 34 |
< |
#include "s_conf.h" |
| 34 |
> |
#include "conf.h" |
| 35 |
|
#include "s_serv.h" |
| 36 |
|
#include "send.h" |
| 38 |
– |
#include "list.h" |
| 39 |
– |
#include "msg.h" |
| 37 |
|
#include "parse.h" |
| 38 |
|
#include "modules.h" |
| 39 |
|
#include "s_user.h" |
| 40 |
+ |
#include "memory.h" |
| 41 |
|
|
| 44 |
– |
static void m_list(struct Client *, struct Client *, int, char **); |
| 45 |
– |
static void ms_list(struct Client *, struct Client *, int, char **); |
| 46 |
– |
static void mo_list(struct Client *, struct Client *, int, char **); |
| 47 |
– |
|
| 48 |
– |
struct Message list_msgtab = { |
| 49 |
– |
"LIST", 0, 0, 0, 0, MFLG_SLOW, 0, |
| 50 |
– |
{m_unregistered, m_list, ms_list, m_ignore, mo_list, m_ignore} |
| 51 |
– |
}; |
| 52 |
– |
|
| 53 |
– |
#ifndef STATIC_MODULES |
| 54 |
– |
void |
| 55 |
– |
_modinit(void) |
| 56 |
– |
{ |
| 57 |
– |
mod_add_cmd(&list_msgtab); |
| 58 |
– |
add_isupport("ELIST", "CMNTU", -1); |
| 59 |
– |
add_isupport("SAFELIST", NULL, -1); |
| 60 |
– |
} |
| 61 |
– |
|
| 62 |
– |
void |
| 63 |
– |
_moddeinit(void) |
| 64 |
– |
{ |
| 65 |
– |
mod_del_cmd(&list_msgtab); |
| 66 |
– |
delete_isupport("ELIST"); |
| 67 |
– |
delete_isupport("SAFELIST"); |
| 68 |
– |
} |
| 69 |
– |
|
| 70 |
– |
const char *_version = "$Revision$"; |
| 71 |
– |
#endif |
| 72 |
– |
|
| 73 |
– |
static int |
| 74 |
– |
has_wildcards(const char *s) |
| 75 |
– |
{ |
| 76 |
– |
char c; |
| 77 |
– |
|
| 78 |
– |
while ((c = *s++)) |
| 79 |
– |
if (IsMWildChar(c)) |
| 80 |
– |
return 1; |
| 81 |
– |
|
| 82 |
– |
return 0; |
| 83 |
– |
} |
| 42 |
|
|
| 43 |
|
static void |
| 44 |
|
do_list(struct Client *source_p, int parc, char *parv[]) |
| 46 |
|
struct ListTask *lt; |
| 47 |
|
int no_masked_channels; |
| 48 |
|
|
| 49 |
< |
if (MyConnect(source_p)) |
| 49 |
> |
if (source_p->localClient->list_task != NULL) |
| 50 |
|
{ |
| 51 |
< |
if (source_p->localClient->list_task != NULL) |
| 52 |
< |
{ |
| 53 |
< |
free_list_task(source_p->localClient->list_task, source_p); |
| 96 |
< |
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name); |
| 97 |
< |
return; |
| 98 |
< |
} |
| 51 |
> |
free_list_task(source_p->localClient->list_task, source_p); |
| 52 |
> |
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name); |
| 53 |
> |
return; |
| 54 |
|
} |
| 55 |
|
|
| 56 |
< |
lt = (struct ListTask *) MyMalloc(sizeof(struct ListTask)); |
| 56 |
> |
lt = MyMalloc(sizeof(struct ListTask)); |
| 57 |
|
lt->users_max = UINT_MAX; |
| 58 |
|
lt->created_max = UINT_MAX; |
| 59 |
|
lt->topicts_max = UINT_MAX; |
| 60 |
< |
if (MyConnect(source_p)) |
| 61 |
< |
source_p->localClient->list_task = lt; |
| 60 |
> |
source_p->localClient->list_task = lt; |
| 61 |
> |
|
| 62 |
|
no_masked_channels = 1; |
| 63 |
|
|
| 64 |
|
if (parc > 1) |
| 65 |
|
{ |
| 66 |
< |
char *opt, *save; |
| 66 |
> |
char *opt, *save = NULL; |
| 67 |
|
dlink_list *list; |
| 68 |
|
int i, errors = 0; |
| 69 |
|
|
| 72 |
|
switch (*opt) |
| 73 |
|
{ |
| 74 |
|
case '<': if ((i = atoi(opt + 1)) > 0) |
| 75 |
< |
lt->users_max = (unsigned int) i - 1; |
| 75 |
> |
lt->users_max = (unsigned int) i - 1; |
| 76 |
|
else |
| 77 |
< |
errors = 1; |
| 78 |
< |
break; |
| 77 |
> |
errors = 1; |
| 78 |
> |
break; |
| 79 |
|
case '>': if ((i = atoi(opt + 1)) >= 0) |
| 80 |
< |
lt->users_min = (unsigned int) i + 1; |
| 81 |
< |
else |
| 82 |
< |
errors = 1; |
| 83 |
< |
break; |
| 80 |
> |
lt->users_min = (unsigned int) i + 1; |
| 81 |
> |
else |
| 82 |
> |
errors = 1; |
| 83 |
> |
break; |
| 84 |
|
case '-': break; |
| 85 |
|
case 'C': |
| 86 |
< |
case 'c': switch (*++opt) |
| 87 |
< |
{ |
| 86 |
> |
case 'c': switch (*++opt) |
| 87 |
> |
{ |
| 88 |
|
case '<': if ((i = atoi(opt + 1)) >= 0) |
| 89 |
|
lt->created_max = (unsigned int) (CurrentTime |
| 90 |
|
- 60 * i); |
| 134 |
|
errors = 1; |
| 135 |
|
if (!errors) |
| 136 |
|
{ |
| 137 |
< |
char *s; |
| 183 |
< |
DupString(s, opt); |
| 137 |
> |
char *s = xstrdup(opt); |
| 138 |
|
dlinkAdd(s, make_dlink_node(), list); |
| 139 |
|
} |
| 140 |
|
} |
| 142 |
|
{ |
| 143 |
|
free_list_task(lt, source_p); |
| 144 |
|
sendto_one(source_p, form_str(ERR_LISTSYNTAX), |
| 145 |
< |
MyConnect(source_p) ? me.name : ID(&me), |
| 192 |
< |
MyConnect(source_p) ? source_p->name : ID(source_p)); |
| 145 |
> |
me.name, source_p->name); |
| 146 |
|
return; |
| 147 |
|
} |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
|
| 151 |
< |
if (MyConnect(source_p)) |
| 152 |
< |
dlinkAdd(source_p, make_dlink_node(), &listing_client_list); |
| 151 |
> |
dlinkAdd(source_p, make_dlink_node(), &listing_client_list); |
| 152 |
> |
|
| 153 |
|
sendto_one(source_p, form_str(RPL_LISTSTART), |
| 154 |
< |
MyConnect(source_p) ? me.name : ID(&me), |
| 202 |
< |
MyConnect(source_p) ? source_p->name : ID(source_p)); |
| 154 |
> |
me.name, source_p->name); |
| 155 |
|
safe_list_channels(source_p, lt, no_masked_channels && |
| 156 |
< |
lt->show_mask.head != NULL, !MyConnect(source_p)); |
| 156 |
> |
lt->show_mask.head != NULL); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
/* |
| 160 |
< |
** m_list |
| 160 |
> |
** mo_list |
| 161 |
|
** parv[0] = sender prefix |
| 162 |
|
** parv[1] = channel |
| 163 |
|
*/ |
| 164 |
|
static void |
| 165 |
< |
m_list(struct Client *client_p, struct Client *source_p, |
| 166 |
< |
int parc, char *parv[]) |
| 165 |
> |
m_list(struct Client *client_p, struct Client *source_p, |
| 166 |
> |
int parc, char *parv[]) |
| 167 |
|
{ |
| 216 |
– |
static time_t last_used = 0; |
| 217 |
– |
|
| 218 |
– |
/* If not a LazyLink connection, see if its still paced */ |
| 219 |
– |
/* If we're forwarding this to uplinks.. it should be paced due to the |
| 220 |
– |
* traffic involved in /list.. -- fl_ */ |
| 221 |
– |
if (((last_used + ConfigFileEntry.pace_wait) > CurrentTime)) |
| 222 |
– |
{ |
| 223 |
– |
sendto_one(source_p,form_str(RPL_LOAD2HI),me.name,parv[0]); |
| 224 |
– |
return; |
| 225 |
– |
} |
| 226 |
– |
else |
| 227 |
– |
last_used = CurrentTime; |
| 228 |
– |
|
| 229 |
– |
/* If its a LazyLinks connection, let uplink handle the list */ |
| 230 |
– |
if (uplink && IsCapable(uplink, CAP_LL)) |
| 231 |
– |
{ |
| 232 |
– |
if (parc < 2) |
| 233 |
– |
sendto_one(uplink, ":%s LIST", source_p->name); |
| 234 |
– |
else |
| 235 |
– |
sendto_one(uplink, ":%s LIST %s", source_p->name, parv[1]); |
| 236 |
– |
return; |
| 237 |
– |
} |
| 238 |
– |
|
| 168 |
|
do_list(source_p, parc, parv); |
| 169 |
|
} |
| 170 |
|
|
| 171 |
< |
/* |
| 172 |
< |
** mo_list |
| 173 |
< |
** parv[0] = sender prefix |
| 174 |
< |
** parv[1] = channel |
| 175 |
< |
*/ |
| 171 |
> |
static struct Message list_msgtab = { |
| 172 |
> |
"LIST", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 173 |
> |
{ m_unregistered, m_list, m_ignore, m_ignore, m_list, m_ignore } |
| 174 |
> |
}; |
| 175 |
> |
|
| 176 |
|
static void |
| 177 |
< |
mo_list(struct Client *client_p, struct Client *source_p, |
| 249 |
< |
int parc, char *parv[]) |
| 177 |
> |
module_init(void) |
| 178 |
|
{ |
| 179 |
< |
/* If its a LazyLinks connection, let uplink handle the list |
| 180 |
< |
* even for opers! |
| 181 |
< |
*/ |
| 254 |
< |
|
| 255 |
< |
if (uplink && IsCapable(uplink, CAP_LL)) |
| 256 |
< |
{ |
| 257 |
< |
if (parc < 2) |
| 258 |
< |
sendto_one(uplink, ":%s LIST", source_p->name); |
| 259 |
< |
else |
| 260 |
< |
sendto_one(uplink, ":%s LIST %s", source_p->name, parv[1]); |
| 261 |
< |
return; |
| 262 |
< |
} |
| 263 |
< |
|
| 264 |
< |
do_list(source_p, parc, parv); |
| 179 |
> |
mod_add_cmd(&list_msgtab); |
| 180 |
> |
add_isupport("ELIST", "CMNTU", -1); |
| 181 |
> |
add_isupport("SAFELIST", NULL, -1); |
| 182 |
|
} |
| 183 |
|
|
| 267 |
– |
/* |
| 268 |
– |
** ms_list |
| 269 |
– |
** parv[0] = sender prefix |
| 270 |
– |
** parv[1] = channel |
| 271 |
– |
*/ |
| 184 |
|
static void |
| 185 |
< |
ms_list(struct Client *client_p, struct Client *source_p, |
| 274 |
< |
int parc, char *parv[]) |
| 185 |
> |
module_exit(void) |
| 186 |
|
{ |
| 187 |
< |
/* Only allow remote list if LazyLink request */ |
| 188 |
< |
if (ServerInfo.hub) |
| 189 |
< |
{ |
| 279 |
< |
if (!IsCapable(client_p->from, CAP_LL) && !MyConnect(source_p)) |
| 280 |
< |
return; |
| 281 |
< |
|
| 282 |
< |
do_list(source_p, parc, parv); |
| 283 |
< |
} |
| 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 |
+ |
}; |