{ STAT(NO_SERVER_ID), "No Server ID given" },
{ STAT(BAD_CLIENT_ID), "Bad Client ID" },
{ STAT(BAD_CHANNEL_ID), "Bad Channel ID" },
- { STAT(NO_SUCH_CLIENT_ID), "There was no such client" },
- { STAT(NO_SUCH_CHANNEL_ID),"There was no such channel" },
+ { STAT(NO_SUCH_CLIENT_ID), "There is no such client" },
+ { STAT(NO_SUCH_CHANNEL_ID),"There is no such channel" },
{ STAT(NICKNAME_IN_USE), "Nickname already exists" },
{ STAT(NOT_ON_CHANNEL), "You are not on that channel" },
{ STAT(USER_NOT_ON_CHANNEL),"They are not on the channel" },
silc_hash_client_id_compare, NULL,
&id_cache)) {
SILC_LOG_DEBUG(("Adding new client entry"));
-
- client_entry = silc_calloc(1, sizeof(*client_entry));
- client_entry->id = client_id;
- silc_parse_nickname(nickname, &client_entry->nickname,
- &client_entry->server, &client_entry->num);
- client_entry->username = strdup(username);
- if (realname)
- client_entry->realname = strdup(realname);
- client_entry->mode = mode;
-
- /* Add client to cache */
- silc_idcache_add(conn->client_cache, client_entry->nickname,
- client_id, (void *)client_entry, FALSE);
+ client_entry =
+ silc_client_add_client(cmd->client, conn, nickname, username, realname,
+ client_id, mode);
} else {
client_entry = (SilcClientEntry)id_cache->context;
- if (client_entry->nickname)
- silc_free(client_entry->nickname);
- if (client_entry->server)
- silc_free(client_entry->server);
- if (client_entry->username)
- silc_free(client_entry->username);
- if (client_entry->realname)
- silc_free(client_entry->realname);
- client_entry->mode = mode;
-
- SILC_LOG_DEBUG(("Updating client entry"));
-
- silc_parse_nickname(nickname, &client_entry->nickname,
- &client_entry->server, &client_entry->num);
- client_entry->username = strdup(username);
- if (realname)
- client_entry->realname = strdup(realname);
-
- /* Remove the old cache entry and create a new one */
- silc_idcache_del_by_context(conn->client_cache, client_entry);
- silc_idcache_add(conn->client_cache, client_entry->nickname,
- client_entry->id, client_entry, FALSE);
+ silc_client_update_client(cmd->client, conn, client_entry,
+ nickname, username, realname, mode);
silc_free(client_id);
}
silc_hash_client_id_compare, NULL,
&id_cache)) {
SILC_LOG_DEBUG(("Adding new client entry"));
-
- client_entry = silc_calloc(1, sizeof(*client_entry));
- client_entry->id = silc_id_dup(client_id, id_type);
- silc_parse_nickname(name, &client_entry->nickname,
- &client_entry->server, &client_entry->num);
- if (info)
- client_entry->username = strdup(info);
-
- /* Add client to cache */
- silc_idcache_add(conn->client_cache, client_entry->nickname,
- client_entry->id, (void *)client_entry, FALSE);
+ client_entry =
+ silc_client_add_client(cmd->client, conn, name, info, NULL,
+ silc_id_dup(client_id, id_type), 0);
} else {
client_entry = (SilcClientEntry)id_cache->context;
- if (client_entry->nickname)
- silc_free(client_entry->nickname);
- if (client_entry->server)
- silc_free(client_entry->server);
- if (info && client_entry->username)
- silc_free(client_entry->username);
-
- SILC_LOG_DEBUG(("Updating client entry"));
-
- silc_parse_nickname(name, &client_entry->nickname,
- &client_entry->server, &client_entry->num);
-
- if (info)
- client_entry->username = strdup(info);
-
- /* Remove the old cache entry and create a new one */
- silc_idcache_del_by_context(conn->client_cache, client_entry);
- silc_idcache_add(conn->client_cache, client_entry->nickname,
- client_entry->id, client_entry, FALSE);
+ silc_client_update_client(cmd->client, conn, client_entry,
+ name, info, NULL, 0);
}
/* Notify application */
server_entry = silc_calloc(1, sizeof(*server_entry));
server_entry->server_id = silc_id_dup(server_id, id_type);
- server_entry->server_name = strdup(name);
+ if (name)
+ server_entry->server_name = strdup(name);
if (info)
server_entry->server_info = strdup(info);
/* Check if we have this channel cached already. */
if (!silc_idcache_find_by_id_one(conn->channel_cache,
(void *)channel_id, &id_cache)) {
+ if (!name)
+ break;
+
SILC_LOG_DEBUG(("Adding new channel entry"));
channel_entry = silc_client_new_channel_id(client, conn->sock,
- name, 0, idp);
+ strdup(name), 0, idp);
} else {
channel_entry = (SilcChannelEntry)id_cache->context;
}
silc_hash_client_id_compare, NULL,
&id_cache)) {
/* No, we don't have it, add entry for it. */
- client_entry = silc_calloc(1, sizeof(*client_entry));
- client_entry->id = silc_id_dup(client_id, SILC_ID_CLIENT);
- silc_idcache_add(conn->client_cache, NULL, client_entry->id,
- (void *)client_entry, FALSE);
+ client_entry =
+ silc_client_add_client(cmd->client, conn, NULL, NULL, NULL,
+ silc_id_dup(client_id, SILC_ID_CLIENT), 0);
} else {
/* Yes, we have it already */
client_entry = (SilcClientEntry)id_cache->context;
/* Get the public key payload */
tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
- if (!tmp)
- goto out;
-
- /* Decode the public key */
-
- SILC_GET16_MSB(pk_len, tmp);
- SILC_GET16_MSB(type, tmp + 2);
- pk = tmp + 4;
-
- if (type != SILC_SKE_PK_TYPE_SILC)
- goto out;
-
- if (!silc_pkcs_public_key_decode(pk, pk_len, &public_key))
- goto out;
-
+ if (tmp) {
+ /* Decode the public key */
+ SILC_GET16_MSB(pk_len, tmp);
+ SILC_GET16_MSB(type, tmp + 2);
+ pk = tmp + 4;
+
+ if (type != SILC_SKE_PK_TYPE_SILC)
+ goto out;
+
+ if (!silc_pkcs_public_key_decode(pk, pk_len, &public_key))
+ goto out;
+ }
+
id_type = silc_id_payload_get_type(idp);
if (id_type == SILC_ID_CLIENT) {
/* Received client's public key */