ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/include/parse.h
Revision: 1361
Committed: Sun Apr 22 19:01:51 2012 UTC (13 years, 4 months ago) by michael
Content type: text/x-chdr
Original Path: ircd-hybrid-8/include/parse.h
File size: 6166 byte(s)
Log Message:
- remove clear_tree_parse()

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * parse.h: A header for the message parser.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #ifndef INCLUDED_parse_h
26     #define INCLUDED_parse_h
27    
28     struct Client;
29    
30 michael 1243
31     /*
32     * m_functions execute protocol messages on this server:
33     * int m_func(struct Client* client_p, struct Client* source_p, int parc, char* parv[]);
34     *
35     * client_p is always NON-NULL, pointing to a *LOCAL* client
36     * structure (with an open socket connected!). This
37     * identifies the physical socket where the message
38     * originated (or which caused the m_function to be
39     * executed--some m_functions may call others...).
40     *
41     * source_p is the source of the message, defined by the
42     * prefix part of the message if present. If not
43     * or prefix not found, then source_p==client_p.
44     *
45     * (!IsServer(client_p)) => (client_p == source_p), because
46     * prefixes are taken *only* from servers...
47     *
48     * (IsServer(client_p))
49     * (source_p == client_p) => the message didn't
50     * have the prefix.
51     *
52     * (source_p != client_p && IsServer(source_p) means
53     * the prefix specified servername. (?)
54     *
55     * (source_p != client_p && !IsServer(source_p) means
56     * that message originated from a remote
57     * user (not local).
58     *
59     *
60     * combining
61     *
62     * (!IsServer(source_p)) means that, source_p can safely
63     * taken as defining the target structure of the
64     * message in this server.
65     *
66     * *Always* true (if 'parse' and others are working correct):
67     *
68     * 1) source_p->from == client_p (note: client_p->from == client_p)
69     *
70     * 2) MyConnect(source_p) <=> source_p == client_p (e.g. source_p
71     * *cannot* be a local connection, unless it's
72     * actually client_p!). [MyConnect(x) should probably
73     * be defined as (x == x->from) --msa ]
74     *
75     * parc number of variable parameter strings (if zero,
76     * parv is allowed to be NULL)
77     *
78     * parv a NULL terminated list of parameter pointers,
79     *
80     * parv[0], sender (prefix string), if not present
81     * this points to an empty string.
82     * parv[1]...parv[parc-1]
83     * pointers to additional parameters
84     * parv[parc] == NULL, *always*
85     *
86     * note: it is guaranteed that parv[0]..parv[parc-1] are all
87     * non-NULL pointers.
88     */
89    
90     /*
91     * MessageHandler
92     */
93     typedef enum HandlerType {
94     UNREGISTERED_HANDLER,
95     CLIENT_HANDLER,
96     SERVER_HANDLER,
97     ENCAP_HANDLER,
98     OPER_HANDLER,
99     DUMMY_HANDLER,
100     LAST_HANDLER_TYPE
101     } HandlerType;
102    
103     /*
104     * MessageHandler function
105     * Params:
106     * struct Client* client_p - connection message originated from
107     * struct Client* source_p - source of message, may be different from client_p
108     * int parc - parameter count
109     * char* parv[] - parameter vector
110     */
111     typedef void (*MessageHandler)(struct Client *, struct Client *, int, char *[]);
112    
113     /*
114     * Message table structure
115     */
116     struct Message
117     {
118     const char *cmd;
119     unsigned int count; /* number of times command used */
120     unsigned int rcount; /* number of times command used by server */
121     unsigned int args_min; /* at least this many args must be passed
122     * or an error will be sent to the user
123     * before the m_func is even called
124     */
125     unsigned int args_max; /* maximum permitted parameters */
126     unsigned int flags; /* bit 0 set means that this command is allowed
127     * to be used only on the average of once per 2
128     * seconds -SRB
129     */
130     uint64_t bytes; /* bytes received for this message */
131    
132     /*
133     * client_p = Connected client ptr
134     * source_p = Source client ptr
135     * parc = parameter count
136     * parv = parameter variable array
137     */
138     /* handlers:
139     * UNREGISTERED, CLIENT, SERVER, ENCAP, OPER, DUMMY, LAST
140     */
141     MessageHandler handlers[LAST_HANDLER_TYPE];
142     };
143    
144     /*
145     * Constants
146     */
147     #define MFLG_SLOW 0x001 /* Command can be executed roughly
148     * once per 2 seconds.
149     */
150     #define MFLG_UNREG 0x002 /* Command available to unregistered
151     * clients.
152     */
153    
154     #define MAXPARA 15
155    
156 adx 30 extern void parse(struct Client *, char *, char *);
157     extern void mod_add_cmd(struct Message *);
158     extern void mod_del_cmd(struct Message *);
159     extern struct Message *find_command(const char *);
160     extern void report_messages(struct Client *);
161    
162 michael 1243 /* generic handlers */
163     extern void rfc1459_command_send_error(struct Client *, struct Client *,int, char *[]);
164     extern void m_ignore(struct Client *, struct Client *, int, char *[]);
165     extern void m_not_oper(struct Client *, struct Client *, int, char *[]);
166     extern void m_registered(struct Client *, struct Client *, int, char *[]);
167     extern void m_unregistered(struct Client *, struct Client *, int, char *[]);
168    
169 adx 30 #endif /* INCLUDED_parse_h */

Properties

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