X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2Fcommand.h;h=c6c597de1cb49f038bb03bc0ca96935819c0fb00;hb=c257b555225193e54d85daf541d29578b3c93882;hp=6b8bd6266eefacb18e5a1ca54688dcee5c57b431;hpb=6394d86063413bc1c473723f3ef971840195bcd3;p=silc.git diff --git a/lib/silcclient/command.h b/lib/silcclient/command.h index 6b8bd626..c6c597de 100644 --- a/lib/silcclient/command.h +++ b/lib/silcclient/command.h @@ -1,6 +1,6 @@ /* - command.h + command.h Author: Pekka Riikonen @@ -20,11 +20,6 @@ #ifndef COMMAND_H #define COMMAND_H -/* Forward declarations */ -typedef struct SilcClientCommandStruct *SilcClientCommand; -typedef struct SilcClientCommandContextStruct *SilcClientCommandContext; - -#include "silcapi.h" #include "command_reply.h" /* Structure holding one command and pointer to its function. This @@ -40,8 +35,8 @@ struct SilcClientCommandStruct { SilcCommandCb command; /* Command function */ SilcCommandCb reply; /* Command reply callback */ char *name; /* Name of the command (optional) */ - uint8 max_args; /* Maximum arguments (optional) */ - uint16 ident; /* Identifier for command (optional) */ + SilcUInt8 max_args; /* Maximum arguments (optional) */ + SilcUInt16 ident; /* Identifier for command (optional) */ struct SilcClientCommandStruct *next; }; @@ -53,10 +48,10 @@ struct SilcClientCommandContextStruct { SilcClient client; SilcClientConnection conn; SilcClientCommand command; - uint32 argc; + SilcUInt32 argc; unsigned char **argv; - uint32 *argv_lens; - uint32 *argv_types; + SilcUInt32 *argv_lens; + SilcUInt32 *argv_types; int pending; /* Command is being re-processed when TRUE */ int users; /* Reference counter */ }; @@ -65,10 +60,10 @@ struct SilcClientCommandContextStruct { executed after command reply has been executed. */ typedef struct SilcClientCommandPendingStruct { SilcCommand reply_cmd; + SilcUInt16 ident; + unsigned int reply_check : 8; SilcCommandCb callback; - SilcClientPendingDestructor destructor; void *context; - uint16 ident; struct SilcClientCommandPendingStruct *next; } SilcClientCommandPending; @@ -93,43 +88,46 @@ silc_client_command_unregister(client, SILC_COMMAND_##cmd, \ void silc_client_command_##func(void *context, void *context2) /* Executed pending command callback */ -#define SILC_CLIENT_PENDING_EXEC(ctx, cmd) \ -do { \ - if ((ctx)->callback) \ - (*ctx->callback)(ctx->context, ctx); \ -} while(0) - -/* Execute destructor for pending command */ -#define SILC_CLIENT_PENDING_DESTRUCTOR(ctx, cmd) \ -do { \ - silc_client_command_pending_del((ctx)->sock->user_data, (cmd), \ - (ctx)->ident); \ - if (ctx->destructor) \ - (*ctx->destructor)(ctx->context); \ +#define SILC_CLIENT_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); \ + silc_client_command_pending_del(ctx->sock->user_data, cmd, ctx->ident); \ } while(0) +SilcClientCommandContext silc_client_command_alloc(void); +void silc_client_command_free(SilcClientCommandContext ctx); +SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx); +SilcClientCommand silc_client_command_find(SilcClient client, + const char *name); bool silc_client_command_register(SilcClient client, SilcCommand command, const char *name, SilcCommandCb command_function, SilcCommandCb command_reply_function, - uint8 max_args, - uint16 ident); + SilcUInt8 max_args, + SilcUInt16 ident); bool silc_client_command_unregister(SilcClient client, SilcCommand command, SilcCommandCb command_function, SilcCommandCb command_reply_function, - uint16 ident); + SilcUInt16 ident); void silc_client_commands_register(SilcClient client); void silc_client_commands_unregister(SilcClient client); void silc_client_command_pending_del(SilcClientConnection conn, SilcCommand reply_cmd, - uint16 ident); -int silc_client_command_pending_check(SilcClientConnection conn, - SilcClientCommandReplyContext ctx, - SilcCommand command, - uint16 ident); - + SilcUInt16 ident); +SilcClientCommandPendingCallbacks +silc_client_command_pending_check(SilcClientConnection conn, + SilcClientCommandReplyContext ctx, + SilcCommand command, + SilcUInt16 ident, + SilcUInt32 *callbacks_count); +void silc_client_command_process(SilcClient client, + SilcSocketConnection sock, + SilcPacketContext *packet); SILC_CLIENT_CMD_FUNC(whois); SILC_CLIENT_CMD_FUNC(whowas); SILC_CLIENT_CMD_FUNC(identify); @@ -140,7 +138,6 @@ SILC_CLIENT_CMD_FUNC(invite); SILC_CLIENT_CMD_FUNC(quit); SILC_CLIENT_CMD_FUNC(kill); SILC_CLIENT_CMD_FUNC(info); -SILC_CLIENT_CMD_FUNC(connect); SILC_CLIENT_CMD_FUNC(ping); SILC_CLIENT_CMD_FUNC(oper); SILC_CLIENT_CMD_FUNC(join); @@ -150,11 +147,15 @@ SILC_CLIENT_CMD_FUNC(cmode); SILC_CLIENT_CMD_FUNC(cumode); SILC_CLIENT_CMD_FUNC(kick); SILC_CLIENT_CMD_FUNC(ban); -SILC_CLIENT_CMD_FUNC(close); -SILC_CLIENT_CMD_FUNC(shutdown); +SILC_CLIENT_CMD_FUNC(detach); +SILC_CLIENT_CMD_FUNC(watch); SILC_CLIENT_CMD_FUNC(silcoper); SILC_CLIENT_CMD_FUNC(leave); SILC_CLIENT_CMD_FUNC(users); SILC_CLIENT_CMD_FUNC(getkey); +SILC_CLIENT_CMD_FUNC(shutdown); +SILC_CLIENT_CMD_FUNC(close); +SILC_CLIENT_CMD_FUNC(connect); + #endif