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 } SilcClientCommandReply;
30 /* All client command replys */
31 extern SilcClientCommandReply silc_command_reply_list[];
33 /* Context sent as argument to all command reply functions */
36 SilcSocketConnection sock;
37 SilcCommandPayload payload;
39 /* If defined this executes the pending command. */
41 SilcClientCommandCallback callback;
42 } *SilcClientCommandReplyContext;
46 /* Macro used for command declaration in command reply list structure */
47 #define SILC_CLIENT_CMD_REPLY(func, cmd ) \
48 { silc_client_command_reply_##func, SILC_COMMAND_##cmd }
50 /* Macro used to declare command reply functions */
51 #define SILC_CLIENT_CMD_REPLY_FUNC(func) \
52 void silc_client_command_reply_##func(void *context)
54 /* Macro used to execute command replies */
55 #define SILC_CLIENT_COMMAND_REPLY_EXEC(ctx) \
57 SilcClientCommandReply *cmd; \
59 for (cmd = silc_command_reply_list; cmd->cb; cmd++) \
60 if (cmd->cmd == silc_command_get(ctx->payload)) { \
72 void silc_client_command_reply_process(SilcClient client,
73 SilcSocketConnection sock,
75 SILC_CLIENT_CMD_REPLY_FUNC(whois);
76 SILC_CLIENT_CMD_REPLY_FUNC(whowas);
77 SILC_CLIENT_CMD_REPLY_FUNC(identify);
78 SILC_CLIENT_CMD_REPLY_FUNC(nick);
79 SILC_CLIENT_CMD_REPLY_FUNC(list);
80 SILC_CLIENT_CMD_REPLY_FUNC(topic);
81 SILC_CLIENT_CMD_REPLY_FUNC(invite);
82 SILC_CLIENT_CMD_REPLY_FUNC(quit);
83 SILC_CLIENT_CMD_REPLY_FUNC(kill);
84 SILC_CLIENT_CMD_REPLY_FUNC(info);
85 SILC_CLIENT_CMD_REPLY_FUNC(links);
86 SILC_CLIENT_CMD_REPLY_FUNC(stats);
87 SILC_CLIENT_CMD_REPLY_FUNC(users);
88 SILC_CLIENT_CMD_REPLY_FUNC(away);
89 SILC_CLIENT_CMD_REPLY_FUNC(connect);
90 SILC_CLIENT_CMD_REPLY_FUNC(ping);
91 SILC_CLIENT_CMD_REPLY_FUNC(pong);
92 SILC_CLIENT_CMD_REPLY_FUNC(oper);
93 SILC_CLIENT_CMD_REPLY_FUNC(join);
94 SILC_CLIENT_CMD_REPLY_FUNC(motd);
95 SILC_CLIENT_CMD_REPLY_FUNC(umode);
96 SILC_CLIENT_CMD_REPLY_FUNC(cmode);
97 SILC_CLIENT_CMD_REPLY_FUNC(kick);
98 SILC_CLIENT_CMD_REPLY_FUNC(restart);
99 SILC_CLIENT_CMD_REPLY_FUNC(close);
100 SILC_CLIENT_CMD_REPLY_FUNC(die);
101 SILC_CLIENT_CMD_REPLY_FUNC(silcoper);
102 SILC_CLIENT_CMD_REPLY_FUNC(leave);
103 SILC_CLIENT_CMD_REPLY_FUNC(names);
104 SILC_CLIENT_CMD_REPLY_FUNC(msg);