| 36 |
|
#include "send.h" |
| 37 |
|
#include "conf.h" |
| 38 |
|
#include "memory.h" |
| 39 |
< |
#include "s_user.h" |
| 40 |
< |
#include "s_serv.h" |
| 39 |
> |
#include "user.h" |
| 40 |
> |
#include "server.h" |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
/* |
| 100 |
|
|
| 101 |
|
static struct MessageTree msg_tree; |
| 102 |
|
|
| 103 |
< |
static char *para[MAXPARA + 2]; /* <command> + <params> + NULL */ |
| 104 |
< |
|
| 105 |
< |
static int cancel_clients(struct Client *, struct Client *, char *); |
| 103 |
> |
static void cancel_clients(struct Client *, struct Client *, char *); |
| 104 |
|
static void remove_unknown(struct Client *, char *, char *); |
| 105 |
< |
static void handle_numeric(char[], struct Client *, int, char *[]); |
| 105 |
> |
static void handle_numeric(unsigned int, struct Client *, int, char *[]); |
| 106 |
|
static void handle_command(struct Message *, struct Client *, unsigned int, char *[]); |
| 107 |
|
|
| 108 |
|
|
| 116 |
|
{ |
| 117 |
|
struct Client *from = client_p; |
| 118 |
|
struct Message *msg_ptr = NULL; |
| 119 |
+ |
char *para[MAXPARA + 2]; /* <command> + <parameters> + NULL */ |
| 120 |
|
char *ch = NULL; |
| 121 |
|
char *s = NULL; |
| 122 |
< |
char *numeric = NULL; |
| 122 |
> |
unsigned int numeric = 0; |
| 123 |
|
unsigned int parc = 0; |
| 124 |
|
unsigned int paramcount; |
| 125 |
|
|
| 129 |
|
assert(client_p->localClient->fd.flags.open); |
| 130 |
|
assert((bufend - pbuffer) < IRCD_BUFSIZE); |
| 131 |
|
|
| 132 |
< |
for (ch = pbuffer; *ch == ' '; ++ch) /* skip spaces */ |
| 133 |
< |
/* null statement */ ; |
| 132 |
> |
for (ch = pbuffer; *ch == ' '; ++ch) /* Skip spaces */ |
| 133 |
> |
; |
| 134 |
|
|
| 135 |
|
if (*ch == ':') |
| 136 |
|
{ |
| 189 |
|
* code. -avalon |
| 190 |
|
*/ |
| 191 |
|
|
| 192 |
< |
/* EOB is 3 chars long but is not a numeric */ |
| 193 |
< |
if (*(ch + 3) == ' ' && /* ok, lets see if its a possible numeric.. */ |
| 192 |
> |
/* EOB is 3 characters long but is not a numeric */ |
| 193 |
> |
if (*(ch + 3) == ' ' && /* Ok, lets see if its a possible numeric.. */ |
| 194 |
|
IsDigit(*ch) && IsDigit(*(ch + 1)) && IsDigit(*(ch + 2))) |
| 195 |
|
{ |
| 196 |
< |
numeric = ch; |
| 197 |
< |
paramcount = 2; /* destination, and the rest of it */ |
| 196 |
> |
numeric = (*ch - '0') * 100 + (*(ch + 1) - '0') * 10 + (*(ch + 2) - '0'); |
| 197 |
> |
paramcount = 2; /* Destination, and the rest of it */ |
| 198 |
|
++ServerStats.is_num; |
| 199 |
< |
s = ch + 3; /* I know this is ' ' from above if */ |
| 200 |
< |
*s++ = '\0'; /* blow away the ' ', and point s to next part */ |
| 199 |
> |
s = ch + 3; /* I know this is ' ' from above if */ |
| 200 |
> |
*s++ = '\0'; /* Blow away the ' ', and point s to next part */ |
| 201 |
|
} |
| 202 |
|
else |
| 203 |
|
{ |
| 219 |
|
* Hm, when is the buffer empty -- if a command |
| 220 |
|
* code has been found ?? -Armin |
| 221 |
|
*/ |
| 222 |
< |
if (*pbuffer != '\0') |
| 222 |
> |
if (*pbuffer) |
| 223 |
|
if (IsClient(from)) |
| 224 |
|
sendto_one_numeric(from, &me, ERR_UNKNOWNCOMMAND, ch); |
| 225 |
|
|
| 295 |
|
*/ |
| 296 |
|
static void |
| 297 |
|
handle_command(struct Message *mptr, struct Client *source_p, |
| 298 |
< |
unsigned int i, char *hpara[]) |
| 298 |
> |
unsigned int i, char *para[]) |
| 299 |
|
{ |
| 300 |
|
if (IsServer(source_p->from)) |
| 301 |
< |
mptr->rcount++; |
| 301 |
> |
++mptr->rcount; |
| 302 |
|
|
| 303 |
< |
mptr->count++; |
| 303 |
> |
++mptr->count; |
| 304 |
|
|
| 305 |
< |
/* Check right amount of params is passed... --is */ |
| 305 |
> |
/* Check right amount of parameters is passed... --is */ |
| 306 |
|
if (i < mptr->args_min) |
| 307 |
|
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, mptr->cmd); |
| 308 |
|
else |
| 309 |
< |
mptr->handlers[source_p->from->handler](source_p, i, hpara); |
| 309 |
> |
mptr->handlers[source_p->from->handler](source_p, i, para); |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
/* add_msg_element() |
| 333 |
|
add_msg_element(struct MessageTree *mtree_p, struct Message *msg_p, |
| 334 |
|
const char *cmd) |
| 335 |
|
{ |
| 336 |
< |
struct MessageTree *ntree_p; |
| 336 |
> |
struct MessageTree *ntree_p = NULL; |
| 337 |
|
|
| 338 |
|
if (*cmd == '\0') |
| 339 |
|
{ |
| 350 |
|
*/ |
| 351 |
|
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) == NULL) |
| 352 |
|
{ |
| 353 |
< |
ntree_p = MyMalloc(sizeof(struct MessageTree)); |
| 353 |
> |
ntree_p = MyCalloc(sizeof(struct MessageTree)); |
| 354 |
|
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = ntree_p; |
| 355 |
|
|
| 356 |
|
mtree_p->links++; /* Have new pointer, so up ref count */ |
| 386 |
|
static void |
| 387 |
|
del_msg_element(struct MessageTree *mtree_p, const char *cmd) |
| 388 |
|
{ |
| 389 |
< |
struct MessageTree *ntree_p; |
| 389 |
> |
struct MessageTree *ntree_p = NULL; |
| 390 |
|
|
| 391 |
|
/* |
| 392 |
|
* In case this is called for a nonexistent command |
| 467 |
|
{ |
| 468 |
|
assert(msg && msg->cmd); |
| 469 |
|
|
| 470 |
+ |
if (!msg_tree_parse(msg->cmd)) |
| 471 |
+ |
return; |
| 472 |
+ |
|
| 473 |
|
del_msg_element(&msg_tree, msg->cmd); |
| 474 |
|
} |
| 475 |
|
|
| 521 |
|
* output - |
| 522 |
|
* side effects - |
| 523 |
|
*/ |
| 524 |
< |
static int |
| 524 |
> |
static void |
| 525 |
|
cancel_clients(struct Client *client_p, struct Client *source_p, char *cmd) |
| 526 |
|
{ |
| 527 |
|
/* |
| 560 |
|
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
| 561 |
|
"Not dropping server %s (%s) for Fake Direction", |
| 562 |
|
client_p->name, source_p->name); |
| 563 |
< |
return -1; |
| 562 |
< |
/* return exit_client(client_p, client_p, &me, "Fake Direction");*/ |
| 563 |
> |
return; |
| 564 |
|
} |
| 565 |
|
|
| 566 |
|
/* |
| 582 |
|
"Message for %s[%s@%s!%s] from %s (TS, ignored)", |
| 583 |
|
source_p->name, source_p->username, source_p->host, |
| 584 |
|
source_p->from->name, get_client_name(client_p, MASK_IP)); |
| 584 |
– |
return 0; |
| 585 |
|
} |
| 586 |
|
|
| 587 |
|
/* remove_unknown() |
| 612 |
|
"Unknown prefix (%s) from %s, Squitting %s", |
| 613 |
|
lbuffer, client_p->name, lsender); |
| 614 |
|
sendto_one(client_p, ":%s SQUIT %s :(Unknown prefix (%s) from %s)", |
| 615 |
< |
me.name, lsender, lbuffer, client_p->name); |
| 615 |
> |
me.id, lsender, lbuffer, client_p->name); |
| 616 |
|
} |
| 617 |
|
else |
| 618 |
|
sendto_one(client_p, ":%s KILL %s :%s (Unknown Client)", |
| 619 |
< |
me.name, lsender, me.name); |
| 619 |
> |
me.id, lsender, me.name); |
| 620 |
|
} |
| 621 |
|
|
| 622 |
|
/* |
| 641 |
|
* the savvy approach is NEVER generate an error in response to an... error :) |
| 642 |
|
*/ |
| 643 |
|
static void |
| 644 |
< |
handle_numeric(char numeric[], struct Client *source_p, int parc, char *parv[]) |
| 644 |
> |
handle_numeric(unsigned int numeric, struct Client *source_p, int parc, char *parv[]) |
| 645 |
|
{ |
| 646 |
|
struct Client *target_p = NULL; |
| 647 |
|
struct Channel *chptr = NULL; |
| 676 |
|
* remotely - but the information they contain may be useful, so we |
| 677 |
|
* remap them up. Weird, but true. -- Isomer |
| 678 |
|
*/ |
| 679 |
< |
if (numeric[0] == '0') |
| 680 |
< |
numeric[0] = '1'; |
| 679 |
> |
if (numeric < 100) |
| 680 |
> |
numeric += 100; |
| 681 |
|
|
| 682 |
|
if (target_p) |
| 683 |
|
{ |
| 684 |
< |
/* Fake it for server hiding, if its our client */ |
| 685 |
< |
if (ConfigServerHide.hide_servers && MyClient(target_p) && |
| 684 |
> |
/* Fake it for server hiding, if it's our client */ |
| 685 |
> |
if (ConfigServerHide.hide_servers && MyConnect(target_p) && |
| 686 |
|
!HasUMode(target_p, UMODE_OPER)) |
| 687 |
< |
sendto_one(target_p, ":%s %s %s %s", me.name, numeric, target_p->name, parv[2]); |
| 687 |
> |
sendto_one_numeric(target_p, &me, numeric|SND_EXPLICIT, "%s", parv[2]); |
| 688 |
|
else |
| 689 |
< |
sendto_one(target_p, ":%s %s %s %s", ID_or_name(source_p, target_p), |
| 690 |
< |
numeric, ID_or_name(target_p, target_p), parv[2]); |
| 689 |
> |
sendto_one_numeric(target_p, source_p, numeric|SND_EXPLICIT, "%s", parv[2]); |
| 690 |
|
} |
| 691 |
|
else |
| 692 |
< |
sendto_channel_butone(source_p, source_p, chptr, 0, "%s %s %s", |
| 692 |
> |
sendto_channel_butone(source_p, source_p, chptr, 0, "%u %s %s", |
| 693 |
|
numeric, chptr->chname, parv[2]); |
| 694 |
|
} |
| 695 |
|
|