| 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 *); |
| 112 |
|
static void add_msg_element(struct MessageTree *, struct Message *, const char *); |
| 113 |
|
static void del_msg_element(struct MessageTree *, const char *); |
| 114 |
|
|
| 123 |
|
{ |
| 124 |
|
struct Client *from = client_p; |
| 125 |
|
struct Message *msg_ptr = NULL; |
| 126 |
< |
char *ch; |
| 127 |
< |
char *s; |
| 128 |
< |
char *numeric = 0; |
| 126 |
> |
char *ch = NULL; |
| 127 |
> |
char *s = NULL; |
| 128 |
> |
char *numeric = NULL; |
| 129 |
|
unsigned int parc = 0; |
| 130 |
|
unsigned int paramcount; |
| 132 |
– |
int mpara = 0; |
| 131 |
|
|
| 132 |
|
if (IsDefunct(client_p)) |
| 133 |
|
return; |
| 135 |
|
assert(client_p->localClient->fd.flags.open); |
| 136 |
|
assert((bufend - pbuffer) < 512); |
| 137 |
|
|
| 138 |
< |
for (ch = pbuffer; *ch == ' '; ch++) /* skip spaces */ |
| 138 |
> |
for (ch = pbuffer; *ch == ' '; ++ch) /* skip spaces */ |
| 139 |
|
/* null statement */ ; |
| 140 |
|
|
| 141 |
|
if (*ch == ':') |
| 154 |
|
|
| 155 |
|
if (*sender && IsServer(client_p)) |
| 156 |
|
{ |
| 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 |
– |
*/ |
| 157 |
|
if ((from = find_person(client_p, sender)) == NULL) |
| 158 |
|
from = hash_find_server(sender); |
| 159 |
|
|
| 224 |
|
* Hm, when is the buffer empty -- if a command |
| 225 |
|
* code has been found ?? -Armin |
| 226 |
|
*/ |
| 227 |
< |
if (pbuffer[0] != '\0') |
| 227 |
> |
if (*pbuffer != '\0') |
| 228 |
|
{ |
| 229 |
|
if (IsClient(from)) |
| 230 |
|
sendto_one(from, form_str(ERR_UNKNOWNCOMMAND), |
| 238 |
|
assert(msg_ptr->cmd != NULL); |
| 239 |
|
|
| 240 |
|
paramcount = msg_ptr->args_max; |
| 247 |
– |
mpara = msg_ptr->args_min; |
| 248 |
– |
|
| 241 |
|
ii = bufend - ((s) ? s : ch); |
| 242 |
|
msg_ptr->bytes += ii; |
| 243 |
|
} |
| 442 |
|
{ |
| 443 |
|
struct MessageTree *ntree_p; |
| 444 |
|
|
| 445 |
< |
/* In case this is called for a nonexistent command |
| 445 |
> |
/* |
| 446 |
> |
* In case this is called for a nonexistent command |
| 447 |
|
* check that there is a msg pointer here, else links-- goes -ve |
| 448 |
|
* -db |
| 449 |
|
*/ |
| 457 |
– |
|
| 450 |
|
if ((*cmd == '\0') && (mtree_p->msg != NULL)) |
| 451 |
|
{ |
| 452 |
|
mtree_p->msg = NULL; |
| 499 |
|
void |
| 500 |
|
mod_add_cmd(struct Message *msg) |
| 501 |
|
{ |
| 502 |
< |
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); |
| 502 |
> |
assert(msg && msg->cmd); |
| 503 |
|
|
| 504 |
|
/* command already added? */ |
| 505 |
< |
if ((found_msg = msg_tree_parse(msg->cmd, &msg_tree)) != NULL) |
| 505 |
> |
if (msg_tree_parse(msg->cmd, &msg_tree)) |
| 506 |
|
return; |
| 507 |
|
|
| 508 |
|
add_msg_element(&msg_tree, msg, msg->cmd); |
| 518 |
|
void |
| 519 |
|
mod_del_cmd(struct Message *msg) |
| 520 |
|
{ |
| 521 |
< |
assert(msg != NULL); |
| 536 |
< |
|
| 537 |
< |
if (msg == NULL) |
| 538 |
< |
return; |
| 521 |
> |
assert(msg && msg->cmd); |
| 522 |
|
|
| 523 |
|
del_msg_element(&msg_tree, msg->cmd); |
| 524 |
|
} |
| 535 |
|
return msg_tree_parse(cmd, &msg_tree); |
| 536 |
|
} |
| 537 |
|
|
| 538 |
+ |
static void |
| 539 |
+ |
recurse_report_messages(struct Client *source_p, const struct MessageTree *mtree) |
| 540 |
+ |
{ |
| 541 |
+ |
unsigned int i; |
| 542 |
+ |
|
| 543 |
+ |
if (mtree->msg != NULL) |
| 544 |
+ |
sendto_one(source_p, form_str(RPL_STATSCOMMANDS), |
| 545 |
+ |
me.name, source_p->name, mtree->msg->cmd, |
| 546 |
+ |
mtree->msg->count, mtree->msg->bytes, |
| 547 |
+ |
mtree->msg->rcount); |
| 548 |
+ |
|
| 549 |
+ |
for (i = 0; i < MAXPTRLEN; ++i) |
| 550 |
+ |
if (mtree->pointers[i] != NULL) |
| 551 |
+ |
recurse_report_messages(source_p, mtree->pointers[i]); |
| 552 |
+ |
} |
| 553 |
+ |
|
| 554 |
|
/* report_messages() |
| 555 |
|
* |
| 556 |
|
* inputs - pointer to client to report to |
| 563 |
|
const struct MessageTree *mtree = &msg_tree; |
| 564 |
|
unsigned int i; |
| 565 |
|
|
| 566 |
< |
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++) |
| 566 |
> |
for (i = 0; i < MAXPTRLEN; ++i) |
| 567 |
|
if (mtree->pointers[i] != NULL) |
| 568 |
|
recurse_report_messages(source_p, mtree->pointers[i]); |
| 569 |
|
} |