aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_namespace.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-10 22:17:19 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-10 22:17:19 +0000
commit7dc9c567366b73f192eaf4eab4570e6119e07000 (patch)
tree03b0db913f12dfa0e575ff5d735902360e0df3b7 /src/fs/fs_namespace.c
parentd0e3840931750ca4bf4848d950ab9a0c0b5022bc (diff)
downloadgnunet-7dc9c567366b73f192eaf4eab4570e6119e07000.tar.gz
gnunet-7dc9c567366b73f192eaf4eab4570e6119e07000.zip
eliminating use of 'namespace' as a fieldname / variable name to be C++ compatible
Diffstat (limited to 'src/fs/fs_namespace.c')
-rw-r--r--src/fs/fs_namespace.c106
1 files changed, 53 insertions, 53 deletions
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index 0c7b445ad..29cef7472 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -282,44 +282,44 @@ GNUNET_FS_namespace_dup (struct GNUNET_FS_Namespace *ns)
282 * memory) or also to freeze the namespace to prevent further 282 * memory) or also to freeze the namespace to prevent further
283 * insertions by anyone. 283 * insertions by anyone.
284 * 284 *
285 * @param namespace handle to the namespace that should be deleted / freed 285 * @param ns handle to the namespace that should be deleted / freed
286 * @param freeze prevents future insertions; creating a namespace 286 * @param freeze prevents future insertions; creating a namespace
287 * with the same name again will create a fresh namespace instead 287 * with the same name again will create a fresh namespace instead
288 * 288 *
289 * @return GNUNET_OK on success, GNUNET_SYSERR on error 289 * @return GNUNET_OK on success, GNUNET_SYSERR on error
290 */ 290 */
291int 291int
292GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *namespace, int freeze) 292GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *ns, int freeze)
293{ 293{
294 unsigned int i; 294 unsigned int i;
295 struct NamespaceUpdateNode *nsn; 295 struct NamespaceUpdateNode *nsn;
296 296
297 namespace->rc--; 297 ns->rc--;
298 if (freeze) 298 if (freeze)
299 { 299 {
300 if (0 != UNLINK (namespace->filename)) 300 if (0 != UNLINK (ns->filename))
301 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink", 301 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink",
302 namespace->filename); 302 ns->filename);
303 } 303 }
304 if (0 != namespace->rc) 304 if (0 != ns->rc)
305 return GNUNET_OK; 305 return GNUNET_OK;
306 GNUNET_CRYPTO_rsa_key_free (namespace->key); 306 GNUNET_CRYPTO_rsa_key_free (ns->key);
307 GNUNET_free (namespace->filename); 307 GNUNET_free (ns->filename);
308 GNUNET_free (namespace->name); 308 GNUNET_free (ns->name);
309 for (i = 0; i < namespace->update_node_count; i++) 309 for (i = 0; i < ns->update_node_count; i++)
310 { 310 {
311 nsn = namespace->update_nodes[i]; 311 nsn = ns->update_nodes[i];
312 GNUNET_CONTAINER_meta_data_destroy (nsn->md); 312 GNUNET_CONTAINER_meta_data_destroy (nsn->md);
313 GNUNET_FS_uri_destroy (nsn->uri); 313 GNUNET_FS_uri_destroy (nsn->uri);
314 GNUNET_free (nsn->id); 314 GNUNET_free (nsn->id);
315 GNUNET_free (nsn->update); 315 GNUNET_free (nsn->update);
316 GNUNET_free (nsn); 316 GNUNET_free (nsn);
317 } 317 }
318 GNUNET_array_grow (namespace->update_nodes, namespace->update_node_count, 318 GNUNET_array_grow (ns->update_nodes, ns->update_node_count,
319 0); 319 0);
320 if (namespace->update_map != NULL) 320 if (ns->update_map != NULL)
321 GNUNET_CONTAINER_multihashmap_destroy (namespace->update_map); 321 GNUNET_CONTAINER_multihashmap_destroy (ns->update_map);
322 GNUNET_free (namespace); 322 GNUNET_free (ns);
323 return GNUNET_OK; 323 return GNUNET_OK;
324} 324}
325 325
@@ -429,7 +429,7 @@ struct GNUNET_FS_PublishSksContext
429 /** 429 /**
430 * Namespace we're publishing to. 430 * Namespace we're publishing to.
431 */ 431 */
432 struct GNUNET_FS_Namespace *namespace; 432 struct GNUNET_FS_Namespace *ns;
433 433
434 /** 434 /**
435 * Handle to the datastore. 435 * Handle to the datastore.
@@ -483,19 +483,19 @@ sb_put_cont (void *cls, int success,
483 /* FIXME: this can be done much more 483 /* FIXME: this can be done much more
484 * efficiently by simply appending to the 484 * efficiently by simply appending to the
485 * file and overwriting the 4-byte header */ 485 * file and overwriting the 4-byte header */
486 if (psc->namespace->update_nodes == NULL) 486 if (psc->ns->update_nodes == NULL)
487 read_update_information_graph (psc->namespace); 487 read_update_information_graph (psc->ns);
488 GNUNET_array_append (psc->namespace->update_nodes, 488 GNUNET_array_append (psc->ns->update_nodes,
489 psc->namespace->update_node_count, psc->nsn); 489 psc->ns->update_node_count, psc->nsn);
490 if (psc->namespace->update_map != NULL) 490 if (psc->ns->update_map != NULL)
491 { 491 {
492 GNUNET_CRYPTO_hash (psc->nsn->id, strlen (psc->nsn->id), &hc); 492 GNUNET_CRYPTO_hash (psc->nsn->id, strlen (psc->nsn->id), &hc);
493 GNUNET_CONTAINER_multihashmap_put (psc->namespace->update_map, &hc, 493 GNUNET_CONTAINER_multihashmap_put (psc->ns->update_map, &hc,
494 psc->nsn, 494 psc->nsn,
495 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 495 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
496 } 496 }
497 psc->nsn = NULL; 497 psc->nsn = NULL;
498 write_update_information_graph (psc->namespace); 498 write_update_information_graph (psc->ns);
499 } 499 }
500 if (NULL != psc->cont) 500 if (NULL != psc->cont)
501 psc->cont (psc->cont_cls, psc->uri, NULL); 501 psc->cont (psc->cont_cls, psc->uri, NULL);
@@ -507,7 +507,7 @@ sb_put_cont (void *cls, int success,
507 * Publish an SBlock on GNUnet. 507 * Publish an SBlock on GNUnet.
508 * 508 *
509 * @param h handle to the file sharing subsystem 509 * @param h handle to the file sharing subsystem
510 * @param namespace namespace to publish in 510 * @param ns namespace to publish in
511 * @param identifier identifier to use 511 * @param identifier identifier to use
512 * @param update update identifier to use 512 * @param update update identifier to use
513 * @param meta metadata to use 513 * @param meta metadata to use
@@ -520,7 +520,7 @@ sb_put_cont (void *cls, int success,
520 */ 520 */
521struct GNUNET_FS_PublishSksContext * 521struct GNUNET_FS_PublishSksContext *
522GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, 522GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
523 struct GNUNET_FS_Namespace *namespace, 523 struct GNUNET_FS_Namespace *ns,
524 const char *identifier, const char *update, 524 const char *identifier, const char *update,
525 const struct GNUNET_CONTAINER_MetaData *meta, 525 const struct GNUNET_CONTAINER_MetaData *meta,
526 const struct GNUNET_FS_Uri *uri, 526 const struct GNUNET_FS_Uri *uri,
@@ -592,12 +592,12 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
592 GNUNET_CRYPTO_hash (&key, sizeof (struct GNUNET_HashCode), &id); 592 GNUNET_CRYPTO_hash (&key, sizeof (struct GNUNET_HashCode), &id);
593 sks_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); 593 sks_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
594 sks_uri->type = sks; 594 sks_uri->type = sks;
595 GNUNET_CRYPTO_rsa_key_get_public (namespace->key, &sb_enc->subspace); 595 GNUNET_CRYPTO_rsa_key_get_public (ns->key, &sb_enc->subspace);
596 GNUNET_CRYPTO_hash (&sb_enc->subspace, 596 GNUNET_CRYPTO_hash (&sb_enc->subspace,
597 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 597 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
598 &sks_uri->data.sks.namespace); 598 &sks_uri->data.sks.ns);
599 sks_uri->data.sks.identifier = GNUNET_strdup (identifier); 599 sks_uri->data.sks.identifier = GNUNET_strdup (identifier);
600 GNUNET_CRYPTO_hash_xor (&id, &sks_uri->data.sks.namespace, 600 GNUNET_CRYPTO_hash_xor (&id, &sks_uri->data.sks.ns,
601 &sb_enc->identifier); 601 &sb_enc->identifier);
602 GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv); 602 GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv);
603 GNUNET_CRYPTO_aes_encrypt (&sb[1], size - sizeof (struct SBlock), &sk, &iv, 603 GNUNET_CRYPTO_aes_encrypt (&sb[1], size - sizeof (struct SBlock), &sk, &iv,
@@ -607,12 +607,12 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
607 htonl (slen + mdsize + nidlen + sizeof (struct SBlock) - 607 htonl (slen + mdsize + nidlen + sizeof (struct SBlock) -
608 sizeof (struct GNUNET_CRYPTO_RsaSignature)); 608 sizeof (struct GNUNET_CRYPTO_RsaSignature));
609 GNUNET_assert (GNUNET_OK == 609 GNUNET_assert (GNUNET_OK ==
610 GNUNET_CRYPTO_rsa_sign (namespace->key, &sb_enc->purpose, 610 GNUNET_CRYPTO_rsa_sign (ns->key, &sb_enc->purpose,
611 &sb_enc->signature)); 611 &sb_enc->signature));
612 psc = GNUNET_malloc (sizeof (struct GNUNET_FS_PublishSksContext)); 612 psc = GNUNET_malloc (sizeof (struct GNUNET_FS_PublishSksContext));
613 psc->uri = sks_uri; 613 psc->uri = sks_uri;
614 psc->cont = cont; 614 psc->cont = cont;
615 psc->namespace = GNUNET_FS_namespace_dup (namespace); 615 psc->ns = GNUNET_FS_namespace_dup (ns);
616 psc->cont_cls = cont_cls; 616 psc->cont_cls = cont_cls;
617 if (0 != (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) 617 if (0 != (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
618 { 618 {
@@ -629,7 +629,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
629 sb_put_cont (psc, GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, _("Failed to connect to datastore.")); 629 sb_put_cont (psc, GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, _("Failed to connect to datastore."));
630 return NULL; 630 return NULL;
631 } 631 }
632 GNUNET_CRYPTO_hash_xor (&sks_uri->data.sks.namespace, &id, &query); 632 GNUNET_CRYPTO_hash_xor (&sks_uri->data.sks.ns, &id, &query);
633 if (NULL != update) 633 if (NULL != update)
634 { 634 {
635 psc->nsn = GNUNET_malloc (sizeof (struct NamespaceUpdateNode)); 635 psc->nsn = GNUNET_malloc (sizeof (struct NamespaceUpdateNode));
@@ -667,7 +667,7 @@ GNUNET_FS_publish_sks_cancel (struct GNUNET_FS_PublishSksContext *psc)
667 GNUNET_DATASTORE_disconnect (psc->dsh, GNUNET_NO); 667 GNUNET_DATASTORE_disconnect (psc->dsh, GNUNET_NO);
668 psc->dsh = NULL; 668 psc->dsh = NULL;
669 } 669 }
670 GNUNET_FS_namespace_delete (psc->namespace, GNUNET_NO); 670 GNUNET_FS_namespace_delete (psc->ns, GNUNET_NO);
671 GNUNET_FS_uri_destroy (psc->uri); 671 GNUNET_FS_uri_destroy (psc->uri);
672 if (NULL != psc->nsn) 672 if (NULL != psc->nsn)
673 { 673 {
@@ -727,7 +727,7 @@ struct FindTreeClosure
727 /** 727 /**
728 * Namespace we are operating on. 728 * Namespace we are operating on.
729 */ 729 */
730 struct GNUNET_FS_Namespace *namespace; 730 struct GNUNET_FS_Namespace *ns;
731 731
732 /** 732 /**
733 * Array with 'head's of TREEs. 733 * Array with 'head's of TREEs.
@@ -799,7 +799,7 @@ find_trees (void *cls, const struct GNUNET_HashCode * key, void *value)
799 nsn->tree_id = UINT_MAX; /* mark as undef */ 799 nsn->tree_id = UINT_MAX; /* mark as undef */
800 /* trace */ 800 /* trace */
801 GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc); 801 GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
802 GNUNET_CONTAINER_multihashmap_get_multiple (fc->namespace->update_map, &hc, 802 GNUNET_CONTAINER_multihashmap_get_multiple (fc->ns->update_map, &hc,
803 &find_trees, fc); 803 &find_trees, fc);
804 } 804 }
805 return GNUNET_YES; 805 return GNUNET_YES;
@@ -823,13 +823,13 @@ find_trees (void *cls, const struct GNUNET_HashCode * key, void *value)
823 * I know, odd definition of a tree, but the GUI will display an actual 823 * I know, odd definition of a tree, but the GUI will display an actual
824 * tree (GtkTreeView), so that's what counts for the term here. 824 * tree (GtkTreeView), so that's what counts for the term here.
825 * 825 *
826 * @param namespace namespace to inspect for updateable content 826 * @param ns namespace to inspect for updateable content
827 * @param next_id ID to look for; use NULL to look for tree roots 827 * @param next_id ID to look for; use NULL to look for tree roots
828 * @param ip function to call on each updateable identifier 828 * @param ip function to call on each updateable identifier
829 * @param ip_cls closure for ip 829 * @param ip_cls closure for ip
830 */ 830 */
831void 831void
832GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace, 832GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *ns,
833 const char *next_id, 833 const char *next_id,
834 GNUNET_FS_IdentifierProcessor ip, 834 GNUNET_FS_IdentifierProcessor ip,
835 void *ip_cls) 835 void *ip_cls)
@@ -841,26 +841,26 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
841 struct ProcessUpdateClosure pc; 841 struct ProcessUpdateClosure pc;
842 struct FindTreeClosure fc; 842 struct FindTreeClosure fc;
843 843
844 if (NULL == namespace->update_nodes) 844 if (NULL == ns->update_nodes)
845 read_update_information_graph (namespace); 845 read_update_information_graph (ns);
846 if (NULL == namespace->update_nodes) 846 if (NULL == ns->update_nodes)
847 { 847 {
848 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 848 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
849 "No updateable nodes found for ID `%s'\n", next_id); 849 "No updateable nodes found for ID `%s'\n", next_id);
850 return; /* no nodes */ 850 return; /* no nodes */
851 } 851 }
852 if (NULL == namespace->update_map) 852 if (NULL == ns->update_map)
853 { 853 {
854 /* need to construct */ 854 /* need to construct */
855 namespace->update_map = 855 ns->update_map =
856 GNUNET_CONTAINER_multihashmap_create (2 + 856 GNUNET_CONTAINER_multihashmap_create (2 +
857 3 * namespace->update_node_count / 857 3 * ns->update_node_count /
858 4); 858 4);
859 for (i = 0; i < namespace->update_node_count; i++) 859 for (i = 0; i < ns->update_node_count; i++)
860 { 860 {
861 nsn = namespace->update_nodes[i]; 861 nsn = ns->update_nodes[i];
862 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc); 862 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
863 GNUNET_CONTAINER_multihashmap_put (namespace->update_map, &hc, nsn, 863 GNUNET_CONTAINER_multihashmap_put (ns->update_map, &hc, nsn,
864 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 864 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
865 } 865 }
866 } 866 }
@@ -869,20 +869,20 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
869 GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc); 869 GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc);
870 pc.ip = ip; 870 pc.ip = ip;
871 pc.ip_cls = ip_cls; 871 pc.ip_cls = ip_cls;
872 GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, &hc, 872 GNUNET_CONTAINER_multihashmap_get_multiple (ns->update_map, &hc,
873 &process_update_node, &pc); 873 &process_update_node, &pc);
874 return; 874 return;
875 } 875 }
876 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 876 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
877 "Calculating TREEs to find roots of update trees\n"); 877 "Calculating TREEs to find roots of update trees\n");
878 /* Find heads of TREEs in update graph */ 878 /* Find heads of TREEs in update graph */
879 nug = ++namespace->nug_gen; 879 nug = ++ns->nug_gen;
880 fc.tree_array = NULL; 880 fc.tree_array = NULL;
881 fc.tree_array_size = 0; 881 fc.tree_array_size = 0;
882 882
883 for (i = 0; i < namespace->update_node_count; i++) 883 for (i = 0; i < ns->update_node_count; i++)
884 { 884 {
885 nsn = namespace->update_nodes[i]; 885 nsn = ns->update_nodes[i];
886 if (nsn->nug == nug) 886 if (nsn->nug == nug)
887 { 887 {
888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TREE of node `%s' is %u\n", nsn->id, 888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TREE of node `%s' is %u\n", nsn->id,
@@ -894,8 +894,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
894 nsn->tree_id = UINT_MAX; 894 nsn->tree_id = UINT_MAX;
895 fc.id = UINT_MAX; 895 fc.id = UINT_MAX;
896 fc.nug = nug; 896 fc.nug = nug;
897 fc.namespace = namespace; 897 fc.ns = ns;
898 GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, &hc, 898 GNUNET_CONTAINER_multihashmap_get_multiple (ns->update_map, &hc,
899 &find_trees, &fc); 899 &find_trees, &fc);
900 if (UINT_MAX == fc.id) 900 if (UINT_MAX == fc.id)
901 { 901 {
@@ -921,8 +921,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
921 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc); 921 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
922 fc.id = nsn->tree_id; 922 fc.id = nsn->tree_id;
923 fc.nug = nug; 923 fc.nug = nug;
924 fc.namespace = namespace; 924 fc.ns = ns;
925 GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, &hc, 925 GNUNET_CONTAINER_multihashmap_get_multiple (ns->update_map, &hc,
926 &find_trees, &fc); 926 &find_trees, &fc);
927 } 927 }
928 else 928 else