X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=apps%2Fsilcd%2Fcommand.h;h=cd317f79e285c968bc042d6d09db49b4e19e0d27;hp=da7a3ea737b96775ae255265838a5e3acce104a7;hb=a818c5b5411bbc4436d1c5f011236985c96bb787;hpb=ab530adb8aab5b1aa48f66f3cd0dd6be509dd6de diff --git a/apps/silcd/command.h b/apps/silcd/command.h index da7a3ea7..cd317f79 100644 --- a/apps/silcd/command.h +++ b/apps/silcd/command.h @@ -58,22 +58,14 @@ typedef struct { int users; /* Reference counter */ } *SilcServerCommandContext; -/* Pending Command callback destructor. This is called after calling the - pending callback or if error occurs while processing the pending command. - If error occurs then the callback won't be called at all, and only this - destructor is called. The `context' is the context given for the function - silc_server_command_pending. */ -typedef void (*SilcServerPendingDestructor)(void *context); - /* Structure holding pending commands. If command is pending it will be executed after command reply has been received and executed. */ typedef struct SilcServerCommandPendingStruct { SilcServer server; SilcCommand reply_cmd; SilcCommandCb callback; - SilcServerPendingDestructor destructor; void *context; - uint16 ident; + SilcUInt16 ident; struct SilcServerCommandPendingStruct *next; } SilcServerCommandPending; @@ -96,22 +88,13 @@ void silc_server_command_##func(void *context, void *context2) /* Executed pending command. The first argument to the callback function is the user specified context. The second argument is always the SilcServerCommandReply context. */ -#define SILC_SERVER_PENDING_EXEC(ctx, cmd) \ +#define SILC_SERVER_PENDING_EXEC(ctx, cmd) \ do { \ int _i; \ for (_i = 0; _i < ctx->callbacks_count; _i++) \ if (ctx->callbacks[_i].callback) \ (*ctx->callbacks[_i].callback)(ctx->callbacks[_i].context, ctx); \ -} while(0) - -/* Execute destructor for pending command */ -#define SILC_SERVER_PENDING_DESTRUCTOR(ctx, cmd) \ -do { \ - int _i; \ - silc_server_command_pending_del(ctx->server, cmd, ctx->ident); \ - for (_i = 0; _i < ctx->callbacks_count; _i++) \ - if (ctx->callbacks[_i].destructor) \ - (*ctx->callbacks[_i].destructor)(ctx->callbacks[_i].context); \ + silc_server_command_pending_del(ctx->server, cmd, ctx->ident); \ } while(0) /* Prototypes */ @@ -122,21 +105,20 @@ SilcServerCommandContext silc_server_command_alloc(); void silc_server_command_free(SilcServerCommandContext ctx); SilcServerCommandContext silc_server_command_dup(SilcServerCommandContext ctx); -void silc_server_command_pending(SilcServer server, +bool silc_server_command_pending(SilcServer server, SilcCommand reply_cmd, - uint16 ident, - SilcServerPendingDestructor destructor, + SilcUInt16 ident, SilcCommandCb callback, void *context); void silc_server_command_pending_del(SilcServer server, SilcCommand reply_cmd, - uint16 ident); + SilcUInt16 ident); SilcServerCommandPendingCallbacks silc_server_command_pending_check(SilcServer server, SilcServerCommandReplyContext ctx, SilcCommand command, - uint16 ident, - uint32 *callbacks_count); + SilcUInt16 ident, + SilcUInt32 *callbacks_count); SILC_SERVER_CMD_FUNC(whois); SILC_SERVER_CMD_FUNC(whowas); SILC_SERVER_CMD_FUNC(identify);