| 1 |
adx |
30 |
/* |
| 2 |
michael |
2865 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
adx |
30 |
* |
| 4 |
michael |
2865 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
| 5 |
adx |
30 |
* |
| 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 |
| 8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
|
|
* (at your option) any later version. |
| 10 |
|
|
* |
| 11 |
|
|
* This program is distributed in the hope that it will be useful, |
| 12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
|
|
* GNU General Public License for more details. |
| 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 |
| 19 |
|
|
* USA |
| 20 |
|
|
*/ |
| 21 |
|
|
|
| 22 |
michael |
2865 |
/*! \file parse.h |
| 23 |
|
|
* \brief A header for the message parser. |
| 24 |
|
|
* \version $Id$ |
| 25 |
|
|
*/ |
| 26 |
|
|
|
| 27 |
adx |
30 |
#ifndef INCLUDED_parse_h |
| 28 |
|
|
#define INCLUDED_parse_h |
| 29 |
|
|
|
| 30 |
|
|
struct Client; |
| 31 |
|
|
|
| 32 |
michael |
1243 |
|
| 33 |
|
|
/* |
| 34 |
|
|
* m_functions execute protocol messages on this server: |
| 35 |
michael |
3159 |
* int m_func(struct Client *source_p, int parc, char *parv[]); |
| 36 |
michael |
1243 |
* |
| 37 |
michael |
3159 |
* source_p is the source of the message, defined by the |
| 38 |
|
|
* prefix part of the message if present. If not |
| 39 |
|
|
* then it is the client of the physical connection. |
| 40 |
|
|
* Note that prefixes are only taken from servers. |
| 41 |
michael |
1243 |
* |
| 42 |
michael |
3159 |
* parc number of variable parameter strings (if zero, |
| 43 |
|
|
* parv is allowed to be NULL) |
| 44 |
michael |
1243 |
* |
| 45 |
michael |
3159 |
* parv a NULL terminated list of parameter pointers, |
| 46 |
michael |
1243 |
* |
| 47 |
michael |
3159 |
* parv[0] command |
| 48 |
|
|
* parv[1]...parv[parc - 1] pointers to additional parameters |
| 49 |
|
|
* parv[parc] == NULL, *always* |
| 50 |
michael |
1243 |
* |
| 51 |
michael |
3159 |
* note: it is guaranteed that parv[0]..parv[parc - 1] are all |
| 52 |
|
|
* non-NULL pointers. |
| 53 |
michael |
1243 |
*/ |
| 54 |
|
|
|
| 55 |
|
|
/* |
| 56 |
|
|
* MessageHandler |
| 57 |
|
|
*/ |
| 58 |
michael |
3159 |
typedef enum HandlerType |
| 59 |
|
|
{ |
| 60 |
michael |
1243 |
UNREGISTERED_HANDLER, |
| 61 |
|
|
CLIENT_HANDLER, |
| 62 |
|
|
SERVER_HANDLER, |
| 63 |
|
|
ENCAP_HANDLER, |
| 64 |
|
|
OPER_HANDLER, |
| 65 |
|
|
DUMMY_HANDLER, |
| 66 |
|
|
LAST_HANDLER_TYPE |
| 67 |
|
|
} HandlerType; |
| 68 |
|
|
|
| 69 |
|
|
/* |
| 70 |
|
|
* MessageHandler function |
| 71 |
|
|
* Params: |
| 72 |
|
|
* struct Client* source_p - source of message, may be different from client_p |
| 73 |
|
|
* int parc - parameter count |
| 74 |
|
|
* char* parv[] - parameter vector |
| 75 |
|
|
*/ |
| 76 |
michael |
3156 |
typedef int (*MessageHandler)(struct Client *, int, char *[]); |
| 77 |
michael |
1243 |
|
| 78 |
michael |
2865 |
/* |
| 79 |
|
|
* Message table structure |
| 80 |
michael |
1243 |
*/ |
| 81 |
|
|
struct Message |
| 82 |
|
|
{ |
| 83 |
|
|
const char *cmd; |
| 84 |
|
|
unsigned int count; /* number of times command used */ |
| 85 |
|
|
unsigned int rcount; /* number of times command used by server */ |
| 86 |
|
|
unsigned int args_min; /* at least this many args must be passed |
| 87 |
michael |
2865 |
* or an error will be sent to the user |
| 88 |
|
|
* before the m_func is even called |
| 89 |
michael |
1243 |
*/ |
| 90 |
|
|
unsigned int args_max; /* maximum permitted parameters */ |
| 91 |
|
|
unsigned int flags; /* bit 0 set means that this command is allowed |
| 92 |
|
|
* to be used only on the average of once per 2 |
| 93 |
|
|
* seconds -SRB |
| 94 |
|
|
*/ |
| 95 |
|
|
uint64_t bytes; /* bytes received for this message */ |
| 96 |
|
|
|
| 97 |
|
|
/* handlers: |
| 98 |
|
|
* UNREGISTERED, CLIENT, SERVER, ENCAP, OPER, DUMMY, LAST |
| 99 |
|
|
*/ |
| 100 |
|
|
MessageHandler handlers[LAST_HANDLER_TYPE]; |
| 101 |
|
|
}; |
| 102 |
|
|
|
| 103 |
|
|
/* |
| 104 |
|
|
* Constants |
| 105 |
|
|
*/ |
| 106 |
|
|
#define MFLG_SLOW 0x001 /* Command can be executed roughly |
| 107 |
michael |
2865 |
* once per 2 seconds. |
| 108 |
michael |
1243 |
*/ |
| 109 |
|
|
#define MAXPARA 15 |
| 110 |
|
|
|
| 111 |
adx |
30 |
extern void parse(struct Client *, char *, char *); |
| 112 |
|
|
extern void mod_add_cmd(struct Message *); |
| 113 |
|
|
extern void mod_del_cmd(struct Message *); |
| 114 |
|
|
extern struct Message *find_command(const char *); |
| 115 |
|
|
extern void report_messages(struct Client *); |
| 116 |
|
|
|
| 117 |
michael |
1243 |
/* generic handlers */ |
| 118 |
michael |
3156 |
extern int m_ignore(struct Client *, int, char *[]); |
| 119 |
|
|
extern int m_not_oper(struct Client *, int, char *[]); |
| 120 |
|
|
extern int m_registered(struct Client *, int, char *[]); |
| 121 |
|
|
extern int m_unregistered(struct Client *, int, char *[]); |
| 122 |
adx |
30 |
#endif /* INCLUDED_parse_h */ |