5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2001 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;
59 int pending; /* Command is being re-processed when TRUE */
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 {
66 SilcCommand reply_cmd;
67 SilcCommandCb callback;
70 struct SilcServerCommandPendingStruct *next;
71 } SilcServerCommandPending;
75 /* Macro used for command declaration in command list structure */
76 #define SILC_SERVER_CMD(func, cmd, flags) \
77 { silc_server_command_##func, SILC_COMMAND_##cmd, flags }
79 /* Macro used to declare command functions */
80 #define SILC_SERVER_CMD_FUNC(func) \
81 void silc_server_command_##func(void *context)
83 /* Executed pending command */
84 #define SILC_SERVER_COMMAND_EXEC_PENDING(ctx, cmd) \
86 if (ctx->callback) { \
87 (*ctx->callback)(ctx->context); \
88 silc_server_command_pending_del(ctx->server, cmd, ctx->ident); \
93 void silc_server_command_process(SilcServer server,
94 SilcSocketConnection sock,
95 SilcPacketContext *packet);
96 void silc_server_command_pending(SilcServer server,
97 SilcCommand reply_cmd,
99 SilcCommandCb callback,
101 void silc_server_command_pending_del(SilcServer server,
102 SilcCommand reply_cmd,
103 unsigned short ident);
104 int silc_server_command_pending_check(SilcServer server,
105 SilcServerCommandReplyContext ctx,
107 unsigned short ident);
108 SILC_SERVER_CMD_FUNC(whois);
109 SILC_SERVER_CMD_FUNC(whowas);
110 SILC_SERVER_CMD_FUNC(identify);
111 SILC_SERVER_CMD_FUNC(newuser);
112 SILC_SERVER_CMD_FUNC(nick);
113 SILC_SERVER_CMD_FUNC(list);
114 SILC_SERVER_CMD_FUNC(topic);
115 SILC_SERVER_CMD_FUNC(invite);
116 SILC_SERVER_CMD_FUNC(quit);
117 SILC_SERVER_CMD_FUNC(kill);
118 SILC_SERVER_CMD_FUNC(info);
119 SILC_SERVER_CMD_FUNC(connect);
120 SILC_SERVER_CMD_FUNC(ping);
121 SILC_SERVER_CMD_FUNC(oper);
122 SILC_SERVER_CMD_FUNC(pass);
123 SILC_SERVER_CMD_FUNC(admin);
124 SILC_SERVER_CMD_FUNC(join);
125 SILC_SERVER_CMD_FUNC(motd);
126 SILC_SERVER_CMD_FUNC(umode);
127 SILC_SERVER_CMD_FUNC(cmode);
128 SILC_SERVER_CMD_FUNC(cumode);
129 SILC_SERVER_CMD_FUNC(kick);
130 SILC_SERVER_CMD_FUNC(ignore);
131 SILC_SERVER_CMD_FUNC(restart);
132 SILC_SERVER_CMD_FUNC(close);
133 SILC_SERVER_CMD_FUNC(die);
134 SILC_SERVER_CMD_FUNC(silcoper);
135 SILC_SERVER_CMD_FUNC(leave);
136 SILC_SERVER_CMD_FUNC(users);