5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 1997 - 2002 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.
25 Structure holding one command and pointer to its function.
29 Callback function called when this command is executed.
33 The actual command. Defined in silccore/silccommand.h
37 Flags for the command. These set how command behaves on different
44 SilcCommandFlag flags;
47 /* All server commands */
48 extern SilcServerCommand silc_command_list[];
50 /* Context sent as argument to all commands */
53 SilcSocketConnection sock;
54 SilcCommandPayload payload;
55 SilcArgumentPayload args;
56 SilcPacketContext *packet;
57 int pending; /* Command is being re-processed when TRUE */
58 int users; /* Reference counter */
59 } *SilcServerCommandContext;
61 /* Structure holding pending commands. If command is pending it will be
62 executed after command reply has been received and executed. */
63 typedef struct SilcServerCommandPendingStruct {
65 SilcCommand reply_cmd;
66 SilcCommandCb callback;
69 struct SilcServerCommandPendingStruct *next;
70 } SilcServerCommandPending;
72 #include "command_reply.h"
76 /* Macro used for command declaration in command list structure */
77 #define SILC_SERVER_CMD(func, cmd, flags) \
78 { silc_server_command_##func, SILC_COMMAND_##cmd, flags }
80 /* Macro used to declare command functions. The `context' will be the
81 SilcServerCommandContext and the `context2' is the
82 SilcServerCommandReplyContext if this function is called from the
83 command reply as pending command callback. Otherwise `context2'
85 #define SILC_SERVER_CMD_FUNC(func) \
86 void silc_server_command_##func(void *context, void *context2)
88 /* Executed pending command. The first argument to the callback function
89 is the user specified context. The second argument is always the
90 SilcServerCommandReply context. */
91 #define SILC_SERVER_PENDING_EXEC(ctx, cmd) \
94 for (_i = 0; _i < ctx->callbacks_count; _i++) \
95 if (ctx->callbacks[_i].callback) \
96 (*ctx->callbacks[_i].callback)(ctx->callbacks[_i].context, ctx); \
97 silc_server_command_pending_del(ctx->server, cmd, ctx->ident); \
101 void silc_server_command_process(SilcServer server,
102 SilcSocketConnection sock,
103 SilcPacketContext *packet);
104 SilcServerCommandContext silc_server_command_alloc();
105 void silc_server_command_free(SilcServerCommandContext ctx);
106 SilcServerCommandContext
107 silc_server_command_dup(SilcServerCommandContext ctx);
108 bool silc_server_command_pending(SilcServer server,
109 SilcCommand reply_cmd,
111 SilcCommandCb callback,
113 void silc_server_command_pending_del(SilcServer server,
114 SilcCommand reply_cmd,
116 SilcServerCommandPendingCallbacks
117 silc_server_command_pending_check(SilcServer server,
118 SilcServerCommandReplyContext ctx,
121 SilcUInt32 *callbacks_count);
122 SILC_SERVER_CMD_FUNC(whois);
123 SILC_SERVER_CMD_FUNC(whowas);
124 SILC_SERVER_CMD_FUNC(identify);
125 SILC_SERVER_CMD_FUNC(newuser);
126 SILC_SERVER_CMD_FUNC(nick);
127 SILC_SERVER_CMD_FUNC(list);
128 SILC_SERVER_CMD_FUNC(topic);
129 SILC_SERVER_CMD_FUNC(invite);
130 SILC_SERVER_CMD_FUNC(quit);
131 SILC_SERVER_CMD_FUNC(kill);
132 SILC_SERVER_CMD_FUNC(info);
133 SILC_SERVER_CMD_FUNC(stats);
134 SILC_SERVER_CMD_FUNC(ping);
135 SILC_SERVER_CMD_FUNC(oper);
136 SILC_SERVER_CMD_FUNC(join);
137 SILC_SERVER_CMD_FUNC(motd);
138 SILC_SERVER_CMD_FUNC(umode);
139 SILC_SERVER_CMD_FUNC(cmode);
140 SILC_SERVER_CMD_FUNC(cumode);
141 SILC_SERVER_CMD_FUNC(kick);
142 SILC_SERVER_CMD_FUNC(ban);
143 SILC_SERVER_CMD_FUNC(detach);
144 SILC_SERVER_CMD_FUNC(silcoper);
145 SILC_SERVER_CMD_FUNC(leave);
146 SILC_SERVER_CMD_FUNC(users);
147 SILC_SERVER_CMD_FUNC(getkey);
149 SILC_SERVER_CMD_FUNC(connect);
150 SILC_SERVER_CMD_FUNC(close);
151 SILC_SERVER_CMD_FUNC(shutdown);