| 19 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 20 |
|
* USA |
| 21 |
|
* |
| 22 |
< |
* $Id: parse.c,v 7.203 2005/08/29 21:02:50 db Exp $ |
| 22 |
> |
* $Id$ |
| 23 |
|
*/ |
| 24 |
|
|
| 25 |
|
#include "stdinc.h" |
| 26 |
– |
#include "parse.h" |
| 26 |
|
#include "client.h" |
| 27 |
+ |
#include "parse.h" |
| 28 |
|
#include "channel.h" |
| 29 |
– |
#include "handlers.h" |
| 30 |
– |
#include "common.h" |
| 29 |
|
#include "hash.h" |
| 30 |
|
#include "irc_string.h" |
| 31 |
|
#include "sprintf_irc.h" |
| 32 |
|
#include "ircd.h" |
| 33 |
|
#include "numeric.h" |
| 34 |
< |
#include "s_log.h" |
| 37 |
< |
#include "s_stats.h" |
| 34 |
> |
#include "log.h" |
| 35 |
|
#include "send.h" |
| 36 |
< |
#include "ircd_handler.h" |
| 40 |
< |
#include "msg.h" |
| 41 |
< |
#include "s_conf.h" |
| 36 |
> |
#include "conf.h" |
| 37 |
|
#include "memory.h" |
| 38 |
|
#include "s_user.h" |
| 39 |
|
#include "s_serv.h" |
| 107 |
|
|
| 108 |
|
static int cancel_clients(struct Client *, struct Client *, char *); |
| 109 |
|
static void remove_unknown(struct Client *, char *, char *); |
| 110 |
< |
static void do_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 *source_p, struct MessageTree *mtree); |
| 113 |
< |
static void add_msg_element(struct MessageTree *mtree_p, struct Message *msg_p, const char *cmd); |
| 119 |
< |
static void del_msg_element(struct MessageTree *mtree_p, const char *cmd); |
| 120 |
< |
|
| 121 |
< |
/* turn a string into a parc/parv pair */ |
| 122 |
< |
static inline int |
| 123 |
< |
string_to_array(char *string, char *parv[MAXPARA]) |
| 124 |
< |
{ |
| 125 |
< |
char *p; |
| 126 |
< |
char *buf = string; |
| 127 |
< |
int x = 1; |
| 128 |
< |
|
| 129 |
< |
parv[x] = NULL; |
| 130 |
< |
|
| 131 |
< |
while (*buf == ' ') /* skip leading spaces */ |
| 132 |
< |
buf++; |
| 133 |
< |
|
| 134 |
< |
if (*buf == '\0') /* ignore all-space args */ |
| 135 |
< |
return(x); |
| 136 |
< |
|
| 137 |
< |
do |
| 138 |
< |
{ |
| 139 |
< |
if (*buf == ':') /* Last parameter */ |
| 140 |
< |
{ |
| 141 |
< |
buf++; |
| 142 |
< |
parv[x++] = buf; |
| 143 |
< |
parv[x] = NULL; |
| 144 |
< |
return(x); |
| 145 |
< |
} |
| 146 |
< |
else |
| 147 |
< |
{ |
| 148 |
< |
parv[x++] = buf; |
| 149 |
< |
parv[x] = NULL; |
| 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 *); |
| 114 |
|
|
| 151 |
– |
if ((p = strchr(buf, ' ')) != NULL) |
| 152 |
– |
{ |
| 153 |
– |
*p++ = '\0'; |
| 154 |
– |
buf = p; |
| 155 |
– |
} |
| 156 |
– |
else |
| 157 |
– |
return(x); |
| 158 |
– |
} |
| 159 |
– |
|
| 160 |
– |
while (*buf == ' ') |
| 161 |
– |
buf++; |
| 162 |
– |
|
| 163 |
– |
if (*buf == '\0') |
| 164 |
– |
return(x); |
| 165 |
– |
} while (x < MAXPARA - 1); |
| 166 |
– |
|
| 167 |
– |
if (*p == ':') |
| 168 |
– |
p++; |
| 169 |
– |
|
| 170 |
– |
parv[x++] = p; |
| 171 |
– |
parv[x] = NULL; |
| 172 |
– |
return(x); |
| 173 |
– |
} |
| 115 |
|
|
| 116 |
|
/* |
| 117 |
|
* parse a buffer. |
| 122 |
|
parse(struct Client *client_p, char *pbuffer, char *bufend) |
| 123 |
|
{ |
| 124 |
|
struct Client *from = client_p; |
| 125 |
< |
char *ch; |
| 126 |
< |
char *s; |
| 127 |
< |
char *numeric = 0; |
| 128 |
< |
unsigned int i = 0; |
| 129 |
< |
int paramcount; |
| 130 |
< |
int mpara = 0; |
| 190 |
< |
struct Message *mptr = NULL; |
| 125 |
> |
struct Message *msg_ptr = NULL; |
| 126 |
> |
char *ch = NULL; |
| 127 |
> |
char *s = NULL; |
| 128 |
> |
char *numeric = NULL; |
| 129 |
> |
unsigned int parc = 0; |
| 130 |
> |
unsigned int paramcount; |
| 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 |
|
|
| 201 |
– |
para[0] = from->name; |
| 202 |
– |
|
| 141 |
|
if (*ch == ':') |
| 142 |
|
{ |
| 143 |
< |
ch++; |
| 144 |
< |
|
| 207 |
< |
/* Copy the prefix to 'sender' assuming it terminates |
| 143 |
> |
/* |
| 144 |
> |
* Copy the prefix to 'sender' assuming it terminates |
| 145 |
|
* with SPACE (or NULL, which is an error, though). |
| 146 |
|
*/ |
| 147 |
< |
sender = ch; |
| 147 |
> |
sender = ++ch; |
| 148 |
|
|
| 149 |
|
if ((s = strchr(ch, ' ')) != NULL) |
| 150 |
|
{ |
| 151 |
|
*s = '\0'; |
| 152 |
< |
s++; |
| 216 |
< |
ch = s; |
| 152 |
> |
ch = ++s; |
| 153 |
|
} |
| 154 |
|
|
| 155 |
|
if (*sender && IsServer(client_p)) |
| 156 |
|
{ |
| 221 |
– |
/* |
| 222 |
– |
* XXX it could be useful to know which of these occurs most frequently. |
| 223 |
– |
* the ID check should always come first, though, since it is so easy. |
| 224 |
– |
*/ |
| 157 |
|
if ((from = find_person(client_p, sender)) == NULL) |
| 158 |
< |
{ |
| 227 |
< |
from = find_server(sender); |
| 158 |
> |
from = hash_find_server(sender); |
| 159 |
|
|
| 229 |
– |
if (from == NULL && IsCapable(client_p, CAP_TS6) && |
| 230 |
– |
client_p->name[0] == '*' && IsDigit(*sender) && strlen(sender) == 3) |
| 231 |
– |
{ |
| 232 |
– |
/* Dirty hack to allow messages from masked SIDs (i.e. the ones |
| 233 |
– |
* hidden by fakename="..."). It shouldn't break anything, since |
| 234 |
– |
* unknown SIDs don't happen during normal ircd work --adx |
| 235 |
– |
*/ |
| 236 |
– |
from = client_p; |
| 237 |
– |
} |
| 238 |
– |
} |
| 239 |
– |
|
| 160 |
|
/* Hmm! If the client corresponding to the |
| 161 |
|
* prefix is not found--what is the correct |
| 162 |
|
* action??? Now, I will ignore the message |
| 165 |
|
*/ |
| 166 |
|
if (from == NULL) |
| 167 |
|
{ |
| 168 |
< |
ServerStats->is_unpf++; |
| 168 |
> |
++ServerStats.is_unpf; |
| 169 |
|
remove_unknown(client_p, sender, pbuffer); |
| 170 |
|
return; |
| 171 |
|
} |
| 172 |
|
|
| 253 |
– |
para[0] = from->name; |
| 254 |
– |
|
| 173 |
|
if (from->from != client_p) |
| 174 |
|
{ |
| 175 |
< |
ServerStats->is_wrdi++; |
| 175 |
> |
++ServerStats.is_wrdi; |
| 176 |
|
cancel_clients(client_p, from, pbuffer); |
| 177 |
|
return; |
| 178 |
|
} |
| 179 |
|
} |
| 180 |
|
|
| 181 |
|
while (*ch == ' ') |
| 182 |
< |
ch++; |
| 182 |
> |
++ch; |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
if (*ch == '\0') |
| 186 |
|
{ |
| 187 |
< |
ServerStats->is_empt++; |
| 187 |
> |
++ServerStats.is_empt; |
| 188 |
|
return; |
| 189 |
|
} |
| 190 |
|
|
| 199 |
|
if (*(ch + 3) == ' ' && /* ok, lets see if its a possible numeric.. */ |
| 200 |
|
IsDigit(*ch) && IsDigit(*(ch + 1)) && IsDigit(*(ch + 2))) |
| 201 |
|
{ |
| 284 |
– |
mptr = NULL; |
| 202 |
|
numeric = ch; |
| 203 |
|
paramcount = MAXPARA; |
| 204 |
< |
ServerStats->is_num++; |
| 204 |
> |
++ServerStats.is_num; |
| 205 |
|
s = ch + 3; /* I know this is ' ' from above if */ |
| 206 |
|
*s++ = '\0'; /* blow away the ' ', and point s to next part */ |
| 207 |
|
} |
| 208 |
|
else |
| 209 |
|
{ |
| 210 |
< |
int ii = 0; |
| 210 |
> |
unsigned int ii = 0; |
| 211 |
|
|
| 212 |
|
if ((s = strchr(ch, ' ')) != NULL) |
| 213 |
|
*s++ = '\0'; |
| 214 |
|
|
| 215 |
< |
if ((mptr = find_command(ch)) == NULL) |
| 215 |
> |
if ((msg_ptr = find_command(ch)) == NULL) |
| 216 |
|
{ |
| 217 |
|
/* Note: Give error message *only* to recognized |
| 218 |
|
* persons. It's a nightmare situation to have |
| 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), |
| 231 |
|
me.name, from->name, ch); |
| 232 |
|
} |
| 233 |
|
|
| 234 |
< |
ServerStats->is_unco++; |
| 234 |
> |
++ServerStats.is_unco; |
| 235 |
|
return; |
| 236 |
|
} |
| 237 |
|
|
| 238 |
< |
assert(mptr->cmd != NULL); |
| 322 |
< |
|
| 323 |
< |
paramcount = mptr->parameters; |
| 324 |
< |
mpara = mptr->maxpara; |
| 238 |
> |
assert(msg_ptr->cmd != NULL); |
| 239 |
|
|
| 240 |
+ |
paramcount = msg_ptr->args_max; |
| 241 |
|
ii = bufend - ((s) ? s : ch); |
| 242 |
< |
mptr->bytes += ii; |
| 242 |
> |
msg_ptr->bytes += ii; |
| 243 |
|
} |
| 244 |
|
|
| 245 |
< |
if (s != NULL) |
| 246 |
< |
i = string_to_array(s, para); |
| 247 |
< |
else |
| 245 |
> |
/* |
| 246 |
> |
* Must the following loop really be so devious? On surface it |
| 247 |
> |
* splits the message to parameters from blank spaces. But, if |
| 248 |
> |
* paramcount has been reached, the rest of the message goes into |
| 249 |
> |
* this last parameter (about same effect as ":" has...) --msa |
| 250 |
> |
*/ |
| 251 |
> |
|
| 252 |
> |
/* Note initially true: s==NULL || *(s-1) == '\0' !! */ |
| 253 |
> |
|
| 254 |
> |
para[parc] = from->name; |
| 255 |
> |
|
| 256 |
> |
if (s) |
| 257 |
|
{ |
| 258 |
< |
i = 0; |
| 259 |
< |
para[1] = NULL; |
| 258 |
> |
if (paramcount > MAXPARA) |
| 259 |
> |
paramcount = MAXPARA; |
| 260 |
> |
|
| 261 |
> |
while (1) |
| 262 |
> |
{ |
| 263 |
> |
while (*s == ' ') |
| 264 |
> |
*s++ = '\0'; |
| 265 |
> |
|
| 266 |
> |
if (*s == '\0') |
| 267 |
> |
break; |
| 268 |
> |
|
| 269 |
> |
if (*s == ':') |
| 270 |
> |
{ |
| 271 |
> |
/* The rest is a single parameter */ |
| 272 |
> |
para[++parc] = s + 1; |
| 273 |
> |
break; |
| 274 |
> |
} |
| 275 |
> |
|
| 276 |
> |
para[++parc] = s; |
| 277 |
> |
|
| 278 |
> |
if (parc >= paramcount) |
| 279 |
> |
break; |
| 280 |
> |
|
| 281 |
> |
while (*s && *s != ' ') |
| 282 |
> |
++s; |
| 283 |
> |
} |
| 284 |
|
} |
| 285 |
|
|
| 286 |
< |
if (mptr == NULL) |
| 287 |
< |
do_numeric(numeric, client_p, from, i, para); |
| 286 |
> |
para[++parc] = NULL; |
| 287 |
> |
|
| 288 |
> |
if (msg_ptr != NULL) |
| 289 |
> |
handle_command(msg_ptr, client_p, from, parc, para); |
| 290 |
|
else |
| 291 |
< |
handle_command(mptr, client_p, from, i, para); |
| 291 |
> |
handle_numeric(numeric, client_p, from, parc, para); |
| 292 |
|
} |
| 293 |
|
|
| 294 |
|
/* handle_command() |
| 327 |
|
handler = mptr->handlers[client_p->handler]; |
| 328 |
|
|
| 329 |
|
/* check right amount of params is passed... --is */ |
| 330 |
< |
if (i < mptr->parameters) |
| 330 |
> |
if (i < mptr->args_min) |
| 331 |
|
{ |
| 332 |
|
if (!IsServer(client_p)) |
| 333 |
|
{ |
| 339 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 340 |
|
"Dropping server %s due to (invalid) command '%s' " |
| 341 |
|
"with only %d arguments (expecting %d).", |
| 342 |
< |
client_p->name, mptr->cmd, i, mptr->parameters); |
| 343 |
< |
ilog(L_CRIT, "Insufficient parameters (%d) for command '%s' from %s.", |
| 342 |
> |
client_p->name, mptr->cmd, i, mptr->args_min); |
| 343 |
> |
ilog(LOG_TYPE_IRCD, "Insufficient parameters (%d) for command '%s' from %s.", |
| 344 |
|
i, mptr->cmd, client_p->name); |
| 345 |
|
exit_client(client_p, client_p, |
| 346 |
|
"Not enough arguments to server command."); |
| 402 |
|
* Thus 'A' -> 0x1 'B' -> 0x2 'c' -> 0x3 etc. |
| 403 |
|
*/ |
| 404 |
|
|
| 405 |
< |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN-1)]) == NULL) |
| 405 |
> |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) == NULL) |
| 406 |
|
{ |
| 407 |
< |
ntree_p = (struct MessageTree *)MyMalloc(sizeof(struct MessageTree)); |
| 408 |
< |
mtree_p->pointers[*cmd & (MAXPTRLEN-1)] = ntree_p; |
| 407 |
> |
ntree_p = MyMalloc(sizeof(struct MessageTree)); |
| 408 |
> |
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = ntree_p; |
| 409 |
|
|
| 410 |
|
mtree_p->links++; /* Have new pointer, so up ref count */ |
| 411 |
|
} |
| 412 |
< |
add_msg_element(ntree_p, msg_p, cmd+1); |
| 412 |
> |
|
| 413 |
> |
add_msg_element(ntree_p, msg_p, cmd + 1); |
| 414 |
|
} |
| 415 |
|
} |
| 416 |
|
|
| 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 |
|
*/ |
| 498 |
– |
|
| 450 |
|
if ((*cmd == '\0') && (mtree_p->msg != NULL)) |
| 451 |
|
{ |
| 452 |
|
mtree_p->msg = NULL; |
| 454 |
|
} |
| 455 |
|
else |
| 456 |
|
{ |
| 457 |
< |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN-1)]) != NULL) |
| 457 |
> |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) != NULL) |
| 458 |
|
{ |
| 459 |
< |
del_msg_element(ntree_p, cmd+1); |
| 459 |
> |
del_msg_element(ntree_p, cmd + 1); |
| 460 |
> |
|
| 461 |
|
if (ntree_p->links == 0) |
| 462 |
|
{ |
| 463 |
< |
mtree_p->pointers[*cmd & (MAXPTRLEN-1)] = NULL; |
| 463 |
> |
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = NULL; |
| 464 |
|
mtree_p->links--; |
| 465 |
|
MyFree(ntree_p); |
| 466 |
|
} |
| 478 |
|
static struct Message * |
| 479 |
|
msg_tree_parse(const char *cmd, struct MessageTree *root) |
| 480 |
|
{ |
| 481 |
< |
struct MessageTree *mtree; |
| 481 |
> |
struct MessageTree *mtree = root; |
| 482 |
|
assert(cmd && *cmd); |
| 531 |
– |
for (mtree = root->pointers[(*cmd) & (MAXPTRLEN-1)]; mtree != NULL; |
| 532 |
– |
mtree = mtree->pointers[(*++cmd) & (MAXPTRLEN-1)]) |
| 533 |
– |
{ |
| 534 |
– |
if (!IsAlpha(*cmd)) |
| 535 |
– |
return(NULL); |
| 536 |
– |
if (*(cmd + 1) == '\0') |
| 537 |
– |
return(mtree->msg); /* NULL if parsed invalid/unknown command */ |
| 483 |
|
|
| 484 |
< |
} |
| 484 |
> |
while (IsAlpha(*cmd) && (mtree = mtree->pointers[*cmd & (MAXPTRLEN - 1)])) |
| 485 |
> |
if (*++cmd == '\0') |
| 486 |
> |
return mtree->msg; |
| 487 |
|
|
| 488 |
< |
return(NULL); |
| 488 |
> |
return NULL; |
| 489 |
|
} |
| 490 |
|
|
| 491 |
|
/* mod_add_cmd() |
| 499 |
|
void |
| 500 |
|
mod_add_cmd(struct Message *msg) |
| 501 |
|
{ |
| 502 |
< |
struct Message *found_msg; |
| 556 |
< |
|
| 557 |
< |
if (msg == NULL) |
| 558 |
< |
return; |
| 559 |
< |
|
| 560 |
< |
/* someone loaded a module with a bad messagetab */ |
| 561 |
< |
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); |
| 581 |
< |
|
| 582 |
< |
if (msg == NULL) |
| 583 |
< |
return; |
| 521 |
> |
assert(msg && msg->cmd); |
| 522 |
|
|
| 523 |
|
del_msg_element(&msg_tree, msg->cmd); |
| 524 |
|
} |
| 532 |
|
struct Message * |
| 533 |
|
find_command(const char *cmd) |
| 534 |
|
{ |
| 535 |
< |
return(msg_tree_parse(cmd, &msg_tree)); |
| 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() |
| 560 |
|
void |
| 561 |
|
report_messages(struct Client *source_p) |
| 562 |
|
{ |
| 563 |
< |
struct MessageTree *mtree = &msg_tree; |
| 564 |
< |
int i; |
| 611 |
< |
|
| 612 |
< |
for (i = 0; i < MAXPTRLEN; i++) |
| 613 |
< |
{ |
| 614 |
< |
if (mtree->pointers[i] != NULL) |
| 615 |
< |
recurse_report_messages(source_p, mtree->pointers[i]); |
| 616 |
< |
} |
| 617 |
< |
} |
| 618 |
< |
|
| 619 |
< |
static void |
| 620 |
< |
recurse_report_messages(struct Client *source_p, struct MessageTree *mtree) |
| 621 |
< |
{ |
| 622 |
< |
int i; |
| 623 |
< |
|
| 624 |
< |
if (mtree->msg != NULL) |
| 625 |
< |
{ |
| 626 |
< |
sendto_one(source_p, form_str(RPL_STATSCOMMANDS), |
| 627 |
< |
me.name, source_p->name, mtree->msg->cmd, |
| 628 |
< |
mtree->msg->count, mtree->msg->bytes, |
| 629 |
< |
mtree->msg->rcount); |
| 630 |
< |
} |
| 563 |
> |
const struct MessageTree *mtree = &msg_tree; |
| 564 |
> |
unsigned int i; |
| 565 |
|
|
| 566 |
< |
for (i = 0; i < MAXPTRLEN; i++) |
| 633 |
< |
{ |
| 566 |
> |
for (i = 0; i < MAXPTRLEN; ++i) |
| 567 |
|
if (mtree->pointers[i] != NULL) |
| 568 |
|
recurse_report_messages(source_p, mtree->pointers[i]); |
| 636 |
– |
} |
| 569 |
|
} |
| 570 |
|
|
| 571 |
|
/* cancel_clients() |
| 608 |
|
sendto_realops_flags(UMODE_DEBUG, L_ALL, |
| 609 |
|
"Not dropping server %s (%s) for Fake Direction", |
| 610 |
|
client_p->name, source_p->name); |
| 611 |
< |
return(-1); |
| 611 |
> |
return -1; |
| 612 |
|
/* return exit_client(client_p, client_p, &me, "Fake Direction");*/ |
| 613 |
|
} |
| 614 |
|
|
| 630 |
|
source_p->name, source_p->username, source_p->host, |
| 631 |
|
source_p->from->name, get_client_name(client_p, MASK_IP)); |
| 632 |
|
|
| 633 |
< |
return(0); |
| 633 |
> |
return 0; |
| 634 |
|
} |
| 635 |
|
|
| 636 |
|
/* remove_unknown() |
| 682 |
|
* a ping pong error message... |
| 683 |
|
*/ |
| 684 |
|
static void |
| 685 |
< |
do_numeric(char numeric[], struct Client *client_p, struct Client *source_p, |
| 686 |
< |
int parc, char *parv[]) |
| 685 |
> |
handle_numeric(char numeric[], struct Client *client_p, struct Client *source_p, |
| 686 |
> |
int parc, char *parv[]) |
| 687 |
|
{ |
| 688 |
|
struct Client *target_p; |
| 689 |
|
struct Channel *chptr; |
| 709 |
|
t += tl; |
| 710 |
|
} |
| 711 |
|
|
| 712 |
< |
ircsprintf(t," :%s", parv[parc-1]); |
| 712 |
> |
ircsprintf(t, " :%s", parv[parc-1]); |
| 713 |
|
|
| 714 |
|
if (((target_p = find_person(client_p, parv[1])) != NULL) || |
| 715 |
< |
((target_p = find_server(parv[1])) != NULL)) |
| 715 |
> |
((target_p = hash_find_server(parv[1])) != NULL)) |
| 716 |
|
{ |
| 717 |
|
if (IsMe(target_p)) |
| 718 |
|
{ |
| 762 |
|
|
| 763 |
|
/* Fake it for server hiding, if its our client */ |
| 764 |
|
if (ConfigServerHide.hide_servers && |
| 765 |
< |
MyClient(target_p) && !IsOper(target_p)) |
| 765 |
> |
MyClient(target_p) && !HasUMode(target_p, UMODE_OPER)) |
| 766 |
|
sendto_one(target_p, ":%s %s %s%s", me.name, numeric, target_p->name, buffer); |
| 767 |
< |
else if (!MyClient(target_p) && IsCapable(target_p->from, CAP_TS6) && HasID(source_p)) |
| 768 |
< |
sendto_one(target_p, ":%s %s %s%s", source_p->id, numeric, target_p->id, buffer); |
| 769 |
< |
else /* either it is our client, or a client linked throuh a non-ts6 server. must use names! */ |
| 838 |
< |
sendto_one(target_p, ":%s %s %s%s", source_p->name, numeric, target_p->name, buffer); |
| 767 |
> |
else |
| 768 |
> |
sendto_one(target_p, ":%s %s %s%s", ID_or_name(source_p, target_p->from), |
| 769 |
> |
numeric, ID_or_name(target_p, target_p->from), buffer); |
| 770 |
|
return; |
| 771 |
|
} |
| 772 |
|
else if ((chptr = hash_find_channel(parv[1])) != NULL) |
| 773 |
< |
sendto_channel_local(ALL_MEMBERS, NO, chptr, |
| 773 |
> |
sendto_channel_local(ALL_MEMBERS, 0, chptr, |
| 774 |
|
":%s %s %s %s", |
| 775 |
|
source_p->name, |
| 776 |
|
numeric, chptr->chname, buffer); |
| 786 |
|
int parc, char *parv[]) |
| 787 |
|
{ |
| 788 |
|
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
| 789 |
< |
me.name, parv[0]); |
| 789 |
> |
me.name, source_p->name); |
| 790 |
|
} |
| 791 |
|
|
| 792 |
|
void |
| 793 |
|
m_unregistered(struct Client *client_p, struct Client *source_p, |
| 794 |
|
int parc, char *parv[]) |
| 795 |
|
{ |
| 796 |
< |
/* bit of a hack. |
| 797 |
< |
* I don't =really= want to waste a bit in a flag |
| 867 |
< |
* number_of_nick_changes is only really valid after the client |
| 868 |
< |
* is fully registered.. |
| 869 |
< |
*/ |
| 870 |
< |
if (client_p->localClient->number_of_nick_changes == 0) |
| 871 |
< |
{ |
| 872 |
< |
sendto_one(client_p, ":%s %d * %s :Register first.", |
| 873 |
< |
me.name, ERR_NOTREGISTERED, parv[0]); |
| 874 |
< |
client_p->localClient->number_of_nick_changes++; |
| 875 |
< |
} |
| 796 |
> |
sendto_one(source_p, form_str(ERR_NOTREGISTERED), me.name, |
| 797 |
> |
source_p->name[0] ? source_p->name : "*"); |
| 798 |
|
} |
| 799 |
|
|
| 800 |
|
void |
| 801 |
|
m_registered(struct Client *client_p, struct Client *source_p, |
| 802 |
|
int parc, char *parv[]) |
| 803 |
|
{ |
| 804 |
< |
sendto_one(client_p, form_str(ERR_ALREADYREGISTRED), |
| 805 |
< |
me.name, parv[0]); |
| 804 |
> |
sendto_one(source_p, form_str(ERR_ALREADYREGISTRED), |
| 805 |
> |
me.name, source_p->name); |
| 806 |
|
} |
| 807 |
|
|
| 808 |
|
void |
| 812 |
|
return; |
| 813 |
|
} |
| 814 |
|
|
| 815 |
+ |
void |
| 816 |
+ |
rfc1459_command_send_error(struct Client *client_p, struct Client *source_p, |
| 817 |
+ |
int parc, char *parv[]) |
| 818 |
+ |
{ |
| 819 |
+ |
const char *in_para; |
| 820 |
+ |
|
| 821 |
+ |
in_para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>"; |
| 822 |
+ |
|
| 823 |
+ |
ilog(LOG_TYPE_IRCD, "Received ERROR message from %s: %s", |
| 824 |
+ |
source_p->name, in_para); |
| 825 |
+ |
|
| 826 |
+ |
if (client_p == source_p) |
| 827 |
+ |
{ |
| 828 |
+ |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s -- %s", |
| 829 |
+ |
get_client_name(client_p, HIDE_IP), in_para); |
| 830 |
+ |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s -- %s", |
| 831 |
+ |
get_client_name(client_p, MASK_IP), in_para); |
| 832 |
+ |
} |
| 833 |
+ |
else |
| 834 |
+ |
{ |
| 835 |
+ |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s via %s -- %s", |
| 836 |
+ |
source_p->name, get_client_name(client_p, MASK_IP), in_para); |
| 837 |
+ |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s via %s -- %s", |
| 838 |
+ |
source_p->name, get_client_name(client_p, HIDE_IP), in_para); |
| 839 |
+ |
} |
| 840 |
+ |
|
| 841 |
+ |
if (MyClient(source_p)) |
| 842 |
+ |
exit_client(source_p, source_p, "ERROR"); |
| 843 |
+ |
} |