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.
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 /* Pending Command callback destructor. This is called after calling the
62 pending callback or if error occurs while processing the pending command.
63 If error occurs then the callback won't be called at all, and only this
64 destructor is called. The `context' is the context given for the function
65 silc_server_command_pending. */
66 typedef void (*SilcServerPendingDestructor)(void *context);
68 /* Structure holding pending commands. If command is pending it will be
69 executed after command reply has been received and executed. */
70 typedef struct SilcServerCommandPendingStruct {
72 SilcCommand reply_cmd;
73 SilcCommandCb callback;
74 SilcServerPendingDestructor destructor;
77 struct SilcServerCommandPendingStruct *next;
78 } SilcServerCommandPending;
80 #include "command_reply.h"
84 /* Macro used for command declaration in command list structure */
85 #define SILC_SERVER_CMD(func, cmd, flags) \
86 { silc_server_command_##func, SILC_COMMAND_##cmd, flags }
88 /* Macro used to declare command functions. The `context' will be the
89 SilcServerCommandContext and the `context2' is the
90 SilcServerCommandReplyContext if this function is called from the
91 command reply as pending command callback. Otherwise `context2'
93 #define SILC_SERVER_CMD_FUNC(func) \
94 void silc_server_command_##func(void *context, void *context2)
96 /* Executed pending command. The first argument to the callback function
97 is the user specified context. The second argument is always the
98 SilcServerCommandReply context. */
99 #define SILC_SERVER_PENDING_EXEC(ctx, cmd) \
102 (*ctx->callback)(ctx->context, ctx); \
105 /* Execute destructor for pending command */
106 #define SILC_SERVER_PENDING_DESTRUCTOR(ctx, cmd) \
108 silc_server_command_pending_del(ctx->server, cmd, ctx->ident); \
109 if (ctx->destructor) \
110 (*ctx->destructor)(ctx->context); \
114 void silc_server_command_process(SilcServer server,
115 SilcSocketConnection sock,
116 SilcPacketContext *packet);
117 SilcServerCommandContext silc_server_command_alloc();
118 void silc_server_command_free(SilcServerCommandContext ctx);
119 SilcServerCommandContext
120 silc_server_command_dup(SilcServerCommandContext ctx);
121 void silc_server_command_pending(SilcServer server,
122 SilcCommand reply_cmd,
124 SilcServerPendingDestructor destructor,
125 SilcCommandCb callback,
127 void silc_server_command_pending_del(SilcServer server,
128 SilcCommand reply_cmd,
130 int silc_server_command_pending_check(SilcServer server,
131 SilcServerCommandReplyContext ctx,
134 SILC_SERVER_CMD_FUNC(whois);
135 SILC_SERVER_CMD_FUNC(whowas);
136 SILC_SERVER_CMD_FUNC(identify);
137 SILC_SERVER_CMD_FUNC(newuser);
138 SILC_SERVER_CMD_FUNC(nick);
139 SILC_SERVER_CMD_FUNC(list);
140 SILC_SERVER_CMD_FUNC(topic);
141 SILC_SERVER_CMD_FUNC(invite);
142 SILC_SERVER_CMD_FUNC(quit);
143 SILC_SERVER_CMD_FUNC(kill);
144 SILC_SERVER_CMD_FUNC(info);
145 SILC_SERVER_CMD_FUNC(connect);
146 SILC_SERVER_CMD_FUNC(ping);
147 SILC_SERVER_CMD_FUNC(oper);
148 SILC_SERVER_CMD_FUNC(pass);
149 SILC_SERVER_CMD_FUNC(admin);
150 SILC_SERVER_CMD_FUNC(join);
151 SILC_SERVER_CMD_FUNC(motd);
152 SILC_SERVER_CMD_FUNC(umode);
153 SILC_SERVER_CMD_FUNC(cmode);
154 SILC_SERVER_CMD_FUNC(cumode);
155 SILC_SERVER_CMD_FUNC(kick);
156 SILC_SERVER_CMD_FUNC(ignore);
157 SILC_SERVER_CMD_FUNC(ban);
158 SILC_SERVER_CMD_FUNC(close);
159 SILC_SERVER_CMD_FUNC(shutdown);
160 SILC_SERVER_CMD_FUNC(silcoper);
161 SILC_SERVER_CMD_FUNC(leave);
162 SILC_SERVER_CMD_FUNC(users);
163 SILC_SERVER_CMD_FUNC(getkey);