]> jfr.im git - irc/rqf/shadowircd.git/blame - include/msg.h
hunt_server: Disallow wildcarded nicknames.
[irc/rqf/shadowircd.git] / include / msg.h
CommitLineData
212380e3 1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * msg.h: A header for the message handler structure.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2004 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
212380e3 24 */
25
26#ifndef INCLUDED_msg_h
27#define INCLUDED_msg_h
28
29#include "config.h"
30
31struct Client;
32
33/* MessageHandler */
34typedef enum HandlerType
35{
36 UNREGISTERED_HANDLER,
37 CLIENT_HANDLER,
38 RCLIENT_HANDLER,
39 SERVER_HANDLER,
40 ENCAP_HANDLER,
41 OPER_HANDLER,
42 LAST_HANDLER_TYPE
43}
44HandlerType;
45
46/* struct Client* client_p - connection message originated from
47 * struct Client* source_p - source of message, may be different from client_p
48 * int parc - parameter count
49 * char* parv[] - parameter vector
50 */
51typedef int (*MessageHandler) (struct Client *, struct Client *, int, const char *[]);
52
53struct MessageEntry
54{
55 MessageHandler handler;
56 int min_para;
57};
58
59/* Message table structure */
60struct Message
61{
b4cd337c 62 const char *cmd;
212380e3 63 unsigned int count; /* number of times command used */
64 unsigned int rcount; /* number of times command used by server */
65 unsigned long bytes; /* bytes received for this message */
66 unsigned int flags; /* bit 0 set means that this command is allowed
67 * to be used only on the average of once per 2
68 * seconds -SRB
69 */
70 /* handlers:
71 * UNREGISTERED, CLIENT, RCLIENT, SERVER, OPER, LAST
72 */
73 struct MessageEntry handlers[LAST_HANDLER_TYPE];
74};
75
76#define MFLG_SLOW 0x01 /* executed roughly once per 2s */
77#define MFLG_UNREG 0x02 /* available to unregistered clients */
78
79#define MAXPARA 15
80
81/* generic handlers */
82extern int m_ignore(struct Client *, struct Client *, int, const char **);
83extern int m_not_oper(struct Client *, struct Client *, int, const char **);
84extern int m_registered(struct Client *, struct Client *, int, const char **);
85extern int m_unregistered(struct Client *, struct Client *, int, const char **);
86
87#define mg_ignore { m_ignore, 0 }
88#define mg_not_oper { m_not_oper, 0 }
89#define mg_reg { m_registered, 0 }
90#define mg_unreg { m_unregistered, 0 }
91
92/*
93 * m_functions execute protocol messages on this server:
94 * int m_func(struct Client* client_p, struct Client* source_p, int parc, char* parv[]);
95 *
96 * client_p is always NON-NULL, pointing to a *LOCAL* client
97 * structure (with an open socket connected!). This
98 * identifies the physical socket where the message
99 * originated (or which caused the m_function to be
100 * executed--some m_functions may call others...).
101 *
102 * source_p is the source of the message, defined by the
103 * prefix part of the message if present. If not
104 * or prefix not found, then source_p==client_p.
105 *
106 * (!IsServer(client_p)) => (client_p == source_p), because
107 * prefixes are taken *only* from servers...
108 *
109 * (IsServer(client_p))
110 * (source_p == client_p) => the message didn't
111 * have the prefix.
112 *
113 * (source_p != client_p && IsServer(source_p) means
114 * the prefix specified servername. (?)
115 *
116 * (source_p != client_p && !IsServer(source_p) means
117 * that message originated from a remote
118 * user (not local).
119 *
120 *
121 * combining
122 *
123 * (!IsServer(source_p)) means that, source_p can safely
124 * taken as defining the target structure of the
125 * message in this server.
126 *
127 * *Always* true (if 'parse' and others are working correct):
128 *
129 * 1) source_p->from == client_p (note: client_p->from == client_p)
130 *
131 * 2) MyConnect(source_p) <=> source_p == client_p (e.g. source_p
132 * *cannot* be a local connection, unless it's
133 * actually client_p!). [MyConnect(x) should probably
134 * be defined as (x == x->from) --msa ]
135 *
136 * parc number of variable parameter strings (if zero,
137 * parv is allowed to be NULL)
138 *
139 * parv a NULL terminated list of parameter pointers,
140 *
ac408af6
JT
141 * parv[0], unused for historical reasons (formerly
142 * sender name)
212380e3 143 * parv[1]...parv[parc-1]
144 * pointers to additional parameters
145 * parv[parc] == NULL, *always*
146 *
ac408af6 147 * note: it is guaranteed that parv[1]..parv[parc-1] are all
212380e3 148 * non-NULL pointers.
149 */
150
151#endif /* INCLUDED_msg_h */