X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2Fcommand_reply.h;h=4eb8ca18ea428b63345f25ae0234cd7d9a8f14af;hb=413da0f8686910f5e627393157566ae729ca99c4;hp=f950447d35f8944fd3c28eeff6e71e47e339c300;hpb=31b9c6e9ceffe13a84659d337e35f7a5960ac6d9;p=silc.git diff --git a/lib/silcclient/command_reply.h b/lib/silcclient/command_reply.h index f950447d..4eb8ca18 100644 --- a/lib/silcclient/command_reply.h +++ b/lib/silcclient/command_reply.h @@ -1,10 +1,10 @@ /* - command_reply.h + command_reply.h Author: Pekka Riikonen - Copyright (C) 1997 - 2001 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 @@ -37,8 +37,8 @@ struct SilcClientCommandReplyContextStruct { SilcClient client; SilcSocketConnection sock; SilcCommandPayload payload; - SilcCommandStatus status; - SilcCommandStatus error; + SilcStatus status; + SilcStatus error; SilcArgumentPayload args; SilcPacketContext *packet; @@ -46,41 +46,45 @@ struct SilcClientCommandReplyContextStruct { SilcClientCommandPendingCallbacks callbacks; SilcUInt32 callbacks_count; SilcUInt16 ident; + SilcUInt8 users; }; /* Macros */ -/* Command reply operation that is called at the end of all command replys. +/* Command reply operation that is called at the end of all command replys. Usage: COMMAND_REPLY((ARGS, argument1, argument2, etc...)), */ #define COMMAND_REPLY(args) cmd->client->internal->ops->command_reply args -#define ARGS cmd->client, cmd->sock->user_data, \ +#define SILC_ARGS cmd->client, cmd->sock->user_data, \ cmd->payload, TRUE, silc_command_get(cmd->payload), cmd->status /* Error reply to application. Usage: COMMAND_REPLY_ERROR; */ -#define COMMAND_REPLY_ERROR cmd->client->internal->ops-> \ - command_reply(cmd->client, cmd->sock->user_data, cmd->payload, \ - FALSE, silc_command_get(cmd->payload), cmd->status) +#define COMMAND_REPLY_ERROR(error) \ +do { \ + if (cmd->status == SILC_STATUS_OK) { \ + cmd->client->internal->ops-> \ + command_reply(cmd->client, cmd->sock->user_data, cmd->payload, \ + FALSE, silc_command_get(cmd->payload), error); \ + } else { \ + void *arg1 = NULL, *arg2 = NULL; \ + silc_status_get_args(cmd->status, cmd->args, &arg1, &arg2); \ + cmd->client->internal->ops-> \ + command_reply(cmd->client, cmd->sock->user_data, cmd->payload, \ + FALSE, silc_command_get(cmd->payload), cmd->status, \ + arg1, arg2); \ + silc_free(arg1); \ + silc_free(arg2); \ + } \ +} while(0) /* Macro used to declare command reply functions */ #define SILC_CLIENT_CMD_REPLY_FUNC(func) \ void silc_client_command_reply_##func(void *context, void *context2) -/* Status message structure. Messages are defined below. */ -typedef struct { - SilcCommandStatus status; - char *message; -} SilcCommandStatusMessage; - -/* Status messages returned by the server */ -#define STAT(x) SILC_STATUS_ERR_##x -DLLAPI extern const SilcCommandStatusMessage silc_command_status_messages[]; - /* Prototypes */ void silc_client_command_reply_process(SilcClient client, SilcSocketConnection sock, SilcPacketContext *packet); -char *silc_client_command_status_message(SilcCommandStatus status); void silc_client_command_reply_free(SilcClientCommandReplyContext cmd); SILC_CLIENT_CMD_REPLY_FUNC(whois); SILC_CLIENT_CMD_REPLY_FUNC(whowas); @@ -102,6 +106,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(cumode); SILC_CLIENT_CMD_REPLY_FUNC(kick); SILC_CLIENT_CMD_REPLY_FUNC(ban); SILC_CLIENT_CMD_REPLY_FUNC(detach); +SILC_CLIENT_CMD_REPLY_FUNC(watch); SILC_CLIENT_CMD_REPLY_FUNC(silcoper); SILC_CLIENT_CMD_REPLY_FUNC(leave); SILC_CLIENT_CMD_REPLY_FUNC(users);