void silc_server_command_reply_free(SilcServerCommandReplyContext cmd)
{
if (cmd) {
- silc_command_free_payload(cmd->payload);
+ silc_command_payload_free(cmd->payload);
if (cmd->sock)
silc_socket_free(cmd->sock); /* Decrease the reference counter */
silc_free(cmd);
char *nickname, *username, *realname, *servername = NULL;
SilcClientID *client_id;
SilcClientEntry client;
- SilcIDCacheEntry cache = NULL;
char global = FALSE;
char *nick;
uint32 mode = 0, len, id_len;
/* Check if we have this client cached already. */
- client = silc_idlist_find_client_by_id(server->local_list, client_id,
- &cache);
+ client = silc_idlist_find_client_by_id(server->local_list, client_id, NULL);
if (!client) {
- client = silc_idlist_find_client_by_id(server->global_list,
- client_id, &cache);
+ client = silc_idlist_find_client_by_id(server->global_list, client_id,
+ NULL);
global = TRUE;
}
/* We don't have that client anywhere, add it. The client is added
to global list since server didn't have it in the lists so it must be
global. */
- client = silc_idlist_add_client(server->global_list, nick, strlen(nick),
+ client = silc_idlist_add_client(server->global_list, nick,
strdup(username),
strdup(realname), client_id,
cmd->sock->user_data, NULL);
client->mode = mode;
client->servername = servername;
- if (cache) {
- cache->data = nick;
- cache->data_len = strlen(nick);
- silc_idcache_sort_by_data(global ? server->global_list->clients :
- server->local_list->clients);
- }
-
+ /* Remove the old cache entry and create a new one */
+ silc_idcache_del_by_context(global ? server->global_list->clients :
+ server->local_list->clients, client);
+ silc_idcache_add(global ? server->global_list->clients :
+ server->local_list->clients, nick, client->id,
+ client, FALSE);
silc_free(client_id);
}
/* We don't have that client anywhere, add it. The client is added
to global list since server didn't have it in the lists so it must be
global. */
- client = silc_idlist_add_client(server->global_list, nick, strlen(nick),
+ client = silc_idlist_add_client(server->global_list, nick,
strdup(username), strdup(realname),
silc_id_dup(client_id, SILC_ID_CLIENT),
cmd->sock->user_data, NULL);
client->username = strdup(username);
client->servername = servername;
- if (cache) {
- cache->data = nick;
- cache->data_len = strlen(nick);
- silc_idcache_sort_by_data(global ? server->global_list->clients :
- server->local_list->clients);
- }
+ /* Remove the old cache entry and create a new one */
+ silc_idcache_del_by_context(global ? server->global_list->clients :
+ server->local_list->clients, client);
+ silc_idcache_add(global ? server->global_list->clients :
+ server->local_list->clients, nick, client->id,
+ client, FALSE);
}
silc_free(client_id);
char *nickname, *username;
SilcClientID *client_id;
SilcClientEntry client;
- SilcIDCacheEntry cache = NULL;
char global = FALSE;
char *nick = NULL;
/* Check if we have this client cached already. */
- client = silc_idlist_find_client_by_id(server->local_list, client_id,
- &cache);
+ client = silc_idlist_find_client_by_id(server->local_list, client_id, NULL);
if (!client) {
- client = silc_idlist_find_client_by_id(server->global_list,
- client_id, &cache);
+ client = silc_idlist_find_client_by_id(server->global_list, client_id,
+ NULL);
global = TRUE;
}
/* We don't have that client anywhere, add it. The client is added
to global list since server didn't have it in the lists so it must be
global. */
- client = silc_idlist_add_client(server->global_list, nick, strlen(nick),
+ client = silc_idlist_add_client(server->global_list, nick,
username ? strdup(username) : NULL, NULL,
client_id, cmd->sock->user_data, NULL);
client->data.registered = TRUE;
client->username = strdup(username);
}
- if (nickname && cache) {
- cache->data = nick;
- cache->data_len = strlen(nick);
- silc_idcache_sort_by_data(global ? server->global_list->clients :
- server->local_list->clients);
+ /* Remove the old cache entry and create a new one */
+ if (nickname) {
+ silc_idcache_del_by_context(global ? server->global_list->clients :
+ server->local_list->clients, client);
+ silc_idcache_add(global ? server->global_list->clients :
+ server->local_list->clients, nick, client->id,
+ client, FALSE);
}
-
silc_free(client_id);
}