| 31 |
|
#include "sprintf_irc.h" |
| 32 |
|
#include "ircd.h" |
| 33 |
|
#include "numeric.h" |
| 34 |
< |
#include "s_log.h" |
| 34 |
> |
#include "log.h" |
| 35 |
|
#include "send.h" |
| 36 |
< |
#include "s_conf.h" |
| 36 |
> |
#include "conf.h" |
| 37 |
|
#include "memory.h" |
| 38 |
|
#include "s_user.h" |
| 39 |
|
#include "s_serv.h" |
| 102 |
|
* NOTE: parse() should not be called recursively by other functions! |
| 103 |
|
*/ |
| 104 |
|
static char *sender; |
| 105 |
< |
static char *para[MAXPARA + 1]; |
| 105 |
> |
static char *para[MAXPARA + 2]; /* <prefix> + <params> + NULL */ |
| 106 |
|
static char buffer[1024]; |
| 107 |
|
|
| 108 |
|
static int cancel_clients(struct Client *, struct Client *, char *); |
| 109 |
|
static void remove_unknown(struct Client *, char *, char *); |
| 110 |
|
static void handle_numeric(char[], struct Client *, struct Client *, int, char *[]); |
| 111 |
|
static void handle_command(struct Message *, struct Client *, struct Client *, unsigned int, char *[]); |
| 112 |
– |
static void recurse_report_messages(struct Client *, const struct MessageTree *); |
| 113 |
– |
static void add_msg_element(struct MessageTree *, struct Message *, const char *); |
| 114 |
– |
static void del_msg_element(struct MessageTree *, const char *); |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
/* |
| 121 |
|
{ |
| 122 |
|
struct Client *from = client_p; |
| 123 |
|
struct Message *msg_ptr = NULL; |
| 124 |
< |
char *ch; |
| 125 |
< |
char *s; |
| 126 |
< |
char *numeric = 0; |
| 124 |
> |
char *ch = NULL; |
| 125 |
> |
char *s = NULL; |
| 126 |
> |
char *numeric = NULL; |
| 127 |
|
unsigned int parc = 0; |
| 128 |
|
unsigned int paramcount; |
| 132 |
– |
int mpara = 0; |
| 129 |
|
|
| 130 |
|
if (IsDefunct(client_p)) |
| 131 |
|
return; |
| 133 |
|
assert(client_p->localClient->fd.flags.open); |
| 134 |
|
assert((bufend - pbuffer) < 512); |
| 135 |
|
|
| 136 |
< |
for (ch = pbuffer; *ch == ' '; ch++) /* skip spaces */ |
| 136 |
> |
for (ch = pbuffer; *ch == ' '; ++ch) /* skip spaces */ |
| 137 |
|
/* null statement */ ; |
| 138 |
|
|
| 139 |
|
if (*ch == ':') |
| 152 |
|
|
| 153 |
|
if (*sender && IsServer(client_p)) |
| 154 |
|
{ |
| 159 |
– |
/* |
| 160 |
– |
* XXX it could be useful to know which of these occurs most frequently. |
| 161 |
– |
* the ID check should always come first, though, since it is so easy. |
| 162 |
– |
*/ |
| 155 |
|
if ((from = find_person(client_p, sender)) == NULL) |
| 156 |
|
from = hash_find_server(sender); |
| 157 |
|
|
| 222 |
|
* Hm, when is the buffer empty -- if a command |
| 223 |
|
* code has been found ?? -Armin |
| 224 |
|
*/ |
| 225 |
< |
if (pbuffer[0] != '\0') |
| 225 |
> |
if (*pbuffer != '\0') |
| 226 |
|
{ |
| 227 |
|
if (IsClient(from)) |
| 228 |
|
sendto_one(from, form_str(ERR_UNKNOWNCOMMAND), |
| 236 |
|
assert(msg_ptr->cmd != NULL); |
| 237 |
|
|
| 238 |
|
paramcount = msg_ptr->args_max; |
| 247 |
– |
mpara = msg_ptr->args_min; |
| 248 |
– |
|
| 239 |
|
ii = bufend - ((s) ? s : ch); |
| 240 |
|
msg_ptr->bytes += ii; |
| 241 |
|
} |
| 301 |
|
*/ |
| 302 |
|
static void |
| 303 |
|
handle_command(struct Message *mptr, struct Client *client_p, |
| 304 |
< |
struct Client *from, unsigned int i, char *hpara[MAXPARA]) |
| 304 |
> |
struct Client *from, unsigned int i, char *hpara[]) |
| 305 |
|
{ |
| 306 |
|
MessageHandler handler = 0; |
| 307 |
|
|
| 338 |
|
"Dropping server %s due to (invalid) command '%s' " |
| 339 |
|
"with only %d arguments (expecting %d).", |
| 340 |
|
client_p->name, mptr->cmd, i, mptr->args_min); |
| 341 |
< |
ilog(L_CRIT, "Insufficient parameters (%d) for command '%s' from %s.", |
| 341 |
> |
ilog(LOG_TYPE_IRCD, "Insufficient parameters (%d) for command '%s' from %s.", |
| 342 |
|
i, mptr->cmd, client_p->name); |
| 343 |
|
exit_client(client_p, client_p, |
| 344 |
|
"Not enough arguments to server command."); |
| 348 |
|
(*handler)(client_p, from, i, hpara); |
| 349 |
|
} |
| 350 |
|
|
| 361 |
– |
/* clear_tree_parse() |
| 362 |
– |
* |
| 363 |
– |
* inputs - NONE |
| 364 |
– |
* output - NONE |
| 365 |
– |
* side effects - MUST MUST be called at startup ONCE before |
| 366 |
– |
* any other keyword routine is used. |
| 367 |
– |
*/ |
| 368 |
– |
void |
| 369 |
– |
clear_tree_parse(void) |
| 370 |
– |
{ |
| 371 |
– |
memset(&msg_tree, 0, sizeof(msg_tree)); |
| 372 |
– |
} |
| 373 |
– |
|
| 351 |
|
/* add_msg_element() |
| 352 |
|
* |
| 353 |
|
* inputs - pointer to MessageTree |
| 427 |
|
{ |
| 428 |
|
struct MessageTree *ntree_p; |
| 429 |
|
|
| 430 |
< |
/* In case this is called for a nonexistent command |
| 430 |
> |
/* |
| 431 |
> |
* In case this is called for a nonexistent command |
| 432 |
|
* check that there is a msg pointer here, else links-- goes -ve |
| 433 |
|
* -db |
| 434 |
|
*/ |
| 457 |
– |
|
| 435 |
|
if ((*cmd == '\0') && (mtree_p->msg != NULL)) |
| 436 |
|
{ |
| 437 |
|
mtree_p->msg = NULL; |
| 484 |
|
void |
| 485 |
|
mod_add_cmd(struct Message *msg) |
| 486 |
|
{ |
| 487 |
< |
struct Message *found_msg; |
| 511 |
< |
|
| 512 |
< |
if (msg == NULL) |
| 513 |
< |
return; |
| 514 |
< |
|
| 515 |
< |
/* someone loaded a module with a bad messagetab */ |
| 516 |
< |
assert(msg->cmd != NULL); |
| 487 |
> |
assert(msg && msg->cmd); |
| 488 |
|
|
| 489 |
|
/* command already added? */ |
| 490 |
< |
if ((found_msg = msg_tree_parse(msg->cmd, &msg_tree)) != NULL) |
| 490 |
> |
if (msg_tree_parse(msg->cmd, &msg_tree)) |
| 491 |
|
return; |
| 492 |
|
|
| 493 |
|
add_msg_element(&msg_tree, msg, msg->cmd); |
| 503 |
|
void |
| 504 |
|
mod_del_cmd(struct Message *msg) |
| 505 |
|
{ |
| 506 |
< |
assert(msg != NULL); |
| 536 |
< |
|
| 537 |
< |
if (msg == NULL) |
| 538 |
< |
return; |
| 506 |
> |
assert(msg && msg->cmd); |
| 507 |
|
|
| 508 |
|
del_msg_element(&msg_tree, msg->cmd); |
| 509 |
|
} |
| 520 |
|
return msg_tree_parse(cmd, &msg_tree); |
| 521 |
|
} |
| 522 |
|
|
| 523 |
+ |
static void |
| 524 |
+ |
recurse_report_messages(struct Client *source_p, const struct MessageTree *mtree) |
| 525 |
+ |
{ |
| 526 |
+ |
unsigned int i; |
| 527 |
+ |
|
| 528 |
+ |
if (mtree->msg != NULL) |
| 529 |
+ |
sendto_one(source_p, form_str(RPL_STATSCOMMANDS), |
| 530 |
+ |
me.name, source_p->name, mtree->msg->cmd, |
| 531 |
+ |
mtree->msg->count, mtree->msg->bytes, |
| 532 |
+ |
mtree->msg->rcount); |
| 533 |
+ |
|
| 534 |
+ |
for (i = 0; i < MAXPTRLEN; ++i) |
| 535 |
+ |
if (mtree->pointers[i] != NULL) |
| 536 |
+ |
recurse_report_messages(source_p, mtree->pointers[i]); |
| 537 |
+ |
} |
| 538 |
+ |
|
| 539 |
|
/* report_messages() |
| 540 |
|
* |
| 541 |
|
* inputs - pointer to client to report to |
| 548 |
|
const struct MessageTree *mtree = &msg_tree; |
| 549 |
|
unsigned int i; |
| 550 |
|
|
| 551 |
< |
for (i = 0; i < MAXPTRLEN; i++) |
| 568 |
< |
if (mtree->pointers[i] != NULL) |
| 569 |
< |
recurse_report_messages(source_p, mtree->pointers[i]); |
| 570 |
< |
} |
| 571 |
< |
|
| 572 |
< |
static void |
| 573 |
< |
recurse_report_messages(struct Client *source_p, const struct MessageTree *mtree) |
| 574 |
< |
{ |
| 575 |
< |
unsigned int i; |
| 576 |
< |
|
| 577 |
< |
if (mtree->msg != NULL) |
| 578 |
< |
sendto_one(source_p, form_str(RPL_STATSCOMMANDS), |
| 579 |
< |
me.name, source_p->name, mtree->msg->cmd, |
| 580 |
< |
mtree->msg->count, mtree->msg->bytes, |
| 581 |
< |
mtree->msg->rcount); |
| 582 |
< |
|
| 583 |
< |
for (i = 0; i < MAXPTRLEN; i++) |
| 551 |
> |
for (i = 0; i < MAXPTRLEN; ++i) |
| 552 |
|
if (mtree->pointers[i] != NULL) |
| 553 |
|
recurse_report_messages(source_p, mtree->pointers[i]); |
| 554 |
|
} |
| 694 |
|
t += tl; |
| 695 |
|
} |
| 696 |
|
|
| 697 |
< |
ircsprintf(t," :%s", parv[parc-1]); |
| 697 |
> |
ircsprintf(t, " :%s", parv[parc-1]); |
| 698 |
|
|
| 699 |
|
if (((target_p = find_person(client_p, parv[1])) != NULL) || |
| 700 |
|
((target_p = hash_find_server(parv[1])) != NULL)) |
| 805 |
|
|
| 806 |
|
in_para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>"; |
| 807 |
|
|
| 808 |
< |
ilog(L_ERROR, "Received ERROR message from %s: %s", |
| 808 |
> |
ilog(LOG_TYPE_IRCD, "Received ERROR message from %s: %s", |
| 809 |
|
source_p->name, in_para); |
| 810 |
|
|
| 811 |
|
if (client_p == source_p) |