5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2000 Pekka Riikonen
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.
21 #ifndef COMMAND_REPLY_H
22 #define COMMAND_REPLY_H
24 /* Structure holding one command reply and pointer to its function. */
28 } SilcServerCommandReply;
30 /* All server command replys */
31 extern SilcServerCommandReply silc_command_reply_list[];
33 /* Context sent as argument to all command reply functions */
36 SilcSocketConnection sock;
37 SilcCommandPayload payload;
38 SilcArgumentPayload args;
40 /* If defined this executes the pending command. */
42 SilcCommandCb callback;
43 } *SilcServerCommandReplyContext;
47 /* Macro used for command declaration in command reply list structure */
48 #define SILC_SERVER_CMD_REPLY(func, cmd ) \
49 { silc_server_command_reply_##func, SILC_COMMAND_##cmd }
51 /* Macro used to declare command reply functions */
52 #define SILC_SERVER_CMD_REPLY_FUNC(func) \
53 void silc_server_command_reply_##func(void *context)
55 /* Macro used to execute command replies */
56 #define SILC_SERVER_COMMAND_REPLY_EXEC(ctx) \
58 SilcServerCommandReply *cmd; \
60 for (cmd = silc_command_reply_list; cmd->cb; cmd++) \
61 if (cmd->cmd == silc_command_get(ctx->payload)) { \
73 void silc_server_command_reply_process(SilcServer server,
74 SilcSocketConnection sock,
76 SILC_SERVER_CMD_REPLY_FUNC(join);
77 SILC_SERVER_CMD_REPLY_FUNC(identify);