| 1 |
|
/* |
| 2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
* |
| 4 |
< |
* Copyright (c) 1997-2014 ircd-hybrid development team |
| 4 |
> |
* Copyright (c) 1997-2020 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 |
| 15 |
|
* |
| 16 |
|
* You should have received a copy of the GNU General Public License |
| 17 |
|
* along with this program; if not, write to the Free Software |
| 18 |
< |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 18 |
> |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
|
* USA |
| 20 |
|
*/ |
| 21 |
|
|
| 62 |
|
SERVER_HANDLER, |
| 63 |
|
ENCAP_HANDLER, |
| 64 |
|
OPER_HANDLER, |
| 65 |
– |
DUMMY_HANDLER, |
| 65 |
|
LAST_HANDLER_TYPE |
| 66 |
|
} HandlerType; |
| 67 |
|
|
| 68 |
< |
typedef int (*MessageHandler)(struct Client *, int, char *[]); |
| 68 |
> |
struct MessageHandler |
| 69 |
> |
{ |
| 70 |
> |
bool empty_last_arg; /**< Last argument is allowed to be empty / NUL */ |
| 71 |
> |
unsigned int args_min; /**< At least this many args must be passed or an error will |
| 72 |
> |
be sent to the user before the m_func is even called */ |
| 73 |
> |
unsigned int args_max; /**< Maximum permitted parameters. If reached, the rest |
| 74 |
> |
of the message will be put into this last parameter */ |
| 75 |
> |
void (*handler)(struct Client *, int, char *[]); |
| 76 |
> |
}; |
| 77 |
|
|
| 78 |
|
/* |
| 79 |
|
* Message table structure |
| 80 |
|
*/ |
| 81 |
|
struct Message |
| 82 |
|
{ |
| 83 |
< |
const char *cmd; |
| 83 |
> |
const char *cmd; /**< The actual command string */ |
| 84 |
|
void *extra; |
| 85 |
< |
unsigned int count; /* number of times command used */ |
| 86 |
< |
unsigned int rcount; /* number of times command used by server */ |
| 87 |
< |
unsigned int args_min; /* at least this many args must be passed |
| 88 |
< |
* or an error will be sent to the user |
| 89 |
< |
* before the m_func is even called |
| 83 |
< |
*/ |
| 84 |
< |
unsigned int args_max; /* maximum permitted parameters */ |
| 85 |
< |
unsigned int flags; /* bit 0 set means that this command is allowed |
| 86 |
< |
* to be used only on the average of once per 2 |
| 87 |
< |
* seconds -SRB |
| 88 |
< |
*/ |
| 89 |
< |
uint64_t bytes; /* bytes received for this message */ |
| 85 |
> |
unsigned int count; /**< Number of times command used */ |
| 86 |
> |
unsigned int rcount; /**< Number of times command used by server */ |
| 87 |
> |
unsigned int ecount; /**< Number of times command has been issued via ENCAP */ |
| 88 |
> |
unsigned int flags; |
| 89 |
> |
uintmax_t bytes; /**< Bytes received for this message */ |
| 90 |
|
|
| 91 |
|
/* handlers: |
| 92 |
< |
* UNREGISTERED, CLIENT, SERVER, ENCAP, OPER, DUMMY, LAST |
| 92 |
> |
* UNREGISTERED, CLIENT, SERVER, ENCAP, OPER, LAST |
| 93 |
|
*/ |
| 94 |
< |
MessageHandler handlers[LAST_HANDLER_TYPE]; |
| 94 |
> |
struct MessageHandler handlers[LAST_HANDLER_TYPE]; |
| 95 |
|
}; |
| 96 |
|
|
| 97 |
< |
/* |
| 98 |
< |
* Constants |
| 99 |
< |
*/ |
| 100 |
< |
#define MFLG_SLOW 0x001 /* Command can be executed roughly |
| 101 |
< |
* once per 2 seconds. |
| 102 |
< |
*/ |
| 103 |
< |
#define MFLG_EXTRA 0x002 |
| 104 |
< |
#define MAXPARA 15 |
| 97 |
> |
/** See 2.3 Messages in RFC1459 */ |
| 98 |
> |
enum { MAXPARA = 15 }; |
| 99 |
> |
|
| 100 |
> |
enum |
| 101 |
> |
{ |
| 102 |
> |
MFLG_EXTRA = 1 << 0, |
| 103 |
> |
MFLG_ENDGRACE = 1 << 1 |
| 104 |
> |
}; |
| 105 |
|
|
| 106 |
|
extern void parse(struct Client *, char *, char *); |
| 107 |
|
extern void mod_add_cmd(struct Message *); |
| 110 |
|
extern void report_messages(struct Client *); |
| 111 |
|
|
| 112 |
|
/* generic handlers */ |
| 113 |
< |
extern int m_ignore(struct Client *, int, char *[]); |
| 114 |
< |
extern int m_not_oper(struct Client *, int, char *[]); |
| 115 |
< |
extern int m_registered(struct Client *, int, char *[]); |
| 116 |
< |
extern int m_unregistered(struct Client *, int, char *[]); |
| 117 |
< |
#endif /* INCLUDED_parse_h */ |
| 113 |
> |
extern void m_ignore(struct Client *, int, char *[]); |
| 114 |
> |
extern void m_not_oper(struct Client *, int, char *[]); |
| 115 |
> |
extern void m_registered(struct Client *, int, char *[]); |
| 116 |
> |
extern void m_unregistered(struct Client *, int, char *[]); |
| 117 |
> |
#endif /* INCLUDED_parse_h */ |