updates. New data types.
[silc.git] / apps / silcd / command_reply.h
1 /*
2
3   command_reply.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
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; either version 2 of the License, or
12   (at your option) any later version.
13   
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.
18
19 */
20
21 #ifndef COMMAND_REPLY_H
22 #define COMMAND_REPLY_H
23
24 #include "command.h"
25
26 /* Structure holding one command reply and pointer to its function. */
27 typedef struct {
28   SilcCommandCb cb;
29   SilcCommand cmd;
30 } SilcServerCommandReply;
31
32 /* All server command replys */
33 extern SilcServerCommandReply silc_command_reply_list[];
34
35 /* Context sent as argument to all command reply functions */
36 typedef struct {
37   SilcServer server;
38   SilcSocketConnection sock;
39   SilcCommandPayload payload;
40   SilcArgumentPayload args;
41
42   /* If defined this executes the pending command. */
43   SilcServerPendingDestructor destructor;
44   SilcCommandCb callback;
45   void *context;
46   uint16 ident;
47 } *SilcServerCommandReplyContext;
48
49 /* Macros */
50
51 /* Macro used for command declaration in command reply list structure */
52 #define SILC_SERVER_CMD_REPLY(func, cmd ) \
53 { silc_server_command_reply_##func, SILC_COMMAND_##cmd }
54
55 /* Macro used to declare command reply functions */
56 #define SILC_SERVER_CMD_REPLY_FUNC(func) \
57 void silc_server_command_reply_##func(void *context)
58
59 /* Prototypes */
60 void silc_server_command_reply_free(SilcServerCommandReplyContext cmd);
61 void silc_server_command_reply_process(SilcServer server,
62                                        SilcSocketConnection sock,
63                                        SilcBuffer buffer);
64 SILC_SERVER_CMD_REPLY_FUNC(whois);
65 SILC_SERVER_CMD_REPLY_FUNC(whowas);
66 SILC_SERVER_CMD_REPLY_FUNC(identify);
67 SILC_SERVER_CMD_REPLY_FUNC(info);
68 SILC_SERVER_CMD_REPLY_FUNC(motd);
69 SILC_SERVER_CMD_REPLY_FUNC(join);
70 SILC_SERVER_CMD_REPLY_FUNC(users);
71
72 #endif