updates.
[silc.git] / apps / silcd / idlist.c
index 5788e65656a497a5f81c1e9e62998b0af0c1f612..fa084ec69496e6349eacc35489e03431b6c57ee8 100644 (file)
@@ -36,14 +36,19 @@ void silc_idlist_add_data(void *entry, SilcIDListData idata)
   SilcIDListData data = (SilcIDListData)entry;
   data->send_key = idata->send_key;
   data->receive_key = idata->receive_key;
-  data->rekey = idata->rekey;
-  data->hash = idata->hash;
   data->hmac_send = idata->hmac_send;
   data->hmac_receive = idata->hmac_receive;
+  data->psn_send = idata->psn_send;
+  data->psn_receive = idata->psn_receive;
+  data->hash = idata->hash;
   data->public_key = idata->public_key;
+  memcpy(data->fingerprint, idata->fingerprint, sizeof(data->fingerprint));
+  data->rekey = idata->rekey;
   data->last_receive = idata->last_receive;
   data->last_sent = idata->last_sent;
   data->status = idata->status;
+
+  data->created = time(0);     /* Update creation time */
 }
 
 /* Free's all data in the common ID entry data structure. */
@@ -62,8 +67,12 @@ void silc_idlist_del_data(void *entry)
     }
     silc_free(idata->rekey);
   }
-  if (idata->hmac_send)                /* Same as idata->hmac_receive */
+  if (idata->hmac_send)
     silc_hmac_free(idata->hmac_send);
+  if (idata->hmac_receive)
+    silc_hmac_free(idata->hmac_receive);
+  if (idata->hash)
+    silc_hash_free(idata->hash);
   if (idata->public_key)
     silc_pkcs_public_key_free(idata->public_key);
 }
@@ -281,10 +290,8 @@ int silc_idlist_del_server(SilcIDList id_list, SilcServerEntry entry)
        return FALSE;
 
     /* Free data */
-    if (entry->server_name)
-      silc_free(entry->server_name);
-    if (entry->id)
-      silc_free(entry->id);
+    silc_free(entry->server_name);
+    silc_free(entry->id);
 
     memset(entry, 'F', sizeof(*entry));
     silc_free(entry);
@@ -352,14 +359,11 @@ int silc_idlist_del_client(SilcIDList id_list, SilcClientEntry entry)
        return FALSE;
 
     /* Free data */
-    if (entry->nickname)
-      silc_free(entry->nickname);
-    if (entry->username)
-      silc_free(entry->username);
-    if (entry->userinfo)
-      silc_free(entry->userinfo);
-    if (entry->id)
-      silc_free(entry->id);
+    silc_free(entry->nickname);
+    silc_free(entry->username);
+    silc_free(entry->userinfo);
+    silc_free(entry->id);
+    silc_hash_table_free(entry->channels);
 
     memset(entry, 'F', sizeof(*entry));
     silc_free(entry);
@@ -532,18 +536,13 @@ void silc_idlist_client_destructor(SilcIDCache cache,
 {
   SilcClientEntry client;
 
-  SILC_LOG_DEBUG(("Start"));
-
   client = (SilcClientEntry)entry->context;
   if (client) {
-    if (client->nickname)
-      silc_free(client->nickname);
-    if (client->username)
-      silc_free(client->username);
-    if (client->userinfo)
-      silc_free(client->userinfo);
-    if (client->id)
-      silc_free(client->id);
+    silc_free(client->nickname);
+    silc_free(client->username);
+    silc_free(client->userinfo);
+    silc_free(client->id);
+    silc_hash_table_free(client->channels);
 
     memset(client, 'F', sizeof(*client));
     silc_free(client);
@@ -575,6 +574,7 @@ silc_idlist_add_channel(SilcIDList id_list, char *channel_name, int mode,
   channel->router = router;
   channel->channel_key = channel_key;
   channel->hmac = hmac;
+  channel->created = time(0);
   if (!channel->hmac)
     if (!silc_hmac_alloc(SILC_DEFAULT_HMAC, NULL, &channel->hmac)) {
       silc_free(channel);
@@ -622,24 +622,20 @@ int silc_idlist_del_channel(SilcIDList id_list, SilcChannelEntry entry)
        return FALSE;
 
     /* Free data */
-    if (entry->channel_name)
-      silc_free(entry->channel_name);
-    if (entry->id)
-      silc_free(entry->id);
-    if (entry->topic)
-      silc_free(entry->topic);
+    silc_free(entry->channel_name);
+    silc_free(entry->id);
+    silc_free(entry->topic);
     if (entry->channel_key)
       silc_cipher_free(entry->channel_key);
     if (entry->key) {
       memset(entry->key, 0, entry->key_len / 8);
       silc_free(entry->key);
     }
-    if (entry->cipher)
-      silc_free(entry->cipher);
-    if (entry->hmac_name)
-      silc_free(entry->hmac_name);
-    if (entry->rekey)
-      silc_free(entry->rekey);
+    silc_free(entry->cipher);
+    if (entry->hmac)
+      silc_hmac_free(entry->hmac);
+    silc_free(entry->hmac_name);
+    silc_free(entry->rekey);
 
     /* Free all client entrys from the users list. The silc_hash_table_free
        will free all the entries so they are not freed at the foreach