| 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 add_msg_element(struct MessageTree *, struct Message *, const char *); |
| 113 |
– |
static void del_msg_element(struct MessageTree *, const char *); |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
/* |
| 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 |
|
|
| 310 |
|
|
| 311 |
|
mptr->count++; |
| 312 |
|
|
| 315 |
– |
/* New patch to avoid server flooding from unregistered connects |
| 316 |
– |
* - Pie-Man 07/27/2000 */ |
| 317 |
– |
if (!IsRegistered(client_p)) |
| 318 |
– |
{ |
| 319 |
– |
/* if its from a possible server connection |
| 320 |
– |
* ignore it.. more than likely its a header thats sneaked through |
| 321 |
– |
*/ |
| 322 |
– |
if ((IsHandshake(client_p) || IsConnecting(client_p) || |
| 323 |
– |
IsServer(client_p)) && !(mptr->flags & MFLG_UNREG)) |
| 324 |
– |
return; |
| 325 |
– |
} |
| 326 |
– |
|
| 313 |
|
handler = mptr->handlers[client_p->handler]; |
| 314 |
|
|
| 315 |
|
/* check right amount of params is passed... --is */ |
| 317 |
|
{ |
| 318 |
|
if (!IsServer(client_p)) |
| 319 |
|
{ |
| 320 |
< |
sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), |
| 321 |
< |
me.name, EmptyString(hpara[0]) ? "*" : hpara[0], mptr->cmd); |
| 320 |
> |
sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), me.name, |
| 321 |
> |
EmptyString(hpara[0]) ? "*" : hpara[0], mptr->cmd); |
| 322 |
|
} |
| 323 |
|
else |
| 324 |
|
{ |
| 336 |
|
(*handler)(client_p, from, i, hpara); |
| 337 |
|
} |
| 338 |
|
|
| 353 |
– |
/* clear_tree_parse() |
| 354 |
– |
* |
| 355 |
– |
* inputs - NONE |
| 356 |
– |
* output - NONE |
| 357 |
– |
* side effects - MUST MUST be called at startup ONCE before |
| 358 |
– |
* any other keyword routine is used. |
| 359 |
– |
*/ |
| 360 |
– |
void |
| 361 |
– |
clear_tree_parse(void) |
| 362 |
– |
{ |
| 363 |
– |
memset(&msg_tree, 0, sizeof(msg_tree)); |
| 364 |
– |
} |
| 365 |
– |
|
| 339 |
|
/* add_msg_element() |
| 340 |
|
* |
| 341 |
|
* inputs - pointer to MessageTree |
| 357 |
|
* in the parent. |
| 358 |
|
*/ |
| 359 |
|
static void |
| 360 |
< |
add_msg_element(struct MessageTree *mtree_p, |
| 361 |
< |
struct Message *msg_p, const char *cmd) |
| 360 |
> |
add_msg_element(struct MessageTree *mtree_p, struct Message *msg_p, |
| 361 |
> |
const char *cmd) |
| 362 |
|
{ |
| 363 |
|
struct MessageTree *ntree_p; |
| 364 |
|
|
| 365 |
|
if (*cmd == '\0') |
| 366 |
|
{ |
| 367 |
|
mtree_p->msg = msg_p; |
| 368 |
< |
mtree_p->links++; /* Have msg pointer, so up ref count */ |
| 368 |
> |
mtree_p->links++; /* Have msg pointer, so up ref count */ |
| 369 |
|
} |
| 370 |
|
else |
| 371 |
|
{ |
| 380 |
|
ntree_p = MyMalloc(sizeof(struct MessageTree)); |
| 381 |
|
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = ntree_p; |
| 382 |
|
|
| 383 |
< |
mtree_p->links++; /* Have new pointer, so up ref count */ |
| 383 |
> |
mtree_p->links++; /* Have new pointer, so up ref count */ |
| 384 |
|
} |
| 385 |
|
|
| 386 |
|
add_msg_element(ntree_p, msg_p, cmd + 1); |
| 433 |
|
|
| 434 |
|
if (ntree_p->links == 0) |
| 435 |
|
{ |
| 436 |
< |
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = NULL; |
| 437 |
< |
mtree_p->links--; |
| 438 |
< |
MyFree(ntree_p); |
| 436 |
> |
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = NULL; |
| 437 |
> |
mtree_p->links--; |
| 438 |
> |
MyFree(ntree_p); |
| 439 |
|
} |
| 440 |
|
} |
| 441 |
|
} |
| 449 |
|
* side effects - none |
| 450 |
|
*/ |
| 451 |
|
static struct Message * |
| 452 |
< |
msg_tree_parse(const char *cmd, struct MessageTree *root) |
| 452 |
> |
msg_tree_parse(const char *cmd) |
| 453 |
|
{ |
| 454 |
< |
struct MessageTree *mtree = root; |
| 454 |
> |
struct MessageTree *mtree = &msg_tree; |
| 455 |
|
assert(cmd && *cmd); |
| 456 |
|
|
| 457 |
|
while (IsAlpha(*cmd) && (mtree = mtree->pointers[*cmd & (MAXPTRLEN - 1)])) |
| 475 |
|
assert(msg && msg->cmd); |
| 476 |
|
|
| 477 |
|
/* command already added? */ |
| 478 |
< |
if (msg_tree_parse(msg->cmd, &msg_tree)) |
| 478 |
> |
if (msg_tree_parse(msg->cmd)) |
| 479 |
|
return; |
| 480 |
|
|
| 481 |
|
add_msg_element(&msg_tree, msg, msg->cmd); |
| 505 |
|
struct Message * |
| 506 |
|
find_command(const char *cmd) |
| 507 |
|
{ |
| 508 |
< |
return msg_tree_parse(cmd, &msg_tree); |
| 508 |
> |
return msg_tree_parse(cmd); |
| 509 |
|
} |
| 510 |
|
|
| 511 |
|
static void |
| 717 |
|
|
| 718 |
|
if ((num != ERR_NOSUCHNICK)) |
| 719 |
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 720 |
< |
"*** %s(via %s) sent a %s numeric to me: %s", |
| 721 |
< |
source_p->name, client_p->name, numeric, buffer); |
| 720 |
> |
"*** %s(via %s) sent a %s numeric to me: %s", |
| 721 |
> |
source_p->name, client_p->name, numeric, buffer); |
| 722 |
|
return; |
| 723 |
|
} |
| 724 |
|
else if (target_p->from == client_p) |
| 743 |
|
return; |
| 744 |
|
} |
| 745 |
|
else if ((chptr = hash_find_channel(parv[1])) != NULL) |
| 746 |
< |
sendto_channel_local(ALL_MEMBERS, 0, chptr, |
| 747 |
< |
":%s %s %s %s", |
| 748 |
< |
source_p->name, |
| 776 |
< |
numeric, chptr->chname, buffer); |
| 746 |
> |
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s %s %s %s", |
| 747 |
> |
source_p->name, |
| 748 |
> |
numeric, chptr->chname, buffer); |
| 749 |
|
} |
| 750 |
|
|
| 751 |
|
/* m_not_oper() |