ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/include/parse.h
Revision: 9857
Committed: Fri Jan 1 04:43:22 2021 UTC (5 years, 6 months ago) by michael
Content type: text/x-chdr
File size: 3608 byte(s)
Log Message:
- Bump copyright years

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2021 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
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
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
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 /** See 2.3 Messages in RFC1459 */
56 enum { MAXPARA = 15 };
57
58 /*
59 * MessageHandler
60 */
61 typedef enum HandlerType
62 {
63 UNREGISTERED_HANDLER,
64 CLIENT_HANDLER,
65 SERVER_HANDLER,
66 ENCAP_HANDLER,
67 OPER_HANDLER,
68 LAST_HANDLER_TYPE
69 } HandlerType;
70
71 struct MessageHandler
72 {
73 bool end_grace_period; /**< Handler ends the flood grace period */
74 bool empty_last_arg; /**< Last argument is allowed to be empty / NUL */
75 unsigned int args_min; /**< At least this many args must be passed or an error will
76 be sent to the user before the m_func is even called */
77 unsigned int args_max; /**< Maximum permitted parameters. If reached, the rest
78 of the message will be put into this last parameter */
79 void (*handler)(struct Client *, int, char *[]);
80 };
81
82 /*
83 * Message table structure
84 */
85 struct Message
86 {
87 const char *cmd; /**< The actual command string */
88 void *extra;
89 unsigned int count; /**< Number of times command used */
90 unsigned int rcount; /**< Number of times command used by server */
91 unsigned int ecount; /**< Number of times command has been issued via ENCAP */
92 uintmax_t bytes; /**< Bytes received for this message */
93
94 /* handlers:
95 * UNREGISTERED, CLIENT, SERVER, ENCAP, OPER, LAST
96 */
97 struct MessageHandler handlers[LAST_HANDLER_TYPE];
98 };
99
100 extern void parse(struct Client *, char *, char *);
101 extern void mod_add_cmd(struct Message *);
102 extern void mod_del_cmd(struct Message *);
103 extern struct Message *find_command(const char *);
104 extern void report_messages(struct Client *);
105
106 /* generic handlers */
107 extern void m_ignore(struct Client *, int, char *[]);
108 extern void m_not_oper(struct Client *, int, char *[]);
109 extern void m_registered(struct Client *, int, char *[]);
110 extern void m_unregistered(struct Client *, int, char *[]);
111 #endif /* INCLUDED_parse_h */

Properties

Name Value
svn:eol-style native
svn:keywords Id