if (!client)
return;
- SILC_LOG_DEBUG(("Remove client from all channels"));
+ SILC_LOG_DEBUG(("Remove client %s from all channels",
+ client->nickname ? client->nickname :
+ (unsigned char *)""));
if (silc_hash_table_find(clients, client, NULL, NULL))
silc_hash_table_del(clients, client);
/* Remove the client from all channels. This generates new keys to the
channels as well. */
silc_server_remove_from_channels(server, NULL, remote_client, FALSE,
- NULL, TRUE);
+ NULL, TRUE, TRUE);
/* Remove the client entry, If it is locally connected then we will also
disconnect the client here */
unsigned char *tmp = NULL;
SilcUInt32 len = 0, t;
SilcHashTableList htl;
- SilcBuffer entry;
+ SilcBuffer entry, idp = NULL;
bool ret = FALSE;
if (type < 1 || type > 3 || !check)
return FALSE;
}
if (type == 3) {
- tmp = silc_id_id2str(check, SILC_ID_CLIENT);
- if (!tmp)
+ idp = silc_id_payload_encode(check, SILC_ID_CLIENT);
+ if (!idp)
return FALSE;
- len = silc_id_get_len(check, SILC_ID_CLIENT);
+ tmp = idp->data;
+ len = idp->len;
}
/* Compare the list */
}
silc_hash_table_list_reset(&htl);
- silc_free(tmp);
+ if (!idp)
+ silc_free(tmp);
+ silc_buffer_free(idp);
return ret;
}
+static void silc_server_inviteban_dummy_dest(void *key, void *context,
+ void *user_context)
+{
+ /* Nothing */
+}
+
/* Process invite or ban information */
void silc_server_inviteban_process(SilcServer server, SilcHashTable list,
char *string = NULL;
silc_hash_table_find(list, (void *)1,
NULL, (void **)&string);
- silc_hash_table_del(list, (void *)1);
+ silc_hash_table_del_ext(list, (void *)1, NULL, NULL, NULL, NULL,
+ silc_server_inviteban_dummy_dest, NULL);
if (!string)
string = silc_calloc(len + 2, sizeof(*string));
else
char *string = NULL, *start, *end, *n;
if (silc_hash_table_find(list, (void *)1, NULL, (void **)&string)) {
- silc_hash_table_del(list, (void *)1);
-
if (!strncmp(string, tmp, strlen(string) - 1)) {
- silc_free(string);
+ silc_hash_table_del(list, (void *)1);
string = NULL;
} else {
start = strstr(string, tmp);
n = silc_calloc(strlen(string) - len, sizeof(*n));
strncat(n, string, start - string);
strncat(n, end + 1, ((string + strlen(string)) - end) - 1);
- silc_free(string);
+ silc_hash_table_del(list, (void *)1);
string = n;
}
}
while (silc_hash_table_get(&htl, (void **)&type, (void **)&tmp2)) {
if (type == 2 && !memcmp(tmp2->data, tmp, len)) {
silc_hash_table_del_by_context(list, (void *)2, tmp2);
- silc_buffer_free(tmp2);
break;
}
}
/* Delete from the invite list */
silc_hash_table_list(list, &htl);
while (silc_hash_table_get(&htl, (void **)&type, (void **)&tmp2)) {
- if (type == 2 && !memcmp(tmp2->data, tmp, len)) {
- silc_hash_table_del_by_context(list, (void *)2, tmp2);
- silc_buffer_free(tmp2);
+ if (type == 3 && !memcmp(tmp2->data, tmp, len)) {
+ silc_hash_table_del_by_context(list, (void *)3, tmp2);
break;
}
}
}
}
}
+
+/* Destructor for invite or ban list entrys */
+
+void silc_server_inviteban_destruct(void *key, void *context,
+ void *user_context)
+{
+ switch ((SilcUInt32)key) {
+ case 1:
+ /* Invite string */
+ silc_free(context);
+ break;
+ case 2:
+ case 3:
+ /* Public key/Channel ID SilcBuffer */
+ silc_buffer_free(context);
+ break;
+ default:
+ break;
+ }
+}