Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2002, 2003 Pekka Riikonen
+ Copyright (C) 2002, 2004 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
/* $Id$ */
-#include "silcincludes.h"
+#include "silc.h"
#include "silcclient.h"
#include "client_internal.h"
/* Save all joined channels */
silc_hash_table_list(conn->local_entry->channels, &htl);
- while (silc_hash_table_get(&htl, NULL, (void **)&chu)) {
+ while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
unsigned char *chid = silc_id_id2str(chu->channel->id, SILC_ID_CHANNEL);
SilcUInt16 chid_len = silc_id_get_len(chu->channel->id, SILC_ID_CHANNEL);
server. To do that call silc_client_resume_session function.
This returns the old detached session client ID. */
-bool silc_client_process_detach_data(SilcClient client,
+SilcBool silc_client_process_detach_data(SilcClient client,
SilcClientConnection conn,
unsigned char **old_id,
SilcUInt16 *old_id_len)
SilcBufferStruct detach;
SilcUInt32 ch_count;
int i, len;
+ char *newnick;
SILC_LOG_DEBUG(("Start"));
- silc_free(conn->nickname);
silc_buffer_set(&detach, conn->internal->params.detach_data,
conn->internal->params.detach_data_len);
SILC_LOG_HEXDUMP(("Detach data"), detach.data, detach.len);
+ *old_id = NULL;
+ *old_id_len = 0;
+
/* Take the old client ID from the detachment data */
len = silc_buffer_unformat(&detach,
- SILC_STR_UI16_NSTRING_ALLOC(&conn->nickname,
+ SILC_STR_UI16_NSTRING_ALLOC(&newnick,
NULL),
SILC_STR_UI16_NSTRING_ALLOC(old_id, old_id_len),
SILC_STR_UI_INT(NULL),
SILC_STR_END);
if (len == -1)
return FALSE;
+ if (!newnick || !(*old_id) || !(*old_id_len))
+ return FALSE;
+
+ silc_free(conn->nickname);
+ conn->nickname = newnick;
silc_buffer_pull(&detach, len);
SilcUInt32 channel_count;
SilcUInt32 *cmd_idents;
SilcUInt32 cmd_idents_count;
- bool success;
+ SilcBool success;
} *SilcClientResumeSession;
/* Generic command reply callback. */
SilcChannelEntry channel;
SilcBuffer tmp;
int i;
- bool ret;
+ SilcBool ret;
SILC_LOG_DEBUG(("Resuming detached session"));