aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-12-04 23:26:25 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-12-04 23:26:25 +0900
commit395bc9345a005a55e29a7882fdcc82f35c06d2e5 (patch)
treeb111592f9f57025a19ddafe11877f6038263ae7f /src/fs
parent3f0d91045d29435feef723f09f9ff75c80296d3d (diff)
downloadgnunet-395bc9345a005a55e29a7882fdcc82f35c06d2e5.tar.gz
gnunet-395bc9345a005a55e29a7882fdcc82f35c06d2e5.zip
Large refactor in order to restore some sanity with respect to private defines used in headers
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/Makefile.am18
-rw-r--r--src/fs/fs.h1
-rw-r--r--src/fs/fs_api.c21
-rw-r--r--src/fs/fs_api.h7
-rw-r--r--src/fs/fs_directory.c65
-rw-r--r--src/fs/fs_dirmetascan.c27
-rw-r--r--src/fs/fs_download.c21
-rw-r--r--src/fs/fs_file_information.c33
-rw-r--r--src/fs/fs_getopt.c43
-rw-r--r--src/fs/fs_list_indexed.c1
-rw-r--r--src/fs/fs_misc.c45
-rw-r--r--src/fs/fs_namespace.c23
-rw-r--r--src/fs/fs_publish.c11
-rw-r--r--src/fs/fs_publish_ksk.c9
-rw-r--r--src/fs/fs_publish_ublock.c8
-rw-r--r--src/fs/fs_publish_ublock.h3
-rw-r--r--src/fs/fs_search.c39
-rw-r--r--src/fs/fs_sharetree.c33
-rw-r--r--src/fs/fs_unindex.c1
-rw-r--r--src/fs/fs_uri.c13
-rw-r--r--src/fs/gnunet-daemon-fsprofiler.c1
-rw-r--r--src/fs/gnunet-directory.c9
-rw-r--r--src/fs/gnunet-download.c1
-rw-r--r--src/fs/gnunet-fs.c1
-rw-r--r--src/fs/gnunet-helper-fs-publish.c45
-rw-r--r--src/fs/gnunet-publish.c27
-rw-r--r--src/fs/gnunet-search.c123
-rw-r--r--src/fs/gnunet-unindex.c1
-rw-r--r--src/fs/meta_data.c1224
-rw-r--r--src/fs/plugin_block_fs.c1
-rw-r--r--src/fs/test_fs_directory.c10
-rw-r--r--src/fs/test_fs_download.c2
-rw-r--r--src/fs/test_fs_download_persistence.c2
-rw-r--r--src/fs/test_fs_file_information.c4
-rw-r--r--src/fs/test_fs_list_indexed.c2
-rw-r--r--src/fs/test_fs_meta_data.c379
-rw-r--r--src/fs/test_fs_namespace.c6
-rw-r--r--src/fs/test_fs_namespace_list_updateable.c8
-rw-r--r--src/fs/test_fs_publish.c2
-rw-r--r--src/fs/test_fs_publish_persistence.c2
-rw-r--r--src/fs/test_fs_search.c2
-rw-r--r--src/fs/test_fs_search_persistence.c2
-rw-r--r--src/fs/test_fs_search_probes.c2
-rw-r--r--src/fs/test_fs_search_with_and.c2
-rw-r--r--src/fs/test_fs_unindex.c2
-rw-r--r--src/fs/test_fs_unindex_persistence.c2
46 files changed, 1963 insertions, 321 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index 56df4bfc7..7773c58ee 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -40,7 +40,8 @@ libgnunetfs_la_SOURCES = \
40 fs_sharetree.c \ 40 fs_sharetree.c \
41 fs_tree.c fs_tree.h \ 41 fs_tree.c fs_tree.h \
42 fs_unindex.c \ 42 fs_unindex.c \
43 fs_uri.c 43 fs_uri.c \
44 meta_data.c
44 45
45libgnunetfs_la_LIBADD = \ 46libgnunetfs_la_LIBADD = \
46 $(top_builddir)/src/datastore/libgnunetdatastore.la \ 47 $(top_builddir)/src/datastore/libgnunetdatastore.la \
@@ -148,8 +149,9 @@ endif
148gnunet_helper_fs_publish_SOURCES = \ 149gnunet_helper_fs_publish_SOURCES = \
149 gnunet-helper-fs-publish.c 150 gnunet-helper-fs-publish.c
150gnunet_helper_fs_publish_LDADD = \ 151gnunet_helper_fs_publish_LDADD = \
151 $(top_builddir)/src/util/libgnunetutil.la \ 152 libgnunetfs.la \
152 $(GN_LIBINTL) 153 $(top_builddir)/src/util/libgnunetutil.la \
154 $(GN_LIBINTL)
153 155
154if HAVE_LIBEXTRACTOR 156if HAVE_LIBEXTRACTOR
155gnunet_helper_fs_publish_LDADD += \ 157gnunet_helper_fs_publish_LDADD += \
@@ -249,6 +251,7 @@ check_PROGRAMS = \
249 test_fs_unindex \ 251 test_fs_unindex \
250 test_fs_unindex_persistence \ 252 test_fs_unindex_persistence \
251 test_fs_uri \ 253 test_fs_uri \
254 test_fs_meta_data \
252 test_gnunet_service_fs_migration \ 255 test_gnunet_service_fs_migration \
253 test_gnunet_service_fs_p2p \ 256 test_gnunet_service_fs_p2p \
254 test_gnunet_service_fs_p2p_cadet \ 257 test_gnunet_service_fs_p2p_cadet \
@@ -294,6 +297,7 @@ TESTS = \
294 test_fs_unindex_persistence \ 297 test_fs_unindex_persistence \
295 test_fs_uri \ 298 test_fs_uri \
296 test_fs_test_lib \ 299 test_fs_test_lib \
300 test_fs_meta_data \
297 test_gnunet_service_fs_migration \ 301 test_gnunet_service_fs_migration \
298 test_gnunet_service_fs_p2p \ 302 test_gnunet_service_fs_p2p \
299 test_gnunet_service_fs_p2p_cadet \ 303 test_gnunet_service_fs_p2p_cadet \
@@ -446,6 +450,13 @@ test_fs_unindex_persistence_LDADD = \
446 libgnunetfs.la \ 450 libgnunetfs.la \
447 $(top_builddir)/src/util/libgnunetutil.la 451 $(top_builddir)/src/util/libgnunetutil.la
448 452
453test_fs_meta_data_SOURCES = \
454 test_fs_meta_data.c
455test_fs_meta_data_LDADD = \
456 libgnunetfs.la \
457 $(top_builddir)/src/util/libgnunetutil.la
458
459
449test_fs_uri_SOURCES = \ 460test_fs_uri_SOURCES = \
450 test_fs_uri.c 461 test_fs_uri.c
451test_fs_uri_LDADD = \ 462test_fs_uri_LDADD = \
@@ -520,7 +531,6 @@ perf_gnunet_service_fs_p2p_respect_LDADD = \
520 libgnunetfs.la \ 531 libgnunetfs.la \
521 $(top_builddir)/src/util/libgnunetutil.la 532 $(top_builddir)/src/util/libgnunetutil.la
522 533
523
524test_gnunet_fs_psd.py: test_gnunet_fs_psd.py.in Makefile 534test_gnunet_fs_psd.py: test_gnunet_fs_psd.py.in Makefile
525 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/test_gnunet_fs_psd.py.in > test_gnunet_fs_psd.py 535 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/test_gnunet_fs_psd.py.in > test_gnunet_fs_psd.py
526 chmod +x test_gnunet_fs_psd.py 536 chmod +x test_gnunet_fs_psd.py
diff --git a/src/fs/fs.h b/src/fs/fs.h
index 4c433e774..920cf27b2 100644
--- a/src/fs/fs.h
+++ b/src/fs/fs.h
@@ -29,6 +29,7 @@
29#include "gnunet_constants.h" 29#include "gnunet_constants.h"
30#include "gnunet_datastore_service.h" 30#include "gnunet_datastore_service.h"
31#include "gnunet_dht_service.h" 31#include "gnunet_dht_service.h"
32#include "gnunet_extractor_compat.h"
32#include "gnunet_fs_service.h" 33#include "gnunet_fs_service.h"
33#include "gnunet_block_lib.h" 34#include "gnunet_block_lib.h"
34#include "block_fs.h" 35#include "block_fs.h"
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c
index 6e97a3812..c786d660c 100644
--- a/src/fs/fs_api.c
+++ b/src/fs/fs_api.c
@@ -26,6 +26,7 @@
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_extractor_compat.h"
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30#include "fs_api.h" 31#include "fs_api.h"
31#include "fs_tree.h" 32#include "fs_tree.h"
@@ -902,7 +903,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
902 chks = NULL; 903 chks = NULL;
903 skss = NULL; 904 skss = NULL;
904 filename = NULL; 905 filename = NULL;
905 if ((GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "metadata", &ret->meta)) || 906 if ((GNUNET_OK != GNUNET_FS_read_meta_data (rh, "metadata", &ret->meta)) ||
906 (GNUNET_OK != GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024)) || 907 (GNUNET_OK != GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024)) ||
907 ((NULL != ksks) && 908 ((NULL != ksks) &&
908 ((NULL == (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL))) || 909 ((NULL == (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL))) ||
@@ -1370,7 +1371,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
1370 skss = NULL; 1371 skss = NULL;
1371 struct GNUNET_BIO_WriteSpec ws1[] = { 1372 struct GNUNET_BIO_WriteSpec ws1[] = {
1372 GNUNET_BIO_write_spec_object ("b", &b, sizeof (b)), 1373 GNUNET_BIO_write_spec_object ("b", &b, sizeof (b)),
1373 GNUNET_BIO_write_spec_meta_data ("meta", fi->meta), 1374 GNUNET_FS_write_spec_meta_data ("meta", fi->meta),
1374 GNUNET_BIO_write_spec_string ("ksks", ksks), 1375 GNUNET_BIO_write_spec_string ("ksks", ksks),
1375 GNUNET_BIO_write_spec_string ("chks", chks), 1376 GNUNET_BIO_write_spec_string ("chks", chks),
1376 GNUNET_BIO_write_spec_string ("skss", skss), 1377 GNUNET_BIO_write_spec_string ("skss", skss),
@@ -1571,7 +1572,7 @@ static int
1571fip_signal_resume (void *cls, 1572fip_signal_resume (void *cls,
1572 struct GNUNET_FS_FileInformation *fi, 1573 struct GNUNET_FS_FileInformation *fi,
1573 uint64_t length, 1574 uint64_t length,
1574 struct GNUNET_CONTAINER_MetaData *meta, 1575 struct GNUNET_FS_MetaData *meta,
1575 struct GNUNET_FS_Uri **uri, 1576 struct GNUNET_FS_Uri **uri,
1576 struct GNUNET_FS_BlockOptions *bo, 1577 struct GNUNET_FS_BlockOptions *bo,
1577 int *do_index, 1578 int *do_index,
@@ -2081,7 +2082,7 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc)
2081 uris = GNUNET_FS_uri_to_string (dc->uri); 2082 uris = GNUNET_FS_uri_to_string (dc->uri);
2082 struct GNUNET_BIO_WriteSpec ws1[] = { 2083 struct GNUNET_BIO_WriteSpec ws1[] = {
2083 GNUNET_BIO_write_spec_string ("uris", uris), 2084 GNUNET_BIO_write_spec_string ("uris", uris),
2084 GNUNET_BIO_write_spec_meta_data ("metadata", dc->meta), 2085 GNUNET_FS_write_spec_meta_data ("metadata", dc->meta),
2085 GNUNET_BIO_write_spec_string ("emsg", dc->emsg), 2086 GNUNET_BIO_write_spec_string ("emsg", dc->emsg),
2086 GNUNET_BIO_write_spec_string ("filename", dc->filename), 2087 GNUNET_BIO_write_spec_string ("filename", dc->filename),
2087 GNUNET_BIO_write_spec_string ("temp filename", dc->temp_filename), 2088 GNUNET_BIO_write_spec_string ("temp filename", dc->temp_filename),
@@ -2184,7 +2185,7 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr)
2184 (sr->update_search != NULL) 2185 (sr->update_search != NULL)
2185 ? sr->update_search->serialization 2186 ? sr->update_search->serialization
2186 : NULL), 2187 : NULL),
2187 GNUNET_BIO_write_spec_meta_data ("metadata", sr->meta), 2188 GNUNET_FS_write_spec_meta_data ("metadata", sr->meta),
2188 GNUNET_BIO_write_spec_object ("key", &sr->key, 2189 GNUNET_BIO_write_spec_object ("key", &sr->key,
2189 sizeof(struct GNUNET_HashCode)), 2190 sizeof(struct GNUNET_HashCode)),
2190 GNUNET_BIO_write_spec_int32 ("mandatory missing", 2191 GNUNET_BIO_write_spec_int32 ("mandatory missing",
@@ -2558,7 +2559,7 @@ deserialize_search_result (void *cls, const char *filename)
2558 GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) || 2559 GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) ||
2559 (GNUNET_OK != 2560 (GNUNET_OK !=
2560 GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) || 2561 GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) ||
2561 (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta)) || 2562 (GNUNET_OK != GNUNET_FS_read_meta_data (rh, "result-meta", &sr->meta)) ||
2562 (GNUNET_OK != GNUNET_BIO_read (rh, 2563 (GNUNET_OK != GNUNET_BIO_read (rh,
2563 "result-key", 2564 "result-key",
2564 &sr->key, 2565 &sr->key,
@@ -2655,7 +2656,7 @@ cleanup:
2655 if (NULL != sr->uri) 2656 if (NULL != sr->uri)
2656 GNUNET_FS_uri_destroy (sr->uri); 2657 GNUNET_FS_uri_destroy (sr->uri);
2657 if (NULL != sr->meta) 2658 if (NULL != sr->meta)
2658 GNUNET_CONTAINER_meta_data_destroy (sr->meta); 2659 GNUNET_FS_meta_data_destroy (sr->meta);
2659 GNUNET_free (sr->serialization); 2660 GNUNET_free (sr->serialization);
2660 GNUNET_free (sr); 2661 GNUNET_free (sr);
2661 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) 2662 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
@@ -2778,7 +2779,7 @@ free_result (void *cls, const struct GNUNET_HashCode *key, void *value)
2778 free_search_context (sr->update_search); 2779 free_search_context (sr->update_search);
2779 GNUNET_assert (NULL == sr->update_search); 2780 GNUNET_assert (NULL == sr->update_search);
2780 } 2781 }
2781 GNUNET_CONTAINER_meta_data_destroy (sr->meta); 2782 GNUNET_FS_meta_data_destroy (sr->meta);
2782 GNUNET_FS_uri_destroy (sr->uri); 2783 GNUNET_FS_uri_destroy (sr->uri);
2783 GNUNET_free (sr); 2784 GNUNET_free (sr);
2784 return GNUNET_YES; 2785 return GNUNET_YES;
@@ -2876,7 +2877,7 @@ free_download_context (struct GNUNET_FS_DownloadContext *dc)
2876 struct GNUNET_FS_DownloadContext *dcc; 2877 struct GNUNET_FS_DownloadContext *dcc;
2877 2878
2878 if (NULL != dc->meta) 2879 if (NULL != dc->meta)
2879 GNUNET_CONTAINER_meta_data_destroy (dc->meta); 2880 GNUNET_FS_meta_data_destroy (dc->meta);
2880 if (NULL != dc->uri) 2881 if (NULL != dc->uri)
2881 GNUNET_FS_uri_destroy (dc->uri); 2882 GNUNET_FS_uri_destroy (dc->uri);
2882 GNUNET_free (dc->temp_filename); 2883 GNUNET_free (dc->temp_filename);
@@ -2925,7 +2926,7 @@ deserialize_download (struct GNUNET_FS_Handle *h,
2925 dc->h = h; 2926 dc->h = h;
2926 dc->serialization = GNUNET_strdup (serialization); 2927 dc->serialization = GNUNET_strdup (serialization);
2927 struct GNUNET_BIO_ReadSpec rs[] = { 2928 struct GNUNET_BIO_ReadSpec rs[] = {
2928 GNUNET_BIO_read_spec_meta_data ("download-meta", &dc->meta), 2929 GNUNET_FS_read_spec_meta_data ("download-meta", &dc->meta),
2929 GNUNET_BIO_read_spec_string ("download-emsg", &dc->emsg, 10 * 1024), 2930 GNUNET_BIO_read_spec_string ("download-emsg", &dc->emsg, 10 * 1024),
2930 GNUNET_BIO_read_spec_string ("download-fn", &dc->filename, 10 * 1024), 2931 GNUNET_BIO_read_spec_string ("download-fn", &dc->filename, 10 * 1024),
2931 GNUNET_BIO_read_spec_string ("download-tfn", 2932 GNUNET_BIO_read_spec_string ("download-tfn",
diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h
index 7c0c58bff..9c9ce0f24 100644
--- a/src/fs/fs_api.h
+++ b/src/fs/fs_api.h
@@ -29,6 +29,7 @@
29#include "gnunet_constants.h" 29#include "gnunet_constants.h"
30#include "gnunet_datastore_service.h" 30#include "gnunet_datastore_service.h"
31#include "gnunet_dht_service.h" 31#include "gnunet_dht_service.h"
32#include "gnunet_extractor_compat.h"
32#include "gnunet_fs_service.h" 33#include "gnunet_fs_service.h"
33#include "gnunet_block_lib.h" 34#include "gnunet_block_lib.h"
34#include "block_fs.h" 35#include "block_fs.h"
@@ -249,7 +250,7 @@ struct GNUNET_FS_FileInformation
249 /** 250 /**
250 * Metadata to use for the file. 251 * Metadata to use for the file.
251 */ 252 */
252 struct GNUNET_CONTAINER_MetaData *meta; 253 struct GNUNET_FS_MetaData *meta;
253 254
254 /** 255 /**
255 * Keywords to use for KBlocks. 256 * Keywords to use for KBlocks.
@@ -525,7 +526,7 @@ struct GNUNET_FS_SearchResult
525 /** 526 /**
526 * Metadata for the search result. 527 * Metadata for the search result.
527 */ 528 */
528 struct GNUNET_CONTAINER_MetaData *meta; 529 struct GNUNET_FS_MetaData *meta;
529 530
530 /** 531 /**
531 * Client info for this search result. 532 * Client info for this search result.
@@ -1801,7 +1802,7 @@ struct GNUNET_FS_DownloadContext
1801 /** 1802 /**
1802 * Known meta-data for the file (can be NULL). 1803 * Known meta-data for the file (can be NULL).
1803 */ 1804 */
1804 struct GNUNET_CONTAINER_MetaData *meta; 1805 struct GNUNET_FS_MetaData *meta;
1805 1806
1806 /** 1807 /**
1807 * Error message, NULL if we're doing OK. 1808 * Error message, NULL if we're doing OK.
diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c
index eb7aac5bb..e53b2dc11 100644
--- a/src/fs/fs_directory.c
+++ b/src/fs/fs_directory.c
@@ -33,6 +33,7 @@
33 * into memory 33 * into memory
34 */ 34 */
35#include "platform.h" 35#include "platform.h"
36#include "gnunet_extractor_compat.h"
36#include "gnunet_fs_service.h" 37#include "gnunet_fs_service.h"
37#include "fs_api.h" 38#include "fs_api.h"
38 39
@@ -52,15 +53,15 @@
52 */ 53 */
53int 54int
54GNUNET_FS_meta_data_test_for_directory (const struct 55GNUNET_FS_meta_data_test_for_directory (const struct
55 GNUNET_CONTAINER_MetaData *md) 56 GNUNET_FS_MetaData *md)
56{ 57{
57 char *mime; 58 char *mime;
58 int ret; 59 int ret;
59 60
60 if (NULL == md) 61 if (NULL == md)
61 return GNUNET_SYSERR; 62 return GNUNET_SYSERR;
62 mime = GNUNET_CONTAINER_meta_data_get_by_type (md, 63 mime = GNUNET_FS_meta_data_get_by_type (md,
63 EXTRACTOR_METATYPE_MIMETYPE); 64 EXTRACTOR_METATYPE_MIMETYPE);
64 if (NULL == mime) 65 if (NULL == mime)
65 return GNUNET_SYSERR; 66 return GNUNET_SYSERR;
66 ret = (0 == strcasecmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES : 67 ret = (0 == strcasecmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES :
@@ -77,19 +78,19 @@ GNUNET_FS_meta_data_test_for_directory (const struct
77 * @param md metadata to add mimetype to 78 * @param md metadata to add mimetype to
78 */ 79 */
79void 80void
80GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md) 81GNUNET_FS_meta_data_make_directory (struct GNUNET_FS_MetaData *md)
81{ 82{
82 char *mime; 83 char *mime;
83 84
84 mime = 85 mime =
85 GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE); 86 GNUNET_FS_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
86 if (mime != NULL) 87 if (mime != NULL)
87 { 88 {
88 GNUNET_break (0 == strcmp (mime, GNUNET_FS_DIRECTORY_MIME)); 89 GNUNET_break (0 == strcmp (mime, GNUNET_FS_DIRECTORY_MIME));
89 GNUNET_free (mime); 90 GNUNET_free (mime);
90 return; 91 return;
91 } 92 }
92 GNUNET_CONTAINER_meta_data_insert (md, "<gnunet>", 93 GNUNET_FS_meta_data_insert (md, "<gnunet>",
93 EXTRACTOR_METATYPE_MIMETYPE, 94 EXTRACTOR_METATYPE_MIMETYPE,
94 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 95 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
95 GNUNET_FS_DIRECTORY_MIME, 96 GNUNET_FS_DIRECTORY_MIME,
@@ -192,7 +193,7 @@ GNUNET_FS_directory_list_contents (size_t size,
192 uint32_t mdSize; 193 uint32_t mdSize;
193 uint64_t epos; 194 uint64_t epos;
194 struct GNUNET_FS_Uri *uri; 195 struct GNUNET_FS_Uri *uri;
195 struct GNUNET_CONTAINER_MetaData *md; 196 struct GNUNET_FS_MetaData *md;
196 char *filename; 197 char *filename;
197 198
198 if ((offset == 0) && 199 if ((offset == 0) &&
@@ -215,8 +216,8 @@ GNUNET_FS_directory_list_contents (size_t size,
215 _ ("MAGIC mismatch. This is not a GNUnet directory.\n")); 216 _ ("MAGIC mismatch. This is not a GNUnet directory.\n"));
216 return GNUNET_SYSERR; 217 return GNUNET_SYSERR;
217 } 218 }
218 md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[8 + sizeof(uint32_t)], 219 md = GNUNET_FS_meta_data_deserialize (&cdata[8 + sizeof(uint32_t)],
219 mdSize); 220 mdSize);
220 if (md == NULL) 221 if (md == NULL)
221 { 222 {
222 GNUNET_break (0); 223 GNUNET_break (0);
@@ -228,7 +229,7 @@ GNUNET_FS_directory_list_contents (size_t size,
228 md, 229 md,
229 0, 230 0,
230 NULL); 231 NULL);
231 GNUNET_CONTAINER_meta_data_destroy (md); 232 GNUNET_FS_meta_data_destroy (md);
232 pos = 8 + sizeof(uint32_t) + mdSize; 233 pos = 8 + sizeof(uint32_t) + mdSize;
233 } 234 }
234 while (pos < size) 235 while (pos < size)
@@ -283,7 +284,7 @@ GNUNET_FS_directory_list_contents (size_t size,
283 return GNUNET_NO; /* malformed - or partial download */ 284 return GNUNET_NO; /* malformed - or partial download */
284 } 285 }
285 286
286 md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[pos], 287 md = GNUNET_FS_meta_data_deserialize (&cdata[pos],
287 mdSize); 288 mdSize);
288 if (NULL == md) 289 if (NULL == md)
289 { 290 {
@@ -293,11 +294,11 @@ GNUNET_FS_directory_list_contents (size_t size,
293 } 294 }
294 pos += mdSize; 295 pos += mdSize;
295 filename = 296 filename =
296 GNUNET_CONTAINER_meta_data_get_by_type (md, 297 GNUNET_FS_meta_data_get_by_type (md,
297 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 298 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
298 full_data.size = 0; 299 full_data.size = 0;
299 full_data.data = NULL; 300 full_data.data = NULL;
300 GNUNET_CONTAINER_meta_data_iterate (md, 301 GNUNET_FS_meta_data_iterate (md,
301 &find_full_data, 302 &find_full_data,
302 &full_data); 303 &full_data);
303 if (NULL != dep) 304 if (NULL != dep)
@@ -311,7 +312,7 @@ GNUNET_FS_directory_list_contents (size_t size,
311 } 312 }
312 GNUNET_free (full_data.data); 313 GNUNET_free (full_data.data);
313 GNUNET_free (filename); 314 GNUNET_free (filename);
314 GNUNET_CONTAINER_meta_data_destroy (md); 315 GNUNET_FS_meta_data_destroy (md);
315 GNUNET_FS_uri_destroy (uri); 316 GNUNET_FS_uri_destroy (uri);
316 } 317 }
317 return GNUNET_OK; 318 return GNUNET_OK;
@@ -342,7 +343,7 @@ struct GNUNET_FS_DirectoryBuilder
342 /** 343 /**
343 * Meta-data for the directory itself. 344 * Meta-data for the directory itself.
344 */ 345 */
345 struct GNUNET_CONTAINER_MetaData *meta; 346 struct GNUNET_FS_MetaData *meta;
346 347
347 /** 348 /**
348 * Head of linked list of entries. 349 * Head of linked list of entries.
@@ -362,16 +363,16 @@ struct GNUNET_FS_DirectoryBuilder
362 * @param mdir metadata for the directory 363 * @param mdir metadata for the directory
363 */ 364 */
364struct GNUNET_FS_DirectoryBuilder * 365struct GNUNET_FS_DirectoryBuilder *
365GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData 366GNUNET_FS_directory_builder_create (const struct GNUNET_FS_MetaData
366 *mdir) 367 *mdir)
367{ 368{
368 struct GNUNET_FS_DirectoryBuilder *ret; 369 struct GNUNET_FS_DirectoryBuilder *ret;
369 370
370 ret = GNUNET_new (struct GNUNET_FS_DirectoryBuilder); 371 ret = GNUNET_new (struct GNUNET_FS_DirectoryBuilder);
371 if (mdir != NULL) 372 if (mdir != NULL)
372 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (mdir); 373 ret->meta = GNUNET_FS_meta_data_duplicate (mdir);
373 else 374 else
374 ret->meta = GNUNET_CONTAINER_meta_data_create (); 375 ret->meta = GNUNET_FS_meta_data_create ();
375 GNUNET_FS_meta_data_make_directory (ret->meta); 376 GNUNET_FS_meta_data_make_directory (ret->meta);
376 return ret; 377 return ret;
377} 378}
@@ -390,7 +391,7 @@ GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData
390void 391void
391GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld, 392GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
392 const struct GNUNET_FS_Uri *uri, 393 const struct GNUNET_FS_Uri *uri,
393 const struct GNUNET_CONTAINER_MetaData *md, 394 const struct GNUNET_FS_MetaData *md,
394 const void *data) 395 const void *data)
395{ 396{
396 struct GNUNET_FS_Uri *curi; 397 struct GNUNET_FS_Uri *curi;
@@ -404,8 +405,8 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
404 char *serialized; 405 char *serialized;
405 char *sptr; 406 char *sptr;
406 size_t slen; 407 size_t slen;
407 struct GNUNET_CONTAINER_MetaData *meta; 408 struct GNUNET_FS_MetaData *meta;
408 const struct GNUNET_CONTAINER_MetaData *meta_use; 409 const struct GNUNET_FS_MetaData *meta_use;
409 410
410 GNUNET_assert (! GNUNET_FS_uri_test_ksk (uri)); 411 GNUNET_assert (! GNUNET_FS_uri_test_ksk (uri));
411 if (NULL != data) 412 if (NULL != data)
@@ -431,17 +432,17 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
431 fsize = 0; /* too large */ 432 fsize = 0; /* too large */
432 uris = GNUNET_FS_uri_to_string (uri); 433 uris = GNUNET_FS_uri_to_string (uri);
433 slen = strlen (uris) + 1; 434 slen = strlen (uris) + 1;
434 mds = GNUNET_CONTAINER_meta_data_get_serialized_size (md); 435 mds = GNUNET_FS_meta_data_get_serialized_size (md);
435 meta_use = md; 436 meta_use = md;
436 meta = NULL; 437 meta = NULL;
437 if (fsize > 0) 438 if (fsize > 0)
438 { 439 {
439 meta = GNUNET_CONTAINER_meta_data_duplicate (md); 440 meta = GNUNET_FS_meta_data_duplicate (md);
440 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", 441 GNUNET_FS_meta_data_insert (meta, "<gnunet>",
441 EXTRACTOR_METATYPE_GNUNET_FULL_DATA, 442 EXTRACTOR_METATYPE_GNUNET_FULL_DATA,
442 EXTRACTOR_METAFORMAT_BINARY, NULL, data, 443 EXTRACTOR_METAFORMAT_BINARY, NULL, data,
443 fsize); 444 fsize);
444 mdxs = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); 445 mdxs = GNUNET_FS_meta_data_get_serialized_size (meta);
445 if ((slen + sizeof(uint32_t) + mdxs - 1) / DBLOCK_SIZE == 446 if ((slen + sizeof(uint32_t) + mdxs - 1) / DBLOCK_SIZE ==
446 (slen + sizeof(uint32_t) + mds - 1) / DBLOCK_SIZE) 447 (slen + sizeof(uint32_t) + mds - 1) / DBLOCK_SIZE)
447 { 448 {
@@ -461,10 +462,10 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
461 GNUNET_free (uris); 462 GNUNET_free (uris);
462 sptr = &serialized[slen + sizeof(uint32_t)]; 463 sptr = &serialized[slen + sizeof(uint32_t)];
463 ret = 464 ret =
464 GNUNET_CONTAINER_meta_data_serialize (meta_use, &sptr, mds, 465 GNUNET_FS_meta_data_serialize (meta_use, &sptr, mds,
465 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); 466 GNUNET_FS_META_DATA_SERIALIZE_PART);
466 if (NULL != meta) 467 if (NULL != meta)
467 GNUNET_CONTAINER_meta_data_destroy (meta); 468 GNUNET_FS_meta_data_destroy (meta);
468 if (ret == -1) 469 if (ret == -1)
469 mds = 0; 470 mds = 0;
470 else 471 else
@@ -593,7 +594,7 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
593 uint32_t big; 594 uint32_t big;
594 595
595 size = strlen (GNUNET_DIRECTORY_MAGIC) + sizeof(uint32_t); 596 size = strlen (GNUNET_DIRECTORY_MAGIC) + sizeof(uint32_t);
596 size += GNUNET_CONTAINER_meta_data_get_serialized_size (bld->meta); 597 size += GNUNET_FS_meta_data_get_serialized_size (bld->meta);
597 sizes = NULL; 598 sizes = NULL;
598 perm = NULL; 599 perm = NULL;
599 bes = NULL; 600 bes = NULL;
@@ -643,10 +644,10 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
643 644
644 sptr = &data[off + sizeof(uint32_t)]; 645 sptr = &data[off + sizeof(uint32_t)];
645 ret = 646 ret =
646 GNUNET_CONTAINER_meta_data_serialize (bld->meta, 647 GNUNET_FS_meta_data_serialize (bld->meta,
647 &sptr, 648 &sptr,
648 size - off - sizeof(uint32_t), 649 size - off - sizeof(uint32_t),
649 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); 650 GNUNET_FS_META_DATA_SERIALIZE_FULL);
650 GNUNET_assert (ret != -1); 651 GNUNET_assert (ret != -1);
651 big = htonl (ret); 652 big = htonl (ret);
652 GNUNET_memcpy (&data[off], 653 GNUNET_memcpy (&data[off],
@@ -666,7 +667,7 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
666 GNUNET_free (perm); 667 GNUNET_free (perm);
667 GNUNET_free (bes); 668 GNUNET_free (bes);
668 GNUNET_assert (off == size); 669 GNUNET_assert (off == size);
669 GNUNET_CONTAINER_meta_data_destroy (bld->meta); 670 GNUNET_FS_meta_data_destroy (bld->meta);
670 GNUNET_free (bld); 671 GNUNET_free (bld);
671 return GNUNET_OK; 672 return GNUNET_OK;
672} 673}
diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c
index 8dd216324..3990a2521 100644
--- a/src/fs/fs_dirmetascan.c
+++ b/src/fs/fs_dirmetascan.c
@@ -26,6 +26,7 @@
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_extractor_compat.h"
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30#include "gnunet_scheduler_lib.h" 31#include "gnunet_scheduler_lib.h"
31#include <pthread.h> 32#include <pthread.h>
@@ -359,26 +360,26 @@ process_helper_msgs (void *cls, const struct GNUNET_MessageHeader *msg)
359 GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED); 360 GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED);
360 if (0 < left) 361 if (0 < left)
361 { 362 {
362 ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize (end, left); 363 ds->pos->meta = GNUNET_FS_meta_data_deserialize (end, left);
363 if (NULL == ds->pos->meta) 364 if (NULL == ds->pos->meta)
364 { 365 {
365 GNUNET_break (0); 366 GNUNET_break (0);
366 break; 367 break;
367 } 368 }
368 /* having full filenames is too dangerous; always make sure we clean them up */ 369 /* having full filenames is too dangerous; always make sure we clean them up */
369 GNUNET_CONTAINER_meta_data_delete (ds->pos->meta, 370 GNUNET_FS_meta_data_delete (ds->pos->meta,
370 EXTRACTOR_METATYPE_FILENAME, 371 EXTRACTOR_METATYPE_FILENAME,
371 NULL, 372 NULL,
372 0); 373 0);
373 /* instead, put in our 'safer' original filename */ 374 /* instead, put in our 'safer' original filename */
374 GNUNET_CONTAINER_meta_data_insert (ds->pos->meta, 375 GNUNET_FS_meta_data_insert (ds->pos->meta,
375 "<libgnunetfs>", 376 "<libgnunetfs>",
376 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 377 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
377 EXTRACTOR_METAFORMAT_UTF8, 378 EXTRACTOR_METAFORMAT_UTF8,
378 "text/plain", 379 "text/plain",
379 ds->pos->short_filename, 380 ds->pos->short_filename,
380 strlen (ds->pos->short_filename) 381 strlen (ds->pos->short_filename)
381 + 1); 382 + 1);
382 } 383 }
383 ds->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data ( 384 ds->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (
384 ds->pos->meta); 385 ds->pos->meta);
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 102b297c1..73e12acb1 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -24,6 +24,7 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_constants.h" 26#include "gnunet_constants.h"
27#include "gnunet_extractor_compat.h"
27#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
28#include "fs_api.h" 29#include "fs_api.h"
29#include "fs_tree.h" 30#include "fs_tree.h"
@@ -280,7 +281,7 @@ static void
280trigger_recursive_download (void *cls, 281trigger_recursive_download (void *cls,
281 const char *filename, 282 const char *filename,
282 const struct GNUNET_FS_Uri *uri, 283 const struct GNUNET_FS_Uri *uri,
283 const struct GNUNET_CONTAINER_MetaData *meta, 284 const struct GNUNET_FS_MetaData *meta,
284 size_t length, 285 size_t length,
285 const void *data); 286 const void *data);
286 287
@@ -850,7 +851,7 @@ static void
850trigger_recursive_download (void *cls, 851trigger_recursive_download (void *cls,
851 const char *filename, 852 const char *filename,
852 const struct GNUNET_FS_Uri *uri, 853 const struct GNUNET_FS_Uri *uri,
853 const struct GNUNET_CONTAINER_MetaData *meta, 854 const struct GNUNET_FS_MetaData *meta,
854 size_t length, 855 size_t length,
855 const void *data) 856 const void *data)
856{ 857{
@@ -968,7 +969,7 @@ trigger_recursive_download (void *cls,
968 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 969 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
969 "Triggering recursive download of size %llu with %u bytes MD\n", 970 "Triggering recursive download of size %llu with %u bytes MD\n",
970 (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri), 971 (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri),
971 (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size ( 972 (unsigned int) GNUNET_FS_meta_data_get_serialized_size (
972 meta)); 973 meta));
973 GNUNET_FS_download_start (dc->h, 974 GNUNET_FS_download_start (dc->h,
974 uri, 975 uri,
@@ -1907,8 +1908,8 @@ GNUNET_FS_download_start_task_ (void *cls)
1907 GNUNET_ERROR_TYPE_DEBUG, 1908 GNUNET_ERROR_TYPE_DEBUG,
1908 "Trying to find embedded meta data for download of size %llu with %u bytes MD\n", 1909 "Trying to find embedded meta data for download of size %llu with %u bytes MD\n",
1909 (unsigned long long) GNUNET_FS_uri_chk_get_file_size (dc->uri), 1910 (unsigned long long) GNUNET_FS_uri_chk_get_file_size (dc->uri),
1910 (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size (dc->meta)); 1911 (unsigned int) GNUNET_FS_meta_data_get_serialized_size (dc->meta));
1911 GNUNET_CONTAINER_meta_data_iterate (dc->meta, &match_full_data, dc); 1912 GNUNET_FS_meta_data_iterate (dc->meta, &match_full_data, dc);
1912 if (BRS_DOWNLOAD_UP == dc->top_request->state) 1913 if (BRS_DOWNLOAD_UP == dc->top_request->state)
1913 { 1914 {
1914 if (NULL != dc->rfh) 1915 if (NULL != dc->rfh)
@@ -1996,7 +1997,7 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
1996 dc->active = NULL; 1997 dc->active = NULL;
1997 } 1998 }
1998 GNUNET_free (dc->filename); 1999 GNUNET_free (dc->filename);
1999 GNUNET_CONTAINER_meta_data_destroy (dc->meta); 2000 GNUNET_FS_meta_data_destroy (dc->meta);
2000 GNUNET_FS_uri_destroy (dc->uri); 2001 GNUNET_FS_uri_destroy (dc->uri);
2001 GNUNET_free (dc->temp_filename); 2002 GNUNET_free (dc->temp_filename);
2002 GNUNET_free (dc->serialization); 2003 GNUNET_free (dc->serialization);
@@ -2027,7 +2028,7 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
2027struct GNUNET_FS_DownloadContext * 2028struct GNUNET_FS_DownloadContext *
2028create_download_context (struct GNUNET_FS_Handle *h, 2029create_download_context (struct GNUNET_FS_Handle *h,
2029 const struct GNUNET_FS_Uri *uri, 2030 const struct GNUNET_FS_Uri *uri,
2030 const struct GNUNET_CONTAINER_MetaData *meta, 2031 const struct GNUNET_FS_MetaData *meta,
2031 const char *filename, 2032 const char *filename,
2032 const char *tempname, 2033 const char *tempname,
2033 uint64_t offset, 2034 uint64_t offset,
@@ -2053,7 +2054,7 @@ create_download_context (struct GNUNET_FS_Handle *h,
2053 (unsigned long long) offset); 2054 (unsigned long long) offset);
2054 dc->h = h; 2055 dc->h = h;
2055 dc->uri = GNUNET_FS_uri_dup (uri); 2056 dc->uri = GNUNET_FS_uri_dup (uri);
2056 dc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 2057 dc->meta = GNUNET_FS_meta_data_duplicate (meta);
2057 dc->client_info = cctx; 2058 dc->client_info = cctx;
2058 dc->start_time = GNUNET_TIME_absolute_get (); 2059 dc->start_time = GNUNET_TIME_absolute_get ();
2059 if (NULL != filename) 2060 if (NULL != filename)
@@ -2098,7 +2099,7 @@ create_download_context (struct GNUNET_FS_Handle *h,
2098struct GNUNET_FS_DownloadContext * 2099struct GNUNET_FS_DownloadContext *
2099GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, 2100GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
2100 const struct GNUNET_FS_Uri *uri, 2101 const struct GNUNET_FS_Uri *uri,
2101 const struct GNUNET_CONTAINER_MetaData *meta, 2102 const struct GNUNET_FS_MetaData *meta,
2102 const char *filename, 2103 const char *filename,
2103 const char *tempname, 2104 const char *tempname,
2104 uint64_t offset, 2105 uint64_t offset,
@@ -2319,7 +2320,7 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
2319 } 2320 }
2320 GNUNET_free (dc->filename); 2321 GNUNET_free (dc->filename);
2321 } 2322 }
2322 GNUNET_CONTAINER_meta_data_destroy (dc->meta); 2323 GNUNET_FS_meta_data_destroy (dc->meta);
2323 GNUNET_FS_uri_destroy (dc->uri); 2324 GNUNET_FS_uri_destroy (dc->uri);
2324 if (NULL != dc->temp_filename) 2325 if (NULL != dc->temp_filename)
2325 { 2326 {
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c
index dc5db9d3f..f23b9da2a 100644
--- a/src/fs/fs_file_information.c
+++ b/src/fs/fs_file_information.c
@@ -57,7 +57,8 @@ GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s)
57 * @return "filename" field of the structure (can be NULL) 57 * @return "filename" field of the structure (can be NULL)
58 */ 58 */
59const char * 59const char *
60GNUNET_FS_file_information_get_filename (const struct GNUNET_FS_FileInformation *s) 60GNUNET_FS_file_information_get_filename (const struct
61 GNUNET_FS_FileInformation *s)
61{ 62{
62 return s->filename; 63 return s->filename;
63} 64}
@@ -89,7 +90,7 @@ GNUNET_FS_file_information_create_from_file (
89 void *client_info, 90 void *client_info,
90 const char *filename, 91 const char *filename,
91 const struct GNUNET_FS_Uri *keywords, 92 const struct GNUNET_FS_Uri *keywords,
92 const struct GNUNET_CONTAINER_MetaData *meta, 93 const struct GNUNET_FS_MetaData *meta,
93 int do_index, 94 int do_index,
94 const struct GNUNET_FS_BlockOptions *bo) 95 const struct GNUNET_FS_BlockOptions *bo)
95{ 96{
@@ -132,13 +133,13 @@ GNUNET_FS_file_information_create_from_file (
132/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then 133/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
133 * this should be changed to EXTRACTOR_METAFORMAT_UTF8 134 * this should be changed to EXTRACTOR_METAFORMAT_UTF8
134 */ 135 */
135 GNUNET_CONTAINER_meta_data_insert (ret->meta, 136 GNUNET_FS_meta_data_insert (ret->meta,
136 "<gnunet>", 137 "<gnunet>",
137 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 138 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
138 EXTRACTOR_METAFORMAT_C_STRING, 139 EXTRACTOR_METAFORMAT_C_STRING,
139 "text/plain", 140 "text/plain",
140 fn, 141 fn,
141 strlen (fn) + 1); 142 strlen (fn) + 1);
142 return ret; 143 return ret;
143} 144}
144 145
@@ -150,7 +151,7 @@ GNUNET_FS_file_information_create_from_data (
150 uint64_t length, 151 uint64_t length,
151 void *data, 152 void *data,
152 const struct GNUNET_FS_Uri *keywords, 153 const struct GNUNET_FS_Uri *keywords,
153 const struct GNUNET_CONTAINER_MetaData *meta, 154 const struct GNUNET_FS_MetaData *meta,
154 int do_index, 155 int do_index,
155 const struct GNUNET_FS_BlockOptions *bo) 156 const struct GNUNET_FS_BlockOptions *bo)
156{ 157{
@@ -180,7 +181,7 @@ GNUNET_FS_file_information_create_from_reader (
180 GNUNET_FS_DataReader reader, 181 GNUNET_FS_DataReader reader,
181 void *reader_cls, 182 void *reader_cls,
182 const struct GNUNET_FS_Uri *keywords, 183 const struct GNUNET_FS_Uri *keywords,
183 const struct GNUNET_CONTAINER_MetaData *meta, 184 const struct GNUNET_FS_MetaData *meta,
184 int do_index, 185 int do_index,
185 const struct GNUNET_FS_BlockOptions *bo) 186 const struct GNUNET_FS_BlockOptions *bo)
186{ 187{
@@ -194,9 +195,9 @@ GNUNET_FS_file_information_create_from_reader (
194 ret = GNUNET_new (struct GNUNET_FS_FileInformation); 195 ret = GNUNET_new (struct GNUNET_FS_FileInformation);
195 ret->h = h; 196 ret->h = h;
196 ret->client_info = client_info; 197 ret->client_info = client_info;
197 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 198 ret->meta = GNUNET_FS_meta_data_duplicate (meta);
198 if (ret->meta == NULL) 199 if (ret->meta == NULL)
199 ret->meta = GNUNET_CONTAINER_meta_data_create (); 200 ret->meta = GNUNET_FS_meta_data_create ();
200 ret->keywords = (keywords == NULL) ? NULL : GNUNET_FS_uri_dup (keywords); 201 ret->keywords = (keywords == NULL) ? NULL : GNUNET_FS_uri_dup (keywords);
201 ret->data.file.reader = reader; 202 ret->data.file.reader = reader;
202 ret->data.file.reader_cls = reader_cls; 203 ret->data.file.reader_cls = reader_cls;
@@ -226,7 +227,7 @@ GNUNET_FS_file_information_create_empty_directory (
226 struct GNUNET_FS_Handle *h, 227 struct GNUNET_FS_Handle *h,
227 void *client_info, 228 void *client_info,
228 const struct GNUNET_FS_Uri *keywords, 229 const struct GNUNET_FS_Uri *keywords,
229 const struct GNUNET_CONTAINER_MetaData *meta, 230 const struct GNUNET_FS_MetaData *meta,
230 const struct GNUNET_FS_BlockOptions *bo, 231 const struct GNUNET_FS_BlockOptions *bo,
231 const char *filename) 232 const char *filename)
232{ 233{
@@ -235,7 +236,7 @@ GNUNET_FS_file_information_create_empty_directory (
235 ret = GNUNET_new (struct GNUNET_FS_FileInformation); 236 ret = GNUNET_new (struct GNUNET_FS_FileInformation);
236 ret->h = h; 237 ret->h = h;
237 ret->client_info = client_info; 238 ret->client_info = client_info;
238 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 239 ret->meta = GNUNET_FS_meta_data_duplicate (meta);
239 ret->keywords = GNUNET_FS_uri_dup (keywords); 240 ret->keywords = GNUNET_FS_uri_dup (keywords);
240 ret->bo = *bo; 241 ret->bo = *bo;
241 ret->is_directory = GNUNET_YES; 242 ret->is_directory = GNUNET_YES;
@@ -392,7 +393,7 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
392 if (NULL != fi->keywords) 393 if (NULL != fi->keywords)
393 GNUNET_FS_uri_destroy (fi->keywords); 394 GNUNET_FS_uri_destroy (fi->keywords);
394 if (NULL != fi->meta) 395 if (NULL != fi->meta)
395 GNUNET_CONTAINER_meta_data_destroy (fi->meta); 396 GNUNET_FS_meta_data_destroy (fi->meta);
396 GNUNET_free (fi->serialization); 397 GNUNET_free (fi->serialization);
397 if (NULL != fi->te) 398 if (NULL != fi->te)
398 { 399 {
diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c
index 945883a45..186963bba 100644
--- a/src/fs/fs_getopt.c
+++ b/src/fs/fs_getopt.c
@@ -24,6 +24,7 @@
24 * @author Igor Wronsky, Christian Grothoff 24 * @author Igor Wronsky, Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_extractor_compat.h"
27#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
28#include "fs_api.h" 29#include "fs_api.h"
29 30
@@ -163,20 +164,20 @@ getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
163 const char *option, 164 const char *option,
164 const char *value) 165 const char *value)
165{ 166{
166 struct GNUNET_CONTAINER_MetaData **mm = scls; 167 struct GNUNET_FS_MetaData **mm = scls;
167 168
168#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR 169#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR
169 enum EXTRACTOR_MetaType type; 170 enum EXTRACTOR_MetaType type;
170 const char *typename; 171 const char *typename;
171 const char *typename_i18n; 172 const char *typename_i18n;
172#endif 173#endif
173 struct GNUNET_CONTAINER_MetaData *meta; 174 struct GNUNET_FS_MetaData *meta;
174 char *tmp; 175 char *tmp;
175 176
176 meta = *mm; 177 meta = *mm;
177 if (meta == NULL) 178 if (meta == NULL)
178 { 179 {
179 meta = GNUNET_CONTAINER_meta_data_create (); 180 meta = GNUNET_FS_meta_data_create ();
180 *mm = meta; 181 *mm = meta;
181 } 182 }
182 183
@@ -196,12 +197,12 @@ getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
196 (tmp[strlen (typename)] == ':') && 197 (tmp[strlen (typename)] == ':') &&
197 (0 == strncmp (typename, tmp, strlen (typename)))) 198 (0 == strncmp (typename, tmp, strlen (typename))))
198 { 199 {
199 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", type, 200 GNUNET_FS_meta_data_insert (meta, "<gnunet>", type,
200 EXTRACTOR_METAFORMAT_UTF8, 201 EXTRACTOR_METAFORMAT_UTF8,
201 "text/plain", 202 "text/plain",
202 &tmp[strlen (typename) + 1], 203 &tmp[strlen (typename) + 1],
203 strlen (&tmp[strlen (typename) + 1]) 204 strlen (&tmp[strlen (typename) + 1])
204 + 1); 205 + 1);
205 GNUNET_free (tmp); 206 GNUNET_free (tmp);
206 tmp = NULL; 207 tmp = NULL;
207 break; 208 break;
@@ -210,13 +211,13 @@ getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
210 (tmp[strlen (typename_i18n)] == ':') && 211 (tmp[strlen (typename_i18n)] == ':') &&
211 (0 == strncmp (typename_i18n, tmp, strlen (typename_i18n)))) 212 (0 == strncmp (typename_i18n, tmp, strlen (typename_i18n))))
212 { 213 {
213 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", type, 214 GNUNET_FS_meta_data_insert (meta, "<gnunet>", type,
214 EXTRACTOR_METAFORMAT_UTF8, 215 EXTRACTOR_METAFORMAT_UTF8,
215 "text/plain", 216 "text/plain",
216 &tmp[strlen (typename_i18n) + 1], 217 &tmp[strlen (typename_i18n) + 1],
217 strlen (&tmp 218 strlen (&tmp
218 [strlen (typename_i18n) + 1]) 219 [strlen (typename_i18n) + 1])
219 + 1); 220 + 1);
220 GNUNET_free (tmp); 221 GNUNET_free (tmp);
221 tmp = NULL; 222 tmp = NULL;
222 break; 223 break;
@@ -226,10 +227,10 @@ getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
226 227
227 if (NULL != tmp) 228 if (NULL != tmp)
228 { 229 {
229 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", 230 GNUNET_FS_meta_data_insert (meta, "<gnunet>",
230 EXTRACTOR_METATYPE_UNKNOWN, 231 EXTRACTOR_METATYPE_UNKNOWN,
231 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 232 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
232 tmp, strlen (tmp) + 1); 233 tmp, strlen (tmp) + 1);
233 GNUNET_free (tmp); 234 GNUNET_free (tmp);
234 printf (_ 235 printf (_
235 ( 236 (
@@ -254,7 +255,7 @@ GNUNET_FS_GETOPT_METADATA (char shortName,
254 const char *name, 255 const char *name,
255 const char *argumentHelp, 256 const char *argumentHelp,
256 const char *description, 257 const char *description,
257 struct GNUNET_CONTAINER_MetaData **meta) 258 struct GNUNET_FS_MetaData **meta)
258{ 259{
259 struct GNUNET_GETOPT_CommandLineOption clo = { 260 struct GNUNET_GETOPT_CommandLineOption clo = {
260 .shortName = shortName, 261 .shortName = shortName,
diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c
index eaee4ce55..7d30933dd 100644
--- a/src/fs/fs_list_indexed.c
+++ b/src/fs/fs_list_indexed.c
@@ -26,6 +26,7 @@
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_constants.h" 28#include "gnunet_constants.h"
29#include "gnunet_extractor_compat.h"
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30#include "gnunet_protocols.h" 31#include "gnunet_protocols.h"
31#include "fs_api.h" 32#include "fs_api.h"
diff --git a/src/fs/fs_misc.c b/src/fs/fs_misc.c
index 2e7816d65..3ae82a82e 100644
--- a/src/fs/fs_misc.c
+++ b/src/fs/fs_misc.c
@@ -24,6 +24,7 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_constants.h" 26#include "gnunet_constants.h"
27#include "gnunet_extractor_compat.h"
27#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
28#include "fs_api.h" 29#include "fs_api.h"
29 30
@@ -35,7 +36,7 @@
35 * @return NULL if meta data is useless for suggesting a filename 36 * @return NULL if meta data is useless for suggesting a filename
36 */ 37 */
37char * 38char *
38GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData 39GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_FS_MetaData
39 *md) 40 *md)
40{ 41{
41 static const char *mimeMap[][2] = { 42 static const char *mimeMap[][2] = {
@@ -111,13 +112,13 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData
111 const char *ext; 112 const char *ext;
112 113
113 ret = 114 ret =
114 GNUNET_CONTAINER_meta_data_get_by_type (md, 115 GNUNET_FS_meta_data_get_by_type (md,
115 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 116 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
116 if (ret != NULL) 117 if (ret != NULL)
117 return ret; 118 return ret;
118 ext = NULL; 119 ext = NULL;
119 mime = 120 mime =
120 GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE); 121 GNUNET_FS_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
121 if (mime != NULL) 122 if (mime != NULL)
122 { 123 {
123 i = 0; 124 i = 0;
@@ -131,24 +132,24 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData
131 GNUNET_free (mime); 132 GNUNET_free (mime);
132 } 133 }
133 base = 134 base =
134 GNUNET_CONTAINER_meta_data_get_first_by_types (md, 135 GNUNET_FS_meta_data_get_first_by_types (md,
135 EXTRACTOR_METATYPE_TITLE, 136 EXTRACTOR_METATYPE_TITLE,
136 EXTRACTOR_METATYPE_BOOK_TITLE, 137 EXTRACTOR_METATYPE_BOOK_TITLE,
137 EXTRACTOR_METATYPE_ORIGINAL_TITLE, 138 EXTRACTOR_METATYPE_ORIGINAL_TITLE,
138 EXTRACTOR_METATYPE_PACKAGE_NAME, 139 EXTRACTOR_METATYPE_PACKAGE_NAME,
139 EXTRACTOR_METATYPE_URL, 140 EXTRACTOR_METATYPE_URL,
140 EXTRACTOR_METATYPE_URI, 141 EXTRACTOR_METATYPE_URI,
141 EXTRACTOR_METATYPE_DESCRIPTION, 142 EXTRACTOR_METATYPE_DESCRIPTION,
142 EXTRACTOR_METATYPE_ISRC, 143 EXTRACTOR_METATYPE_ISRC,
143 EXTRACTOR_METATYPE_JOURNAL_NAME, 144 EXTRACTOR_METATYPE_JOURNAL_NAME,
144 EXTRACTOR_METATYPE_AUTHOR_NAME, 145 EXTRACTOR_METATYPE_AUTHOR_NAME,
145 EXTRACTOR_METATYPE_SUBJECT, 146 EXTRACTOR_METATYPE_SUBJECT,
146 EXTRACTOR_METATYPE_ALBUM, 147 EXTRACTOR_METATYPE_ALBUM,
147 EXTRACTOR_METATYPE_ARTIST, 148 EXTRACTOR_METATYPE_ARTIST,
148 EXTRACTOR_METATYPE_KEYWORDS, 149 EXTRACTOR_METATYPE_KEYWORDS,
149 EXTRACTOR_METATYPE_COMMENT, 150 EXTRACTOR_METATYPE_COMMENT,
150 EXTRACTOR_METATYPE_UNKNOWN, 151 EXTRACTOR_METATYPE_UNKNOWN,
151 -1); 152 -1);
152 if ((base == NULL) && (ext == NULL)) 153 if ((base == NULL) && (ext == NULL))
153 return NULL; 154 return NULL;
154 if (base == NULL) 155 if (base == NULL)
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index bc94dd1fc..b3eeeb23c 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -28,6 +28,7 @@
28#include "gnunet_constants.h" 28#include "gnunet_constants.h"
29#include "gnunet_signatures.h" 29#include "gnunet_signatures.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_extractor_compat.h"
31#include "gnunet_fs_service.h" 32#include "gnunet_fs_service.h"
32#include "fs_api.h" 33#include "fs_api.h"
33#include "fs_publish_ublock.h" 34#include "fs_publish_ublock.h"
@@ -52,7 +53,7 @@ struct NamespaceUpdateNode
52 /** 53 /**
53 * Metadata for this entry. 54 * Metadata for this entry.
54 */ 55 */
55 struct GNUNET_CONTAINER_MetaData *md; 56 struct GNUNET_FS_MetaData *md;
56 57
57 /** 58 /**
58 * URI of this entry in the namespace. 59 * URI of this entry in the namespace.
@@ -167,7 +168,7 @@ free_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
167 for (i = 0; i < uig->update_node_count; i++) 168 for (i = 0; i < uig->update_node_count; i++)
168 { 169 {
169 nsn = uig->update_nodes[i]; 170 nsn = uig->update_nodes[i];
170 GNUNET_CONTAINER_meta_data_destroy (nsn->md); 171 GNUNET_FS_meta_data_destroy (nsn->md);
171 GNUNET_FS_uri_destroy (nsn->uri); 172 GNUNET_FS_uri_destroy (nsn->uri);
172 GNUNET_free (nsn->id); 173 GNUNET_free (nsn->id);
173 GNUNET_free (nsn->update); 174 GNUNET_free (nsn->update);
@@ -215,7 +216,7 @@ write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
215 uris = GNUNET_FS_uri_to_string (n->uri); 216 uris = GNUNET_FS_uri_to_string (n->uri);
216 struct GNUNET_BIO_WriteSpec ws[] = { 217 struct GNUNET_BIO_WriteSpec ws[] = {
217 GNUNET_BIO_write_spec_string ("fs-namespace-node-id", n->id), 218 GNUNET_BIO_write_spec_string ("fs-namespace-node-id", n->id),
218 GNUNET_BIO_write_spec_meta_data ("fs-namespace-node-meta", n->md), 219 GNUNET_FS_write_spec_meta_data ("fs-namespace-node-meta", n->md),
219 GNUNET_BIO_write_spec_string ("fs-namespace-node-update", n->update), 220 GNUNET_BIO_write_spec_string ("fs-namespace-node-update", n->update),
220 GNUNET_BIO_write_spec_string ("fs-namespace-uris", uris), 221 GNUNET_BIO_write_spec_string ("fs-namespace-uris", uris),
221 GNUNET_BIO_write_spec_end (), 222 GNUNET_BIO_write_spec_end (),
@@ -227,7 +228,7 @@ write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
227 } 228 }
228 GNUNET_free (uris); 229 GNUNET_free (uris);
229 } 230 }
230END: 231 END:
231 if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL)) 232 if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
232 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 233 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
233 _ ("Failed to write `%s': %s\n"), 234 _ ("Failed to write `%s': %s\n"),
@@ -293,7 +294,7 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
293 n = GNUNET_new (struct NamespaceUpdateNode); 294 n = GNUNET_new (struct NamespaceUpdateNode);
294 struct GNUNET_BIO_ReadSpec rs[] = { 295 struct GNUNET_BIO_ReadSpec rs[] = {
295 GNUNET_BIO_read_spec_string ("identifier", &n->id, 1024), 296 GNUNET_BIO_read_spec_string ("identifier", &n->id, 1024),
296 GNUNET_BIO_read_spec_meta_data ("meta", &n->md), 297 GNUNET_FS_read_spec_meta_data ("meta", &n->md),
297 GNUNET_BIO_read_spec_string ("update-id", &n->update, 1024), 298 GNUNET_BIO_read_spec_string ("update-id", &n->update, 1024),
298 GNUNET_BIO_read_spec_string ("uri", &uris, 1024 * 2), 299 GNUNET_BIO_read_spec_string ("uri", &uris, 1024 * 2),
299 GNUNET_BIO_read_spec_end (), 300 GNUNET_BIO_read_spec_end (),
@@ -304,7 +305,7 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
304 GNUNET_free (n->id); 305 GNUNET_free (n->id);
305 GNUNET_free (n->update); 306 GNUNET_free (n->update);
306 if (n->md != NULL) 307 if (n->md != NULL)
307 GNUNET_CONTAINER_meta_data_destroy (n->md); 308 GNUNET_FS_meta_data_destroy (n->md);
308 GNUNET_free (n); 309 GNUNET_free (n);
309 break; 310 break;
310 } 311 }
@@ -316,14 +317,14 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
316 GNUNET_free (emsg); 317 GNUNET_free (emsg);
317 GNUNET_free (n->id); 318 GNUNET_free (n->id);
318 GNUNET_free (n->update); 319 GNUNET_free (n->update);
319 GNUNET_CONTAINER_meta_data_destroy (n->md); 320 GNUNET_FS_meta_data_destroy (n->md);
320 GNUNET_free (n); 321 GNUNET_free (n);
321 break; 322 break;
322 } 323 }
323 uig->update_nodes[i] = n; 324 uig->update_nodes[i] = n;
324 } 325 }
325 uig->update_node_count = i; 326 uig->update_node_count = i;
326END: 327 END:
327 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) 328 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
328 { 329 {
329 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 330 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -428,7 +429,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
428 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, 429 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
429 const char *identifier, 430 const char *identifier,
430 const char *update, 431 const char *update,
431 const struct GNUNET_CONTAINER_MetaData *meta, 432 const struct GNUNET_FS_MetaData *meta,
432 const struct GNUNET_FS_Uri *uri, 433 const struct GNUNET_FS_Uri *uri,
433 const struct GNUNET_FS_BlockOptions *bo, 434 const struct GNUNET_FS_BlockOptions *bo,
434 enum GNUNET_FS_PublishOptions options, 435 enum GNUNET_FS_PublishOptions options,
@@ -463,7 +464,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
463 psc->nsn = GNUNET_new (struct NamespaceUpdateNode); 464 psc->nsn = GNUNET_new (struct NamespaceUpdateNode);
464 psc->nsn->id = GNUNET_strdup (identifier); 465 psc->nsn->id = GNUNET_strdup (identifier);
465 psc->nsn->update = GNUNET_strdup (update); 466 psc->nsn->update = GNUNET_strdup (update);
466 psc->nsn->md = GNUNET_CONTAINER_meta_data_duplicate (meta); 467 psc->nsn->md = GNUNET_FS_meta_data_duplicate (meta);
467 psc->nsn->uri = GNUNET_FS_uri_dup (uri); 468 psc->nsn->uri = GNUNET_FS_uri_dup (uri);
468 } 469 }
469 psc->uc = GNUNET_FS_publish_ublock_ (h, 470 psc->uc = GNUNET_FS_publish_ublock_ (h,
@@ -502,7 +503,7 @@ GNUNET_FS_publish_sks_cancel (struct GNUNET_FS_PublishSksContext *psc)
502 GNUNET_FS_uri_destroy (psc->uri); 503 GNUNET_FS_uri_destroy (psc->uri);
503 if (NULL != psc->nsn) 504 if (NULL != psc->nsn)
504 { 505 {
505 GNUNET_CONTAINER_meta_data_destroy (psc->nsn->md); 506 GNUNET_FS_meta_data_destroy (psc->nsn->md);
506 GNUNET_FS_uri_destroy (psc->nsn->uri); 507 GNUNET_FS_uri_destroy (psc->nsn->uri);
507 GNUNET_free (psc->nsn->id); 508 GNUNET_free (psc->nsn->id);
508 GNUNET_free (psc->nsn->update); 509 GNUNET_free (psc->nsn->update);
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 5cdf8f6e8..bd533fcfb 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -28,6 +28,7 @@
28#include "gnunet_constants.h" 28#include "gnunet_constants.h"
29#include "gnunet_signatures.h" 29#include "gnunet_signatures.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_extractor_compat.h"
31#include "gnunet_fs_service.h" 32#include "gnunet_fs_service.h"
32#include "fs_api.h" 33#include "fs_api.h"
33#include "fs_tree.h" 34#include "fs_tree.h"
@@ -1098,8 +1099,8 @@ GNUNET_FS_publish_main_ (void *cls)
1098 * related files as well! */ 1099 * related files as well! */
1099 while (NULL != p->dir) 1100 while (NULL != p->dir)
1100 { 1101 {
1101 fn = GNUNET_CONTAINER_meta_data_get_by_type (p->meta, 1102 fn = GNUNET_FS_meta_data_get_by_type (p->meta,
1102 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 1103 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
1103 p = p->dir; 1104 p = p->dir;
1104 if (fn != NULL) 1105 if (fn != NULL)
1105 { 1106 {
@@ -1193,7 +1194,7 @@ static int
1193fip_signal_start (void *cls, 1194fip_signal_start (void *cls,
1194 struct GNUNET_FS_FileInformation *fi, 1195 struct GNUNET_FS_FileInformation *fi,
1195 uint64_t length, 1196 uint64_t length,
1196 struct GNUNET_CONTAINER_MetaData *meta, 1197 struct GNUNET_FS_MetaData *meta,
1197 struct GNUNET_FS_Uri **uri, 1198 struct GNUNET_FS_Uri **uri,
1198 struct GNUNET_FS_BlockOptions *bo, 1199 struct GNUNET_FS_BlockOptions *bo,
1199 int *do_index, 1200 int *do_index,
@@ -1319,7 +1320,7 @@ static int
1319fip_signal_suspend (void *cls, 1320fip_signal_suspend (void *cls,
1320 struct GNUNET_FS_FileInformation *fi, 1321 struct GNUNET_FS_FileInformation *fi,
1321 uint64_t length, 1322 uint64_t length,
1322 struct GNUNET_CONTAINER_MetaData *meta, 1323 struct GNUNET_FS_MetaData *meta,
1323 struct GNUNET_FS_Uri **uri, 1324 struct GNUNET_FS_Uri **uri,
1324 struct GNUNET_FS_BlockOptions *bo, 1325 struct GNUNET_FS_BlockOptions *bo,
1325 int *do_index, 1326 int *do_index,
@@ -1523,7 +1524,7 @@ static int
1523fip_signal_stop (void *cls, 1524fip_signal_stop (void *cls,
1524 struct GNUNET_FS_FileInformation *fi, 1525 struct GNUNET_FS_FileInformation *fi,
1525 uint64_t length, 1526 uint64_t length,
1526 struct GNUNET_CONTAINER_MetaData *meta, 1527 struct GNUNET_FS_MetaData *meta,
1527 struct GNUNET_FS_Uri **uri, 1528 struct GNUNET_FS_Uri **uri,
1528 struct GNUNET_FS_BlockOptions *bo, 1529 struct GNUNET_FS_BlockOptions *bo,
1529 int *do_index, void **client_info) 1530 int *do_index, void **client_info)
diff --git a/src/fs/fs_publish_ksk.c b/src/fs/fs_publish_ksk.c
index dae5ccdf3..d8ea22da2 100644
--- a/src/fs/fs_publish_ksk.c
+++ b/src/fs/fs_publish_ksk.c
@@ -30,6 +30,7 @@
30#include "gnunet_constants.h" 30#include "gnunet_constants.h"
31#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
32#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
33#include "gnunet_extractor_compat.h"
33#include "gnunet_fs_service.h" 34#include "gnunet_fs_service.h"
34#include "fs_api.h" 35#include "fs_api.h"
35#include "fs_tree.h" 36#include "fs_tree.h"
@@ -53,7 +54,7 @@ struct GNUNET_FS_PublishKskContext
53 /** 54 /**
54 * Metadata to use. 55 * Metadata to use.
55 */ 56 */
56 struct GNUNET_CONTAINER_MetaData *meta; 57 struct GNUNET_FS_MetaData *meta;
57 58
58 /** 59 /**
59 * Global FS context. 60 * Global FS context.
@@ -186,7 +187,7 @@ publish_ksk_cont (void *cls)
186struct GNUNET_FS_PublishKskContext * 187struct GNUNET_FS_PublishKskContext *
187GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, 188GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
188 const struct GNUNET_FS_Uri *ksk_uri, 189 const struct GNUNET_FS_Uri *ksk_uri,
189 const struct GNUNET_CONTAINER_MetaData *meta, 190 const struct GNUNET_FS_MetaData *meta,
190 const struct GNUNET_FS_Uri *uri, 191 const struct GNUNET_FS_Uri *uri,
191 const struct GNUNET_FS_BlockOptions *bo, 192 const struct GNUNET_FS_BlockOptions *bo,
192 enum GNUNET_FS_PublishOptions options, 193 enum GNUNET_FS_PublishOptions options,
@@ -201,7 +202,7 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
201 pkc->options = options; 202 pkc->options = options;
202 pkc->cont = cont; 203 pkc->cont = cont;
203 pkc->cont_cls = cont_cls; 204 pkc->cont_cls = cont_cls;
204 pkc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 205 pkc->meta = GNUNET_FS_meta_data_duplicate (meta);
205 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) 206 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
206 { 207 {
207 pkc->dsh = GNUNET_DATASTORE_connect (h->cfg); 208 pkc->dsh = GNUNET_DATASTORE_connect (h->cfg);
@@ -244,7 +245,7 @@ GNUNET_FS_publish_ksk_cancel (struct GNUNET_FS_PublishKskContext *pkc)
244 GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO); 245 GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
245 pkc->dsh = NULL; 246 pkc->dsh = NULL;
246 } 247 }
247 GNUNET_CONTAINER_meta_data_destroy (pkc->meta); 248 GNUNET_FS_meta_data_destroy (pkc->meta);
248 GNUNET_FS_uri_destroy (pkc->ksk_uri); 249 GNUNET_FS_uri_destroy (pkc->ksk_uri);
249 GNUNET_FS_uri_destroy (pkc->uri); 250 GNUNET_FS_uri_destroy (pkc->uri);
250 GNUNET_free (pkc); 251 GNUNET_free (pkc);
diff --git a/src/fs/fs_publish_ublock.c b/src/fs/fs_publish_ublock.c
index aed090bb3..ad12d9b08 100644
--- a/src/fs/fs_publish_ublock.c
+++ b/src/fs/fs_publish_ublock.c
@@ -155,7 +155,7 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
155 const char *label, 155 const char *label,
156 const char *ulabel, 156 const char *ulabel,
157 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, 157 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
158 const struct GNUNET_CONTAINER_MetaData *meta, 158 const struct GNUNET_FS_MetaData *meta,
159 const struct GNUNET_FS_Uri *uri, 159 const struct GNUNET_FS_Uri *uri,
160 const struct GNUNET_FS_BlockOptions *bo, 160 const struct GNUNET_FS_BlockOptions *bo,
161 enum GNUNET_FS_PublishOptions options, 161 enum GNUNET_FS_PublishOptions options,
@@ -181,7 +181,7 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
181 if (NULL == meta) 181 if (NULL == meta)
182 mdsize = 0; 182 mdsize = 0;
183 else 183 else
184 mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); 184 mdsize = GNUNET_FS_meta_data_get_serialized_size (meta);
185 GNUNET_assert (mdsize >= 0); 185 GNUNET_assert (mdsize >= 0);
186 uris = GNUNET_FS_uri_to_string (uri); 186 uris = GNUNET_FS_uri_to_string (uri);
187 slen = strlen (uris) + 1; 187 slen = strlen (uris) + 1;
@@ -206,8 +206,8 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
206 sptr = kbe; 206 sptr = kbe;
207 if (NULL != meta) 207 if (NULL != meta)
208 mdsize = 208 mdsize =
209 GNUNET_CONTAINER_meta_data_serialize (meta, &sptr, mdsize, 209 GNUNET_FS_meta_data_serialize (meta, &sptr, mdsize,
210 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); 210 GNUNET_FS_META_DATA_SERIALIZE_PART);
211 if (-1 == mdsize) 211 if (-1 == mdsize)
212 { 212 {
213 GNUNET_break (0); 213 GNUNET_break (0);
diff --git a/src/fs/fs_publish_ublock.h b/src/fs/fs_publish_ublock.h
index bd1c1a4dd..991926444 100644
--- a/src/fs/fs_publish_ublock.h
+++ b/src/fs/fs_publish_ublock.h
@@ -30,6 +30,7 @@
30 30
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_datastore_service.h" 32#include "gnunet_datastore_service.h"
33#include "gnunet_extractor_compat.h"
33#include "gnunet_fs_service.h" 34#include "gnunet_fs_service.h"
34#include "gnunet_identity_service.h" 35#include "gnunet_identity_service.h"
35 36
@@ -90,7 +91,7 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
90 const char *label, 91 const char *label,
91 const char *ulabel, 92 const char *ulabel,
92 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, 93 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
93 const struct GNUNET_CONTAINER_MetaData *meta, 94 const struct GNUNET_FS_MetaData *meta,
94 const struct GNUNET_FS_Uri *uri, 95 const struct GNUNET_FS_Uri *uri,
95 const struct GNUNET_FS_BlockOptions *bo, 96 const struct GNUNET_FS_BlockOptions *bo,
96 enum GNUNET_FS_PublishOptions options, 97 enum GNUNET_FS_PublishOptions options,
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 5538b7838..975dcfb14 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -24,6 +24,7 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_constants.h" 26#include "gnunet_constants.h"
27#include "gnunet_extractor_compat.h"
27#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
28#include "gnunet_protocols.h" 29#include "gnunet_protocols.h"
29#include "fs_api.h" 30#include "fs_api.h"
@@ -487,7 +488,7 @@ GNUNET_FS_search_start_probe_ (struct GNUNET_FS_SearchResult *sr)
487struct GNUNET_FS_SearchResult * 488struct GNUNET_FS_SearchResult *
488GNUNET_FS_probe (struct GNUNET_FS_Handle *h, 489GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
489 const struct GNUNET_FS_Uri *uri, 490 const struct GNUNET_FS_Uri *uri,
490 const struct GNUNET_CONTAINER_MetaData *meta, 491 const struct GNUNET_FS_MetaData *meta,
491 void *client_info, 492 void *client_info,
492 uint32_t anonymity) 493 uint32_t anonymity)
493{ 494{
@@ -498,7 +499,7 @@ GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
498 sr = GNUNET_new (struct GNUNET_FS_SearchResult); 499 sr = GNUNET_new (struct GNUNET_FS_SearchResult);
499 sr->h = h; 500 sr->h = h;
500 sr->uri = GNUNET_FS_uri_dup (uri); 501 sr->uri = GNUNET_FS_uri_dup (uri);
501 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 502 sr->meta = GNUNET_FS_meta_data_duplicate (meta);
502 sr->client_info = client_info; 503 sr->client_info = client_info;
503 sr->anonymity = anonymity; 504 sr->anonymity = anonymity;
504 GNUNET_FS_search_start_probe_ (sr); 505 GNUNET_FS_search_start_probe_ (sr);
@@ -543,7 +544,7 @@ GNUNET_FS_probe_stop (struct GNUNET_FS_SearchResult *sr)
543 GNUNET_assert (NULL == sr->sc); 544 GNUNET_assert (NULL == sr->sc);
544 GNUNET_FS_search_stop_probe_ (sr); 545 GNUNET_FS_search_stop_probe_ (sr);
545 GNUNET_FS_uri_destroy (sr->uri); 546 GNUNET_FS_uri_destroy (sr->uri);
546 GNUNET_CONTAINER_meta_data_destroy (sr->meta); 547 GNUNET_FS_meta_data_destroy (sr->meta);
547 client_info = sr->client_info; 548 client_info = sr->client_info;
548 GNUNET_free (sr); 549 GNUNET_free (sr);
549 return client_info; 550 return client_info;
@@ -564,7 +565,7 @@ static void
564process_ksk_result (struct GNUNET_FS_SearchContext *sc, 565process_ksk_result (struct GNUNET_FS_SearchContext *sc,
565 struct SearchRequestEntry *ent, 566 struct SearchRequestEntry *ent,
566 const struct GNUNET_FS_Uri *uri, 567 const struct GNUNET_FS_Uri *uri,
567 const struct GNUNET_CONTAINER_MetaData *meta) 568 const struct GNUNET_FS_MetaData *meta)
568{ 569{
569 struct GNUNET_HashCode key; 570 struct GNUNET_HashCode key;
570 struct GNUNET_FS_SearchResult *sr; 571 struct GNUNET_FS_SearchResult *sr;
@@ -602,7 +603,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
602 sr->sc = sc; 603 sr->sc = sc;
603 sr->anonymity = sc->anonymity; 604 sr->anonymity = sc->anonymity;
604 sr->uri = GNUNET_FS_uri_dup (uri); 605 sr->uri = GNUNET_FS_uri_dup (uri);
605 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 606 sr->meta = GNUNET_FS_meta_data_duplicate (meta);
606 sr->mandatory_missing = sc->mandatory_count; 607 sr->mandatory_missing = sc->mandatory_count;
607 sr->key = key; 608 sr->key = key;
608 sr->keyword_bitmap = GNUNET_malloc ((sc->uri->data.ksk.keywordCount + 7) 609 sr->keyword_bitmap = GNUNET_malloc ((sc->uri->data.ksk.keywordCount + 7)
@@ -612,7 +613,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
612 } 613 }
613 else 614 else
614 { 615 {
615 GNUNET_CONTAINER_meta_data_merge (sr->meta, meta); 616 GNUNET_FS_meta_data_merge (sr->meta, meta);
616 } 617 }
617 GNUNET_break (GNUNET_OK == 618 GNUNET_break (GNUNET_OK ==
618 GNUNET_CONTAINER_multihashmap_put (ent->results, 619 GNUNET_CONTAINER_multihashmap_put (ent->results,
@@ -685,7 +686,7 @@ static void
685process_sks_result (struct GNUNET_FS_SearchContext *sc, 686process_sks_result (struct GNUNET_FS_SearchContext *sc,
686 const char *id_update, 687 const char *id_update,
687 const struct GNUNET_FS_Uri *uri, 688 const struct GNUNET_FS_Uri *uri,
688 const struct GNUNET_CONTAINER_MetaData *meta) 689 const struct GNUNET_FS_MetaData *meta)
689{ 690{
690 struct GNUNET_FS_Uri uu; 691 struct GNUNET_FS_Uri uu;
691 struct GNUNET_HashCode key; 692 struct GNUNET_HashCode key;
@@ -713,7 +714,7 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc,
713 sr->sc = sc; 714 sr->sc = sc;
714 sr->anonymity = sc->anonymity; 715 sr->anonymity = sc->anonymity;
715 sr->uri = GNUNET_FS_uri_dup (uri); 716 sr->uri = GNUNET_FS_uri_dup (uri);
716 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 717 sr->meta = GNUNET_FS_meta_data_duplicate (meta);
717 sr->key = key; 718 sr->key = key;
718 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &key, sr, 719 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &key, sr,
719 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 720 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
@@ -800,7 +801,7 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
800 size_t j; 801 size_t j;
801 char pt[size - sizeof(struct UBlock)]; 802 char pt[size - sizeof(struct UBlock)];
802 const char *eos; 803 const char *eos;
803 struct GNUNET_CONTAINER_MetaData *meta; 804 struct GNUNET_FS_MetaData *meta;
804 struct GNUNET_FS_Uri *uri; 805 struct GNUNET_FS_Uri *uri;
805 char *emsg; 806 char *emsg;
806 int i; 807 int i;
@@ -835,9 +836,9 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
835 } 836 }
836 j = eos - pt + 1; 837 j = eos - pt + 1;
837 if (sizeof(pt) == j) 838 if (sizeof(pt) == j)
838 meta = GNUNET_CONTAINER_meta_data_create (); 839 meta = GNUNET_FS_meta_data_create ();
839 else 840 else
840 meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[j], sizeof(pt) - j); 841 meta = GNUNET_FS_meta_data_deserialize (&pt[j], sizeof(pt) - j);
841 if (NULL == meta) 842 if (NULL == meta)
842 { 843 {
843 GNUNET_break_op (0); /* ublock malformed */ 844 GNUNET_break_op (0); /* ublock malformed */
@@ -850,7 +851,7 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
850 meta); 851 meta);
851 852
852 /* clean up */ 853 /* clean up */
853 GNUNET_CONTAINER_meta_data_destroy (meta); 854 GNUNET_FS_meta_data_destroy (meta);
854 GNUNET_FS_uri_destroy (uri); 855 GNUNET_FS_uri_destroy (uri);
855} 856}
856 857
@@ -872,7 +873,7 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
872 size_t len = size - sizeof(struct UBlock); 873 size_t len = size - sizeof(struct UBlock);
873 char pt[len]; 874 char pt[len];
874 struct GNUNET_FS_Uri *uri; 875 struct GNUNET_FS_Uri *uri;
875 struct GNUNET_CONTAINER_MetaData *meta; 876 struct GNUNET_FS_MetaData *meta;
876 const char *id; 877 const char *id;
877 const char *uris; 878 const char *uris;
878 size_t off; 879 size_t off;
@@ -888,8 +889,8 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
888 GNUNET_break_op (0); /* ublock malformed */ 889 GNUNET_break_op (0); /* ublock malformed */
889 return; 890 return;
890 } 891 }
891 if (NULL == (meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[off], len 892 if (NULL == (meta = GNUNET_FS_meta_data_deserialize (&pt[off], len
892 - off))) 893 - off)))
893 { 894 {
894 GNUNET_break_op (0); /* ublock malformed */ 895 GNUNET_break_op (0); /* ublock malformed */
895 return; 896 return;
@@ -901,14 +902,14 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
901 uris, emsg); 902 uris, emsg);
902 GNUNET_break_op (0); /* ublock malformed */ 903 GNUNET_break_op (0); /* ublock malformed */
903 GNUNET_free (emsg); 904 GNUNET_free (emsg);
904 GNUNET_CONTAINER_meta_data_destroy (meta); 905 GNUNET_FS_meta_data_destroy (meta);
905 return; 906 return;
906 } 907 }
907 /* process */ 908 /* process */
908 process_sks_result (sc, id, uri, meta); 909 process_sks_result (sc, id, uri, meta);
909 /* clean up */ 910 /* clean up */
910 GNUNET_FS_uri_destroy (uri); 911 GNUNET_FS_uri_destroy (uri);
911 GNUNET_CONTAINER_meta_data_destroy (meta); 912 GNUNET_FS_meta_data_destroy (meta);
912} 913}
913 914
914 915
@@ -1543,7 +1544,7 @@ search_result_suspend (void *cls,
1543 GNUNET_break (NULL == sr->client_info); 1544 GNUNET_break (NULL == sr->client_info);
1544 GNUNET_free (sr->serialization); 1545 GNUNET_free (sr->serialization);
1545 GNUNET_FS_uri_destroy (sr->uri); 1546 GNUNET_FS_uri_destroy (sr->uri);
1546 GNUNET_CONTAINER_meta_data_destroy (sr->meta); 1547 GNUNET_FS_meta_data_destroy (sr->meta);
1547 GNUNET_free (sr->keyword_bitmap); 1548 GNUNET_free (sr->keyword_bitmap);
1548 GNUNET_free (sr); 1549 GNUNET_free (sr);
1549 return GNUNET_OK; 1550 return GNUNET_OK;
@@ -1749,7 +1750,7 @@ search_result_free (void *cls,
1749 GNUNET_break (NULL == sr->client_info); 1750 GNUNET_break (NULL == sr->client_info);
1750 GNUNET_free (sr->serialization); 1751 GNUNET_free (sr->serialization);
1751 GNUNET_FS_uri_destroy (sr->uri); 1752 GNUNET_FS_uri_destroy (sr->uri);
1752 GNUNET_CONTAINER_meta_data_destroy (sr->meta); 1753 GNUNET_FS_meta_data_destroy (sr->meta);
1753 GNUNET_free (sr->keyword_bitmap); 1754 GNUNET_free (sr->keyword_bitmap);
1754 GNUNET_free (sr); 1755 GNUNET_free (sr);
1755 return GNUNET_OK; 1756 return GNUNET_OK;
diff --git a/src/fs/fs_sharetree.c b/src/fs/fs_sharetree.c
index 3610b202e..a09b3589d 100644
--- a/src/fs/fs_sharetree.c
+++ b/src/fs/fs_sharetree.c
@@ -25,6 +25,7 @@
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_extractor_compat.h"
28#include "gnunet_fs_service.h" 29#include "gnunet_fs_service.h"
29#include "gnunet_scheduler_lib.h" 30#include "gnunet_scheduler_lib.h"
30#include <pthread.h> 31#include <pthread.h>
@@ -308,13 +309,13 @@ migrate_and_drop_metadata (void *cls, const struct GNUNET_HashCode *key,
308 if (counter->count >= tc->move_threshold) 309 if (counter->count >= tc->move_threshold)
309 { 310 {
310 if (NULL == tc->pos->meta) 311 if (NULL == tc->pos->meta)
311 tc->pos->meta = GNUNET_CONTAINER_meta_data_create (); 312 tc->pos->meta = GNUNET_FS_meta_data_create ();
312 GNUNET_CONTAINER_meta_data_insert (tc->pos->meta, 313 GNUNET_FS_meta_data_insert (tc->pos->meta,
313 counter->plugin_name, 314 counter->plugin_name,
314 counter->type, 315 counter->type,
315 counter->format, 316 counter->format,
316 counter->data_mime_type, counter->data, 317 counter->data_mime_type, counter->data,
317 counter->data_size); 318 counter->data_size);
318 } 319 }
319 GNUNET_assert (GNUNET_YES == 320 GNUNET_assert (GNUNET_YES ==
320 GNUNET_CONTAINER_multihashmap_remove (tc->metacounter, 321 GNUNET_CONTAINER_multihashmap_remove (tc->metacounter,
@@ -356,12 +357,12 @@ share_tree_trim (struct TrimContext *tc,
356 { 357 {
357 /* only use filename if it doesn't match $USER */ 358 /* only use filename if it doesn't match $USER */
358 if (NULL == tree->meta) 359 if (NULL == tree->meta)
359 tree->meta = GNUNET_CONTAINER_meta_data_create (); 360 tree->meta = GNUNET_FS_meta_data_create ();
360 GNUNET_CONTAINER_meta_data_insert (tree->meta, "<libgnunetfs>", 361 GNUNET_FS_meta_data_insert (tree->meta, "<libgnunetfs>",
361 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 362 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
362 EXTRACTOR_METAFORMAT_UTF8, 363 EXTRACTOR_METAFORMAT_UTF8,
363 "text/plain", tree->short_filename, 364 "text/plain", tree->short_filename,
364 strlen (tree->short_filename) + 1); 365 strlen (tree->short_filename) + 1);
365 } 366 }
366 } 367 }
367 368
@@ -372,8 +373,8 @@ share_tree_trim (struct TrimContext *tc,
372 for (pos = tree->children_head; NULL != pos; pos = pos->next) 373 for (pos = tree->children_head; NULL != pos; pos = pos->next)
373 { 374 {
374 if (NULL != pos->meta) 375 if (NULL != pos->meta)
375 GNUNET_CONTAINER_meta_data_iterate (pos->meta, &add_to_meta_counter, 376 GNUNET_FS_meta_data_iterate (pos->meta, &add_to_meta_counter,
376 tc->metacounter); 377 tc->metacounter);
377 if (NULL != pos->ksk_uri) 378 if (NULL != pos->ksk_uri)
378 GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter, 379 GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter,
379 tc->keywordcounter); 380 tc->keywordcounter);
@@ -444,7 +445,7 @@ GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel)
444 toplevel->parent->children_tail, 445 toplevel->parent->children_tail,
445 toplevel); 446 toplevel);
446 if (NULL != toplevel->meta) 447 if (NULL != toplevel->meta)
447 GNUNET_CONTAINER_meta_data_destroy (toplevel->meta); 448 GNUNET_FS_meta_data_destroy (toplevel->meta);
448 if (NULL != toplevel->ksk_uri) 449 if (NULL != toplevel->ksk_uri)
449 GNUNET_FS_uri_destroy (toplevel->ksk_uri); 450 GNUNET_FS_uri_destroy (toplevel->ksk_uri);
450 GNUNET_free (toplevel->filename); 451 GNUNET_free (toplevel->filename);
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index 8c27af9de..6031d7bc3 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -26,6 +26,7 @@
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_constants.h" 28#include "gnunet_constants.h"
29#include "gnunet_extractor_compat.h"
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30#include "gnunet_protocols.h" 31#include "gnunet_protocols.h"
31#include "fs_api.h" 32#include "fs_api.h"
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index cdea8b72d..0810f77ca 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -81,6 +81,7 @@
81 * 81 *
82 */ 82 */
83#include "platform.h" 83#include "platform.h"
84#include "gnunet_extractor_compat.h"
84#include "gnunet_fs_service.h" 85#include "gnunet_fs_service.h"
85#include "gnunet_signatures.h" 86#include "gnunet_signatures.h"
86#include "fs_api.h" 87#include "fs_api.h"
@@ -343,7 +344,7 @@ uri_ksk_parse (const char *s, char **emsg)
343 ret->data.ksk.keywordCount = iret; 344 ret->data.ksk.keywordCount = iret;
344 ret->data.ksk.keywords = keywords; 345 ret->data.ksk.keywords = keywords;
345 return ret; 346 return ret;
346CLEANUP: 347 CLEANUP:
347 for (i = 0; i < max; i++) 348 for (i = 0; i < max; i++)
348 GNUNET_free (keywords[i]); 349 GNUNET_free (keywords[i]);
349 GNUNET_free (keywords); 350 GNUNET_free (keywords);
@@ -620,7 +621,7 @@ uri_loc_parse (const char *s, char **emsg)
620 uri->data.loc.contentSignature = sig; 621 uri->data.loc.contentSignature = sig;
621 622
622 return uri; 623 return uri;
623ERR: 624 ERR:
624 return NULL; 625 return NULL;
625} 626}
626 627
@@ -1768,7 +1769,7 @@ gather_uri_data (void *cls,
1768 */ 1769 */
1769struct GNUNET_FS_Uri * 1770struct GNUNET_FS_Uri *
1770GNUNET_FS_uri_ksk_create_from_meta_data ( 1771GNUNET_FS_uri_ksk_create_from_meta_data (
1771 const struct GNUNET_CONTAINER_MetaData *md) 1772 const struct GNUNET_FS_MetaData *md)
1772{ 1773{
1773 struct GNUNET_FS_Uri *ret; 1774 struct GNUNET_FS_Uri *ret;
1774 char *filename; 1775 char *filename;
@@ -1782,10 +1783,10 @@ GNUNET_FS_uri_ksk_create_from_meta_data (
1782 return NULL; 1783 return NULL;
1783 ret = GNUNET_new (struct GNUNET_FS_Uri); 1784 ret = GNUNET_new (struct GNUNET_FS_Uri);
1784 ret->type = GNUNET_FS_URI_KSK; 1785 ret->type = GNUNET_FS_URI_KSK;
1785 ent = GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL); 1786 ent = GNUNET_FS_meta_data_iterate (md, NULL, NULL);
1786 if (ent > 0) 1787 if (ent > 0)
1787 { 1788 {
1788 full_name = GNUNET_CONTAINER_meta_data_get_first_by_types ( 1789 full_name = GNUNET_FS_meta_data_get_first_by_types (
1789 md, 1790 md,
1790 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 1791 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
1791 -1); 1792 -1);
@@ -1801,7 +1802,7 @@ GNUNET_FS_uri_ksk_create_from_meta_data (
1801 plus theoretically one more for mime... */ 1802 plus theoretically one more for mime... */
1802 ret->data.ksk.keywords = 1803 ret->data.ksk.keywords =
1803 GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3, char *); 1804 GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3, char *);
1804 GNUNET_CONTAINER_meta_data_iterate (md, &gather_uri_data, ret); 1805 GNUNET_FS_meta_data_iterate (md, &gather_uri_data, ret);
1805 } 1806 }
1806 if (tok_keywords > 0) 1807 if (tok_keywords > 0)
1807 ret->data.ksk.keywordCount += 1808 ret->data.ksk.keywordCount +=
diff --git a/src/fs/gnunet-daemon-fsprofiler.c b/src/fs/gnunet-daemon-fsprofiler.c
index fbb7c6028..bc7ca9521 100644
--- a/src/fs/gnunet-daemon-fsprofiler.c
+++ b/src/fs/gnunet-daemon-fsprofiler.c
@@ -27,6 +27,7 @@
27 * - how to signal driver that we're done? 27 * - how to signal driver that we're done?
28 */ 28 */
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_extractor_compat.h"
30#include "gnunet_fs_service.h" 31#include "gnunet_fs_service.h"
31#include "gnunet_statistics_service.h" 32#include "gnunet_statistics_service.h"
32 33
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c
index ef5c40ae2..e720628b3 100644
--- a/src/fs/gnunet-directory.c
+++ b/src/fs/gnunet-directory.c
@@ -23,6 +23,7 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_extractor_compat.h"
26#include "gnunet_fs_service.h" 27#include "gnunet_fs_service.h"
27 28
28static int ret; 29static int ret;
@@ -90,20 +91,20 @@ static void
90print_entry (void *cls, 91print_entry (void *cls,
91 const char *filename, 92 const char *filename,
92 const struct GNUNET_FS_Uri *uri, 93 const struct GNUNET_FS_Uri *uri,
93 const struct GNUNET_CONTAINER_MetaData *meta, 94 const struct GNUNET_FS_MetaData *meta,
94 size_t length, 95 size_t length,
95 const void *data) 96 const void *data)
96{ 97{
97 char *string; 98 char *string;
98 char *name; 99 char *name;
99 100
100 name = GNUNET_CONTAINER_meta_data_get_by_type ( 101 name = GNUNET_FS_meta_data_get_by_type (
101 meta, 102 meta,
102 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 103 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
103 if (uri == NULL) 104 if (uri == NULL)
104 { 105 {
105 printf (_ ("Directory `%s' meta data:\n"), name ? name : ""); 106 printf (_ ("Directory `%s' meta data:\n"), name ? name : "");
106 GNUNET_CONTAINER_meta_data_iterate (meta, &item_printer, NULL); 107 GNUNET_FS_meta_data_iterate (meta, &item_printer, NULL);
107 printf ("\n"); 108 printf ("\n");
108 printf (_ ("Directory `%s' contents:\n"), name ? name : ""); 109 printf (_ ("Directory `%s' contents:\n"), name ? name : "");
109 GNUNET_free (name); 110 GNUNET_free (name);
@@ -112,7 +113,7 @@ print_entry (void *cls,
112 string = GNUNET_FS_uri_to_string (uri); 113 string = GNUNET_FS_uri_to_string (uri);
113 printf ("%s (%s):\n", name ? name : "", string); 114 printf ("%s (%s):\n", name ? name : "", string);
114 GNUNET_free (string); 115 GNUNET_free (string);
115 GNUNET_CONTAINER_meta_data_iterate (meta, &item_printer, NULL); 116 GNUNET_FS_meta_data_iterate (meta, &item_printer, NULL);
116 printf ("\n"); 117 printf ("\n");
117 GNUNET_free (name); 118 GNUNET_free (name);
118} 119}
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index eebf8e993..f463f901e 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -26,6 +26,7 @@
26 * @author Igor Wronsky 26 * @author Igor Wronsky
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_extractor_compat.h"
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30 31
31static int ret; 32static int ret;
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c
index 0f8f02a1c..3dd00c7dc 100644
--- a/src/fs/gnunet-fs.c
+++ b/src/fs/gnunet-fs.c
@@ -23,6 +23,7 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_extractor_compat.h"
26#include "gnunet_fs_service.h" 27#include "gnunet_fs_service.h"
27 28
28/** 29/**
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c
index ef1a9ce4b..b886280c9 100644
--- a/src/fs/gnunet-helper-fs-publish.c
+++ b/src/fs/gnunet-helper-fs-publish.c
@@ -27,6 +27,7 @@
27 * and report the results to stdout. 27 * and report the results to stdout.
28 */ 28 */
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_extractor_compat.h"
30#include "gnunet_fs_service.h" 31#include "gnunet_fs_service.h"
31 32
32 33
@@ -120,7 +121,7 @@ add_to_md (void *cls,
120 const char *data, 121 const char *data,
121 size_t data_len) 122 size_t data_len)
122{ 123{
123 struct GNUNET_CONTAINER_MetaData *md = cls; 124 struct GNUNET_FS_MetaData *md = cls;
124 125
125 if (((EXTRACTOR_METAFORMAT_UTF8 == format) || 126 if (((EXTRACTOR_METAFORMAT_UTF8 == format) ||
126 (EXTRACTOR_METAFORMAT_C_STRING == format)) && 127 (EXTRACTOR_METAFORMAT_C_STRING == format)) &&
@@ -129,23 +130,23 @@ add_to_md (void *cls,
129 char zdata[data_len + 1]; 130 char zdata[data_len + 1];
130 GNUNET_memcpy (zdata, data, data_len); 131 GNUNET_memcpy (zdata, data, data_len);
131 zdata[data_len] = '\0'; 132 zdata[data_len] = '\0';
132 (void) GNUNET_CONTAINER_meta_data_insert (md, 133 (void) GNUNET_FS_meta_data_insert (md,
133 plugin_name, 134 plugin_name,
134 type, 135 type,
135 format, 136 format,
136 data_mime_type, 137 data_mime_type,
137 zdata, 138 zdata,
138 data_len + 1); 139 data_len + 1);
139 } 140 }
140 else 141 else
141 { 142 {
142 (void) GNUNET_CONTAINER_meta_data_insert (md, 143 (void) GNUNET_FS_meta_data_insert (md,
143 plugin_name, 144 plugin_name,
144 type, 145 type,
145 format, 146 format,
146 data_mime_type, 147 data_mime_type,
147 data, 148 data,
148 data_len); 149 data_len);
149 } 150 }
150 return 0; 151 return 0;
151} 152}
@@ -373,7 +374,7 @@ preprocess_file (const char *filename, struct ScanTreeNode **dst)
373static int 374static int
374extract_files (struct ScanTreeNode *item) 375extract_files (struct ScanTreeNode *item)
375{ 376{
376 struct GNUNET_CONTAINER_MetaData *meta; 377 struct GNUNET_FS_MetaData *meta;
377 ssize_t size; 378 ssize_t size;
378 size_t slen; 379 size_t slen;
379 380
@@ -390,16 +391,16 @@ extract_files (struct ScanTreeNode *item)
390 } 391 }
391 392
392 /* this is the expensive operation, *afterwards* we'll check for aborts */ 393 /* this is the expensive operation, *afterwards* we'll check for aborts */
393 meta = GNUNET_CONTAINER_meta_data_create (); 394 meta = GNUNET_FS_meta_data_create ();
394#if HAVE_LIBEXTRACTOR 395#if HAVE_LIBEXTRACTOR
395 EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta); 396 EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta);
396#endif 397#endif
397 slen = strlen (item->filename) + 1; 398 slen = strlen (item->filename) + 1;
398 size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); 399 size = GNUNET_FS_meta_data_get_serialized_size (meta);
399 if (-1 == size) 400 if (-1 == size)
400 { 401 {
401 /* no meta data */ 402 /* no meta data */
402 GNUNET_CONTAINER_meta_data_destroy (meta); 403 GNUNET_FS_meta_data_destroy (meta);
403 if (GNUNET_OK != 404 if (GNUNET_OK !=
404 write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, 405 write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
405 item->filename, 406 item->filename,
@@ -417,17 +418,17 @@ extract_files (struct ScanTreeNode *item)
417 char *dst = &buf[slen]; 418 char *dst = &buf[slen];
418 419
419 GNUNET_memcpy (buf, item->filename, slen); 420 GNUNET_memcpy (buf, item->filename, slen);
420 size = GNUNET_CONTAINER_meta_data_serialize ( 421 size = GNUNET_FS_meta_data_serialize (
421 meta, 422 meta,
422 &dst, 423 &dst,
423 size, 424 size,
424 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); 425 GNUNET_FS_META_DATA_SERIALIZE_PART);
425 if (size < 0) 426 if (size < 0)
426 { 427 {
427 GNUNET_break (0); 428 GNUNET_break (0);
428 size = 0; 429 size = 0;
429 } 430 }
430 GNUNET_CONTAINER_meta_data_destroy (meta); 431 GNUNET_FS_meta_data_destroy (meta);
431 if (GNUNET_OK != 432 if (GNUNET_OK !=
432 write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, 433 write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
433 buf, 434 buf,
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index c62edcd61..094cbc9b9 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -26,6 +26,7 @@
26 * @author Igor Wronsky 26 * @author Igor Wronsky
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_extractor_compat.h"
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
31 32
@@ -57,7 +58,7 @@ static struct GNUNET_FS_PublishContext *pc;
57/** 58/**
58 * Meta-data provided via command-line option. 59 * Meta-data provided via command-line option.
59 */ 60 */
60static struct GNUNET_CONTAINER_MetaData *meta; 61static struct GNUNET_FS_MetaData *meta;
61 62
62/** 63/**
63 * Keywords provided via command-line option. 64 * Keywords provided via command-line option.
@@ -175,7 +176,7 @@ do_stop_task (void *cls)
175 } 176 }
176 if (NULL != meta) 177 if (NULL != meta)
177 { 178 {
178 GNUNET_CONTAINER_meta_data_destroy (meta); 179 GNUNET_FS_meta_data_destroy (meta);
179 meta = NULL; 180 meta = NULL;
180 } 181 }
181 if (NULL != uri) 182 if (NULL != uri)
@@ -376,7 +377,7 @@ static int
376publish_inspector (void *cls, 377publish_inspector (void *cls,
377 struct GNUNET_FS_FileInformation *fi, 378 struct GNUNET_FS_FileInformation *fi,
378 uint64_t length, 379 uint64_t length,
379 struct GNUNET_CONTAINER_MetaData *m, 380 struct GNUNET_FS_MetaData *m,
380 struct GNUNET_FS_Uri **uri, 381 struct GNUNET_FS_Uri **uri,
381 struct GNUNET_FS_BlockOptions *bo, 382 struct GNUNET_FS_BlockOptions *bo,
382 int *do_index, 383 int *do_index,
@@ -410,20 +411,20 @@ publish_inspector (void *cls,
410 } 411 }
411 if (NULL != meta) 412 if (NULL != meta)
412 { 413 {
413 GNUNET_CONTAINER_meta_data_merge (m, meta); 414 GNUNET_FS_meta_data_merge (m, meta);
414 GNUNET_CONTAINER_meta_data_destroy (meta); 415 GNUNET_FS_meta_data_destroy (meta);
415 meta = NULL; 416 meta = NULL;
416 } 417 }
417 if (enable_creation_time) 418 if (enable_creation_time)
418 GNUNET_CONTAINER_meta_data_add_publication_date (m); 419 GNUNET_FS_meta_data_add_publication_date (m);
419 if (extract_only) 420 if (extract_only)
420 { 421 {
421 fn = GNUNET_CONTAINER_meta_data_get_by_type ( 422 fn = GNUNET_FS_meta_data_get_by_type (
422 m, 423 m,
423 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 424 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
424 fs = GNUNET_STRINGS_byte_size_fancy (length); 425 fs = GNUNET_STRINGS_byte_size_fancy (length);
425 fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs); 426 fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs);
426 GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL); 427 GNUNET_FS_meta_data_iterate (m, &meta_printer, NULL);
427 fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs); 428 fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs);
428 GNUNET_free (fn); 429 GNUNET_free (fn);
429 GNUNET_free (fs); 430 GNUNET_free (fs);
@@ -521,11 +522,11 @@ get_file_information (struct GNUNET_FS_ShareTreeItem *item)
521 if (GNUNET_YES == item->is_directory) 522 if (GNUNET_YES == item->is_directory)
522 { 523 {
523 if (NULL == item->meta) 524 if (NULL == item->meta)
524 item->meta = GNUNET_CONTAINER_meta_data_create (); 525 item->meta = GNUNET_FS_meta_data_create ();
525 GNUNET_CONTAINER_meta_data_delete (item->meta, 526 GNUNET_FS_meta_data_delete (item->meta,
526 EXTRACTOR_METATYPE_MIMETYPE, 527 EXTRACTOR_METATYPE_MIMETYPE,
527 NULL, 528 NULL,
528 0); 529 0);
529 GNUNET_FS_meta_data_make_directory (item->meta); 530 GNUNET_FS_meta_data_make_directory (item->meta);
530 if (NULL == item->ksk_uri) 531 if (NULL == item->ksk_uri)
531 { 532 {
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index 78f4f3d4d..b55602523 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -30,11 +30,12 @@
30#include <ctype.h> 30#include <ctype.h>
31#include <inttypes.h> 31#include <inttypes.h>
32#include <limits.h> 32#include <limits.h>
33#include "gnunet_extractor_compat.h"
33#include "gnunet_fs_service.h" 34#include "gnunet_fs_service.h"
34 35
35 36
36#define GNUNET_SEARCH_log(kind, ...) \ 37#define GNUNET_SEARCH_log(kind, ...) \
37 GNUNET_log_from(kind, "gnunet-search", __VA_ARGS__) 38 GNUNET_log_from (kind, "gnunet-search", __VA_ARGS__)
38 39
39 40
40/* The default settings that we use for the printed output */ 41/* The default settings that we use for the printed output */
@@ -61,14 +62,16 @@
61#define GENERIC_FILE_MIMETYPE "application/octet-stream" 62#define GENERIC_FILE_MIMETYPE "application/octet-stream"
62 63
63 64
64enum GNUNET_SEARCH_MetadataPrinterFlags { 65enum GNUNET_SEARCH_MetadataPrinterFlags
66{
65 METADATA_PRINTER_FLAG_NONE = 0, 67 METADATA_PRINTER_FLAG_NONE = 0,
66 METADATA_PRINTER_FLAG_ONE_RUN = 1, 68 METADATA_PRINTER_FLAG_ONE_RUN = 1,
67 METADATA_PRINTER_FLAG_HAVE_TYPE = 2 69 METADATA_PRINTER_FLAG_HAVE_TYPE = 2
68}; 70};
69 71
70 72
71struct GNUNET_SEARCH_MetadataPrinterInfo { 73struct GNUNET_SEARCH_MetadataPrinterInfo
74{
72 unsigned int counter; 75 unsigned int counter;
73 unsigned int flags; 76 unsigned int flags;
74 int type; 77 int type;
@@ -132,7 +135,7 @@ static const char *
132print_escape_sequence (const char *const esc) 135print_escape_sequence (const char *const esc)
133{ 136{
134 unsigned int probe; 137 unsigned int probe;
135 const char * cursor = esc + 1; 138 const char *cursor = esc + 1;
136 char tmp; 139 char tmp;
137 switch (*cursor) 140 switch (*cursor)
138 { 141 {
@@ -150,7 +153,7 @@ print_escape_sequence (const char *const esc)
150 /* Possibly hexadecimal code point */ 153 /* Possibly hexadecimal code point */
151 case 'x': 154 case 'x':
152 probe = 0; 155 probe = 0;
153 while (probe < 256 && isxdigit((tmp = *++cursor))) 156 while (probe < 256 && isxdigit ((tmp = *++cursor)))
154 probe = (probe << 4) + tmp - (tmp > 96 ? 87 : tmp > 64 ? 55 : 48); 157 probe = (probe << 4) + tmp - (tmp > 96 ? 87 : tmp > 64 ? 55 : 48);
155 goto maybe_codepoint; 158 goto maybe_codepoint;
156 159
@@ -167,7 +170,7 @@ print_escape_sequence (const char *const esc)
167 default: printf ("\\%c", *cursor); return cursor + 1; 170 default: printf ("\\%c", *cursor); return cursor + 1;
168 } 171 }
169 172
170maybe_codepoint: 173 maybe_codepoint:
171 if (probe < 256) 174 if (probe < 256)
172 putchar (probe); 175 putchar (probe);
173 else 176 else
@@ -212,31 +215,31 @@ item_printer (void *const cls,
212 return 0; 215 return 0;
213 216
214 const char *cursor = meta_format_string; 217 const char *cursor = meta_format_string;
215 const char *next_spec = strchr(cursor, '%'); 218 const char *next_spec = strchr (cursor, '%');
216 const char *next_esc = strchr(cursor, '\\'); 219 const char *next_esc = strchr (cursor, '\\');
217 220
218parse_format: 221 parse_format:
219 222
220 /* If an escape sequence exists before the next format specifier... */ 223 /* If an escape sequence exists before the next format specifier... */
221 if (next_esc && (!next_spec || next_esc < next_spec)) 224 if (next_esc && (! next_spec || next_esc < next_spec))
222 { 225 {
223 if (next_esc > cursor) 226 if (next_esc > cursor)
224 fwrite (cursor, 1, next_esc - cursor, stdout); 227 fwrite (cursor, 1, next_esc - cursor, stdout);
225 228
226 cursor = print_escape_sequence (next_esc); 229 cursor = print_escape_sequence (next_esc);
227 next_esc = strchr(cursor, '\\'); 230 next_esc = strchr (cursor, '\\');
228 goto parse_format; 231 goto parse_format;
229 } 232 }
230 233
231 /* If a format specifier exists before the next escape sequence... */ 234 /* If a format specifier exists before the next escape sequence... */
232 if (next_spec && (!next_esc || next_spec < next_esc)) 235 if (next_spec && (! next_esc || next_spec < next_esc))
233 { 236 {
234 if (next_spec > cursor) 237 if (next_spec > cursor)
235 fwrite (cursor, 1, next_spec - cursor, stdout); 238 fwrite (cursor, 1, next_spec - cursor, stdout);
236 239
237 switch (*++next_spec) 240 switch (*++next_spec)
238 { 241 {
239 case '%': putchar('%'); break; 242 case '%': putchar ('%'); break;
240 case 'i': printf ("%d", type); break; 243 case 'i': printf ("%d", type); break;
241 case 'l': printf ("%lu", (long unsigned int) data_size); break; 244 case 'l': printf ("%lu", (long unsigned int) data_size); break;
242 case 'n': printf ("%u", info->counter); break; 245 case 'n': printf ("%u", info->counter); break;
@@ -249,11 +252,11 @@ parse_format:
249 break; 252 break;
250#endif 253#endif
251 case 'w': printf ("%s", plugin_name); break; 254 case 'w': printf ("%s", plugin_name); break;
252 case '\0': putchar('%'); return 0; 255 case '\0': putchar ('%'); return 0;
253 default: printf ("%%%c", *next_spec); break; 256 default: printf ("%%%c", *next_spec); break;
254 } 257 }
255 cursor = next_spec + 1; 258 cursor = next_spec + 1;
256 next_spec = strchr(cursor, '%'); 259 next_spec = strchr (cursor, '%');
257 goto parse_format; 260 goto parse_format;
258 } 261 }
259 262
@@ -270,7 +273,7 @@ parse_format:
270 * 273 *
271 * @param filename the filename for this result 274 * @param filename the filename for this result
272 * @param uri the `struct GNUNET_FS_Uri` this result refers to 275 * @param uri the `struct GNUNET_FS_Uri` this result refers to
273 * @param metadata the `struct GNUNET_CONTAINER_MetaData` associated with this 276 * @param metadata the `struct GNUNET_FS_MetaData` associated with this
274 result 277 result
275 * @param resultnum the result number 278 * @param resultnum the result number
276 * @param is_directory GNUNET_YES if this is a directory, otherwise GNUNET_NO 279 * @param is_directory GNUNET_YES if this is a directory, otherwise GNUNET_NO
@@ -279,34 +282,34 @@ parse_format:
279static void 282static void
280print_search_result (const char *const filename, 283print_search_result (const char *const filename,
281 const struct GNUNET_FS_Uri *const uri, 284 const struct GNUNET_FS_Uri *const uri,
282 const struct GNUNET_CONTAINER_MetaData *const metadata, 285 const struct GNUNET_FS_MetaData *const metadata,
283 const unsigned int resultnum, 286 const unsigned int resultnum,
284 const int is_directory) 287 const int is_directory)
285{ 288{
286 289
287 const char *cursor = GNUNET_YES == is_directory ? 290 const char *cursor = GNUNET_YES == is_directory ?
288 dir_format_string 291 dir_format_string
289 : format_string; 292 : format_string;
290 293
291 const char *next_spec = strchr(cursor, '%'); 294 const char *next_spec = strchr (cursor, '%');
292 const char *next_esc = strchr(cursor, '\\'); 295 const char *next_esc = strchr (cursor, '\\');
293 char *placeholder; 296 char *placeholder;
294 struct GNUNET_SEARCH_MetadataPrinterInfo info; 297 struct GNUNET_SEARCH_MetadataPrinterInfo info;
295 298
296parse_format: 299 parse_format:
297 /* If an escape sequence exists before the next format specifier... */ 300 /* If an escape sequence exists before the next format specifier... */
298 if (next_esc && (!next_spec || next_esc < next_spec)) 301 if (next_esc && (! next_spec || next_esc < next_spec))
299 { 302 {
300 if (next_esc > cursor) 303 if (next_esc > cursor)
301 fwrite (cursor, 1, next_esc - cursor, stdout); 304 fwrite (cursor, 1, next_esc - cursor, stdout);
302 305
303 cursor = print_escape_sequence (next_esc); 306 cursor = print_escape_sequence (next_esc);
304 next_esc = strchr(cursor, '\\'); 307 next_esc = strchr (cursor, '\\');
305 goto parse_format; 308 goto parse_format;
306 } 309 }
307 310
308 /* If a format specifier exists before the next escape sequence... */ 311 /* If a format specifier exists before the next escape sequence... */
309 if (next_spec && (!next_esc || next_spec < next_esc)) 312 if (next_spec && (! next_esc || next_spec < next_esc))
310 { 313 {
311 if (next_spec > cursor) 314 if (next_spec > cursor)
312 fwrite (cursor, 1, next_spec - cursor, stdout); 315 fwrite (cursor, 1, next_spec - cursor, stdout);
@@ -317,9 +320,9 @@ parse_format:
317 case 'a': 320 case 'a':
318 info.flags = METADATA_PRINTER_FLAG_NONE; 321 info.flags = METADATA_PRINTER_FLAG_NONE;
319 322
320iterate_meta: 323 iterate_meta:
321 info.counter = 0; 324 info.counter = 0;
322 GNUNET_CONTAINER_meta_data_iterate (metadata, &item_printer, &info); 325 GNUNET_FS_meta_data_iterate (metadata, &item_printer, &info);
323 break; 326 break;
324 /* File's name */ 327 /* File's name */
325 case 'f': 328 case 'f':
@@ -337,11 +340,11 @@ iterate_meta:
337 /* File name's length */ 340 /* File name's length */
338 case 'l': 341 case 'l':
339 printf ("%lu", 342 printf ("%lu",
340 (long unsigned int) ( GNUNET_YES == is_directory ? 343 (long unsigned int) (GNUNET_YES == is_directory ?
341 strlen(filename) + 344 strlen (filename)
342 (sizeof(GNUNET_FS_DIRECTORY_EXT) - 1) 345 + (sizeof(GNUNET_FS_DIRECTORY_EXT) - 1)
343 : 346 :
344 strlen(filename))); 347 strlen (filename)));
345 break; 348 break;
346 /* File's mime type */ 349 /* File's mime type */
347 case 'm': 350 case 'm':
@@ -350,7 +353,7 @@ iterate_meta:
350 printf ("%s", GNUNET_FS_DIRECTORY_MIME); 353 printf ("%s", GNUNET_FS_DIRECTORY_MIME);
351 break; 354 break;
352 } 355 }
353 placeholder = GNUNET_CONTAINER_meta_data_get_by_type ( 356 placeholder = GNUNET_FS_meta_data_get_by_type (
354 metadata, 357 metadata,
355 EXTRACTOR_METATYPE_MIMETYPE); 358 EXTRACTOR_METATYPE_MIMETYPE);
356 printf ("%s", placeholder ? placeholder : GENERIC_FILE_MIMETYPE); 359 printf ("%s", placeholder ? placeholder : GENERIC_FILE_MIMETYPE);
@@ -376,7 +379,7 @@ iterate_meta:
376 case '5': case '6': case '7': case '8': case '9': 379 case '5': case '6': case '7': case '8': case '9':
377 cursor = next_spec; 380 cursor = next_spec;
378 info.type = *cursor - 48; 381 info.type = *cursor - 48;
379 while (isdigit(*++cursor) && info.type < (INT_MAX - *cursor + 48) / 10) 382 while (isdigit (*++cursor) && info.type < (INT_MAX - *cursor + 48) / 10)
380 info.type = info.type * 10 + *cursor - 48; 383 info.type = info.type * 10 + *cursor - 48;
381 if (info.type == 0 || *cursor != '#') 384 if (info.type == 0 || *cursor != '#')
382 goto not_a_specifier; 385 goto not_a_specifier;
@@ -391,21 +394,21 @@ iterate_meta:
391 /* Only the first metadata field of type `info.type` */ 394 /* Only the first metadata field of type `info.type` */
392 case 'j': 395 case 'j':
393 next_spec = cursor; 396 next_spec = cursor;
394 info.flags = METADATA_PRINTER_FLAG_HAVE_TYPE | 397 info.flags = METADATA_PRINTER_FLAG_HAVE_TYPE
395 METADATA_PRINTER_FLAG_ONE_RUN; 398 | METADATA_PRINTER_FLAG_ONE_RUN;
396 goto iterate_meta; 399 goto iterate_meta;
397 } 400 }
398 goto not_a_specifier; 401 goto not_a_specifier;
399 402
400 /* All other cases */ 403 /* All other cases */
401 case '%': putchar('%'); break; 404 case '%': putchar ('%'); break;
402 case '\0': putchar('%'); return; 405 case '\0': putchar ('%'); return;
403 406
404not_a_specifier: 407 not_a_specifier:
405 default: printf ("%%%c", *next_spec); break; 408 default: printf ("%%%c", *next_spec); break;
406 } 409 }
407 cursor = next_spec + 1; 410 cursor = next_spec + 1;
408 next_spec = strchr(cursor, '%'); 411 next_spec = strchr (cursor, '%');
409 goto parse_format; 412 goto parse_format;
410 } 413 }
411 414
@@ -439,10 +442,10 @@ clean_task (void *const cls)
439 GNUNET_DISK_PERM_USER_READ 442 GNUNET_DISK_PERM_USER_READ
440 | GNUNET_DISK_PERM_USER_WRITE)) 443 | GNUNET_DISK_PERM_USER_WRITE))
441 { 444 {
442 GNUNET_SEARCH_log(GNUNET_ERROR_TYPE_ERROR, 445 GNUNET_SEARCH_log (GNUNET_ERROR_TYPE_ERROR,
443 _ ("Failed to write directory with search results to " 446 _ ("Failed to write directory with search results to "
444 "`%s'\n"), 447 "`%s'\n"),
445 output_filename); 448 output_filename);
446 } 449 }
447 GNUNET_free (ddata); 450 GNUNET_free (ddata);
448 GNUNET_free (output_filename); 451 GNUNET_free (output_filename);
@@ -490,7 +493,7 @@ progress_cb (void *const cls,
490 break; 493 break;
491 494
492 cnt++; 495 cnt++;
493 filename = GNUNET_CONTAINER_meta_data_get_by_type ( 496 filename = GNUNET_FS_meta_data_get_by_type (
494 info->value.search.specifics.result.meta, 497 info->value.search.specifics.result.meta,
495 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 498 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
496 is_directory = GNUNET_FS_meta_data_test_for_directory ( 499 is_directory = GNUNET_FS_meta_data_test_for_directory (
@@ -501,12 +504,12 @@ progress_cb (void *const cls,
501 filename[strlen (filename) - 1] = '\0'; 504 filename[strlen (filename) - 1] = '\0';
502 GNUNET_DISK_filename_canonicalize (filename); 505 GNUNET_DISK_filename_canonicalize (filename);
503 } 506 }
504 print_search_result ( filename ? 507 print_search_result (filename ?
505 filename 508 filename
506 : is_directory ? 509 : is_directory ?
507 GENERIC_DIRECTORY_NAME 510 GENERIC_DIRECTORY_NAME
508 : 511 :
509 GENERIC_FILE_NAME, 512 GENERIC_FILE_NAME,
510 info->value.search.specifics.result.uri, 513 info->value.search.specifics.result.uri,
511 info->value.search.specifics.result.meta, 514 info->value.search.specifics.result.meta,
512 cnt, 515 cnt,
@@ -528,9 +531,9 @@ progress_cb (void *const cls,
528 break; 531 break;
529 532
530 case GNUNET_FS_STATUS_SEARCH_ERROR: 533 case GNUNET_FS_STATUS_SEARCH_ERROR:
531 GNUNET_SEARCH_log(GNUNET_ERROR_TYPE_ERROR, 534 GNUNET_SEARCH_log (GNUNET_ERROR_TYPE_ERROR,
532 _ ("Error searching: %s.\n"), 535 _ ("Error searching: %s.\n"),
533 info->value.search.specifics.error.message); 536 info->value.search.specifics.error.message);
534 GNUNET_SCHEDULER_shutdown (); 537 GNUNET_SCHEDULER_shutdown ();
535 break; 538 break;
536 539
@@ -539,9 +542,9 @@ progress_cb (void *const cls,
539 break; 542 break;
540 543
541 default: 544 default:
542 GNUNET_SEARCH_log(GNUNET_ERROR_TYPE_ERROR, 545 GNUNET_SEARCH_log (GNUNET_ERROR_TYPE_ERROR,
543 _ ("Unexpected status: %d\n"), 546 _ ("Unexpected status: %d\n"),
544 info->status); 547 info->status);
545 break; 548 break;
546 } 549 }
547 return NULL; 550 return NULL;
@@ -600,7 +603,7 @@ run (void *const cls,
600 ret = 1; 603 ret = 1;
601 return; 604 return;
602 } 605 }
603 if (silent_mode && !output_filename) 606 if (silent_mode && ! output_filename)
604 { 607 {
605 fprintf (stderr, _ ("An output file is mandatory for silent mode.\n")); 608 fprintf (stderr, _ ("An output file is mandatory for silent mode.\n"));
606 ret = 1; 609 ret = 1;
@@ -627,7 +630,7 @@ run (void *const cls,
627 ret = 1; 630 ret = 1;
628 return; 631 return;
629 } 632 }
630 if (!GNUNET_FS_uri_test_ksk (uri) && !GNUNET_FS_uri_test_sks (uri)) 633 if (! GNUNET_FS_uri_test_ksk (uri) && ! GNUNET_FS_uri_test_sks (uri))
631 { 634 {
632 fprintf (stderr, 635 fprintf (stderr,
633 "%s", 636 "%s",
@@ -640,7 +643,7 @@ run (void *const cls,
640 } 643 }
641 if (bookmark_only) 644 if (bookmark_only)
642 { 645 {
643 char * bmstr = GNUNET_FS_uri_to_string (uri); 646 char *bmstr = GNUNET_FS_uri_to_string (uri);
644 printf ("%s\n", bmstr); 647 printf ("%s\n", bmstr);
645 GNUNET_free (bmstr); 648 GNUNET_free (bmstr);
646 GNUNET_FS_uri_destroy (uri); 649 GNUNET_FS_uri_destroy (uri);
@@ -779,15 +782,15 @@ main (int argc, char *const *argv)
779 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 782 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
780 return 12; 783 return 12;
781 784
782 if (GNUNET_SYSERR == 785 if (GNUNET_SYSERR ==
783 GNUNET_PROGRAM_run (argc, 786 GNUNET_PROGRAM_run (argc,
784 argv, 787 argv,
785 "gnunet-search [OPTIONS] KEYWORD1 KEYWORD2 ...", 788 "gnunet-search [OPTIONS] KEYWORD1 KEYWORD2 ...",
786 gettext_noop ("Search for files that have been " 789 gettext_noop ("Search for files that have been "
787 "published on GNUnet\n"), 790 "published on GNUnet\n"),
788 options, 791 options,
789 &run, 792 &run,
790 NULL)) 793 NULL))
791 ret = 1; 794 ret = 1;
792 795
793 GNUNET_free_nz ((void *) argv); 796 GNUNET_free_nz ((void *) argv);
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index afc547127..80cd95c19 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -26,6 +26,7 @@
26 * @author Igor Wronsky 26 * @author Igor Wronsky
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_extractor_compat.h"
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30 31
31static int ret; 32static int ret;
diff --git a/src/fs/meta_data.c b/src/fs/meta_data.c
new file mode 100644
index 000000000..f676ce57c
--- /dev/null
+++ b/src/fs/meta_data.c
@@ -0,0 +1,1224 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file fs/meta_data.c
23 * @brief Storing of meta data
24 * @author Christian Grothoff
25 * @author Martin Schanzenbach
26 */
27
28
29#include "platform.h"
30#include "gnunet_util_lib.h"
31#include "gnunet_extractor_compat.h"
32#include "gnunet_fs_service.h"
33
34/**
35 * Maximum size allowed for meta data written/read from disk.
36 * File-sharing limits to 64k, so this should be rather generous.
37 */
38#define MAX_META_DATA (1024 * 1024)
39
40
41#define LOG(kind, ...) GNUNET_log_from (kind, "fs-meta-data", \
42 __VA_ARGS__)
43
44
45
46/**
47 * Meta data item.
48 */
49struct MetaItem
50{
51 /**
52 * This is a doubly linked list.
53 */
54 struct MetaItem *next;
55
56 /**
57 * This is a doubly linked list.
58 */
59 struct MetaItem *prev;
60
61 /**
62 * Name of the extracting plugin.
63 */
64 char *plugin_name;
65
66 /**
67 * Mime-type of data.
68 */
69 char *mime_type;
70
71 /**
72 * The actual meta data.
73 */
74 char *data;
75
76 /**
77 * Number of bytes in 'data'.
78 */
79 size_t data_size;
80
81 /**
82 * Type of the meta data.
83 */
84 enum EXTRACTOR_MetaType type;
85
86 /**
87 * Format of the meta data.
88 */
89 enum EXTRACTOR_MetaFormat format;
90};
91
92/**
93 * Meta data to associate with a file, directory or namespace.
94 */
95struct GNUNET_FS_MetaData
96{
97 /**
98 * Head of linked list of the meta data items.
99 */
100 struct MetaItem *items_head;
101
102 /**
103 * Tail of linked list of the meta data items.
104 */
105 struct MetaItem *items_tail;
106
107 /**
108 * Complete serialized and compressed buffer of the items.
109 * NULL if we have not computed that buffer yet.
110 */
111 char *sbuf;
112
113 /**
114 * Number of bytes in 'sbuf'. 0 if the buffer is stale.
115 */
116 size_t sbuf_size;
117
118 /**
119 * Number of items in the linked list.
120 */
121 unsigned int item_count;
122};
123
124
125/**
126 * Create a fresh struct FS_MetaData token.
127 *
128 * @return empty meta-data container
129 */
130struct GNUNET_FS_MetaData *
131GNUNET_FS_meta_data_create ()
132{
133 return GNUNET_new (struct GNUNET_FS_MetaData);
134}
135
136
137/**
138 * Free meta data item.
139 *
140 * @param mi item to free
141 */
142static void
143meta_item_free (struct MetaItem *mi)
144{
145 GNUNET_free (mi->plugin_name);
146 GNUNET_free (mi->mime_type);
147 GNUNET_free (mi->data);
148 GNUNET_free (mi);
149}
150
151
152/**
153 * The meta data has changed, invalidate its serialization
154 * buffer.
155 *
156 * @param md meta data that changed
157 */
158static void
159invalidate_sbuf (struct GNUNET_FS_MetaData *md)
160{
161 if (NULL == md->sbuf)
162 return;
163 GNUNET_free (md->sbuf);
164 md->sbuf = NULL;
165 md->sbuf_size = 0;
166}
167
168
169void
170GNUNET_FS_meta_data_destroy (struct GNUNET_FS_MetaData *md)
171{
172 struct MetaItem *pos;
173
174 if (NULL == md)
175 return;
176 while (NULL != (pos = md->items_head))
177 {
178 GNUNET_CONTAINER_DLL_remove (md->items_head, md->items_tail, pos);
179 meta_item_free (pos);
180 }
181 GNUNET_free (md->sbuf);
182 GNUNET_free (md);
183}
184
185
186void
187GNUNET_FS_meta_data_clear (struct GNUNET_FS_MetaData *md)
188{
189 struct MetaItem *mi;
190
191 if (NULL == md)
192 return;
193 while (NULL != (mi = md->items_head))
194 {
195 GNUNET_CONTAINER_DLL_remove (md->items_head, md->items_tail, mi);
196 meta_item_free (mi);
197 }
198 GNUNET_free (md->sbuf);
199 memset (md, 0, sizeof(struct GNUNET_FS_MetaData));
200}
201
202
203int
204GNUNET_FS_meta_data_test_equal (const struct GNUNET_FS_MetaData
205 *md1,
206 const struct GNUNET_FS_MetaData
207 *md2)
208{
209 struct MetaItem *i;
210 struct MetaItem *j;
211 int found;
212
213 if (md1 == md2)
214 return GNUNET_YES;
215 if (md1->item_count != md2->item_count)
216 return GNUNET_NO;
217 for (i = md1->items_head; NULL != i; i = i->next)
218 {
219 found = GNUNET_NO;
220 for (j = md2->items_head; NULL != j; j = j->next)
221 {
222 if ((i->type == j->type) && (i->format == j->format) &&
223 (i->data_size == j->data_size) &&
224 (0 == memcmp (i->data, j->data, i->data_size)))
225 {
226 found = GNUNET_YES;
227 break;
228 }
229 if (j->data_size < i->data_size)
230 break; /* elements are sorted by (decreasing) size... */
231 }
232 if (GNUNET_NO == found)
233 return GNUNET_NO;
234 }
235 return GNUNET_YES;
236}
237
238
239/**
240 * Extend metadata. Note that the list of meta data items is
241 * sorted by size (largest first).
242 *
243 * @param md metadata to extend
244 * @param plugin_name name of the plugin that produced this value;
245 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
246 * used in the main libextractor library and yielding
247 * meta data).
248 * @param type libextractor-type describing the meta data
249 * @param format basic format information about data
250 * @param data_mime_type mime-type of data (not of the original file);
251 * can be NULL (if mime-type is not known)
252 * @param data actual meta-data found
253 * @param data_size number of bytes in @a data
254 * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exists
255 * data_mime_type and plugin_name are not considered for "exists" checks
256 */
257int
258GNUNET_FS_meta_data_insert (struct GNUNET_FS_MetaData *md,
259 const char *plugin_name,
260 enum EXTRACTOR_MetaType type,
261 enum EXTRACTOR_MetaFormat format,
262 const char *data_mime_type, const char *data,
263 size_t data_size)
264{
265 struct MetaItem *pos;
266 struct MetaItem *mi;
267 char *p;
268
269 if ((EXTRACTOR_METAFORMAT_UTF8 == format) ||
270 (EXTRACTOR_METAFORMAT_C_STRING == format))
271 GNUNET_break ('\0' == data[data_size - 1]);
272
273 for (pos = md->items_head; NULL != pos; pos = pos->next)
274 {
275 if (pos->data_size < data_size)
276 break; /* elements are sorted by size in the list */
277 if ((pos->type == type) && (pos->data_size == data_size) &&
278 (0 == memcmp (pos->data, data, data_size)))
279 {
280 if ((NULL == pos->mime_type) && (NULL != data_mime_type))
281 {
282 pos->mime_type = GNUNET_strdup (data_mime_type);
283 invalidate_sbuf (md);
284 }
285 if ((EXTRACTOR_METAFORMAT_C_STRING == pos->format) &&
286 (EXTRACTOR_METAFORMAT_UTF8 == format))
287 {
288 pos->format = EXTRACTOR_METAFORMAT_UTF8;
289 invalidate_sbuf (md);
290 }
291 return GNUNET_SYSERR;
292 }
293 }
294 md->item_count++;
295 mi = GNUNET_new (struct MetaItem);
296 mi->type = type;
297 mi->format = format;
298 mi->data_size = data_size;
299 if (NULL == pos)
300 GNUNET_CONTAINER_DLL_insert_tail (md->items_head,
301 md->items_tail,
302 mi);
303 else
304 GNUNET_CONTAINER_DLL_insert_after (md->items_head,
305 md->items_tail,
306 pos->prev,
307 mi);
308 mi->mime_type =
309 (NULL == data_mime_type) ? NULL : GNUNET_strdup (data_mime_type);
310 mi->plugin_name = (NULL == plugin_name) ? NULL : GNUNET_strdup (plugin_name);
311 mi->data = GNUNET_malloc (data_size);
312 GNUNET_memcpy (mi->data, data, data_size);
313 /* change all dir separators to POSIX style ('/') */
314 if ((EXTRACTOR_METATYPE_FILENAME == type) ||
315 (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type))
316 {
317 p = mi->data;
318 while (('\0' != *p) && (p < mi->data + data_size))
319 {
320 if ('\\' == *p)
321 *p = '/';
322 p++;
323 }
324 }
325 invalidate_sbuf (md);
326 return GNUNET_OK;
327}
328
329
330/**
331 * Merge given meta data.
332 *
333 * @param cls the `struct GNUNET_FS_MetaData` to merge into
334 * @param plugin_name name of the plugin that produced this value;
335 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
336 * used in the main libextractor library and yielding
337 * meta data).
338 * @param type libextractor-type describing the meta data
339 * @param format basic format information about data
340 * @param data_mime_type mime-type of data (not of the original file);
341 * can be NULL (if mime-type is not known)
342 * @param data actual meta-data found
343 * @param data_size number of bytes in @a data
344 * @return 0 (to continue)
345 */
346static int
347merge_helper (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
348 enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
349 const char *data, size_t data_size)
350{
351 struct GNUNET_FS_MetaData *md = cls;
352
353 (void) GNUNET_FS_meta_data_insert (md, plugin_name, type, format,
354 data_mime_type, data, data_size);
355 return 0;
356}
357
358
359void
360GNUNET_FS_meta_data_merge (struct GNUNET_FS_MetaData *md,
361 const struct GNUNET_FS_MetaData *in)
362{
363 GNUNET_FS_meta_data_iterate (in, &merge_helper, md);
364}
365
366
367int
368GNUNET_FS_meta_data_delete (struct GNUNET_FS_MetaData *md,
369 enum EXTRACTOR_MetaType type,
370 const char *data, size_t data_size)
371{
372 struct MetaItem *pos;
373
374 for (pos = md->items_head; NULL != pos; pos = pos->next)
375 {
376 if (pos->data_size < data_size)
377 break; /* items are sorted by (decreasing) size */
378 if ((pos->type == type) &&
379 ((NULL == data) ||
380 ((pos->data_size == data_size) &&
381 (0 == memcmp (pos->data, data, data_size)))))
382 {
383 GNUNET_CONTAINER_DLL_remove (md->items_head, md->items_tail, pos);
384 meta_item_free (pos);
385 md->item_count--;
386 invalidate_sbuf (md);
387 return GNUNET_OK;
388 }
389 }
390 return GNUNET_SYSERR;
391}
392
393
394void
395GNUNET_FS_meta_data_add_publication_date (struct
396 GNUNET_FS_MetaData *md)
397{
398 const char *dat;
399 struct GNUNET_TIME_Absolute t;
400
401 t = GNUNET_TIME_absolute_get ();
402 GNUNET_FS_meta_data_delete (md,
403 EXTRACTOR_METATYPE_PUBLICATION_DATE,
404 NULL, 0);
405 dat = GNUNET_STRINGS_absolute_time_to_string (t);
406 GNUNET_FS_meta_data_insert (md, "<gnunet>",
407 EXTRACTOR_METATYPE_PUBLICATION_DATE,
408 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
409 dat, strlen (dat) + 1);
410}
411
412
413/**
414 * Iterate over MD entries.
415 *
416 * @param md metadata to inspect
417 * @param iter function to call on each entry
418 * @param iter_cls closure for iterator
419 * @return number of entries
420 */
421int
422GNUNET_FS_meta_data_iterate (const struct GNUNET_FS_MetaData *md,
423 EXTRACTOR_MetaDataProcessor iter,
424 void *iter_cls)
425{
426 struct MetaItem *pos;
427
428 if (NULL == md)
429 return 0;
430 if (NULL == iter)
431 return md->item_count;
432 for (pos = md->items_head; NULL != pos; pos = pos->next)
433 if (0 !=
434 iter (iter_cls, pos->plugin_name, pos->type, pos->format,
435 pos->mime_type, pos->data, pos->data_size))
436 return md->item_count;
437 return md->item_count;
438}
439
440
441char *
442GNUNET_FS_meta_data_get_by_type (const struct
443 GNUNET_FS_MetaData *md,
444 enum EXTRACTOR_MetaType type)
445{
446 struct MetaItem *pos;
447
448 if (NULL == md)
449 return NULL;
450 for (pos = md->items_head; NULL != pos; pos = pos->next)
451 if ((type == pos->type) &&
452 ((pos->format == EXTRACTOR_METAFORMAT_UTF8) ||
453 (pos->format == EXTRACTOR_METAFORMAT_C_STRING)))
454 return GNUNET_strdup (pos->data);
455 return NULL;
456}
457
458
459char *
460GNUNET_FS_meta_data_get_first_by_types (const struct
461 GNUNET_FS_MetaData *md,
462 ...)
463{
464 char *ret;
465 va_list args;
466 int type;
467
468 if (NULL == md)
469 return NULL;
470 ret = NULL;
471 va_start (args, md);
472 while (1)
473 {
474 type = va_arg (args, int);
475 if (-1 == type)
476 break;
477 if (NULL != (ret = GNUNET_FS_meta_data_get_by_type (md, type)))
478 break;
479 }
480 va_end (args);
481 return ret;
482}
483
484
485/**
486 * Get a thumbnail from the meta-data (if present).
487 *
488 * @param md metadata to get the thumbnail from
489 * @param thumb will be set to the thumbnail data. Must be
490 * freed by the caller!
491 * @return number of bytes in thumbnail, 0 if not available
492 */
493size_t
494GNUNET_FS_meta_data_get_thumbnail (const struct GNUNET_FS_MetaData
495 *md, unsigned char **thumb)
496{
497 struct MetaItem *pos;
498 struct MetaItem *match;
499
500 if (NULL == md)
501 return 0;
502 match = NULL;
503 for (pos = md->items_head; NULL != pos; pos = pos->next)
504 {
505 if ((NULL != pos->mime_type) &&
506 (0 == strncasecmp ("image/", pos->mime_type, strlen ("image/"))) &&
507 (EXTRACTOR_METAFORMAT_BINARY == pos->format))
508 {
509 if (NULL == match)
510 match = pos;
511 else if ((match->type != EXTRACTOR_METATYPE_THUMBNAIL) &&
512 (pos->type == EXTRACTOR_METATYPE_THUMBNAIL))
513 match = pos;
514 }
515 }
516 if ((NULL == match) || (0 == match->data_size))
517 return 0;
518 *thumb = GNUNET_malloc (match->data_size);
519 GNUNET_memcpy (*thumb, match->data, match->data_size);
520 return match->data_size;
521}
522
523
524/**
525 * Duplicate a `struct GNUNET_FS_MetaData`.
526 *
527 * @param md what to duplicate
528 * @return duplicate meta-data container
529 */
530struct GNUNET_FS_MetaData *
531GNUNET_FS_meta_data_duplicate (const struct GNUNET_FS_MetaData
532 *md)
533{
534 struct GNUNET_FS_MetaData *ret;
535 struct MetaItem *pos;
536
537 if (NULL == md)
538 return NULL;
539 ret = GNUNET_FS_meta_data_create ();
540 for (pos = md->items_tail; NULL != pos; pos = pos->prev)
541 GNUNET_FS_meta_data_insert (ret, pos->plugin_name, pos->type,
542 pos->format, pos->mime_type, pos->data,
543 pos->data_size);
544 return ret;
545}
546
547
548/**
549 * Flag in 'version' that indicates compressed meta-data.
550 */
551#define HEADER_COMPRESSED 0x80000000
552
553
554/**
555 * Bits in 'version' that give the version number.
556 */
557#define HEADER_VERSION_MASK 0x7FFFFFFF
558
559
560/**
561 * Header for serialized meta data.
562 */
563struct MetaDataHeader
564{
565 /**
566 * The version of the MD serialization. The highest bit is used to
567 * indicate compression.
568 *
569 * Version 0 is traditional (pre-0.9) meta data (unsupported)
570 * Version is 1 for a NULL pointer
571 * Version 2 is for 0.9.x (and possibly higher)
572 * Other version numbers are not yet defined.
573 */
574 uint32_t version;
575
576 /**
577 * How many MD entries are there?
578 */
579 uint32_t entries;
580
581 /**
582 * Size of the decompressed meta data.
583 */
584 uint32_t size;
585
586 /**
587 * This is followed by 'entries' values of type 'struct MetaDataEntry'
588 * and then by 'entry' plugin names, mime-types and data blocks
589 * as specified in those meta data entries.
590 */
591};
592
593
594/**
595 * Entry of serialized meta data.
596 */
597struct MetaDataEntry
598{
599 /**
600 * Meta data type. Corresponds to an 'enum EXTRACTOR_MetaType'
601 */
602 uint32_t type;
603
604 /**
605 * Meta data format. Corresponds to an 'enum EXTRACTOR_MetaFormat'
606 */
607 uint32_t format;
608
609 /**
610 * Number of bytes of meta data.
611 */
612 uint32_t data_size;
613
614 /**
615 * Number of bytes in the plugin name including 0-terminator. 0 for NULL.
616 */
617 uint32_t plugin_name_len;
618
619 /**
620 * Number of bytes in the mime type including 0-terminator. 0 for NULL.
621 */
622 uint32_t mime_type_len;
623};
624
625
626/**
627 * Serialize meta-data to target.
628 *
629 * @param md metadata to serialize
630 * @param target where to write the serialized metadata;
631 * *target can be NULL, in which case memory is allocated
632 * @param max maximum number of bytes available in target
633 * @param opt is it ok to just write SOME of the
634 * meta-data to match the size constraint,
635 * possibly discarding some data?
636 * @return number of bytes written on success,
637 * #GNUNET_SYSERR on error (typically: not enough
638 * space)
639 */
640ssize_t
641GNUNET_FS_meta_data_serialize (const struct GNUNET_FS_MetaData
642 *md, char **target, size_t max,
643 enum
644 GNUNET_FS_MetaDataSerializationOptions
645 opt)
646{
647 struct GNUNET_FS_MetaData *vmd;
648 struct MetaItem *pos;
649 struct MetaDataHeader ihdr;
650 struct MetaDataHeader *hdr;
651 struct MetaDataEntry *ent;
652 char *dst;
653 unsigned int i;
654 uint64_t msize;
655 size_t off;
656 char *mdata;
657 char *cdata;
658 size_t mlen;
659 size_t plen;
660 size_t size;
661 size_t left;
662 size_t clen;
663 size_t rlen;
664 int comp;
665
666 if (max < sizeof(struct MetaDataHeader))
667 return GNUNET_SYSERR; /* far too small */
668 if (NULL == md)
669 return 0;
670
671 if (NULL != md->sbuf)
672 {
673 /* try to use serialization cache */
674 if (md->sbuf_size <= max)
675 {
676 if (NULL == *target)
677 *target = GNUNET_malloc (md->sbuf_size);
678 GNUNET_memcpy (*target, md->sbuf, md->sbuf_size);
679 return md->sbuf_size;
680 }
681 if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_PART))
682 return GNUNET_SYSERR; /* can say that this will fail */
683 /* need to compute a partial serialization, sbuf useless ... */
684 }
685 dst = NULL;
686 msize = 0;
687 for (pos = md->items_tail; NULL != pos; pos = pos->prev)
688 {
689 msize += sizeof(struct MetaDataEntry);
690 msize += pos->data_size;
691 if (NULL != pos->plugin_name)
692 msize += strlen (pos->plugin_name) + 1;
693 if (NULL != pos->mime_type)
694 msize += strlen (pos->mime_type) + 1;
695 }
696 size = (size_t) msize;
697 if (size != msize)
698 {
699 GNUNET_break (0); /* integer overflow */
700 return GNUNET_SYSERR;
701 }
702 if (size >= GNUNET_MAX_MALLOC_CHECKED)
703 {
704 /* too large to be processed */
705 return GNUNET_SYSERR;
706 }
707 ent = GNUNET_malloc (size);
708 mdata = (char *) &ent[md->item_count];
709 off = size - (md->item_count * sizeof(struct MetaDataEntry));
710 i = 0;
711 for (pos = md->items_head; NULL != pos; pos = pos->next)
712 {
713 ent[i].type = htonl ((uint32_t) pos->type);
714 ent[i].format = htonl ((uint32_t) pos->format);
715 ent[i].data_size = htonl ((uint32_t) pos->data_size);
716 if (NULL == pos->plugin_name)
717 plen = 0;
718 else
719 plen = strlen (pos->plugin_name) + 1;
720 ent[i].plugin_name_len = htonl ((uint32_t) plen);
721 if (NULL == pos->mime_type)
722 mlen = 0;
723 else
724 mlen = strlen (pos->mime_type) + 1;
725 ent[i].mime_type_len = htonl ((uint32_t) mlen);
726 off -= pos->data_size;
727 if ((EXTRACTOR_METAFORMAT_UTF8 == pos->format) ||
728 (EXTRACTOR_METAFORMAT_C_STRING == pos->format))
729 GNUNET_break ('\0' == pos->data[pos->data_size - 1]);
730 GNUNET_memcpy (&mdata[off], pos->data, pos->data_size);
731 off -= plen;
732 if (NULL != pos->plugin_name)
733 GNUNET_memcpy (&mdata[off], pos->plugin_name, plen);
734 off -= mlen;
735 if (NULL != pos->mime_type)
736 GNUNET_memcpy (&mdata[off], pos->mime_type, mlen);
737 i++;
738 }
739 GNUNET_assert (0 == off);
740
741 clen = 0;
742 cdata = NULL;
743 left = size;
744 i = 0;
745 for (pos = md->items_head; NULL != pos; pos = pos->next)
746 {
747 comp = GNUNET_NO;
748 if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_NO_COMPRESS))
749 comp = GNUNET_try_compression ((const char *) &ent[i],
750 left,
751 &cdata,
752 &clen);
753
754 if ((NULL == md->sbuf) && (0 == i))
755 {
756 /* fill 'sbuf'; this "modifies" md, but since this is only
757 * an internal cache we will cast away the 'const' instead
758 * of making the API look strange. */
759 vmd = (struct GNUNET_FS_MetaData *) md;
760 hdr = GNUNET_malloc (left + sizeof(struct MetaDataHeader));
761 hdr->size = htonl (left);
762 hdr->entries = htonl (md->item_count);
763 if (GNUNET_YES == comp)
764 {
765 GNUNET_assert (clen < left);
766 hdr->version = htonl (2 | HEADER_COMPRESSED);
767 GNUNET_memcpy (&hdr[1], cdata, clen);
768 vmd->sbuf_size = clen + sizeof(struct MetaDataHeader);
769 }
770 else
771 {
772 hdr->version = htonl (2);
773 GNUNET_memcpy (&hdr[1], &ent[0], left);
774 vmd->sbuf_size = left + sizeof(struct MetaDataHeader);
775 }
776 vmd->sbuf = (char *) hdr;
777 }
778
779 if (((left + sizeof(struct MetaDataHeader)) <= max) ||
780 ((GNUNET_YES == comp) && (clen <= max)))
781 {
782 /* success, this now fits! */
783 if (GNUNET_YES == comp)
784 {
785 if (NULL == dst)
786 dst = GNUNET_malloc (clen + sizeof(struct MetaDataHeader));
787 hdr = (struct MetaDataHeader *) dst;
788 hdr->version = htonl (2 | HEADER_COMPRESSED);
789 hdr->size = htonl (left);
790 hdr->entries = htonl (md->item_count - i);
791 GNUNET_memcpy (&dst[sizeof(struct MetaDataHeader)], cdata, clen);
792 GNUNET_free (cdata);
793 cdata = NULL;
794 GNUNET_free (ent);
795 rlen = clen + sizeof(struct MetaDataHeader);
796 }
797 else
798 {
799 if (NULL == dst)
800 dst = GNUNET_malloc (left + sizeof(struct MetaDataHeader));
801 hdr = (struct MetaDataHeader *) dst;
802 hdr->version = htonl (2);
803 hdr->entries = htonl (md->item_count - i);
804 hdr->size = htonl (left);
805 GNUNET_memcpy (&dst[sizeof(struct MetaDataHeader)], &ent[i], left);
806 GNUNET_free (ent);
807 rlen = left + sizeof(struct MetaDataHeader);
808 }
809 if (NULL != *target)
810 {
811 if (GNUNET_YES == comp)
812 GNUNET_memcpy (*target, dst, clen + sizeof(struct MetaDataHeader));
813 else
814 GNUNET_memcpy (*target, dst, left + sizeof(struct MetaDataHeader));
815 GNUNET_free (dst);
816 }
817 else
818 {
819 *target = dst;
820 }
821 return rlen;
822 }
823
824 if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_PART))
825 {
826 /* does not fit! */
827 GNUNET_free (ent);
828 if (NULL != cdata)
829 GNUNET_free (cdata);
830 cdata = NULL;
831 return GNUNET_SYSERR;
832 }
833
834 /* next iteration: ignore the corresponding meta data at the
835 * end and try again without it */
836 left -= sizeof(struct MetaDataEntry);
837 left -= pos->data_size;
838 if (NULL != pos->plugin_name)
839 left -= strlen (pos->plugin_name) + 1;
840 if (NULL != pos->mime_type)
841 left -= strlen (pos->mime_type) + 1;
842
843 if (NULL != cdata)
844 GNUNET_free (cdata);
845 cdata = NULL;
846 i++;
847 }
848 GNUNET_free (ent);
849
850 /* nothing fit, only write header! */
851 ihdr.version = htonl (2);
852 ihdr.entries = htonl (0);
853 ihdr.size = htonl (0);
854 if (NULL == *target)
855 *target = (char *) GNUNET_new (struct MetaDataHeader);
856 GNUNET_memcpy (*target, &ihdr, sizeof(struct MetaDataHeader));
857 return sizeof(struct MetaDataHeader);
858}
859
860
861ssize_t
862GNUNET_FS_meta_data_get_serialized_size (const struct
863 GNUNET_FS_MetaData *md)
864{
865 ssize_t ret;
866 char *ptr;
867
868 if (NULL != md->sbuf)
869 return md->sbuf_size;
870 ptr = NULL;
871 ret =
872 GNUNET_FS_meta_data_serialize (md, &ptr, GNUNET_MAX_MALLOC_CHECKED,
873 GNUNET_FS_META_DATA_SERIALIZE_FULL);
874 if (-1 != ret)
875 GNUNET_free (ptr);
876 return ret;
877}
878
879
880/**
881 * Deserialize meta-data. Initializes md.
882 *
883 * @param input buffer with the serialized metadata
884 * @param size number of bytes available in input
885 * @return MD on success, NULL on error (i.e.
886 * bad format)
887 */
888struct GNUNET_FS_MetaData *
889GNUNET_FS_meta_data_deserialize (const char *input, size_t size)
890{
891 struct GNUNET_FS_MetaData *md;
892 struct MetaDataHeader hdr;
893 struct MetaDataEntry ent;
894 uint32_t ic;
895 uint32_t i;
896 char *data;
897 const char *cdata;
898 uint32_t version;
899 uint32_t dataSize;
900 int compressed;
901 size_t left;
902 uint32_t mlen;
903 uint32_t plen;
904 uint32_t dlen;
905 const char *mdata;
906 const char *meta_data;
907 const char *plugin_name;
908 const char *mime_type;
909 enum EXTRACTOR_MetaFormat format;
910
911 if (size < sizeof(struct MetaDataHeader))
912 return NULL;
913 GNUNET_memcpy (&hdr, input, sizeof(struct MetaDataHeader));
914 version = ntohl (hdr.version) & HEADER_VERSION_MASK;
915 compressed = (ntohl (hdr.version) & HEADER_COMPRESSED) != 0;
916
917 if (1 == version)
918 return NULL; /* null pointer */
919 if (2 != version)
920 {
921 GNUNET_break_op (0); /* unsupported version */
922 return NULL;
923 }
924
925 ic = ntohl (hdr.entries);
926 dataSize = ntohl (hdr.size);
927 if (((sizeof(struct MetaDataEntry) * ic) > dataSize) ||
928 ((0 != ic) &&
929 (dataSize / ic < sizeof(struct MetaDataEntry))))
930 {
931 GNUNET_break_op (0);
932 return NULL;
933 }
934
935 if (compressed)
936 {
937 if (dataSize >= GNUNET_MAX_MALLOC_CHECKED)
938 {
939 /* make sure we don't blow our memory limit because of a mal-formed
940 * message... */
941 GNUNET_break_op (0);
942 return NULL;
943 }
944 data =
945 GNUNET_decompress ((const char *) &input[sizeof(struct MetaDataHeader)],
946 size - sizeof(struct MetaDataHeader),
947 dataSize);
948 if (NULL == data)
949 {
950 GNUNET_break_op (0);
951 return NULL;
952 }
953 cdata = data;
954 }
955 else
956 {
957 data = NULL;
958 cdata = (const char *) &input[sizeof(struct MetaDataHeader)];
959 if (dataSize != size - sizeof(struct MetaDataHeader))
960 {
961 GNUNET_break_op (0);
962 return NULL;
963 }
964 }
965
966 md = GNUNET_FS_meta_data_create ();
967 left = dataSize - ic * sizeof(struct MetaDataEntry);
968 mdata = &cdata[ic * sizeof(struct MetaDataEntry)];
969 for (i = 0; i < ic; i++)
970 {
971 GNUNET_memcpy (&ent, &cdata[i * sizeof(struct MetaDataEntry)],
972 sizeof(struct MetaDataEntry));
973 format = (enum EXTRACTOR_MetaFormat) ntohl (ent.format);
974 if ((EXTRACTOR_METAFORMAT_UTF8 != format) &&
975 (EXTRACTOR_METAFORMAT_C_STRING != format) &&
976 (EXTRACTOR_METAFORMAT_BINARY != format))
977 {
978 GNUNET_break_op (0);
979 break;
980 }
981 dlen = ntohl (ent.data_size);
982 plen = ntohl (ent.plugin_name_len);
983 mlen = ntohl (ent.mime_type_len);
984 if (dlen > left)
985 {
986 GNUNET_break_op (0);
987 break;
988 }
989 left -= dlen;
990 meta_data = &mdata[left];
991 if ((EXTRACTOR_METAFORMAT_UTF8 == format) ||
992 (EXTRACTOR_METAFORMAT_C_STRING == format))
993 {
994 if (0 == dlen)
995 {
996 GNUNET_break_op (0);
997 break;
998 }
999 if ('\0' != meta_data[dlen - 1])
1000 {
1001 GNUNET_break_op (0);
1002 break;
1003 }
1004 }
1005 if (plen > left)
1006 {
1007 GNUNET_break_op (0);
1008 break;
1009 }
1010 left -= plen;
1011 if ((plen > 0) && ('\0' != mdata[left + plen - 1]))
1012 {
1013 GNUNET_break_op (0);
1014 break;
1015 }
1016 if (0 == plen)
1017 plugin_name = NULL;
1018 else
1019 plugin_name = &mdata[left];
1020
1021 if (mlen > left)
1022 {
1023 GNUNET_break_op (0);
1024 break;
1025 }
1026 left -= mlen;
1027 if ((mlen > 0) && ('\0' != mdata[left + mlen - 1]))
1028 {
1029 GNUNET_break_op (0);
1030 break;
1031 }
1032 if (0 == mlen)
1033 mime_type = NULL;
1034 else
1035 mime_type = &mdata[left];
1036 GNUNET_FS_meta_data_insert (md, plugin_name,
1037 (enum EXTRACTOR_MetaType)
1038 ntohl (ent.type), format, mime_type,
1039 meta_data, dlen);
1040 }
1041 GNUNET_free (data);
1042 return md;
1043}
1044
1045/**
1046 * Read a metadata container.
1047 *
1048 * @param h handle to an open file
1049 * @param what describes what is being read (for error message creation)
1050 * @param result the buffer to store a pointer to the (allocated) metadata
1051 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
1052 */
1053int
1054GNUNET_FS_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
1055 const char *what,
1056 struct GNUNET_FS_MetaData **result)
1057{
1058 uint32_t size;
1059 char *buf;
1060 struct GNUNET_FS_MetaData *meta;
1061
1062 if (GNUNET_OK != GNUNET_BIO_read_int32 (h,
1063 _ ("metadata length"),
1064 (int32_t *) &size))
1065 return GNUNET_SYSERR;
1066 if (0 == size)
1067 {
1068 *result = NULL;
1069 return GNUNET_OK;
1070 }
1071 if (MAX_META_DATA < size)
1072 {
1073 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1074 _ ("Serialized metadata `%s' larger than allowed (%u > %u)"),
1075 what,
1076 size,
1077 MAX_META_DATA);
1078 return GNUNET_SYSERR;
1079 }
1080 buf = GNUNET_malloc (size);
1081 if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, size))
1082 {
1083 GNUNET_free (buf);
1084 return GNUNET_SYSERR;
1085 }
1086 meta = GNUNET_FS_meta_data_deserialize (buf, size);
1087 if (NULL == meta)
1088 {
1089 GNUNET_free (buf);
1090 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1091 _ ("Failed to deserialize metadata `%s'"), what);
1092 return GNUNET_SYSERR;
1093 }
1094 GNUNET_free (buf);
1095 *result = meta;
1096 return GNUNET_OK;
1097}
1098
1099/**
1100 * Write a metadata container.
1101 *
1102 * @param h the IO handle to write to
1103 * @param what what is being written (for error message creation)
1104 * @param m metadata to write
1105 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1106 */
1107enum GNUNET_GenericReturnValue
1108GNUNET_FS_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
1109 const char *what,
1110 const struct GNUNET_FS_MetaData *m)
1111{
1112 ssize_t size;
1113 char *buf;
1114
1115 if (m == NULL)
1116 return GNUNET_BIO_write_int32 (h, _ ("metadata length"), 0);
1117 buf = NULL;
1118 size = GNUNET_FS_meta_data_serialize (m,
1119 &buf,
1120 MAX_META_DATA,
1121 GNUNET_FS_META_DATA_SERIALIZE_PART);
1122 if (-1 == size)
1123 {
1124 GNUNET_free (buf);
1125 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1126 _ ("Failed to serialize metadata `%s'"),
1127 what);
1128 return GNUNET_SYSERR;
1129 }
1130 if ((GNUNET_OK != GNUNET_BIO_write_int32 (h,
1131 _ ("metadata length"),
1132 (uint32_t) size))
1133 || (GNUNET_OK != GNUNET_BIO_write (h, what, buf, size)))
1134 {
1135 GNUNET_free (buf);
1136 return GNUNET_SYSERR;
1137 }
1138 GNUNET_free (buf);
1139 return GNUNET_OK;
1140}
1141
1142/**
1143 * Function used internally to read a metadata container from within a read
1144 * spec.
1145 *
1146 * @param cls ignored, always NULL
1147 * @param h the IO handle to read from
1148 * @param what what is being read (for error message creation)
1149 * @param target where to store the data
1150 * @param target_size ignored
1151 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1152 */
1153static int
1154read_spec_handler_meta_data (void *cls,
1155 struct GNUNET_BIO_ReadHandle *h,
1156 const char *what,
1157 void *target,
1158 size_t target_size)
1159{
1160 struct GNUNET_FS_MetaData **result = target;
1161 return GNUNET_FS_read_meta_data (h, what, result);
1162}
1163
1164/**
1165 * Create the specification to read a metadata container.
1166 *
1167 * @param what describes what is being read (for error message creation)
1168 * @param result the buffer to store a pointer to the (allocated) metadata
1169 * @return the read spec
1170 */
1171struct GNUNET_BIO_ReadSpec
1172GNUNET_FS_read_spec_meta_data (const char *what,
1173 struct GNUNET_FS_MetaData **result)
1174{
1175 struct GNUNET_BIO_ReadSpec rs = {
1176 .rh = &read_spec_handler_meta_data,
1177 .cls = NULL,
1178 .target = result,
1179 .size = 0,
1180 };
1181
1182 return rs;
1183}
1184
1185/**
1186 * Function used internally to write a metadata container from within a write
1187 * spec.
1188 *
1189 * @param cls ignored, always NULL
1190 * @param h the IO handle to write to
1191 * @param what what is being written (for error message creation)
1192 * @param source the data to write
1193 * @param source_size ignored
1194 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
1195 */
1196static int
1197write_spec_handler_meta_data (void *cls,
1198 struct GNUNET_BIO_WriteHandle *h,
1199 const char *what,
1200 void *source,
1201 size_t source_size)
1202{
1203 const struct GNUNET_FS_MetaData *m = source;
1204 return GNUNET_FS_write_meta_data (h, what, m);
1205}
1206
1207
1208struct GNUNET_BIO_WriteSpec
1209GNUNET_FS_write_spec_meta_data (const char *what,
1210 const struct GNUNET_FS_MetaData *m)
1211{
1212 struct GNUNET_BIO_WriteSpec ws = {
1213 .wh = &write_spec_handler_meta_data,
1214 .cls = NULL,
1215 .what = what,
1216 .source = (void *) m,
1217 .source_size = 0,
1218 };
1219
1220 return ws;
1221}
1222
1223
1224/* end of meta_data.c */
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c
index 11677a6b2..a6cfb2e64 100644
--- a/src/fs/plugin_block_fs.c
+++ b/src/fs/plugin_block_fs.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_block_plugin.h" 27#include "gnunet_block_plugin.h"
28#include "gnunet_extractor_compat.h"
28#include "gnunet_fs_service.h" 29#include "gnunet_fs_service.h"
29#include "block_fs.h" 30#include "block_fs.h"
30#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
diff --git a/src/fs/test_fs_directory.c b/src/fs/test_fs_directory.c
index 908e7c555..f1f86fbf7 100644
--- a/src/fs/test_fs_directory.c
+++ b/src/fs/test_fs_directory.c
@@ -36,14 +36,14 @@
36struct PCLS 36struct PCLS
37{ 37{
38 struct GNUNET_FS_Uri **uri; 38 struct GNUNET_FS_Uri **uri;
39 struct GNUNET_CONTAINER_MetaData **md; 39 struct GNUNET_FS_MetaData **md;
40 unsigned int pos; 40 unsigned int pos;
41 unsigned int max; 41 unsigned int max;
42}; 42};
43 43
44static void 44static void
45processor (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, 45processor (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
46 const struct GNUNET_CONTAINER_MetaData *md, size_t length, 46 const struct GNUNET_FS_MetaData *md, size_t length,
47 const void *data) 47 const void *data)
48{ 48{
49 struct PCLS *p = cls; 49 struct PCLS *p = cls;
@@ -71,8 +71,8 @@ testDirectory (unsigned int i)
71 char *data; 71 char *data;
72 size_t dlen; 72 size_t dlen;
73 struct GNUNET_FS_Uri **uris; 73 struct GNUNET_FS_Uri **uris;
74 struct GNUNET_CONTAINER_MetaData **mds; 74 struct GNUNET_FS_MetaData **mds;
75 struct GNUNET_CONTAINER_MetaData *meta; 75 struct GNUNET_FS_MetaData *meta;
76 struct PCLS cls; 76 struct PCLS cls;
77 char *emsg; 77 char *emsg;
78 int p; 78 int p;
@@ -85,7 +85,7 @@ testDirectory (unsigned int i)
85 85
86 cls.max = i; 86 cls.max = i;
87 uris = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri *) * i); 87 uris = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri *) * i);
88 mds = GNUNET_malloc (sizeof(struct GNUNET_CONTAINER_MetaData *) * i); 88 mds = GNUNET_malloc (sizeof(struct GNUNET_FS_MetaData *) * i);
89 meta = GNUNET_CONTAINER_meta_data_create (); 89 meta = GNUNET_CONTAINER_meta_data_create ();
90 GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE, 90 GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE,
91 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 91 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c
index 2fe0da77c..e8011f1e4 100644
--- a/src/fs/test_fs_download.c
+++ b/src/fs/test_fs_download.c
@@ -267,7 +267,7 @@ run (void *cls,
267 "down_bar", 267 "down_bar",
268 }; 268 };
269 char *buf; 269 char *buf;
270 struct GNUNET_CONTAINER_MetaData *meta; 270 struct GNUNET_FS_MetaData *meta;
271 struct GNUNET_FS_Uri *kuri; 271 struct GNUNET_FS_Uri *kuri;
272 struct GNUNET_FS_FileInformation *fi; 272 struct GNUNET_FS_FileInformation *fi;
273 size_t i; 273 size_t i;
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c
index 35d4ed441..c77d9277e 100644
--- a/src/fs/test_fs_download_persistence.c
+++ b/src/fs/test_fs_download_persistence.c
@@ -302,7 +302,7 @@ run (void *cls,
302 "down_bar", 302 "down_bar",
303 }; 303 };
304 char *buf; 304 char *buf;
305 struct GNUNET_CONTAINER_MetaData *meta; 305 struct GNUNET_FS_MetaData *meta;
306 struct GNUNET_FS_Uri *kuri; 306 struct GNUNET_FS_Uri *kuri;
307 struct GNUNET_FS_FileInformation *fi; 307 struct GNUNET_FS_FileInformation *fi;
308 size_t i; 308 size_t i;
diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c
index 22013db27..fb9ddaa3d 100644
--- a/src/fs/test_fs_file_information.c
+++ b/src/fs/test_fs_file_information.c
@@ -49,7 +49,7 @@
49 49
50static int 50static int
51mycleaner (void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, 51mycleaner (void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length,
52 struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, 52 struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri,
53 struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) 53 struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
54{ 54{
55 return GNUNET_OK; 55 return GNUNET_OK;
@@ -67,7 +67,7 @@ run (void *cls, char *const *args, const char *cfgfile,
67 char *fn1; 67 char *fn1;
68 char *fn2; 68 char *fn2;
69 char *buf; 69 char *buf;
70 struct GNUNET_CONTAINER_MetaData *meta; 70 struct GNUNET_FS_MetaData *meta;
71 struct GNUNET_FS_Uri *kuri; 71 struct GNUNET_FS_Uri *kuri;
72 struct GNUNET_FS_FileInformation *fi1; 72 struct GNUNET_FS_FileInformation *fi1;
73 struct GNUNET_FS_FileInformation *fi2; 73 struct GNUNET_FS_FileInformation *fi2;
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c
index 2f04a017a..2f0c32756 100644
--- a/src/fs/test_fs_list_indexed.c
+++ b/src/fs/test_fs_list_indexed.c
@@ -183,7 +183,7 @@ run (void *cls,
183 "down_bar", 183 "down_bar",
184 }; 184 };
185 char *buf; 185 char *buf;
186 struct GNUNET_CONTAINER_MetaData *meta; 186 struct GNUNET_FS_MetaData *meta;
187 struct GNUNET_FS_Uri *kuri; 187 struct GNUNET_FS_Uri *kuri;
188 struct GNUNET_FS_FileInformation *fi1; 188 struct GNUNET_FS_FileInformation *fi1;
189 struct GNUNET_FS_FileInformation *fi2; 189 struct GNUNET_FS_FileInformation *fi2;
diff --git a/src/fs/test_fs_meta_data.c b/src/fs/test_fs_meta_data.c
new file mode 100644
index 000000000..50f902cb5
--- /dev/null
+++ b/src/fs/test_fs_meta_data.c
@@ -0,0 +1,379 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2003, 2004, 2006, 2009, 2010, 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file util/test_fs_meta_data.c
23 * @brief Test for fs_meta_data.c
24 * @author Christian Grothoff
25 * @author Martin Schanzenbach
26 */
27
28
29#include "platform.h"
30#include "gnunet_util_lib.h"
31#include "gnunet_extractor_compat.h"
32#include "gnunet_fs_service.h"
33
34#define ABORT(m) { fprintf (stderr, "Error at %s:%d\n", __FILE__, __LINE__); \
35 if (m != NULL) GNUNET_FS_meta_data_destroy (m); \
36 return 1; }
37
38
39static int
40testMeta (int i)
41{
42 struct GNUNET_FS_MetaData *m;
43 char val[256];
44 char *sval;
45 int j;
46 unsigned int size;
47
48 m = GNUNET_FS_meta_data_create ();
49 if (GNUNET_OK !=
50 GNUNET_FS_meta_data_insert (m, "<test>", EXTRACTOR_METATYPE_TITLE,
51 EXTRACTOR_METAFORMAT_UTF8,
52 "text/plain", "TestTitle",
53 strlen ("TestTitle") + 1))
54 ABORT (m);
55 if (GNUNET_OK !=
56 GNUNET_FS_meta_data_insert (m, "<test>",
57 EXTRACTOR_METATYPE_AUTHOR_NAME,
58 EXTRACTOR_METAFORMAT_UTF8,
59 "text/plain", "TestTitle",
60 strlen ("TestTitle") + 1))
61 ABORT (m);
62 if (GNUNET_OK == GNUNET_FS_meta_data_insert (m, "<test>",
63 EXTRACTOR_METATYPE_TITLE,
64 EXTRACTOR_METAFORMAT_UTF8,
65 "text/plain",
66 "TestTitle", strlen (
67 "TestTitle") + 1)) /* dup! */
68 ABORT (m);
69 if (GNUNET_OK == GNUNET_FS_meta_data_insert (m, "<test>",
70 EXTRACTOR_METATYPE_AUTHOR_NAME,
71 EXTRACTOR_METAFORMAT_UTF8,
72 "text/plain",
73 "TestTitle", strlen (
74 "TestTitle") + 1)) /* dup! */
75 ABORT (m);
76 if (2 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
77 ABORT (m);
78 if (GNUNET_OK !=
79 GNUNET_FS_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME,
80 "TestTitle", strlen ("TestTitle") + 1))
81 ABORT (m);
82 if (GNUNET_OK == GNUNET_FS_meta_data_delete (m,
83 EXTRACTOR_METATYPE_AUTHOR_NAME,
84 "TestTitle", strlen (
85 "TestTitle") + 1)) /* already gone */
86 ABORT (m);
87 if (1 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
88 ABORT (m);
89 if (GNUNET_OK !=
90 GNUNET_FS_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE,
91 "TestTitle", strlen ("TestTitle") + 1))
92 ABORT (m);
93 if (GNUNET_OK == GNUNET_FS_meta_data_delete (m,
94 EXTRACTOR_METATYPE_TITLE,
95 "TestTitle", strlen (
96 "TestTitle") + 1)) /* already gone */
97 ABORT (m);
98 if (0 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
99 ABORT (m);
100 for (j = 0; j < i; j++)
101 {
102 GNUNET_snprintf (val, sizeof(val), "%s.%d",
103 "A teststring that should compress well.", j);
104 if (GNUNET_OK !=
105 GNUNET_FS_meta_data_insert (m, "<test>",
106 EXTRACTOR_METATYPE_UNKNOWN,
107 EXTRACTOR_METAFORMAT_UTF8,
108 "text/plain", val, strlen (val) + 1))
109 ABORT (m);
110 }
111 if (i != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
112 ABORT (m);
113
114 size = GNUNET_FS_meta_data_get_serialized_size (m);
115 sval = NULL;
116 if (size !=
117 GNUNET_FS_meta_data_serialize (m, &sval, size,
118 GNUNET_FS_META_DATA_SERIALIZE_FULL))
119 {
120 GNUNET_free (sval);
121 ABORT (m);
122 }
123 GNUNET_FS_meta_data_destroy (m);
124 m = GNUNET_FS_meta_data_deserialize (sval, size);
125 GNUNET_free (sval);
126 if (m == NULL)
127 ABORT (m);
128 for (j = 0; j < i; j++)
129 {
130 GNUNET_snprintf (val,
131 sizeof(val),
132 "%s.%d",
133 "A teststring that should compress well.",
134 j);
135 if (GNUNET_OK !=
136 GNUNET_FS_meta_data_delete (m,
137 EXTRACTOR_METATYPE_UNKNOWN,
138 val,
139 strlen (val) + 1))
140 {
141 ABORT (m);
142 }
143 }
144 if (0 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
145 ABORT (m);
146 GNUNET_FS_meta_data_destroy (m);
147 return 0;
148}
149
150
151static int
152testMetaMore (int i)
153{
154 struct GNUNET_FS_MetaData *meta;
155 int q;
156 char txt[128];
157 char *data;
158 unsigned long long size;
159
160 meta = GNUNET_FS_meta_data_create ();
161 for (q = 0; q <= i; q++)
162 {
163 GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
164 GNUNET_FS_meta_data_insert (meta, "<test>",
165 q
166 % 42 /* EXTRACTOR_metatype_get_max () */,
167 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
168 txt, strlen (txt) + 1);
169 }
170 size = GNUNET_FS_meta_data_get_serialized_size (meta);
171 data = GNUNET_malloc (size * 4);
172 if (size !=
173 GNUNET_FS_meta_data_serialize (meta, &data, size * 4,
174 GNUNET_FS_META_DATA_SERIALIZE_FULL))
175 {
176 GNUNET_free (data);
177 ABORT (meta);
178 }
179 GNUNET_FS_meta_data_destroy (meta);
180 GNUNET_free (data);
181 return 0;
182}
183
184
185static int
186testMetaLink ()
187{
188 struct GNUNET_FS_MetaData *m;
189 char *val;
190 unsigned int size;
191
192 m = GNUNET_FS_meta_data_create ();
193 if (GNUNET_OK !=
194 GNUNET_FS_meta_data_insert (m, "<test>",
195 EXTRACTOR_METATYPE_UNKNOWN,
196 EXTRACTOR_METAFORMAT_UTF8,
197 "text/plain", "link",
198 strlen ("link") + 1))
199 ABORT (m);
200 if (GNUNET_OK !=
201 GNUNET_FS_meta_data_insert (m, "<test>",
202 EXTRACTOR_METATYPE_FILENAME,
203 EXTRACTOR_METAFORMAT_UTF8,
204 "text/plain", "lib-link.m4",
205 strlen ("lib-link.m4") + 1))
206 ABORT (m);
207 val = NULL;
208 size =
209 GNUNET_FS_meta_data_serialize (m, &val, (size_t) -1,
210 GNUNET_FS_META_DATA_SERIALIZE_FULL);
211 GNUNET_FS_meta_data_destroy (m);
212 m = GNUNET_FS_meta_data_deserialize (val, size);
213 GNUNET_free (val);
214 if (m == NULL)
215 ABORT (m);
216 GNUNET_FS_meta_data_destroy (m);
217 return 0;
218}
219
220
221static int
222check ()
223{
224 struct GNUNET_FS_MetaData *meta;
225 struct GNUNET_FS_MetaData *meta2;
226 int q;
227 int i = 100;
228 char txt[128];
229 char *str;
230 unsigned char *thumb;
231
232 meta = GNUNET_FS_meta_data_create ();
233 meta2 = GNUNET_FS_meta_data_create ();
234 for (q = 0; q <= i; q++)
235 {
236 GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
237 GNUNET_FS_meta_data_insert (meta, "<test>",
238 EXTRACTOR_METATYPE_UNKNOWN,
239 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
240 "TestTitle", strlen ("TestTitle") + 1);
241 GNUNET_FS_meta_data_insert (meta2, "<test>",
242 EXTRACTOR_METATYPE_UNKNOWN,
243 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
244 "TestTitle", strlen ("TestTitle") + 1);
245 }
246
247 // check meta_data_test_equal
248 if (GNUNET_YES != GNUNET_FS_meta_data_test_equal (meta, meta2))
249 {
250 GNUNET_FS_meta_data_destroy (meta2);
251 ABORT (meta);
252 }
253
254 // check meta_data_clear
255 GNUNET_FS_meta_data_clear (meta2);
256 if (0 != GNUNET_FS_meta_data_iterate (meta2, NULL, NULL))
257 {
258 GNUNET_FS_meta_data_destroy (meta2);
259 ABORT (meta);
260 }
261 // check equal branch in meta_data_test_equal
262 if (GNUNET_YES != GNUNET_FS_meta_data_test_equal (meta, meta))
263 {
264 GNUNET_FS_meta_data_destroy (meta2);
265 ABORT (meta);
266 }
267 // check "count" branch in meta_data_test_equal
268 if (GNUNET_NO != GNUNET_FS_meta_data_test_equal (meta, meta2))
269 {
270 GNUNET_FS_meta_data_destroy (meta2);
271 ABORT (meta);
272 }
273
274 // check meta_data_add_publication_date
275 GNUNET_FS_meta_data_add_publication_date (meta2);
276
277 // check meta_data_merge
278 GNUNET_FS_meta_data_clear (meta2);
279 GNUNET_FS_meta_data_merge (meta2, meta);
280 if (100 == GNUNET_FS_meta_data_iterate (meta2, NULL, NULL))
281 {
282 GNUNET_FS_meta_data_destroy (meta2);
283 ABORT (meta);
284 }
285
286 // check meta_data_get_by_type
287 GNUNET_FS_meta_data_clear (meta2);
288 if (NULL !=
289 (str =
290 GNUNET_FS_meta_data_get_by_type (meta2,
291 EXTRACTOR_METATYPE_UNKNOWN)))
292 {
293 GNUNET_FS_meta_data_destroy (meta2);
294 GNUNET_free (str);
295 ABORT (meta);
296 }
297
298 str =
299 GNUNET_FS_meta_data_get_by_type (meta, EXTRACTOR_METATYPE_UNKNOWN);
300 GNUNET_assert (NULL != str);
301 if (str[0] != 'T')
302 {
303 GNUNET_FS_meta_data_destroy (meta2);
304 GNUNET_free (str);
305 ABORT (meta);
306 }
307 GNUNET_free (str);
308
309 // check branch
310 if (NULL !=
311 (str =
312 GNUNET_FS_meta_data_get_by_type (meta,
313 EXTRACTOR_METATYPE_PUBLICATION_DATE)))
314 {
315 GNUNET_free (str);
316 GNUNET_FS_meta_data_destroy (meta2);
317 ABORT (meta);
318 }
319
320 // check meta_data_get_first_by_types
321 str =
322 GNUNET_FS_meta_data_get_first_by_types (meta,
323 EXTRACTOR_METATYPE_UNKNOWN,
324 -1);
325 GNUNET_assert (NULL != str);
326 if (str[0] != 'T')
327 {
328 GNUNET_FS_meta_data_destroy (meta2);
329 GNUNET_free (str);
330 ABORT (meta);
331 }
332 GNUNET_free (str);
333
334 // check meta_data_get_thumbnail
335 if (GNUNET_FS_meta_data_get_thumbnail (meta, &thumb) != 0)
336 {
337 GNUNET_free (thumb);
338 GNUNET_FS_meta_data_destroy (meta2);
339 ABORT (meta);
340 }
341 GNUNET_FS_meta_data_destroy (meta2);
342 // check meta_data_duplicate
343 meta2 = GNUNET_FS_meta_data_duplicate (meta);
344 if (200 == GNUNET_FS_meta_data_iterate (meta2, NULL, NULL))
345 {
346 GNUNET_FS_meta_data_destroy (meta2);
347 ABORT (meta);
348 }
349 GNUNET_FS_meta_data_destroy (meta2);
350 GNUNET_FS_meta_data_destroy (meta);
351 return 0;
352}
353
354
355int
356main (int argc, char *argv[])
357{
358 int failureCount = 0;
359 int i;
360
361 GNUNET_log_setup ("test-container-meta-data", "WARNING", NULL);
362 for (i = 0; i < 255; i++)
363 failureCount += testMeta (i);
364 for (i = 1; i < 255; i++)
365 failureCount += testMetaMore (i);
366 failureCount += testMetaLink ();
367
368 int ret = check ();
369
370 if (ret == 1)
371 return 1;
372
373 if (failureCount != 0)
374 return 1;
375 return 0;
376}
377
378
379/* end of test_container_meta_data.c */
diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c
index c1e10d575..3544b825e 100644
--- a/src/fs/test_fs_namespace.c
+++ b/src/fs/test_fs_namespace.c
@@ -206,7 +206,7 @@ publish_cont (void *cls, const struct GNUNET_FS_Uri *ksk_uri, const char *emsg)
206static void 206static void
207sks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) 207sks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
208{ 208{
209 struct GNUNET_CONTAINER_MetaData *meta; 209 struct GNUNET_FS_MetaData *meta;
210 struct GNUNET_FS_Uri *ksk_uri; 210 struct GNUNET_FS_Uri *ksk_uri;
211 char *msg; 211 char *msg;
212 struct GNUNET_FS_BlockOptions bo; 212 struct GNUNET_FS_BlockOptions bo;
@@ -238,7 +238,7 @@ sks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
238static void 238static void
239adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) 239adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
240{ 240{
241 struct GNUNET_CONTAINER_MetaData *meta; 241 struct GNUNET_FS_MetaData *meta;
242 struct GNUNET_CRYPTO_EcdsaPrivateKey ns; 242 struct GNUNET_CRYPTO_EcdsaPrivateKey ns;
243 struct GNUNET_FS_BlockOptions bo; 243 struct GNUNET_FS_BlockOptions bo;
244 244
@@ -270,7 +270,7 @@ static void
270testNamespace (void) 270testNamespace (void)
271{ 271{
272 struct GNUNET_FS_BlockOptions bo; 272 struct GNUNET_FS_BlockOptions bo;
273 struct GNUNET_CONTAINER_MetaData *meta; 273 struct GNUNET_FS_MetaData *meta;
274 struct GNUNET_FS_Uri *ksk_uri; 274 struct GNUNET_FS_Uri *ksk_uri;
275 struct GNUNET_FS_Uri *sks_uri; 275 struct GNUNET_FS_Uri *sks_uri;
276 276
diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c
index 2132220fb..54f6c9a66 100644
--- a/src/fs/test_fs_namespace_list_updateable.c
+++ b/src/fs/test_fs_namespace_list_updateable.c
@@ -35,7 +35,7 @@ static int err;
35 35
36static struct GNUNET_CRYPTO_EcdsaPrivateKey ns; 36static struct GNUNET_CRYPTO_EcdsaPrivateKey ns;
37 37
38static struct GNUNET_CONTAINER_MetaData *meta; 38static struct GNUNET_FS_MetaData *meta;
39 39
40static struct GNUNET_FS_Uri *uri_this; 40static struct GNUNET_FS_Uri *uri_this;
41 41
@@ -66,7 +66,7 @@ do_shutdown ()
66static void 66static void
67check_next (void *cls, const char *last_id, 67check_next (void *cls, const char *last_id,
68 const struct GNUNET_FS_Uri *last_uri, 68 const struct GNUNET_FS_Uri *last_uri,
69 const struct GNUNET_CONTAINER_MetaData *last_meta, 69 const struct GNUNET_FS_MetaData *last_meta,
70 const char *next_id) 70 const char *next_id)
71{ 71{
72 GNUNET_break (0 == strcmp (last_id, "next")); 72 GNUNET_break (0 == strcmp (last_id, "next"));
@@ -78,7 +78,7 @@ check_next (void *cls, const char *last_id,
78static void 78static void
79check_this_next (void *cls, const char *last_id, 79check_this_next (void *cls, const char *last_id,
80 const struct GNUNET_FS_Uri *last_uri, 80 const struct GNUNET_FS_Uri *last_uri,
81 const struct GNUNET_CONTAINER_MetaData *last_meta, 81 const struct GNUNET_FS_MetaData *last_meta,
82 const char *next_id) 82 const char *next_id)
83{ 83{
84 GNUNET_break (0 == strcmp (last_id, "this")); 84 GNUNET_break (0 == strcmp (last_id, "this"));
@@ -101,7 +101,7 @@ sks_cont_next (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
101static void 101static void
102check_this (void *cls, const char *last_id, 102check_this (void *cls, const char *last_id,
103 const struct GNUNET_FS_Uri *last_uri, 103 const struct GNUNET_FS_Uri *last_uri,
104 const struct GNUNET_CONTAINER_MetaData *last_meta, 104 const struct GNUNET_FS_MetaData *last_meta,
105 const char *next_id) 105 const char *next_id)
106{ 106{
107 GNUNET_break (0 == strcmp (last_id, "this")); 107 GNUNET_break (0 == strcmp (last_id, "this"));
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c
index 2ffc722da..687ada0f1 100644
--- a/src/fs/test_fs_publish.c
+++ b/src/fs/test_fs_publish.c
@@ -169,7 +169,7 @@ run (void *cls,
169 "down_bar", 169 "down_bar",
170 }; 170 };
171 char *buf; 171 char *buf;
172 struct GNUNET_CONTAINER_MetaData *meta; 172 struct GNUNET_FS_MetaData *meta;
173 struct GNUNET_FS_Uri *kuri; 173 struct GNUNET_FS_Uri *kuri;
174 struct GNUNET_FS_FileInformation *fi1; 174 struct GNUNET_FS_FileInformation *fi1;
175 struct GNUNET_FS_FileInformation *fi2; 175 struct GNUNET_FS_FileInformation *fi2;
diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c
index da0209793..d92006853 100644
--- a/src/fs/test_fs_publish_persistence.c
+++ b/src/fs/test_fs_publish_persistence.c
@@ -242,7 +242,7 @@ run (void *cls,
242 "down_bar", 242 "down_bar",
243 }; 243 };
244 char *buf; 244 char *buf;
245 struct GNUNET_CONTAINER_MetaData *meta; 245 struct GNUNET_FS_MetaData *meta;
246 struct GNUNET_FS_Uri *kuri; 246 struct GNUNET_FS_Uri *kuri;
247 struct GNUNET_FS_FileInformation *fi1; 247 struct GNUNET_FS_FileInformation *fi1;
248 struct GNUNET_FS_FileInformation *fi2; 248 struct GNUNET_FS_FileInformation *fi2;
diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c
index b392cc8ac..252ab3de3 100644
--- a/src/fs/test_fs_search.c
+++ b/src/fs/test_fs_search.c
@@ -204,7 +204,7 @@ run (void *cls,
204 "down_bar" 204 "down_bar"
205 }; 205 };
206 char *buf; 206 char *buf;
207 struct GNUNET_CONTAINER_MetaData *meta; 207 struct GNUNET_FS_MetaData *meta;
208 struct GNUNET_FS_Uri *kuri; 208 struct GNUNET_FS_Uri *kuri;
209 struct GNUNET_FS_BlockOptions bo; 209 struct GNUNET_FS_BlockOptions bo;
210 struct GNUNET_FS_FileInformation *fi; 210 struct GNUNET_FS_FileInformation *fi;
diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c
index d523a6404..cbd87c077 100644
--- a/src/fs/test_fs_search_persistence.c
+++ b/src/fs/test_fs_search_persistence.c
@@ -269,7 +269,7 @@ run (void *cls,
269 "down_bar" 269 "down_bar"
270 }; 270 };
271 char *buf; 271 char *buf;
272 struct GNUNET_CONTAINER_MetaData *meta; 272 struct GNUNET_FS_MetaData *meta;
273 struct GNUNET_FS_Uri *kuri; 273 struct GNUNET_FS_Uri *kuri;
274 struct GNUNET_FS_FileInformation *fi; 274 struct GNUNET_FS_FileInformation *fi;
275 size_t i; 275 size_t i;
diff --git a/src/fs/test_fs_search_probes.c b/src/fs/test_fs_search_probes.c
index b3c717aa1..510d18e9b 100644
--- a/src/fs/test_fs_search_probes.c
+++ b/src/fs/test_fs_search_probes.c
@@ -209,7 +209,7 @@ run (void *cls,
209 "down_bar" 209 "down_bar"
210 }; 210 };
211 char *buf; 211 char *buf;
212 struct GNUNET_CONTAINER_MetaData *meta; 212 struct GNUNET_FS_MetaData *meta;
213 struct GNUNET_FS_Uri *kuri; 213 struct GNUNET_FS_Uri *kuri;
214 struct GNUNET_FS_BlockOptions bo; 214 struct GNUNET_FS_BlockOptions bo;
215 struct GNUNET_FS_FileInformation *fi; 215 struct GNUNET_FS_FileInformation *fi;
diff --git a/src/fs/test_fs_search_with_and.c b/src/fs/test_fs_search_with_and.c
index 2187f4531..e0018cec4 100644
--- a/src/fs/test_fs_search_with_and.c
+++ b/src/fs/test_fs_search_with_and.c
@@ -216,7 +216,7 @@ run (void *cls,
216 "down_bar" 216 "down_bar"
217 }; 217 };
218 char *buf; 218 char *buf;
219 struct GNUNET_CONTAINER_MetaData *meta; 219 struct GNUNET_FS_MetaData *meta;
220 struct GNUNET_FS_Uri *kuri; 220 struct GNUNET_FS_Uri *kuri;
221 struct GNUNET_FS_BlockOptions bo; 221 struct GNUNET_FS_BlockOptions bo;
222 struct GNUNET_FS_FileInformation *fi; 222 struct GNUNET_FS_FileInformation *fi;
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c
index 992672244..c72bbce97 100644
--- a/src/fs/test_fs_unindex.c
+++ b/src/fs/test_fs_unindex.c
@@ -184,7 +184,7 @@ run (void *cls,
184 "down_bar", 184 "down_bar",
185 }; 185 };
186 char *buf; 186 char *buf;
187 struct GNUNET_CONTAINER_MetaData *meta; 187 struct GNUNET_FS_MetaData *meta;
188 struct GNUNET_FS_Uri *kuri; 188 struct GNUNET_FS_Uri *kuri;
189 struct GNUNET_FS_FileInformation *fi; 189 struct GNUNET_FS_FileInformation *fi;
190 size_t i; 190 size_t i;
diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c
index 802aaf7ca..b903d07ee 100644
--- a/src/fs/test_fs_unindex_persistence.c
+++ b/src/fs/test_fs_unindex_persistence.c
@@ -253,7 +253,7 @@ run (void *cls,
253 "down_bar", 253 "down_bar",
254 }; 254 };
255 char *buf; 255 char *buf;
256 struct GNUNET_CONTAINER_MetaData *meta; 256 struct GNUNET_FS_MetaData *meta;
257 struct GNUNET_FS_Uri *kuri; 257 struct GNUNET_FS_Uri *kuri;
258 struct GNUNET_FS_FileInformation *fi; 258 struct GNUNET_FS_FileInformation *fi;
259 size_t i; 259 size_t i;