]> jfr.im git - solanum.git/blame - include/msg.h
refuse opers setting an invalidly long k-line reason
[solanum.git] / include / msg.h
CommitLineData
212380e3
AC
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
212380e3
AC
23 */
24
25#ifndef INCLUDED_msg_h
26#define INCLUDED_msg_h
27
9b8e9eb3 28#include "defaults.h"
b830b641 29#include "msgbuf.h"
212380e3
AC
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
4a84a763
AC
46/* struct MsgBuf* msgbuf_p - message buffer (including tags)
47 * struct Client* client_p - connection message originated from
212380e3 48 * struct Client* source_p - source of message, may be different from client_p
4a84a763
AC
49 * int parc - parameter count (from msgbuf_p)
50 * char* parv[] - parameter vector (from msgbuf_p)
212380e3 51 */
3c7d6fcc 52typedef void (*MessageHandler) (struct MsgBuf *, struct Client *, struct Client *, int, const char *[]);
212380e3
AC
53
54struct MessageEntry
55{
56 MessageHandler handler;
66769bc1 57 size_t min_para;
212380e3
AC
58};
59
60/* Message table structure */
61struct Message
62{
d48a5597 63 const char *cmd;
212380e3
AC
64 unsigned int count; /* number of times command used */
65 unsigned int rcount; /* number of times command used by server */
66 unsigned long bytes; /* bytes received for this message */
7baa37a9
AC
67 unsigned int flags;
68
212380e3 69 /* handlers:
b2ee72e4 70 * UNREGISTERED, CLIENT, RCLIENT, SERVER, ENCAP, OPER
212380e3
AC
71 */
72 struct MessageEntry handlers[LAST_HANDLER_TYPE];
73};
74
212380e3 75/* generic handlers */
3c7d6fcc
EM
76extern void m_ignore(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
77extern void m_not_oper(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
78extern void m_registered(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
79extern void m_unregistered(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
212380e3
AC
80
81#define mg_ignore { m_ignore, 0 }
82#define mg_not_oper { m_not_oper, 0 }
83#define mg_reg { m_registered, 0 }
84#define mg_unreg { m_unregistered, 0 }
85
86/*
87 * m_functions execute protocol messages on this server:
a5590329 88 * void m_func(struct MsgBuf *, struct Client* client_p, struct Client* source_p, int parc, char* parv[]);
212380e3
AC
89 *
90 * client_p is always NON-NULL, pointing to a *LOCAL* client
91 * structure (with an open socket connected!). This
92 * identifies the physical socket where the message
93 * originated (or which caused the m_function to be
94 * executed--some m_functions may call others...).
95 *
96 * source_p is the source of the message, defined by the
97 * prefix part of the message if present. If not
98 * or prefix not found, then source_p==client_p.
99 *
100 * (!IsServer(client_p)) => (client_p == source_p), because
101 * prefixes are taken *only* from servers...
102 *
103 * (IsServer(client_p))
104 * (source_p == client_p) => the message didn't
105 * have the prefix.
106 *
107 * (source_p != client_p && IsServer(source_p) means
108 * the prefix specified servername. (?)
109 *
110 * (source_p != client_p && !IsServer(source_p) means
111 * that message originated from a remote
112 * user (not local).
113 *
114 *
115 * combining
116 *
117 * (!IsServer(source_p)) means that, source_p can safely
118 * taken as defining the target structure of the
119 * message in this server.
120 *
121 * *Always* true (if 'parse' and others are working correct):
122 *
123 * 1) source_p->from == client_p (note: client_p->from == client_p)
124 *
125 * 2) MyConnect(source_p) <=> source_p == client_p (e.g. source_p
126 * *cannot* be a local connection, unless it's
127 * actually client_p!). [MyConnect(x) should probably
128 * be defined as (x == x->from) --msa ]
129 *
130 * parc number of variable parameter strings (if zero,
131 * parv is allowed to be NULL)
132 *
133 * parv a NULL terminated list of parameter pointers,
134 *
161f0409
JT
135 * parv[0], unused for historical reasons (formerly
136 * sender name)
212380e3
AC
137 * parv[1]...parv[parc-1]
138 * pointers to additional parameters
139 * parv[parc] == NULL, *always*
140 *
161f0409 141 * note: it is guaranteed that parv[1]..parv[parc-1] are all
212380e3
AC
142 * non-NULL pointers.
143 */
144
145#endif /* INCLUDED_msg_h */