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, \
- cmd->payload, TRUE, silc_command_get(cmd->payload), status
+ 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), status)
+ FALSE, silc_command_get(cmd->payload), cmd->status)
#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")); \
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); \
- if (status != SILC_STATUS_OK) { \
- COMMAND_REPLY_ERROR; \
- goto out; \
- } \
+#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")); \
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); \
- if (status != SILC_STATUS_OK && \
- status != SILC_STATUS_LIST_START && \
- status != SILC_STATUS_LIST_ITEM && \
- status != SILC_STATUS_LIST_END) { \
- COMMAND_REPLY_ERROR; \
- goto out; \
- } \
+#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; \
+ } \
} 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);
return;
}
- client_id = silc_id_payload_parse_id(id_data, len);
+ client_id = silc_id_payload_parse_id(id_data, len, NULL);
if (!client_id) {
if (notify)
COMMAND_REPLY_ERROR;
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
COMMAND_CHECK_STATUS_LIST;
/* Save WHOIS info */
- silc_client_command_reply_whois_save(cmd, status, TRUE);
+ silc_client_command_reply_whois_save(cmd, cmd->status, TRUE);
/* Pending callbacks are not executed if this was an list entry */
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_END) {
+ if (cmd->status != SILC_STATUS_OK &&
+ cmd->status != SILC_STATUS_LIST_END) {
silc_client_command_reply_free(cmd);
return;
}
/* If we received notify for invalid ID we'll remove the ID if we
have it cached. */
- if (status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+ if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
SilcClientEntry client_entry;
SilcUInt32 tmp_len;
unsigned char *tmp =
silc_argument_get_arg_type(silc_command_get_args(cmd->payload),
2, &tmp_len);
if (tmp) {
- SilcClientID *client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ SilcClientID *client_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
if (client_id) {
client_entry = silc_client_get_client_by_id(cmd->client, conn,
client_id);
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SilcClientID *client_id;
SilcClientEntry client_entry = NULL;
SilcUInt32 len;
goto out;
}
- client_id = silc_id_payload_parse_id(id_data, len);
+ client_id = silc_id_payload_parse_id(id_data, len, NULL);
if (!client_id) {
COMMAND_REPLY_ERROR;
goto out;
COMMAND_REPLY((ARGS, client_entry, nickname, username, realname));
/* Pending callbacks are not executed if this was an list entry */
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_END) {
+ if (cmd->status != SILC_STATUS_OK &&
+ cmd->status != SILC_STATUS_LIST_END) {
silc_client_command_reply_free(cmd);
return;
}
SilcClientID *client_id = NULL;
SilcServerID *server_id = NULL;
SilcChannelID *channel_id = NULL;
- SilcIDCacheEntry id_cache = NULL;
SilcClientEntry client_entry;
SilcServerEntry server_entry;
SilcChannelEntry channel_entry;
SILC_LOG_DEBUG(("Received server information"));
/* Check if we have this server cached already. */
- if (!silc_idcache_find_by_id_one(conn->server_cache,
- (void *)server_id, &id_cache)) {
+ server_entry = silc_client_get_server_by_id(cmd->client, conn, server_id);
+ if (!server_entry) {
SILC_LOG_DEBUG(("Adding new server entry"));
-
- server_entry = silc_calloc(1, sizeof(*server_entry));
- server_entry->server_id = silc_id_dup(server_id, id_type);
- if (name)
- server_entry->server_name = strdup(name);
- if (info)
- server_entry->server_info = strdup(info);
-
- /* Add server to cache */
- silc_idcache_add(conn->server_cache, server_entry->server_name,
- server_entry->server_id, (void *)server_entry,
- 0, NULL);
- } else {
- server_entry = (SilcServerEntry)id_cache->context;
+ server_entry = silc_client_add_server(cmd->client, conn, name, info,
+ silc_id_dup(server_id, id_type));
+ if (!server_entry) {
+ if (notify)
+ COMMAND_REPLY_ERROR;
+ return;
+ }
}
/* Notify application */
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
COMMAND_CHECK_STATUS_LIST;
/* Save IDENTIFY info */
- silc_client_command_reply_identify_save(cmd, status, TRUE);
+ silc_client_command_reply_identify_save(cmd, cmd->status, TRUE);
/* Pending callbacks are not executed if this was an list entry */
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_END) {
+ if (cmd->status != SILC_STATUS_OK &&
+ cmd->status != SILC_STATUS_LIST_END) {
silc_client_command_reply_free(cmd);
return;
}
/* If we received notify for invalid ID we'll remove the ID if we
have it cached. */
- if (status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+ if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
SilcClientEntry client_entry;
SilcUInt32 tmp_len;
unsigned char *tmp =
silc_argument_get_arg_type(silc_command_get_args(cmd->payload),
2, &tmp_len);
if (tmp) {
- SilcClientID *client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ SilcClientID *client_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
if (client_id) {
client_entry = silc_client_get_client_by_id(cmd->client, conn,
client_id);
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SilcIDPayload idp;
unsigned char *tmp;
SilcUInt32 argc, len;
SILC_LOG_DEBUG(("Start"));
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "Cannot set nickname: %s", silc_client_command_status_message(status));
+ "Cannot set nickname: %s",
+ silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
SILC_CLIENT_CMD_REPLY_FUNC(list)
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
- SilcCommandStatus status;
unsigned char *tmp, *name, *topic;
SilcUInt32 usercount = 0;
COMMAND_REPLY((ARGS, NULL, name, topic, usercount));
/* Pending callbacks are not executed if this was an list entry */
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_END) {
+ if (cmd->status != SILC_STATUS_OK &&
+ cmd->status != SILC_STATUS_LIST_END) {
silc_client_command_reply_free(cmd);
return;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SilcChannelEntry channel;
SilcChannelID *channel_id = NULL;
unsigned char *tmp;
char *topic;
SilcUInt32 argc, len;
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
if (!topic)
goto out;
- channel_id = silc_id_payload_parse_id(tmp, len);
+ channel_id = silc_id_payload_parse_id(tmp, len, NULL);
if (!channel_id)
goto out;
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SilcChannelEntry channel;
SilcChannelID *channel_id;
unsigned char *tmp;
SilcUInt32 len;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
if (!tmp)
goto out;
- channel_id = silc_id_payload_parse_id(tmp, len);
+ channel_id = silc_id_payload_parse_id(tmp, len, NULL);
if (!channel_id)
goto out;
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
unsigned char *tmp;
- SilcIDCacheEntry id_cache;
SilcServerEntry server;
SilcServerID *server_id = NULL;
char *server_name, *server_info;
SILC_LOG_DEBUG(("Start"));
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s",
- silc_client_command_status_message(status));
+ silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
if (!tmp)
goto out;
- server_id = silc_id_payload_parse_id(tmp, len);
+ server_id = silc_id_payload_parse_id(tmp, len, NULL);
if (!server_id)
goto out;
goto out;
/* See whether we have this server cached. If not create it. */
- if (!silc_idcache_find_by_id_one(conn->server_cache, (void *)server_id,
- &id_cache)) {
+ server = silc_client_get_server_by_id(cmd->client, conn, server_id);
+ if (!server) {
SILC_LOG_DEBUG(("New server entry"));
-
- server = silc_calloc(1, sizeof(*server));
- server->server_name = strdup(server_name);
- server->server_info = strdup(server_info);
- server->server_id = silc_id_dup(server_id, SILC_ID_SERVER);
-
- /* Add it to the cache */
- silc_idcache_add(conn->server_cache, server->server_name,
- server->server_id, (void *)server, 0, NULL);
- } else {
- server = (SilcServerEntry)id_cache->context;
+ server = silc_client_add_server(cmd->client, conn, server_name,
+ server_info,
+ silc_id_dup(server_id, SILC_ID_SERVER));
+ if (!server)
+ goto out;
}
-
+
/* Notify application */
COMMAND_REPLY((ARGS, server, server->server_name, server->server_info));
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
void *id;
int i;
time_t diff, curtime;
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SilcChannelEntry channel;
SilcChannelUser chu;
SilcChannelID *channel_id;
SILC_LOG_DEBUG(("Start"));
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
- if (status != SILC_STATUS_OK) {
- if (status != SILC_STATUS_ERR_USER_ON_CHANNEL)
+ if (cmd->status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_ERR_USER_ON_CHANNEL)
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
COMMAND_REPLY_ERROR;
goto out;
}
- channel_id = silc_id_payload_parse_id(tmp, len);
+ channel_id = silc_id_payload_parse_id(tmp, len, NULL);
if (!channel_id) {
COMMAND_REPLY_ERROR;
goto out;
/* Client ID */
SILC_GET16_MSB(idp_len, client_id_list->data + 2);
idp_len += 4;
- client_id = silc_id_payload_parse_id(client_id_list->data, idp_len);
+ client_id = silc_id_payload_parse_id(client_id_list->data, idp_len, NULL);
if (!client_id)
continue;
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SilcUInt32 argc, i;
- unsigned char *tmp;
char *motd = NULL, *cp, line[256];
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
return;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
unsigned char *tmp;
SilcUInt32 mode;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
unsigned char *tmp;
SilcUInt32 mode;
SilcChannelID *channel_id;
SilcChannelEntry channel;
SilcUInt32 len;
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
if (!tmp)
goto out;
- channel_id = silc_id_payload_parse_id(tmp, len);
+ channel_id = silc_id_payload_parse_id(tmp, len, NULL);
if (!channel_id)
goto out;
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SilcClientID *client_id;
SilcChannelID *channel_id;
SilcClientEntry client_entry;
unsigned char *modev, *tmp, *id;
SilcUInt32 len, mode;
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
if (!tmp)
goto out;
- channel_id = silc_id_payload_parse_id(tmp, len);
+ channel_id = silc_id_payload_parse_id(tmp, len, NULL);
if (!channel_id)
goto out;
COMMAND_REPLY_ERROR;
goto out;
}
- client_id = silc_id_payload_parse_id(id, len);
+ client_id = silc_id_payload_parse_id(id, len, NULL);
if (!client_id) {
silc_free(channel_id);
COMMAND_REPLY_ERROR;
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
- unsigned char *tmp;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
- unsigned char *tmp;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
- unsigned char *tmp;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
- unsigned char *tmp;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SilcChannelEntry channel;
SilcChannelID *channel_id;
unsigned char *tmp;
SilcUInt32 len;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
if (!tmp)
goto out;
- channel_id = silc_id_payload_parse_id(tmp, len);
+ channel_id = silc_id_payload_parse_id(tmp, len, NULL);
if (!channel_id)
goto out;
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
- unsigned char *tmp;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
- unsigned char *tmp;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
- unsigned char *tmp;
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SilcChannelEntry channel;
SilcClientEntry client_entry;
SilcChannelUser chu;
SILC_LOG_DEBUG(("Start"));
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
COMMAND_REPLY_ERROR;
goto out;
}
- channel_id = silc_id_payload_parse_id(tmp, tmp_len);
+ channel_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
if (!channel_id) {
COMMAND_REPLY_ERROR;
goto out;
/* Client ID */
SILC_GET16_MSB(idp_len, client_id_list->data + 2);
idp_len += 4;
- client_id = silc_id_payload_parse_id(client_id_list->data, idp_len);
+ client_id = silc_id_payload_parse_id(client_id_list->data, idp_len, NULL);
if (!client_id)
continue;
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
- SilcIDCacheEntry id_cache;
SilcIDPayload idp = NULL;
SilcClientID *client_id = NULL;
SilcClientEntry client_entry;
SILC_LOG_DEBUG(("Start"));
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK) {
+ if (cmd->status != SILC_STATUS_OK) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "%s", silc_client_command_status_message(status));
+ "%s", silc_client_command_status_message(cmd->status));
COMMAND_REPLY_ERROR;
goto out;
}
} else if (id_type == SILC_ID_SERVER) {
/* Received server's public key */
server_id = silc_id_payload_get_id(idp);
- if (!silc_idcache_find_by_id_one(conn->server_cache, (void *)server_id,
- &id_cache)) {
+ server_entry = silc_client_get_server_by_id(cmd->client, conn, server_id);
+ if (!server_entry) {
COMMAND_REPLY_ERROR;
goto out;
}
- server_entry = (SilcServerEntry)id_cache->context;
-
/* Notify application */
COMMAND_REPLY((ARGS, id_type, server_entry, public_key));
}
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SILC_LOG_DEBUG(("Start"));
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_START &&
- status != SILC_STATUS_LIST_ITEM &&
- status != SILC_STATUS_LIST_END)
+ if (cmd->status != SILC_STATUS_OK &&
+ cmd->status != SILC_STATUS_LIST_START &&
+ cmd->status != SILC_STATUS_LIST_ITEM &&
+ cmd->status != SILC_STATUS_LIST_END)
goto out;
/* Save WHOIS info */
- silc_client_command_reply_whois_save(cmd, status, FALSE);
+ silc_client_command_reply_whois_save(cmd, cmd->status, FALSE);
/* Pending callbacks are not executed if this was an list entry */
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_END) {
+ if (cmd->status != SILC_STATUS_OK &&
+ cmd->status != SILC_STATUS_LIST_END) {
silc_client_command_reply_free(cmd);
return;
}
/* If we received notify for invalid ID we'll remove the ID if we
have it cached. */
- if (status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+ if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
SilcClientEntry client_entry;
SilcUInt32 tmp_len;
unsigned char *tmp =
silc_argument_get_arg_type(silc_command_get_args(cmd->payload),
2, &tmp_len);
if (tmp) {
- SilcClientID *client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ SilcClientID *client_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
if (client_id) {
client_entry = silc_client_get_client_by_id(cmd->client, conn,
client_id);
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
SILC_LOG_DEBUG(("Start"));
- SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_START &&
- status != SILC_STATUS_LIST_ITEM &&
- status != SILC_STATUS_LIST_END)
+ if (cmd->status != SILC_STATUS_OK &&
+ cmd->status != SILC_STATUS_LIST_START &&
+ cmd->status != SILC_STATUS_LIST_ITEM &&
+ cmd->status != SILC_STATUS_LIST_END)
goto out;
/* Save IDENTIFY info */
- silc_client_command_reply_identify_save(cmd, status, FALSE);
+ silc_client_command_reply_identify_save(cmd, cmd->status, FALSE);
/* Pending callbacks are not executed if this was an list entry */
- if (status != SILC_STATUS_OK &&
- status != SILC_STATUS_LIST_END) {
+ if (cmd->status != SILC_STATUS_OK &&
+ cmd->status != SILC_STATUS_LIST_END) {
silc_client_command_reply_free(cmd);
return;
}
/* If we received notify for invalid ID we'll remove the ID if we
have it cached. */
- if (status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+ if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
SilcClientEntry client_entry;
SilcUInt32 tmp_len;
unsigned char *tmp =
silc_argument_get_arg_type(silc_command_get_args(cmd->payload),
2, &tmp_len);
if (tmp) {
- SilcClientID *client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ SilcClientID *client_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
if (client_id) {
client_entry = silc_client_get_client_by_id(cmd->client, conn,
client_id);
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcCommandStatus status;
unsigned char *tmp;
- SilcIDCacheEntry id_cache;
SilcServerEntry server;
SilcServerID *server_id = NULL;
char *server_name, *server_info;
SILC_LOG_DEBUG(("Start"));
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
- if (status != SILC_STATUS_OK)
+ if (cmd->status != SILC_STATUS_OK)
goto out;
/* Get server ID */
if (!tmp)
goto out;
- server_id = silc_id_payload_parse_id(tmp, len);
+ server_id = silc_id_payload_parse_id(tmp, len, NULL);
if (!server_id)
goto out;
goto out;
/* See whether we have this server cached. If not create it. */
- if (!silc_idcache_find_by_id_one(conn->server_cache, (void *)server_id,
- &id_cache)) {
+ server = silc_client_get_server_by_id(cmd->client, conn, server_id);
+ if (!server) {
SILC_LOG_DEBUG(("New server entry"));
- server = silc_calloc(1, sizeof(*server));
- server->server_name = strdup(server_name);
- server->server_info = strdup(server_info);
- server->server_id = silc_id_dup(server_id, SILC_ID_SERVER);
-
- /* Add it to the cache */
- silc_idcache_add(conn->server_cache, server->server_name,
- server->server_id, (void *)server, 0, NULL);
+ silc_client_add_server(cmd->client, conn, server_name, server_info,
+ silc_id_dup(server_id, SILC_ID_SERVER));
}
out: