| 1 |
|
/* |
| 2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
< |
* parse.c: The message parser. |
| 2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
* |
| 4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
| 4 |
> |
* Copyright (c) 1997-2014 ircd-hybrid development team |
| 5 |
|
* |
| 6 |
|
* This program is free software; you can redistribute it and/or modify |
| 7 |
|
* it under the terms of the GNU General Public License as published by |
| 17 |
|
* along with this program; if not, write to the Free Software |
| 18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 19 |
|
* USA |
| 20 |
< |
* |
| 21 |
< |
* $Id$ |
| 20 |
> |
*/ |
| 21 |
> |
|
| 22 |
> |
/*! \file parse.c |
| 23 |
> |
* \brief The message parser. |
| 24 |
> |
* \version $Id$ |
| 25 |
|
*/ |
| 26 |
|
|
| 27 |
|
#include "stdinc.h" |
| 39 |
|
#include "s_user.h" |
| 40 |
|
#include "s_serv.h" |
| 41 |
|
|
| 42 |
+ |
|
| 43 |
|
/* |
| 44 |
|
* (based on orabidoo's parser code) |
| 45 |
|
* |
| 54 |
|
* 't' points -> [MessageTree *] 'r' -> [MessageTree *] -> 'i' |
| 55 |
|
* -> [MessageTree *] -> [MessageTree *] -> 'e' and matches |
| 56 |
|
* |
| 57 |
< |
* 'i' -> [MessageTree *] -> 'e' and matches |
| 57 |
> |
* 'i' -> [MessageTree *] -> 'e' and matches |
| 58 |
|
* |
| 59 |
|
* BUGS (Limitations!) |
| 60 |
|
* |
| 100 |
|
|
| 101 |
|
static struct MessageTree msg_tree; |
| 102 |
|
|
| 103 |
< |
/* |
| 101 |
< |
* NOTE: parse() should not be called recursively by other functions! |
| 102 |
< |
*/ |
| 103 |
< |
static char *sender; |
| 104 |
< |
static char *para[MAXPARA + 2]; /* <prefix> + <params> + NULL */ |
| 103 |
> |
static char *para[MAXPARA + 2]; /* <command> + <params> + NULL */ |
| 104 |
|
|
| 105 |
|
static int cancel_clients(struct Client *, struct Client *, char *); |
| 106 |
|
static void remove_unknown(struct Client *, char *, char *); |
| 139 |
|
* Copy the prefix to 'sender' assuming it terminates |
| 140 |
|
* with SPACE (or NULL, which is an error, though). |
| 141 |
|
*/ |
| 142 |
< |
sender = ++ch; |
| 142 |
> |
char *sender = ++ch; |
| 143 |
|
|
| 144 |
|
if ((s = strchr(ch, ' ')) != NULL) |
| 145 |
|
{ |
| 209 |
|
|
| 210 |
|
if ((msg_ptr = find_command(ch)) == NULL) |
| 211 |
|
{ |
| 212 |
< |
/* |
| 212 |
> |
/* |
| 213 |
|
* Note: Give error message *only* to recognized |
| 214 |
|
* persons. It's a nightmare situation to have |
| 215 |
|
* two programs sending "Unknown command"'s or |
| 247 |
|
|
| 248 |
|
/* Note initially true: s==NULL || *(s-1) == '\0' !! */ |
| 249 |
|
|
| 250 |
< |
para[parc] = from->name; |
| 250 |
> |
para[parc] = ch; |
| 251 |
|
|
| 252 |
|
if (s) |
| 253 |
|
{ |
| 316 |
|
if (!IsServer(client_p)) |
| 317 |
|
{ |
| 318 |
|
sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), me.name, |
| 319 |
< |
EmptyString(hpara[0]) ? "*" : hpara[0], mptr->cmd); |
| 319 |
> |
client_p->name[0] ? client_p->name : "*", mptr->cmd); |
| 320 |
|
} |
| 321 |
|
else |
| 322 |
|
{ |
| 715 |
|
!HasUMode(target_p, UMODE_OPER)) |
| 716 |
|
sendto_one(target_p, ":%s %s %s %s", me.name, numeric, target_p->name, parv[2]); |
| 717 |
|
else |
| 718 |
< |
sendto_one(target_p, ":%s %s %s %s", ID_or_name(source_p, target_p->from), |
| 719 |
< |
numeric, ID_or_name(target_p, target_p->from), parv[2]); |
| 718 |
> |
sendto_one(target_p, ":%s %s %s %s", ID_or_name(source_p, target_p), |
| 719 |
> |
numeric, ID_or_name(target_p, target_p), parv[2]); |
| 720 |
|
} |
| 721 |
|
else |
| 722 |
< |
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s %s %s %s", |
| 723 |
< |
source_p->name, numeric, chptr->chname, parv[2]); |
| 722 |
> |
sendto_channel_butone(source_p, source_p, chptr, 0, "%s %s %s", |
| 723 |
> |
numeric, chptr->chname, parv[2]); |
| 724 |
|
} |
| 725 |
|
|
| 726 |
|
/* m_not_oper() |
| 728 |
|
* output - |
| 729 |
|
* side effects - just returns a nastyogram to given user |
| 730 |
|
*/ |
| 731 |
< |
void |
| 731 |
> |
int |
| 732 |
|
m_not_oper(struct Client *client_p, struct Client *source_p, |
| 733 |
|
int parc, char *parv[]) |
| 734 |
|
{ |
| 735 |
|
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
| 736 |
|
me.name, source_p->name); |
| 737 |
+ |
return 0; |
| 738 |
|
} |
| 739 |
|
|
| 740 |
< |
void |
| 740 |
> |
int |
| 741 |
|
m_unregistered(struct Client *client_p, struct Client *source_p, |
| 742 |
|
int parc, char *parv[]) |
| 743 |
|
{ |
| 744 |
|
sendto_one(source_p, form_str(ERR_NOTREGISTERED), me.name, |
| 745 |
|
source_p->name[0] ? source_p->name : "*"); |
| 746 |
+ |
return 0; |
| 747 |
|
} |
| 748 |
|
|
| 749 |
< |
void |
| 749 |
> |
int |
| 750 |
|
m_registered(struct Client *client_p, struct Client *source_p, |
| 751 |
|
int parc, char *parv[]) |
| 752 |
|
{ |
| 753 |
|
sendto_one(source_p, form_str(ERR_ALREADYREGISTRED), |
| 754 |
|
me.name, source_p->name); |
| 755 |
+ |
return 0; |
| 756 |
|
} |
| 757 |
|
|
| 758 |
< |
void |
| 758 |
> |
int |
| 759 |
|
m_ignore(struct Client *client_p, struct Client *source_p, |
| 760 |
|
int parc, char *parv[]) |
| 761 |
|
{ |
| 762 |
< |
return; |
| 762 |
> |
return 0; |
| 763 |
|
} |