+ GNUNET_CONFIGURATION_get_value_filename (h->cfg, "FS", "UPDATE_DIR",
+ &dn))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "fs", "UPDATE_DIR");
+ return NULL;
+ }
+ GNUNET_CRYPTO_ecdsa_key_get_public (ns, &pub);
+ GNUNET_CRYPTO_hash (&pub, sizeof (pub), &hc);
+ GNUNET_CRYPTO_hash_to_enc (&hc,
+ &enc);
+ GNUNET_asprintf (&ret, "%s%s%s",
+ dn,
+ DIR_SEPARATOR_STR,
+ (const char *) enc.encoding);
+ GNUNET_free (dn);
+ return ret;
+}
+
+
+/**
+ * Release memory occupied by UIG datastructure.
+ *
+ * @param uig data structure to free
+ */
+static void
+free_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
+{
+ unsigned int i;
+ struct NamespaceUpdateNode *nsn;
+
+ for (i = 0; i < uig->update_node_count; i++)
+ {
+ nsn = uig->update_nodes[i];
+ GNUNET_CONTAINER_meta_data_destroy (nsn->md);
+ GNUNET_FS_uri_destroy (nsn->uri);
+ GNUNET_free (nsn->id);
+ GNUNET_free (nsn->update);
+ GNUNET_free (nsn);
+ }
+ GNUNET_array_grow (uig->update_nodes, uig->update_node_count,
+ 0);
+ if (NULL != uig->update_map)
+ GNUNET_CONTAINER_multihashmap_destroy (uig->update_map);
+ GNUNET_free (uig);
+}
+
+
+/**
+ * Write a namespace's update node graph to a file.
+ *
+ * @param uig update information graph to dump
+ */
+static void
+write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
+{
+ char *fn;
+ struct GNUNET_BIO_WriteHandle *wh;
+ unsigned int i;
+ struct NamespaceUpdateNode *n;
+ char *uris;
+
+ fn = get_update_information_directory (uig->h,
+ &uig->ns);
+ wh = GNUNET_BIO_write_open (fn);
+ if (NULL == wh)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to open `%s' for writing: %s\n"), STRERROR (errno));
+ GNUNET_free (fn);
+ return;
+ }
+ if (GNUNET_OK != GNUNET_BIO_write_int32 (wh, uig->update_node_count))
+ goto END;
+ for (i = 0; i < uig->update_node_count; i++)
+ {
+ n = uig->update_nodes[i];
+ uris = GNUNET_FS_uri_to_string (n->uri);
+ if ((GNUNET_OK != GNUNET_BIO_write_string (wh, n->id)) ||
+ (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, n->md)) ||
+ (GNUNET_OK != GNUNET_BIO_write_string (wh, n->update)) ||
+ (GNUNET_OK != GNUNET_BIO_write_string (wh, uris)))