#define SAY cmd->client->internal->ops->say
-/* All functions that call the COMMAND_CHECK_STATUS or the
- COMMAND_CHECK_STATUS_LIST macros must have out: goto label. */
-
-#define COMMAND_CHECK_STATUS \
-do { \
- SILC_LOG_DEBUG(("Start")); \
- if (cmd->status != SILC_STATUS_OK) { \
- COMMAND_REPLY_ERROR; \
- goto out; \
- } \
-} while(0)
-
-#define COMMAND_CHECK_STATUS_LIST \
-do { \
- SILC_LOG_DEBUG(("Start")); \
- if (cmd->status != SILC_STATUS_OK && \
- cmd->status != SILC_STATUS_LIST_START && \
- cmd->status != SILC_STATUS_LIST_ITEM && \
- cmd->status != SILC_STATUS_LIST_END) { \
- COMMAND_REPLY_ERROR; \
- goto out; \
- } \
+/* All functions that call the COMMAND_CHECK_STATUS macro must have
+ out: goto label. */
+
+#define COMMAND_CHECK_STATUS \
+do { \
+ SILC_LOG_DEBUG(("Start")); \
+ if (!silc_command_get_status(cmd->payload, NULL, NULL)) { \
+ COMMAND_REPLY_ERROR; \
+ goto out; \
+ } \
} while(0)
/* Process received command reply. */
ctx->client = client;
ctx->sock = sock;
ctx->payload = payload;
- ctx->status = silc_command_get_status(ctx->payload);
ctx->args = silc_command_get_args(ctx->payload);
ctx->packet = packet;
ctx->ident = silc_command_get_ident(ctx->payload);
+ silc_command_get_status(ctx->payload, &ctx->status, &ctx->error);
/* Check for pending commands and mark to be exeucted */
silc_client_command_pending_check(sock->user_data, ctx,
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- COMMAND_CHECK_STATUS_LIST;
+ COMMAND_CHECK_STATUS;
/* Save WHOIS info */
silc_client_command_reply_whois_save(cmd, cmd->status, TRUE);
/* If we received notify for invalid ID we'll remove the ID if we
have it cached. */
- if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+ if (cmd->error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
SilcClientEntry client_entry;
SilcUInt32 tmp_len;
unsigned char *tmp =
char *nickname, *username;
char *realname = NULL;
- COMMAND_CHECK_STATUS_LIST;
+ COMMAND_CHECK_STATUS;
id_data = silc_argument_get_arg_type(cmd->args, 2, &len);
if (!id_data) {
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- COMMAND_CHECK_STATUS_LIST;
+ COMMAND_CHECK_STATUS;
/* Save IDENTIFY info */
silc_client_command_reply_identify_save(cmd, cmd->status, TRUE);
/* If we received notify for invalid ID we'll remove the ID if we
have it cached. */
- if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+ if (cmd->error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
SilcClientEntry client_entry;
SilcUInt32 tmp_len;
unsigned char *tmp =
SILC_LOG_DEBUG(("Start"));
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Cannot set nickname: %s",
- silc_client_command_status_message(cmd->status));
+ silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SilcChannelID *channel_id = NULL;
SilcChannelEntry channel_entry;
- COMMAND_CHECK_STATUS_LIST;
+ COMMAND_CHECK_STATUS;
tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
if (!tmp) {
char *topic;
SilcUInt32 argc, len;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
unsigned char *tmp;
SilcUInt32 len;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SILC_LOG_DEBUG(("Start"));
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s",
- silc_client_command_status_message(cmd->status));
+ silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
int i;
time_t diff, curtime;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SILC_LOG_DEBUG(("Start"));
- if (cmd->status != SILC_STATUS_OK) {
- if (cmd->status != SILC_STATUS_ERR_USER_ON_CHANNEL)
+ if (cmd->error != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_ERR_USER_ON_CHANNEL)
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SilcUInt32 argc, i;
char *motd = NULL, *cp, line[256];
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
return;
}
unsigned char *tmp;
SilcUInt32 mode;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SilcChannelEntry channel;
SilcUInt32 len;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
unsigned char *modev, *tmp, *id;
SilcUInt32 len, mode;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
unsigned char *tmp;
SilcUInt32 len;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
unsigned char *tmp;
SilcUInt32 len;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
if (!channels_count) {
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status = SILC_STATUS_ERR_NO_SUCH_CHANNEL;
+ cmd->status = cmd->error = SILC_STATUS_ERR_NO_SUCH_CHANNEL;
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_USERS);
silc_client_command_reply_free(cmd);
SILC_LOG_DEBUG(("Start"));
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SILC_LOG_DEBUG(("Start"));
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SILC_LOG_DEBUG(("Start"));
- if (cmd->status != SILC_STATUS_OK &&
- cmd->status != SILC_STATUS_LIST_START &&
- cmd->status != SILC_STATUS_LIST_ITEM &&
- cmd->status != SILC_STATUS_LIST_END)
+ if (cmd->error != SILC_STATUS_OK)
goto out;
/* Save WHOIS info */
/* If we received notify for invalid ID we'll remove the ID if we
have it cached. */
- if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+ if (cmd->error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
SilcClientEntry client_entry;
SilcUInt32 tmp_len;
unsigned char *tmp =
SILC_LOG_DEBUG(("Start"));
- if (cmd->status != SILC_STATUS_OK &&
- cmd->status != SILC_STATUS_LIST_START &&
- cmd->status != SILC_STATUS_LIST_ITEM &&
- cmd->status != SILC_STATUS_LIST_END)
+ if (cmd->error != SILC_STATUS_OK)
goto out;
/* Save IDENTIFY info */
/* If we received notify for invalid ID we'll remove the ID if we
have it cached. */
- if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+ if (cmd->error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
SilcClientEntry client_entry;
SilcUInt32 tmp_len;
unsigned char *tmp =
SILC_LOG_DEBUG(("Start"));
- if (cmd->status != SILC_STATUS_OK)
+ if (cmd->error != SILC_STATUS_OK)
goto out;
/* Get server ID */
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->error != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(cmd->status));
+ "%s", silc_client_command_status_message(cmd->error));
COMMAND_REPLY_ERROR;
goto out;
}