1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* parse.h: A header for 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: parse.h,v 7.20 2004/02/03 03:59:54 michael Exp $ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file parse.h |
23 |
> |
* \brief A header for the message parser. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#ifndef INCLUDED_parse_h |
28 |
|
#define INCLUDED_parse_h |
29 |
|
|
28 |
– |
struct Message; |
30 |
|
struct Client; |
31 |
|
|
32 |
+ |
|
33 |
+ |
/* |
34 |
+ |
* m_functions execute protocol messages on this server: |
35 |
+ |
* int m_func(struct Client *source_p, int parc, char *parv[]); |
36 |
+ |
* |
37 |
+ |
* 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 |
+ |
* |
42 |
+ |
* parc number of variable parameter strings (if zero, |
43 |
+ |
* parv is allowed to be NULL) |
44 |
+ |
* |
45 |
+ |
* parv a NULL terminated list of parameter pointers, |
46 |
+ |
* |
47 |
+ |
* parv[0] command |
48 |
+ |
* parv[1]...parv[parc - 1] pointers to additional parameters |
49 |
+ |
* parv[parc] == NULL, *always* |
50 |
+ |
* |
51 |
+ |
* note: it is guaranteed that parv[0]..parv[parc - 1] are all |
52 |
+ |
* non-NULL pointers. |
53 |
+ |
*/ |
54 |
+ |
|
55 |
+ |
/* |
56 |
+ |
* MessageHandler |
57 |
+ |
*/ |
58 |
+ |
typedef enum HandlerType |
59 |
+ |
{ |
60 |
+ |
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 |
+ |
typedef int (*MessageHandler)(struct Client *, int, char *[]); |
70 |
+ |
|
71 |
+ |
/* |
72 |
+ |
* Message table structure |
73 |
+ |
*/ |
74 |
+ |
struct Message |
75 |
+ |
{ |
76 |
+ |
const char *cmd; |
77 |
+ |
void *extra; |
78 |
+ |
unsigned int count; /* number of times command used */ |
79 |
+ |
unsigned int rcount; /* number of times command used by server */ |
80 |
+ |
unsigned int args_min; /* at least this many args must be passed |
81 |
+ |
* or an error will be sent to the user |
82 |
+ |
* 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 */ |
90 |
+ |
|
91 |
+ |
/* handlers: |
92 |
+ |
* UNREGISTERED, CLIENT, SERVER, ENCAP, OPER, DUMMY, LAST |
93 |
+ |
*/ |
94 |
+ |
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 |
105 |
+ |
|
106 |
|
extern void parse(struct Client *, char *, char *); |
32 |
– |
extern void clear_tree_parse(void); |
107 |
|
extern void mod_add_cmd(struct Message *); |
108 |
|
extern void mod_del_cmd(struct Message *); |
109 |
|
extern struct Message *find_command(const char *); |
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 */ |