1d1d20834522dcbe1a14a84ab71833a4d9f77cdc
[silc.git] / lib / silcclient / command_reply.h
1 /*
2
3   command_reply.h 
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 1997 - 2001 Pekka Riikonen
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; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 #ifndef COMMAND_REPLY_H
21 #define COMMAND_REPLY_H
22
23 /* Structure holding one command reply and pointer to its function. */
24 typedef struct {
25   SilcCommandCb cb;
26   SilcCommand cmd;
27 } SilcClientCommandReply;
28
29 /* Context sent as argument to all command reply functions */
30 struct SilcClientCommandReplyContextStruct {
31   SilcClient client;
32   SilcSocketConnection sock;
33   SilcCommandPayload payload;
34   SilcCommandStatus status;
35   SilcCommandStatus error;
36   SilcArgumentPayload args;
37   SilcPacketContext *packet;
38
39   /* If defined this executes the pending command. */
40   SilcCommandCb callback;
41   void *context;
42   SilcUInt16 ident;
43 };
44
45 /* Macros */
46
47 /* Macro used to declare command reply functions */
48 #define SILC_CLIENT_CMD_REPLY_FUNC(func)                                \
49 void silc_client_command_reply_##func(void *context, void *context2)
50
51 /* Status message structure. Messages are defined below. */
52 typedef struct {
53   SilcCommandStatus status;
54   char *message;
55 } SilcCommandStatusMessage;
56
57 /* Status messages returned by the server */
58 #define STAT(x) SILC_STATUS_ERR_##x
59 DLLAPI extern const SilcCommandStatusMessage silc_command_status_messages[];
60
61 /* Prototypes */
62
63 void silc_client_command_reply_process(SilcClient client,
64                                        SilcSocketConnection sock,
65                                        SilcPacketContext *packet);
66 char *silc_client_command_status_message(SilcCommandStatus status);
67 SILC_CLIENT_CMD_REPLY_FUNC(whois);
68 SILC_CLIENT_CMD_REPLY_FUNC(whowas);
69 SILC_CLIENT_CMD_REPLY_FUNC(identify);
70 SILC_CLIENT_CMD_REPLY_FUNC(nick);
71 SILC_CLIENT_CMD_REPLY_FUNC(list);
72 SILC_CLIENT_CMD_REPLY_FUNC(topic);
73 SILC_CLIENT_CMD_REPLY_FUNC(invite);
74 SILC_CLIENT_CMD_REPLY_FUNC(kill);
75 SILC_CLIENT_CMD_REPLY_FUNC(info);
76 SILC_CLIENT_CMD_REPLY_FUNC(links);
77 SILC_CLIENT_CMD_REPLY_FUNC(stats);
78 SILC_CLIENT_CMD_REPLY_FUNC(users);
79 SILC_CLIENT_CMD_REPLY_FUNC(connect);
80 SILC_CLIENT_CMD_REPLY_FUNC(ping);
81 SILC_CLIENT_CMD_REPLY_FUNC(pong);
82 SILC_CLIENT_CMD_REPLY_FUNC(oper);
83 SILC_CLIENT_CMD_REPLY_FUNC(join);
84 SILC_CLIENT_CMD_REPLY_FUNC(motd);
85 SILC_CLIENT_CMD_REPLY_FUNC(umode);
86 SILC_CLIENT_CMD_REPLY_FUNC(cmode);
87 SILC_CLIENT_CMD_REPLY_FUNC(cumode);
88 SILC_CLIENT_CMD_REPLY_FUNC(kick);
89 SILC_CLIENT_CMD_REPLY_FUNC(ban);
90 SILC_CLIENT_CMD_REPLY_FUNC(close);
91 SILC_CLIENT_CMD_REPLY_FUNC(shutdown);
92 SILC_CLIENT_CMD_REPLY_FUNC(silcoper);
93 SILC_CLIENT_CMD_REPLY_FUNC(leave);
94 SILC_CLIENT_CMD_REPLY_FUNC(users);
95 SILC_CLIENT_CMD_REPLY_FUNC(getkey);
96 SILC_CLIENT_CMD_REPLY_FUNC(quit);
97
98 /* Internal command reply functions */
99 SILC_CLIENT_CMD_REPLY_FUNC(whois_i);
100 SILC_CLIENT_CMD_REPLY_FUNC(identify_i);
101 SILC_CLIENT_CMD_REPLY_FUNC(info_i);
102
103 #endif