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.
24 #include "command_reply.h"
27 Structure holding one command and pointer to its function.
31 Callback function called when this command is executed.
35 The actual command. Defined in silccore/silccommand.h
39 Flags for the command. These set how command behaves on different
46 SilcCommandFlag flags;
49 /* All server commands */
50 extern SilcServerCommand silc_command_list[];
52 /* Context sent as argument to all commands */
55 SilcSocketConnection sock;
56 SilcCommandPayload payload;
57 SilcArgumentPayload args;
58 SilcPacketContext *packet;
60 } *SilcServerCommandContext;
62 /* Structure holding pending commands. If command is pending it will be
63 executed after command reply has been received and executed. */
64 typedef struct SilcServerCommandPendingStruct {
65 SilcCommand reply_cmd;
66 SilcCommandCb callback;
69 struct SilcServerCommandPendingStruct *next;
70 } SilcServerCommandPending;
74 /* Macro used for command declaration in command list structure */
75 #define SILC_SERVER_CMD(func, cmd, flags) \
76 { silc_server_command_##func, SILC_COMMAND_##cmd, flags }
78 /* Macro used to declare command functions */
79 #define SILC_SERVER_CMD_FUNC(func) \
80 void silc_server_command_##func(void *context)
82 /* Executed pending command */
83 #define SILC_SERVER_COMMAND_EXEC_PENDING(ctx, cmd) \
85 if (ctx->callback) { \
86 (*ctx->callback)(ctx->context); \
87 silc_server_command_pending_del(cmd, ctx->ident); \
92 void silc_server_command_process(SilcServer server,
93 SilcSocketConnection sock,
94 SilcPacketContext *packet);
95 void silc_server_command_pending(SilcCommand reply_cmd,
97 SilcCommandCb callback,
99 void silc_server_command_pending_del(SilcCommand reply_cmd,
100 unsigned short ident);
101 int silc_server_command_pending_check(SilcServerCommandReplyContext ctx,
103 unsigned short ident);
104 SILC_SERVER_CMD_FUNC(whois);
105 SILC_SERVER_CMD_FUNC(whowas);
106 SILC_SERVER_CMD_FUNC(identify);
107 SILC_SERVER_CMD_FUNC(newuser);
108 SILC_SERVER_CMD_FUNC(nick);
109 SILC_SERVER_CMD_FUNC(list);
110 SILC_SERVER_CMD_FUNC(topic);
111 SILC_SERVER_CMD_FUNC(invite);
112 SILC_SERVER_CMD_FUNC(quit);
113 SILC_SERVER_CMD_FUNC(kill);
114 SILC_SERVER_CMD_FUNC(info);
115 SILC_SERVER_CMD_FUNC(connect);
116 SILC_SERVER_CMD_FUNC(ping);
117 SILC_SERVER_CMD_FUNC(oper);
118 SILC_SERVER_CMD_FUNC(pass);
119 SILC_SERVER_CMD_FUNC(admin);
120 SILC_SERVER_CMD_FUNC(join);
121 SILC_SERVER_CMD_FUNC(motd);
122 SILC_SERVER_CMD_FUNC(umode);
123 SILC_SERVER_CMD_FUNC(cmode);
124 SILC_SERVER_CMD_FUNC(cumode);
125 SILC_SERVER_CMD_FUNC(kick);
126 SILC_SERVER_CMD_FUNC(ignore);
127 SILC_SERVER_CMD_FUNC(restart);
128 SILC_SERVER_CMD_FUNC(close);
129 SILC_SERVER_CMD_FUNC(die);
130 SILC_SERVER_CMD_FUNC(silcoper);
131 SILC_SERVER_CMD_FUNC(leave);
132 SILC_SERVER_CMD_FUNC(names);