| 21 |
|
* |
| 22 |
|
* $Id$ |
| 23 |
|
*/ |
| 24 |
+ |
|
| 25 |
|
#include "stdinc.h" |
| 26 |
< |
#include "tools.h" |
| 26 |
> |
#include "list.h" |
| 27 |
|
#include "common.h" |
| 28 |
|
#include "handlers.h" |
| 29 |
|
#include "client.h" |
| 34 |
|
#include "numeric.h" |
| 35 |
|
#include "s_serv.h" |
| 36 |
|
#include "send.h" |
| 36 |
– |
#include "list.h" |
| 37 |
|
#include "irc_string.h" |
| 38 |
|
#include "sprintf_irc.h" |
| 39 |
|
#include "s_conf.h" |
| 43 |
|
|
| 44 |
|
static time_t last_used = 0; |
| 45 |
|
|
| 46 |
< |
static void m_who(struct Client *, struct Client *, int, char **); |
| 47 |
< |
static void ms_who(struct Client *, struct Client *, int, char **); |
| 46 |
> |
static void m_who(struct Client *, struct Client *, int, char *[]); |
| 47 |
|
|
| 48 |
|
struct Message who_msgtab = { |
| 49 |
|
"WHO", 0, 0, 2, 0, MFLG_SLOW, 0, |
| 50 |
< |
{m_unregistered, m_who, ms_who, m_ignore, m_who, m_ignore} |
| 50 |
> |
{m_unregistered, m_who, m_ignore, m_ignore, m_who, m_ignore} |
| 51 |
|
}; |
| 52 |
|
|
| 54 |
– |
#ifndef STATIC_MODULES |
| 53 |
|
void |
| 54 |
|
_modinit(void) |
| 55 |
|
{ |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
const char *_version = "$Revision$"; |
| 68 |
– |
#endif |
| 66 |
|
|
| 67 |
< |
static void who_global(struct Client *source_p, char *mask, int server_oper); |
| 68 |
< |
static void do_who(struct Client *source_p, struct Client *target_p, |
| 69 |
< |
const char *chname, const char *op_flags); |
| 70 |
< |
static void do_who_on_channel(struct Client *source_p, struct Channel *chptr, |
| 71 |
< |
const char *chname, int member, int server_oper); |
| 67 |
> |
static void who_global(struct Client *, char *, int); |
| 68 |
> |
static void do_who(struct Client *, struct Client *, |
| 69 |
> |
const char *, const char *); |
| 70 |
> |
static void do_who_on_channel(struct Client *, struct Channel *, |
| 71 |
> |
const char *, int, int); |
| 72 |
|
|
| 73 |
|
/* |
| 74 |
|
** m_who |
| 85 |
|
dlink_node *lp; |
| 86 |
|
int server_oper = parc > 2 ? (*parv[2] == 'o') : 0; /* Show OPERS only */ |
| 87 |
|
struct Channel *chptr; |
| 91 |
– |
const char *from, *to; |
| 92 |
– |
|
| 93 |
– |
if (IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
| 94 |
– |
{ |
| 95 |
– |
from = me.id; |
| 96 |
– |
to = source_p->id; |
| 97 |
– |
} |
| 98 |
– |
else |
| 99 |
– |
{ |
| 100 |
– |
from = me.name; |
| 101 |
– |
to = source_p->name; |
| 102 |
– |
} |
| 88 |
|
|
| 89 |
|
/* See if mask is there, collapse it or return if not there */ |
| 90 |
< |
if (mask == NULL || !*mask) |
| 90 |
> |
if (EmptyString(mask)) |
| 91 |
|
{ |
| 92 |
|
who_global(source_p, mask, server_oper); |
| 93 |
|
sendto_one(source_p, form_str(RPL_ENDOFWHO), |
| 94 |
< |
from, to, "*"); |
| 94 |
> |
me.name, source_p->name, "*"); |
| 95 |
|
return; |
| 96 |
|
} |
| 97 |
|
|
| 108 |
|
server_oper); |
| 109 |
|
} |
| 110 |
|
|
| 111 |
< |
sendto_one(source_p, form_str(RPL_ENDOFWHO), from, to, "*"); |
| 111 |
> |
sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, source_p->name, "*"); |
| 112 |
|
return; |
| 113 |
|
} |
| 114 |
|
|
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
sendto_one(source_p, form_str(RPL_ENDOFWHO), |
| 128 |
< |
from, to, mask); |
| 128 |
> |
me.name, source_p->name, mask); |
| 129 |
|
return; |
| 130 |
|
} |
| 131 |
|
|
| 133 |
|
if (((target_p = find_client(mask)) != NULL) && |
| 134 |
|
IsClient(target_p) && (!server_oper || IsOper(target_p))) |
| 135 |
|
{ |
| 151 |
– |
if (IsServer(client_p)) |
| 152 |
– |
client_burst_if_needed(client_p,target_p); |
| 153 |
– |
|
| 136 |
|
DLINK_FOREACH(lp, target_p->channel.head) |
| 137 |
|
{ |
| 138 |
|
chptr = ((struct Membership *) lp->data)->chptr; |
| 147 |
|
do_who(source_p, target_p, NULL, ""); |
| 148 |
|
|
| 149 |
|
sendto_one(source_p, form_str(RPL_ENDOFWHO), |
| 150 |
< |
from, to, mask); |
| 150 |
> |
me.name, source_p->name, mask); |
| 151 |
|
return; |
| 152 |
|
} |
| 153 |
|
|
| 159 |
|
|
| 160 |
|
/* Wasn't a nick, wasn't a channel, wasn't a '*' so ... */ |
| 161 |
|
sendto_one(source_p, form_str(RPL_ENDOFWHO), |
| 162 |
< |
from, to, mask); |
| 162 |
> |
me.name, source_p->name, mask); |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
/* who_common_channel |
| 237 |
|
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
| 238 |
|
{ |
| 239 |
|
/* safe enough to give this on a local connect only */ |
| 240 |
< |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
| 259 |
< |
me.name, source_p->name); |
| 240 |
> |
sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name); |
| 241 |
|
return; |
| 242 |
|
} |
| 243 |
< |
else |
| 244 |
< |
last_used = CurrentTime; |
| 243 |
> |
|
| 244 |
> |
last_used = CurrentTime; |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
/* first, list all matching invisible clients on common channels */ |
| 333 |
|
const char *chname, const char *op_flags) |
| 334 |
|
{ |
| 335 |
|
char status[6]; |
| 355 |
– |
const char *from, *to; |
| 356 |
– |
|
| 357 |
– |
if (IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
| 358 |
– |
{ |
| 359 |
– |
from = me.id; |
| 360 |
– |
to = source_p->id; |
| 361 |
– |
} |
| 362 |
– |
else |
| 363 |
– |
{ |
| 364 |
– |
from = me.name; |
| 365 |
– |
to = source_p->name; |
| 366 |
– |
} |
| 336 |
|
|
| 337 |
|
if (IsOper(source_p)) |
| 338 |
< |
ircsprintf(status, "%c%s%s%s", |
| 370 |
< |
target_p->away ? 'G' : 'H', |
| 338 |
> |
ircsprintf(status, "%c%s%s%s", target_p->away ? 'G' : 'H', |
| 339 |
|
IsOper(target_p) ? "*" : "", IsCaptured(target_p) ? "#" : "", op_flags); |
| 340 |
|
else |
| 341 |
|
ircsprintf(status, "%c%s%s", target_p->away ? 'G' : 'H', |
| 343 |
|
|
| 344 |
|
if (ConfigServerHide.hide_servers) |
| 345 |
|
{ |
| 346 |
< |
sendto_one(source_p, form_str(RPL_WHOREPLY), from, to, |
| 346 |
> |
sendto_one(source_p, form_str(RPL_WHOREPLY), me.name, source_p->name, |
| 347 |
|
(chname) ? (chname) : "*", |
| 348 |
< |
target_p->username, target_p->host, |
| 348 |
> |
target_p->username, target_p->host, |
| 349 |
|
IsOper(source_p) ? target_p->servptr->name : "*", |
| 350 |
|
target_p->name, status, 0, target_p->info); |
| 351 |
|
} |
| 352 |
|
else |
| 353 |
|
{ |
| 354 |
< |
sendto_one(source_p, form_str(RPL_WHOREPLY), from, to, |
| 355 |
< |
(chname) ? (chname) : "*", |
| 388 |
< |
target_p->username, |
| 354 |
> |
sendto_one(source_p, form_str(RPL_WHOREPLY), me.name, source_p->name, |
| 355 |
> |
(chname) ? (chname) : "*", target_p->username, |
| 356 |
|
target_p->host, target_p->servptr->name, target_p->name, |
| 357 |
|
status, target_p->hopcount, target_p->info); |
| 358 |
|
} |
| 359 |
|
} |
| 393 |
– |
|
| 394 |
– |
/* |
| 395 |
– |
** ms_who() |
| 396 |
– |
** parv[0] = sender prefix |
| 397 |
– |
** parv[1] = nickname mask list |
| 398 |
– |
** parv[2] = additional selection flag, only 'o' for now. |
| 399 |
– |
*/ |
| 400 |
– |
static void |
| 401 |
– |
ms_who(struct Client *client_p, struct Client *source_p, |
| 402 |
– |
int parc, char *parv[]) |
| 403 |
– |
{ |
| 404 |
– |
/* If its running as a hub, and linked with lazy links |
| 405 |
– |
* then allow leaf to use normal client m_who() |
| 406 |
– |
* other wise, ignore it. |
| 407 |
– |
*/ |
| 408 |
– |
if (IsClient(source_p) && ServerInfo.hub && |
| 409 |
– |
IsCapable(client_p->from, CAP_LL)) |
| 410 |
– |
m_who(client_p, source_p, parc, parv); |
| 411 |
– |
} |