]>
jfr.im git - solanum.git/blob - include/msg.h
2 * ircd-ratbox: A slightly useful ircd.
3 * msg.h: A header for the message handler structure.
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
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.
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.
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
24 * $Id: msg.h 6 2005-09-10 01:02:21Z nenolod $
27 #ifndef INCLUDED_msg_h
28 #define INCLUDED_msg_h
35 typedef enum HandlerType
47 /* struct Client* client_p - connection message originated from
48 * struct Client* source_p - source of message, may be different from client_p
49 * int parc - parameter count
50 * char* parv[] - parameter vector
52 typedef int (*MessageHandler
) (struct Client
*, struct Client
*, int, const char *[]);
56 MessageHandler handler
;
60 /* Message table structure */
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 */
67 unsigned int flags
; /* bit 0 set means that this command is allowed
68 * to be used only on the average of once per 2
72 * UNREGISTERED, CLIENT, RCLIENT, SERVER, OPER, LAST
74 struct MessageEntry handlers
[LAST_HANDLER_TYPE
];
77 #define MFLG_SLOW 0x01 /* executed roughly once per 2s */
78 #define MFLG_UNREG 0x02 /* available to unregistered clients */
82 /* generic handlers */
83 extern int m_ignore(struct Client
*, struct Client
*, int, const char **);
84 extern int m_not_oper(struct Client
*, struct Client
*, int, const char **);
85 extern int m_registered(struct Client
*, struct Client
*, int, const char **);
86 extern int m_unregistered(struct Client
*, struct Client
*, int, const char **);
88 #define mg_ignore { m_ignore, 0 }
89 #define mg_not_oper { m_not_oper, 0 }
90 #define mg_reg { m_registered, 0 }
91 #define mg_unreg { m_unregistered, 0 }
94 * m_functions execute protocol messages on this server:
95 * int m_func(struct Client* client_p, struct Client* source_p, int parc, char* parv[]);
97 * client_p is always NON-NULL, pointing to a *LOCAL* client
98 * structure (with an open socket connected!). This
99 * identifies the physical socket where the message
100 * originated (or which caused the m_function to be
101 * executed--some m_functions may call others...).
103 * source_p is the source of the message, defined by the
104 * prefix part of the message if present. If not
105 * or prefix not found, then source_p==client_p.
107 * (!IsServer(client_p)) => (client_p == source_p), because
108 * prefixes are taken *only* from servers...
110 * (IsServer(client_p))
111 * (source_p == client_p) => the message didn't
114 * (source_p != client_p && IsServer(source_p) means
115 * the prefix specified servername. (?)
117 * (source_p != client_p && !IsServer(source_p) means
118 * that message originated from a remote
124 * (!IsServer(source_p)) means that, source_p can safely
125 * taken as defining the target structure of the
126 * message in this server.
128 * *Always* true (if 'parse' and others are working correct):
130 * 1) source_p->from == client_p (note: client_p->from == client_p)
132 * 2) MyConnect(source_p) <=> source_p == client_p (e.g. source_p
133 * *cannot* be a local connection, unless it's
134 * actually client_p!). [MyConnect(x) should probably
135 * be defined as (x == x->from) --msa ]
137 * parc number of variable parameter strings (if zero,
138 * parv is allowed to be NULL)
140 * parv a NULL terminated list of parameter pointers,
142 * parv[0], sender (prefix string), if not present
143 * this points to an empty string.
144 * parv[1]...parv[parc-1]
145 * pointers to additional parameters
146 * parv[parc] == NULL, *always*
148 * note: it is guaranteed that parv[0]..parv[parc-1] are all
152 #endif /* INCLUDED_msg_h */