X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fsilcd%2Fcommand_reply.h;h=371cce46d4ecb572012d01c6612225aae98ef227;hb=413da0f8686910f5e627393157566ae729ca99c4;hp=0e67aa287dbb2dddb0119ca1fe7df8f42d28c6e2;hpb=62f89b2886bbe9df82d9b2fdabfe707509d9e0fc;p=silc.git diff --git a/apps/silcd/command_reply.h b/apps/silcd/command_reply.h index 0e67aa28..371cce46 100644 --- a/apps/silcd/command_reply.h +++ b/apps/silcd/command_reply.h @@ -2,15 +2,15 @@ command_reply.h - Author: Pekka Riikonen + Author: Pekka Riikonen - Copyright (C) 1997 - 2000 Pekka Riikonen + Copyright (C) 1997 - 2003 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -21,6 +21,8 @@ #ifndef COMMAND_REPLY_H #define COMMAND_REPLY_H +#include "command.h" + /* Structure holding one command reply and pointer to its function. */ typedef struct { SilcCommandCb cb; @@ -30,15 +32,23 @@ typedef struct { /* All server command replys */ extern SilcServerCommandReply silc_command_reply_list[]; +/* Context holding pending command callbacks. */ +typedef struct { + SilcCommandCb callback; + void *context; +} *SilcServerCommandPendingCallbacks; + /* Context sent as argument to all command reply functions */ typedef struct { SilcServer server; SilcSocketConnection sock; SilcCommandPayload payload; + SilcArgumentPayload args; /* If defined this executes the pending command. */ - void *context; - SilcCommandCb callback; + SilcServerCommandPendingCallbacks callbacks; + SilcUInt32 callbacks_count; + SilcUInt16 ident; } *SilcServerCommandReplyContext; /* Macros */ @@ -49,29 +59,24 @@ typedef struct { /* Macro used to declare command reply functions */ #define SILC_SERVER_CMD_REPLY_FUNC(func) \ -void silc_server_command_reply_##func(void *context) - -/* Macro used to execute command replies */ -#define SILC_SERVER_COMMAND_REPLY_EXEC(ctx) \ -do { \ - SilcServerCommandReply *cmd; \ - \ - for (cmd = silc_command_reply_list; cmd->cb; cmd++) \ - if (cmd->cmd == silc_command_get(ctx->payload)) { \ - cmd->cb(ctx); \ - break; \ - } \ - \ - if (cmd == NULL) { \ - silc_free(ctx); \ - return; \ - } \ -} while(0) +void silc_server_command_reply_##func(void *context, void *context2) /* Prototypes */ +void silc_server_command_reply_free(SilcServerCommandReplyContext cmd); void silc_server_command_reply_process(SilcServer server, SilcSocketConnection sock, SilcBuffer buffer); +SILC_SERVER_CMD_REPLY_FUNC(whois); +SILC_SERVER_CMD_REPLY_FUNC(whowas); +SILC_SERVER_CMD_REPLY_FUNC(identify); +SILC_SERVER_CMD_REPLY_FUNC(info); +SILC_SERVER_CMD_REPLY_FUNC(motd); SILC_SERVER_CMD_REPLY_FUNC(join); +SILC_SERVER_CMD_REPLY_FUNC(stats); +SILC_SERVER_CMD_REPLY_FUNC(users); +SILC_SERVER_CMD_REPLY_FUNC(getkey); +SILC_SERVER_CMD_REPLY_FUNC(list); +SILC_SERVER_CMD_REPLY_FUNC(watch); +SILC_SERVER_CMD_REPLY_FUNC(ping); #endif