2004-05-09 Michael Poole <mdpoole@troilus.org>
[ircu2.10.12-pk.git] / include / msg.h
1 /*
2  * IRC - Internet Relay Chat, include/msg.h
3  * Copyright (C) 1990 Jarkko Oikarinen and
4  *                    University of Oulu, Computing Center
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 1, or (at your option)
9  * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  * $Id$
21  */
22 #ifndef INCLUDED_msg_h
23 #define INCLUDED_msg_h
24 #ifndef INCLUDED_ircd_handler_h
25 #include "ircd_handler.h"
26 #endif
27
28 struct Client;
29
30 /*
31  * General defines
32  */
33
34 #define MAXPARA    15
35
36 /*-----------------------------------------------------------------------------
37  * Macros
38  */
39
40 /*
41  * Tokenization:
42  * Each command must have a TOK_COMMAND and MSG_COMMAND definition.
43  * If you don't want one or the other, make them the same.
44  * Also each command has a "msgclass" used for debugging purposes.
45  */
46
47 /* *INDENT-OFF* */
48
49 #define MSG_PRIVATE             "PRIVMSG"       /* PRIV */
50 #define TOK_PRIVATE             "P"
51 #define CMD_PRIVATE             MSG_PRIVATE, TOK_PRIVATE
52
53 #define MSG_WHO                 "WHO"           /* WHO  -> WHOC */
54 #define TOK_WHO                 "H"
55 #define CMD_WHO                 MSG_WHO, TOK_WHO
56
57 #define MSG_WHOIS               "WHOIS"         /* WHOI */
58 #define TOK_WHOIS               "W"
59 #define CMD_WHOIS               MSG_WHOIS, TOK_WHOIS
60
61 #define MSG_WHOWAS              "WHOWAS"        /* WHOW */
62 #define TOK_WHOWAS              "X"
63 #define CMD_WHOWAS              MSG_WHOWAS, TOK_WHOWAS
64
65 #define MSG_USER                "USER"          /* USER */
66 #define TOK_USER                "USER"
67 #define CMD_USER                MSG_USER, TOK_USER
68
69 #define MSG_NICK                "NICK"          /* NICK */
70 #define TOK_NICK                "N"
71 #define CMD_NICK                MSG_NICK, TOK_NICK
72
73 #define MSG_SERVER              "SERVER"        /* SERV */
74 #define TOK_SERVER              "S"
75 #define CMD_SERVER              MSG_SERVER, TOK_SERVER
76
77 #define MSG_LIST                "LIST"          /* LIST */
78 #define TOK_LIST                "LIST"
79 #define CMD_LIST                MSG_LIST, TOK_LIST
80
81 #define MSG_TOPIC               "TOPIC"         /* TOPI */
82 #define TOK_TOPIC               "T"
83 #define CMD_TOPIC               MSG_TOPIC, TOK_TOPIC
84
85 #define MSG_INVITE              "INVITE"        /* INVI */
86 #define TOK_INVITE              "I"
87 #define CMD_INVITE              MSG_INVITE, TOK_INVITE
88
89 #define MSG_VERSION             "VERSION"       /* VERS */
90 #define TOK_VERSION             "V"
91 #define CMD_VERSION             MSG_VERSION, TOK_VERSION
92
93 #define MSG_QUIT                "QUIT"          /* QUIT */
94 #define TOK_QUIT                "Q"
95 #define CMD_QUIT                MSG_QUIT, TOK_QUIT
96
97 #define MSG_SQUIT               "SQUIT"         /* SQUI */
98 #define TOK_SQUIT               "SQ"
99 #define CMD_SQUIT               MSG_SQUIT, TOK_SQUIT
100
101 #define MSG_KILL                "KILL"          /* KILL */
102 #define TOK_KILL                "D"
103 #define CMD_KILL                MSG_KILL, TOK_KILL
104
105 #define MSG_INFO                "INFO"          /* INFO */
106 #define TOK_INFO                "F"
107 #define CMD_INFO                MSG_INFO, TOK_INFO
108
109 #define MSG_LINKS               "LINKS"         /* LINK */
110 #define TOK_LINKS               "LI"
111 #define CMD_LINKS               MSG_LINKS, TOK_LINKS
112
113 #define MSG_STATS               "STATS"         /* STAT */
114 #define TOK_STATS               "R"
115 #define CMD_STATS               MSG_STATS, TOK_STATS
116
117 #define MSG_HELP                "HELP"          /* HELP */
118 #define TOK_HELP                "HELP"
119 #define CMD_HELP                MSG_HELP, TOK_HELP
120
121 #define MSG_ERROR               "ERROR"         /* ERRO */
122 #define TOK_ERROR               "Y"
123 #define CMD_ERROR               MSG_ERROR, TOK_ERROR
124
125 #define MSG_AWAY                "AWAY"          /* AWAY */
126 #define TOK_AWAY                "A"
127 #define CMD_AWAY                MSG_AWAY, TOK_AWAY
128
129 #define MSG_CONNECT             "CONNECT"       /* CONN */
130 #define TOK_CONNECT             "CO"
131 #define CMD_CONNECT             MSG_CONNECT, TOK_CONNECT
132
133 #define MSG_MAP                 "MAP"           /* MAP  */
134 #define TOK_MAP                 "MAP"
135 #define CMD_MAP                 MSG_MAP, TOK_MAP
136
137 #define MSG_PING                "PING"          /* PING */
138 #define TOK_PING                "G"
139 #define CMD_PING                MSG_PING, TOK_PING
140
141 #define MSG_PONG                "PONG"          /* PONG */
142 #define TOK_PONG                "Z"
143 #define CMD_PONG                MSG_PONG, TOK_PONG
144
145 #define MSG_OPER                "OPER"          /* OPER */
146 #define TOK_OPER                "OPER"
147 #define CMD_OPER                MSG_OPER, TOK_OPER
148
149 #define MSG_PASS                "PASS"          /* PASS */
150 #define TOK_PASS                "PA"
151 #define CMD_PASS                MSG_PASS, TOK_PASS
152
153 #define MSG_WALLOPS             "WALLOPS"       /* WALL */
154 #define TOK_WALLOPS             "WA"
155 #define CMD_WALLOPS             MSG_WALLOPS, TOK_WALLOPS
156
157 #define MSG_WALLUSERS           "WALLUSERS"     /* WALL */
158 #define TOK_WALLUSERS           "WU"
159 #define CMD_WALLUSERS           MSG_WALLUSERS, TOK_WALLUSERS
160
161 #define MSG_DESYNCH             "DESYNCH"       /* DESY */
162 #define TOK_DESYNCH             "DS"
163 #define CMD_DESYNCH             MSG_DESYNCH, TOK_DESYNCH
164
165 #define MSG_TIME                "TIME"          /* TIME */
166 #define TOK_TIME                "TI"
167 #define CMD_TIME                MSG_TIME, TOK_TIME
168
169 #define MSG_SETTIME             "SETTIME"       /* SETT */
170 #define TOK_SETTIME             "SE"
171 #define CMD_SETTIME             MSG_SETTIME, TOK_SETTIME
172
173 #define MSG_RPING               "RPING"         /* RPIN */
174 #define TOK_RPING               "RI"
175 #define CMD_RPING               MSG_RPING, TOK_RPING
176
177 #define MSG_RPONG               "RPONG"         /* RPON */
178 #define TOK_RPONG               "RO"
179 #define CMD_RPONG               MSG_RPONG, TOK_RPONG
180
181 #define MSG_NAMES               "NAMES"         /* NAME */
182 #define TOK_NAMES               "E"
183 #define CMD_NAMES               MSG_NAMES, TOK_NAMES
184
185 #define MSG_ADMIN               "ADMIN"         /* ADMI */
186 #define TOK_ADMIN               "AD"
187 #define CMD_ADMIN               MSG_ADMIN, TOK_ADMIN
188
189 #define MSG_TRACE               "TRACE"         /* TRAC */
190 #define TOK_TRACE               "TR"
191 #define CMD_TRACE               MSG_TRACE, TOK_TRACE
192
193 #define MSG_NOTICE              "NOTICE"        /* NOTI */
194 #define TOK_NOTICE              "O"
195 #define CMD_NOTICE              MSG_NOTICE, TOK_NOTICE
196
197 #define MSG_WALLCHOPS           "WALLCHOPS"     /* WC */
198 #define TOK_WALLCHOPS           "WC"
199 #define CMD_WALLCHOPS           MSG_WALLCHOPS, TOK_WALLCHOPS
200
201 #define MSG_WALLVOICES           "WALLVOICES"     /* WV */
202 #define TOK_WALLVOICES           "WV"
203 #define CMD_WALLVOICES          MSG_WALLVOICES, TOK_WALLVOICES
204
205 #define MSG_CPRIVMSG            "CPRIVMSG"      /* CPRI */
206 #define TOK_CPRIVMSG            "CP"
207 #define CMD_CPRIVMSG            MSG_CPRIVMSG, TOK_CPRIVMSG
208
209 #define MSG_CNOTICE             "CNOTICE"       /* CNOT */
210 #define TOK_CNOTICE             "CN"
211 #define CMD_CNOTICE             MSG_CNOTICE, TOK_CNOTICE
212
213 #define MSG_JOIN                "JOIN"          /* JOIN */
214 #define TOK_JOIN                "J"
215 #define CMD_JOIN                MSG_JOIN, TOK_JOIN
216
217 #define MSG_PART                "PART"          /* PART */
218 #define TOK_PART                "L"
219 #define CMD_PART                MSG_PART, TOK_PART
220
221 #define MSG_LUSERS              "LUSERS"        /* LUSE */
222 #define TOK_LUSERS              "LU"
223 #define CMD_LUSERS              MSG_LUSERS, TOK_LUSERS
224
225 #define MSG_MOTD                "MOTD"          /* MOTD */
226 #define TOK_MOTD                "MO"
227 #define CMD_MOTD                MSG_MOTD, TOK_MOTD
228
229 #define MSG_MODE                "MODE"          /* MODE */
230 #define TOK_MODE                "M"
231 #define CMD_MODE                MSG_MODE, TOK_MODE
232
233 #define MSG_KICK                "KICK"          /* KICK */
234 #define TOK_KICK                "K"
235 #define CMD_KICK                MSG_KICK, TOK_KICK
236
237 #define MSG_USERHOST            "USERHOST"      /* USER -> USRH */
238 #define TOK_USERHOST            "USERHOST"
239 #define CMD_USERHOST            MSG_USERHOST, TOK_USERHOST
240
241 #define MSG_USERIP              "USERIP"        /* USER -> USIP */
242 #define TOK_USERIP              "USERIP"
243 #define CMD_USERIP              MSG_USERIP, TOK_USERIP
244
245 #define MSG_ISON                "ISON"          /* ISON */
246 #define TOK_ISON                "ISON"
247 #define CMD_ISON                MSG_ISON, TOK_ISON
248
249 #define MSG_SQUERY              "SQUERY"        /* SQUE */
250 #define TOK_SQUERY              "SQUERY"
251 #define CMD_SQUERY              MSG_SQUERY, TOK_SQUERY
252
253 #define MSG_SERVLIST            "SERVLIST"      /* SERV -> SLIS */
254 #define TOK_SERVLIST            "SERVSET"
255 #define CMD_SERVLIST            MSG_SERVLIST, TOK_SERVLIST
256
257 #define MSG_SERVSET             "SERVSET"       /* SERV -> SSET */
258 #define TOK_SERVSET             "SERVSET"
259 #define CMD_SERVSET             MSG_SERVSET, TOK_SERVSET
260
261 #define MSG_REHASH              "REHASH"        /* REHA */
262 #define TOK_REHASH              "REHASH"
263 #define CMD_REHASH              MSG_REHASH, TOK_REHASH
264
265 #define MSG_RESTART             "RESTART"       /* REST */
266 #define TOK_RESTART             "RESTART"
267 #define CMD_RESTART             MSG_RESTART, TOK_RESTART
268
269 #define MSG_CLOSE               "CLOSE"         /* CLOS */
270 #define TOK_CLOSE               "CLOSE"
271 #define CMD_CLOSE               MSG_CLOSE, TOK_CLOSE
272
273 #define MSG_DIE                 "DIE"           /* DIE  */
274 #define TOK_DIE                 "DIE"
275 #define CMD_DIE                 MSG_DIE, TOK_DIE
276
277 #define MSG_HASH                "HASH"          /* HASH */
278 #define TOK_HASH                "HASH"
279 #define CMD_HASH                MSG_HASH, TOK_HASH
280
281 #define MSG_DNS                 "DNS"           /* DNS  -> DNSS */
282 #define TOK_DNS                 "DNS"
283 #define CMD_DNS                 MSG_DNS, TOK_DNS
284
285 #define MSG_SILENCE             "SILENCE"       /* SILE */
286 #define TOK_SILENCE             "U"
287 #define CMD_SILENCE             MSG_SILENCE, TOK_SILENCE
288
289 #define MSG_GLINE               "GLINE"         /* GLIN */
290 #define TOK_GLINE               "GL"
291 #define CMD_GLINE               MSG_GLINE, TOK_GLINE
292
293 #define MSG_BURST               "BURST"         /* BURS */
294 #define TOK_BURST               "B"
295 #define CMD_BURST               MSG_BURST, TOK_BURST
296
297 #define MSG_UPING               "UPING"         /* UPIN */
298 #define TOK_UPING               "UP"
299 #define CMD_UPING               MSG_UPING, TOK_UPING
300
301 #define MSG_CREATE              "CREATE"        /* CREA */
302 #define TOK_CREATE              "C"
303 #define CMD_CREATE              MSG_CREATE, TOK_CREATE
304
305 #define MSG_DESTRUCT            "DESTRUCT"      /* DEST */
306 #define TOK_DESTRUCT            "DE"
307 #define CMD_DESTRUCT            MSG_DESTRUCT, TOK_DESTRUCT
308
309 #define MSG_END_OF_BURST        "END_OF_BURST"  /* END_ */
310 #define TOK_END_OF_BURST        "EB"
311 #define CMD_END_OF_BURST        MSG_END_OF_BURST, TOK_END_OF_BURST
312
313 #define MSG_END_OF_BURST_ACK    "EOB_ACK"       /* EOB_ */
314 #define TOK_END_OF_BURST_ACK    "EA"
315 #define CMD_END_OF_BURST_ACK    MSG_END_OF_BURST_ACK, TOK_END_OF_BURST_ACK
316
317 #define MSG_PROTO               "PROTO"         /* PROTO */
318 #define TOK_PROTO               "PROTO"         /* PROTO */
319 #define CMD_PROTO               MSG_PROTO, TOK_PROTO
320
321 #define MSG_JUPE                "JUPE"          /* JUPE */
322 #define TOK_JUPE                "JU"
323 #define CMD_JUPE                MSG_JUPE, TOK_JUPE
324
325 #define MSG_OPMODE              "OPMODE"        /* OPMO */
326 #define TOK_OPMODE              "OM"
327 #define CMD_OPMODE              MSG_OPMODE, TOK_OPMODE
328
329 #define MSG_CLEARMODE           "CLEARMODE"     /* CLMO */
330 #define TOK_CLEARMODE           "CM"
331 #define CMD_CLEARMODE           MSG_CLEARMODE, TOK_CLEARMODE
332
333 #define MSG_ACCOUNT             "ACCOUNT"       /* ACCO */
334 #define TOK_ACCOUNT             "AC"
335 #define CMD_ACCOUNT             MSG_ACCOUNT, TOK_ACCOUNT
336
337 #define MSG_ASLL               "ASLL"          /* ASLL */
338 #define TOK_ASLL               "LL"
339 #define CMD_ASLL               MSG_ASLL, TOK_ASLL
340
341 #define MSG_POST                "POST"          /* POST */
342 #define TOK_POST                "POST"
343
344 #define MSG_SET                 "SET"           /* SET */
345 #define TOK_SET                 "SET"
346
347 #define MSG_RESET               "RESET"         /* RESE */
348 #define TOK_RESET               "RESET"
349
350 #define MSG_GET                 "GET"           /* GET */
351 #define TOK_GET                 "GET"
352
353 #define MSG_PRIVS               "PRIVS"         /* PRIV */
354 #define TOK_PRIVS               "PRIVS"
355
356 /*
357  * Constants
358  */
359 #define   MFLG_SLOW              0x01   /* Command can be executed roughly    *
360                                          * once per 2 seconds.                */
361 #define   MFLG_UNREG             0x02   /* Command available to unregistered  *
362                                          * clients.                           */
363 #define   MFLG_IGNORE            0x04   /* silently ignore command from
364                                          * unregistered clients */
365 #define   MFLG_EXTRA             0x08   /* Handler requests that mptr->extra
366                                          * be passed in parv[1] */
367
368 /*
369  * Structures
370  */
371 struct Message {
372   char *cmd;                  /* command string */
373   char *tok;                  /* token (shorter command string) */
374   unsigned int count;         /* number of times message used */
375   unsigned int parameters;
376   unsigned int flags;           /* bit 0 set means that this command is allowed
377                                    to be used only on the average of once per 2
378                                    seconds -SRB */
379   unsigned int bytes;         /* bytes received for this message */
380   void *extra;                /* extra pointer to be passed in parv[1] */
381   /*
382    * cptr = Connected client ptr
383    * sptr = Source client ptr
384    * parc = parameter count
385    * parv = parameter variable array
386    */
387   /* handlers:
388    * UNREGISTERED, CLIENT, SERVER, OPER, SERVICE, LAST
389    */
390   MessageHandler handlers[LAST_HANDLER_TYPE];
391 };
392
393 extern struct Message msgtab[];
394
395 #endif /* INCLUDED_msg_h */