snprintf(ident, sizeof(ident), "IDENTIFY %s", nickname);
silc_parse_command_line(ident, &ctx->argv, &ctx->argv_lens,
&ctx->argv_types, &ctx->argc, 2);
- ctx->command->cb(ctx);
-
- i->cmd = ctx;
+
+ i->cmd = silc_client_command_dup(ctx);
i->nickname = nickname ? strdup(nickname) : NULL;
i->server = server ? strdup(server) : NULL;
i->completion = completion;
i->context = context;
+ /* Call the command */
+ ctx->command->cb(ctx);
+
/* Add pending callback */
silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY,
- ++conn->cmd_ident,
+ conn->cmd_ident,
silc_client_get_client_destructor,
silc_client_command_get_client_callback,
(void *)i);
int i = 0;
/* Find ID from cache */
- if (!silc_idcache_find_by_data_loose(conn->client_cache, nickname, &list))
+ if (!silc_idcache_find_by_name(conn->client_cache, nickname, &list))
return NULL;
if (!silc_idcache_list_count(list)) {
continue;
/* Get the client entry */
- if (silc_idcache_find_by_id_one(i->conn->client_cache, (void *)client_id,
- SILC_ID_CLIENT, &id_cache)) {
+ if (silc_idcache_find_by_id_one_ext(i->conn->client_cache,
+ (void *)client_id,
+ NULL, NULL,
+ silc_hash_client_id_compare, NULL,
+ &id_cache)) {
clients = silc_realloc(clients, sizeof(*clients) *
(clients_count + 1));
clients[clients_count] = (SilcClientEntry)id_cache->context;
/* Check if we have this client cached already. */
id_cache = NULL;
- silc_idcache_find_by_id_one(conn->client_cache, (void *)client_id,
- SILC_ID_CLIENT, &id_cache);
+ silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)client_id,
+ NULL, NULL,
+ silc_hash_client_id_compare, NULL,
+ &id_cache);
/* If we don't have the entry or it has incomplete info, then resolve
it from the server. */
SilcClientEntry entry = NULL;
/* Find ID from cache */
- if (!silc_idcache_find_by_data_loose(conn->client_cache, nickname, &list)) {
+ if (!silc_idcache_find_by_name(conn->client_cache, nickname, &list)) {
identify:
if (query) {
silc_id_render(client_id, SILC_ID_CLIENT)));
/* Find ID from cache */
- if (!silc_idcache_find_by_id_one(conn->client_cache, client_id,
- SILC_ID_CLIENT, &id_cache))
+ if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)client_id,
+ NULL, NULL,
+ silc_hash_client_id_compare, NULL,
+ &id_cache))
return NULL;
SILC_LOG_DEBUG(("Found"));
(void *)i);
}
+/* Removes client from the cache by the client entry. */
+
+bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
+ SilcClientEntry client_entry)
+{
+ return silc_idcache_del_by_context(conn->client_cache, client_entry);
+}
+
+/* Removes client from the cache by the client ID. */
+
+bool silc_client_del_client_by_id(SilcClient client,
+ SilcClientConnection conn,
+ SilcClientID *client_id)
+{
+ return silc_idcache_del_by_id_ext(conn->client_cache, (void *)client_id,
+ NULL, NULL,
+ silc_hash_client_id_compare, NULL);
+}
+
/* Finds entry for channel by the channel name. Returns the entry or NULL
if the entry was not found. It is found only if the client is joined
to the channel. */
SilcIDCacheEntry id_cache;
SilcChannelEntry entry;
- if (!silc_idcache_find_by_data_one(conn->channel_cache, channel, &id_cache))
+ if (!silc_idcache_find_by_name_one(conn->channel_cache, channel,
+ &id_cache))
return NULL;
entry = (SilcChannelEntry)id_cache->context;