aboutsummaryrefslogtreecommitdiff
path: root/src
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
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')
-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.c (renamed from src/util/container_meta_data.c)440
-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
-rw-r--r--src/include/gnunet_bio_lib.h49
-rw-r--r--src/include/gnunet_config.h.in3
-rw-r--r--src/include/gnunet_container_lib.h389
-rw-r--r--src/include/gnunet_extractor_compat.h149
-rw-r--r--src/include/gnunet_fs_service.h393
-rw-r--r--src/include/gnunet_mysql_compat.h63
-rw-r--r--src/include/gnunet_util_lib.h37
-rw-r--r--src/util/Makefile.am7
-rw-r--r--src/util/bio.c198
-rw-r--r--src/util/compress.c91
-rw-r--r--src/util/crypto_crc.c6
-rw-r--r--src/util/test_container_meta_data.c376
58 files changed, 1720 insertions, 1541 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/util/container_meta_data.c b/src/fs/meta_data.c
index b5b457291..f676ce57c 100644
--- a/src/util/container_meta_data.c
+++ b/src/fs/meta_data.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 GNUnet e.V. 3 Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 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 6 under the terms of the GNU Affero General Public License as published
@@ -19,104 +19,28 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file util/container_meta_data.c 22 * @file fs/meta_data.c
23 * @brief Storing of meta data 23 * @brief Storing of meta data
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Martin Schanzenbach
25 */ 26 */
26 27
27 28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30#if HAVE_EXTRACTOR_H 31#include "gnunet_extractor_compat.h"
31#include <extractor.h> 32#include "gnunet_fs_service.h"
32#endif
33#include <zlib.h>
34
35#define LOG(kind, ...) GNUNET_log_from (kind, "util-container-meta-data", \
36 __VA_ARGS__)
37
38 33
39/** 34/**
40 * Try to compress the given block of data using libz. Only returns 35 * Maximum size allowed for meta data written/read from disk.
41 * the compressed block if compression worked and the new block is 36 * File-sharing limits to 64k, so this should be rather generous.
42 * actually smaller. Decompress using #GNUNET_decompress().
43 *
44 * @param data block to compress; if compression
45 * resulted in a smaller block, the first
46 * bytes of data are updated to the compressed
47 * data
48 * @param old_size number of bytes in data
49 * @param[out] result set to the compressed data, if compression worked
50 * @param[out] new_size set to size of result, if compression worked
51 * @return #GNUNET_YES if compression reduce the size,
52 * #GNUNET_NO if compression did not help
53 */ 37 */
54int 38#define MAX_META_DATA (1024 * 1024)
55GNUNET_try_compression (const char *data,
56 size_t old_size,
57 char **result,
58 size_t *new_size)
59{
60 char *tmp;
61 uLongf dlen;
62
63 *result = NULL;
64 *new_size = 0;
65#ifdef compressBound
66 dlen = compressBound (old_size);
67#else
68 dlen = old_size + (old_size / 100) + 20;
69 /* documentation says 100.1% oldSize + 12 bytes, but we
70 * should be able to overshoot by more to be safe */
71#endif
72 tmp = GNUNET_malloc (dlen);
73 if (Z_OK ==
74 compress2 ((Bytef *) tmp,
75 &dlen,
76 (const Bytef *) data,
77 old_size, 9))
78 {
79 if (dlen < old_size)
80 {
81 *result = tmp;
82 *new_size = dlen;
83 return GNUNET_YES;
84 }
85 }
86 GNUNET_free (tmp);
87 return GNUNET_NO;
88}
89 39
90 40
91/** 41#define LOG(kind, ...) GNUNET_log_from (kind, "fs-meta-data", \
92 * Decompress input, return the decompressed data as output. Dual to 42 __VA_ARGS__)
93 * #GNUNET_try_compression(). Caller must set @a output_size to the 43
94 * number of bytes that were originally compressed.
95 *
96 * @param input compressed data
97 * @param input_size number of bytes in input
98 * @param output_size expected size of the output
99 * @return NULL on error, buffer of @a output_size decompressed bytes otherwise
100 */
101char *
102GNUNET_decompress (const char *input,
103 size_t input_size,
104 size_t output_size)
105{
106 char *output;
107 uLongf olen;
108
109 olen = output_size;
110 output = GNUNET_malloc (olen);
111 if (Z_OK ==
112 uncompress ((Bytef *) output,
113 &olen,
114 (const Bytef *) input,
115 input_size))
116 return output;
117 GNUNET_free (output);
118 return NULL;
119}
120 44
121 45
122/** 46/**
@@ -168,7 +92,7 @@ struct MetaItem
168/** 92/**
169 * Meta data to associate with a file, directory or namespace. 93 * Meta data to associate with a file, directory or namespace.
170 */ 94 */
171struct GNUNET_CONTAINER_MetaData 95struct GNUNET_FS_MetaData
172{ 96{
173 /** 97 /**
174 * Head of linked list of the meta data items. 98 * Head of linked list of the meta data items.
@@ -199,14 +123,14 @@ struct GNUNET_CONTAINER_MetaData
199 123
200 124
201/** 125/**
202 * Create a fresh struct CONTAINER_MetaData token. 126 * Create a fresh struct FS_MetaData token.
203 * 127 *
204 * @return empty meta-data container 128 * @return empty meta-data container
205 */ 129 */
206struct GNUNET_CONTAINER_MetaData * 130struct GNUNET_FS_MetaData *
207GNUNET_CONTAINER_meta_data_create () 131GNUNET_FS_meta_data_create ()
208{ 132{
209 return GNUNET_new (struct GNUNET_CONTAINER_MetaData); 133 return GNUNET_new (struct GNUNET_FS_MetaData);
210} 134}
211 135
212 136
@@ -232,7 +156,7 @@ meta_item_free (struct MetaItem *mi)
232 * @param md meta data that changed 156 * @param md meta data that changed
233 */ 157 */
234static void 158static void
235invalidate_sbuf (struct GNUNET_CONTAINER_MetaData *md) 159invalidate_sbuf (struct GNUNET_FS_MetaData *md)
236{ 160{
237 if (NULL == md->sbuf) 161 if (NULL == md->sbuf)
238 return; 162 return;
@@ -243,7 +167,7 @@ invalidate_sbuf (struct GNUNET_CONTAINER_MetaData *md)
243 167
244 168
245void 169void
246GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md) 170GNUNET_FS_meta_data_destroy (struct GNUNET_FS_MetaData *md)
247{ 171{
248 struct MetaItem *pos; 172 struct MetaItem *pos;
249 173
@@ -260,7 +184,7 @@ GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md)
260 184
261 185
262void 186void
263GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md) 187GNUNET_FS_meta_data_clear (struct GNUNET_FS_MetaData *md)
264{ 188{
265 struct MetaItem *mi; 189 struct MetaItem *mi;
266 190
@@ -272,15 +196,15 @@ GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md)
272 meta_item_free (mi); 196 meta_item_free (mi);
273 } 197 }
274 GNUNET_free (md->sbuf); 198 GNUNET_free (md->sbuf);
275 memset (md, 0, sizeof(struct GNUNET_CONTAINER_MetaData)); 199 memset (md, 0, sizeof(struct GNUNET_FS_MetaData));
276} 200}
277 201
278 202
279int 203int
280GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData 204GNUNET_FS_meta_data_test_equal (const struct GNUNET_FS_MetaData
281 *md1, 205 *md1,
282 const struct GNUNET_CONTAINER_MetaData 206 const struct GNUNET_FS_MetaData
283 *md2) 207 *md2)
284{ 208{
285 struct MetaItem *i; 209 struct MetaItem *i;
286 struct MetaItem *j; 210 struct MetaItem *j;
@@ -331,12 +255,12 @@ GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData
331 * data_mime_type and plugin_name are not considered for "exists" checks 255 * data_mime_type and plugin_name are not considered for "exists" checks
332 */ 256 */
333int 257int
334GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, 258GNUNET_FS_meta_data_insert (struct GNUNET_FS_MetaData *md,
335 const char *plugin_name, 259 const char *plugin_name,
336 enum EXTRACTOR_MetaType type, 260 enum EXTRACTOR_MetaType type,
337 enum EXTRACTOR_MetaFormat format, 261 enum EXTRACTOR_MetaFormat format,
338 const char *data_mime_type, const char *data, 262 const char *data_mime_type, const char *data,
339 size_t data_size) 263 size_t data_size)
340{ 264{
341 struct MetaItem *pos; 265 struct MetaItem *pos;
342 struct MetaItem *mi; 266 struct MetaItem *mi;
@@ -406,7 +330,7 @@ GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
406/** 330/**
407 * Merge given meta data. 331 * Merge given meta data.
408 * 332 *
409 * @param cls the `struct GNUNET_CONTAINER_MetaData` to merge into 333 * @param cls the `struct GNUNET_FS_MetaData` to merge into
410 * @param plugin_name name of the plugin that produced this value; 334 * @param plugin_name name of the plugin that produced this value;
411 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being 335 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
412 * used in the main libextractor library and yielding 336 * used in the main libextractor library and yielding
@@ -424,26 +348,26 @@ merge_helper (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
424 enum EXTRACTOR_MetaFormat format, const char *data_mime_type, 348 enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
425 const char *data, size_t data_size) 349 const char *data, size_t data_size)
426{ 350{
427 struct GNUNET_CONTAINER_MetaData *md = cls; 351 struct GNUNET_FS_MetaData *md = cls;
428 352
429 (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, 353 (void) GNUNET_FS_meta_data_insert (md, plugin_name, type, format,
430 data_mime_type, data, data_size); 354 data_mime_type, data, data_size);
431 return 0; 355 return 0;
432} 356}
433 357
434 358
435void 359void
436GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md, 360GNUNET_FS_meta_data_merge (struct GNUNET_FS_MetaData *md,
437 const struct GNUNET_CONTAINER_MetaData *in) 361 const struct GNUNET_FS_MetaData *in)
438{ 362{
439 GNUNET_CONTAINER_meta_data_iterate (in, &merge_helper, md); 363 GNUNET_FS_meta_data_iterate (in, &merge_helper, md);
440} 364}
441 365
442 366
443int 367int
444GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, 368GNUNET_FS_meta_data_delete (struct GNUNET_FS_MetaData *md,
445 enum EXTRACTOR_MetaType type, 369 enum EXTRACTOR_MetaType type,
446 const char *data, size_t data_size) 370 const char *data, size_t data_size)
447{ 371{
448 struct MetaItem *pos; 372 struct MetaItem *pos;
449 373
@@ -468,21 +392,21 @@ GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
468 392
469 393
470void 394void
471GNUNET_CONTAINER_meta_data_add_publication_date (struct 395GNUNET_FS_meta_data_add_publication_date (struct
472 GNUNET_CONTAINER_MetaData *md) 396 GNUNET_FS_MetaData *md)
473{ 397{
474 const char *dat; 398 const char *dat;
475 struct GNUNET_TIME_Absolute t; 399 struct GNUNET_TIME_Absolute t;
476 400
477 t = GNUNET_TIME_absolute_get (); 401 t = GNUNET_TIME_absolute_get ();
478 GNUNET_CONTAINER_meta_data_delete (md, 402 GNUNET_FS_meta_data_delete (md,
479 EXTRACTOR_METATYPE_PUBLICATION_DATE, 403 EXTRACTOR_METATYPE_PUBLICATION_DATE,
480 NULL, 0); 404 NULL, 0);
481 dat = GNUNET_STRINGS_absolute_time_to_string (t); 405 dat = GNUNET_STRINGS_absolute_time_to_string (t);
482 GNUNET_CONTAINER_meta_data_insert (md, "<gnunet>", 406 GNUNET_FS_meta_data_insert (md, "<gnunet>",
483 EXTRACTOR_METATYPE_PUBLICATION_DATE, 407 EXTRACTOR_METATYPE_PUBLICATION_DATE,
484 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 408 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
485 dat, strlen (dat) + 1); 409 dat, strlen (dat) + 1);
486} 410}
487 411
488 412
@@ -495,9 +419,9 @@ GNUNET_CONTAINER_meta_data_add_publication_date (struct
495 * @return number of entries 419 * @return number of entries
496 */ 420 */
497int 421int
498GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md, 422GNUNET_FS_meta_data_iterate (const struct GNUNET_FS_MetaData *md,
499 EXTRACTOR_MetaDataProcessor iter, 423 EXTRACTOR_MetaDataProcessor iter,
500 void *iter_cls) 424 void *iter_cls)
501{ 425{
502 struct MetaItem *pos; 426 struct MetaItem *pos;
503 427
@@ -515,9 +439,9 @@ GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md,
515 439
516 440
517char * 441char *
518GNUNET_CONTAINER_meta_data_get_by_type (const struct 442GNUNET_FS_meta_data_get_by_type (const struct
519 GNUNET_CONTAINER_MetaData *md, 443 GNUNET_FS_MetaData *md,
520 enum EXTRACTOR_MetaType type) 444 enum EXTRACTOR_MetaType type)
521{ 445{
522 struct MetaItem *pos; 446 struct MetaItem *pos;
523 447
@@ -533,9 +457,9 @@ GNUNET_CONTAINER_meta_data_get_by_type (const struct
533 457
534 458
535char * 459char *
536GNUNET_CONTAINER_meta_data_get_first_by_types (const struct 460GNUNET_FS_meta_data_get_first_by_types (const struct
537 GNUNET_CONTAINER_MetaData *md, 461 GNUNET_FS_MetaData *md,
538 ...) 462 ...)
539{ 463{
540 char *ret; 464 char *ret;
541 va_list args; 465 va_list args;
@@ -550,7 +474,7 @@ GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
550 type = va_arg (args, int); 474 type = va_arg (args, int);
551 if (-1 == type) 475 if (-1 == type)
552 break; 476 break;
553 if (NULL != (ret = GNUNET_CONTAINER_meta_data_get_by_type (md, type))) 477 if (NULL != (ret = GNUNET_FS_meta_data_get_by_type (md, type)))
554 break; 478 break;
555 } 479 }
556 va_end (args); 480 va_end (args);
@@ -567,8 +491,8 @@ GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
567 * @return number of bytes in thumbnail, 0 if not available 491 * @return number of bytes in thumbnail, 0 if not available
568 */ 492 */
569size_t 493size_t
570GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_MetaData 494GNUNET_FS_meta_data_get_thumbnail (const struct GNUNET_FS_MetaData
571 *md, unsigned char **thumb) 495 *md, unsigned char **thumb)
572{ 496{
573 struct MetaItem *pos; 497 struct MetaItem *pos;
574 struct MetaItem *match; 498 struct MetaItem *match;
@@ -598,25 +522,25 @@ GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_MetaData
598 522
599 523
600/** 524/**
601 * Duplicate a `struct GNUNET_CONTAINER_MetaData`. 525 * Duplicate a `struct GNUNET_FS_MetaData`.
602 * 526 *
603 * @param md what to duplicate 527 * @param md what to duplicate
604 * @return duplicate meta-data container 528 * @return duplicate meta-data container
605 */ 529 */
606struct GNUNET_CONTAINER_MetaData * 530struct GNUNET_FS_MetaData *
607GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData 531GNUNET_FS_meta_data_duplicate (const struct GNUNET_FS_MetaData
608 *md) 532 *md)
609{ 533{
610 struct GNUNET_CONTAINER_MetaData *ret; 534 struct GNUNET_FS_MetaData *ret;
611 struct MetaItem *pos; 535 struct MetaItem *pos;
612 536
613 if (NULL == md) 537 if (NULL == md)
614 return NULL; 538 return NULL;
615 ret = GNUNET_CONTAINER_meta_data_create (); 539 ret = GNUNET_FS_meta_data_create ();
616 for (pos = md->items_tail; NULL != pos; pos = pos->prev) 540 for (pos = md->items_tail; NULL != pos; pos = pos->prev)
617 GNUNET_CONTAINER_meta_data_insert (ret, pos->plugin_name, pos->type, 541 GNUNET_FS_meta_data_insert (ret, pos->plugin_name, pos->type,
618 pos->format, pos->mime_type, pos->data, 542 pos->format, pos->mime_type, pos->data,
619 pos->data_size); 543 pos->data_size);
620 return ret; 544 return ret;
621} 545}
622 546
@@ -714,13 +638,13 @@ struct MetaDataEntry
714 * space) 638 * space)
715 */ 639 */
716ssize_t 640ssize_t
717GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData 641GNUNET_FS_meta_data_serialize (const struct GNUNET_FS_MetaData
718 *md, char **target, size_t max, 642 *md, char **target, size_t max,
719 enum 643 enum
720 GNUNET_CONTAINER_MetaDataSerializationOptions 644 GNUNET_FS_MetaDataSerializationOptions
721 opt) 645 opt)
722{ 646{
723 struct GNUNET_CONTAINER_MetaData *vmd; 647 struct GNUNET_FS_MetaData *vmd;
724 struct MetaItem *pos; 648 struct MetaItem *pos;
725 struct MetaDataHeader ihdr; 649 struct MetaDataHeader ihdr;
726 struct MetaDataHeader *hdr; 650 struct MetaDataHeader *hdr;
@@ -754,7 +678,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
754 GNUNET_memcpy (*target, md->sbuf, md->sbuf_size); 678 GNUNET_memcpy (*target, md->sbuf, md->sbuf_size);
755 return md->sbuf_size; 679 return md->sbuf_size;
756 } 680 }
757 if (0 == (opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_PART)) 681 if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_PART))
758 return GNUNET_SYSERR; /* can say that this will fail */ 682 return GNUNET_SYSERR; /* can say that this will fail */
759 /* need to compute a partial serialization, sbuf useless ... */ 683 /* need to compute a partial serialization, sbuf useless ... */
760 } 684 }
@@ -821,7 +745,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
821 for (pos = md->items_head; NULL != pos; pos = pos->next) 745 for (pos = md->items_head; NULL != pos; pos = pos->next)
822 { 746 {
823 comp = GNUNET_NO; 747 comp = GNUNET_NO;
824 if (0 == (opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS)) 748 if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_NO_COMPRESS))
825 comp = GNUNET_try_compression ((const char *) &ent[i], 749 comp = GNUNET_try_compression ((const char *) &ent[i],
826 left, 750 left,
827 &cdata, 751 &cdata,
@@ -832,7 +756,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
832 /* fill 'sbuf'; this "modifies" md, but since this is only 756 /* fill 'sbuf'; this "modifies" md, but since this is only
833 * an internal cache we will cast away the 'const' instead 757 * an internal cache we will cast away the 'const' instead
834 * of making the API look strange. */ 758 * of making the API look strange. */
835 vmd = (struct GNUNET_CONTAINER_MetaData *) md; 759 vmd = (struct GNUNET_FS_MetaData *) md;
836 hdr = GNUNET_malloc (left + sizeof(struct MetaDataHeader)); 760 hdr = GNUNET_malloc (left + sizeof(struct MetaDataHeader));
837 hdr->size = htonl (left); 761 hdr->size = htonl (left);
838 hdr->entries = htonl (md->item_count); 762 hdr->entries = htonl (md->item_count);
@@ -897,7 +821,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
897 return rlen; 821 return rlen;
898 } 822 }
899 823
900 if (0 == (opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_PART)) 824 if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_PART))
901 { 825 {
902 /* does not fit! */ 826 /* does not fit! */
903 GNUNET_free (ent); 827 GNUNET_free (ent);
@@ -935,8 +859,8 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
935 859
936 860
937ssize_t 861ssize_t
938GNUNET_CONTAINER_meta_data_get_serialized_size (const struct 862GNUNET_FS_meta_data_get_serialized_size (const struct
939 GNUNET_CONTAINER_MetaData *md) 863 GNUNET_FS_MetaData *md)
940{ 864{
941 ssize_t ret; 865 ssize_t ret;
942 char *ptr; 866 char *ptr;
@@ -945,8 +869,8 @@ GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
945 return md->sbuf_size; 869 return md->sbuf_size;
946 ptr = NULL; 870 ptr = NULL;
947 ret = 871 ret =
948 GNUNET_CONTAINER_meta_data_serialize (md, &ptr, GNUNET_MAX_MALLOC_CHECKED, 872 GNUNET_FS_meta_data_serialize (md, &ptr, GNUNET_MAX_MALLOC_CHECKED,
949 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); 873 GNUNET_FS_META_DATA_SERIALIZE_FULL);
950 if (-1 != ret) 874 if (-1 != ret)
951 GNUNET_free (ptr); 875 GNUNET_free (ptr);
952 return ret; 876 return ret;
@@ -961,10 +885,10 @@ GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
961 * @return MD on success, NULL on error (i.e. 885 * @return MD on success, NULL on error (i.e.
962 * bad format) 886 * bad format)
963 */ 887 */
964struct GNUNET_CONTAINER_MetaData * 888struct GNUNET_FS_MetaData *
965GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size) 889GNUNET_FS_meta_data_deserialize (const char *input, size_t size)
966{ 890{
967 struct GNUNET_CONTAINER_MetaData *md; 891 struct GNUNET_FS_MetaData *md;
968 struct MetaDataHeader hdr; 892 struct MetaDataHeader hdr;
969 struct MetaDataEntry ent; 893 struct MetaDataEntry ent;
970 uint32_t ic; 894 uint32_t ic;
@@ -1039,7 +963,7 @@ GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size)
1039 } 963 }
1040 } 964 }
1041 965
1042 md = GNUNET_CONTAINER_meta_data_create (); 966 md = GNUNET_FS_meta_data_create ();
1043 left = dataSize - ic * sizeof(struct MetaDataEntry); 967 left = dataSize - ic * sizeof(struct MetaDataEntry);
1044 mdata = &cdata[ic * sizeof(struct MetaDataEntry)]; 968 mdata = &cdata[ic * sizeof(struct MetaDataEntry)];
1045 for (i = 0; i < ic; i++) 969 for (i = 0; i < ic; i++)
@@ -1109,14 +1033,192 @@ GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size)
1109 mime_type = NULL; 1033 mime_type = NULL;
1110 else 1034 else
1111 mime_type = &mdata[left]; 1035 mime_type = &mdata[left];
1112 GNUNET_CONTAINER_meta_data_insert (md, plugin_name, 1036 GNUNET_FS_meta_data_insert (md, plugin_name,
1113 (enum EXTRACTOR_MetaType) 1037 (enum EXTRACTOR_MetaType)
1114 ntohl (ent.type), format, mime_type, 1038 ntohl (ent.type), format, mime_type,
1115 meta_data, dlen); 1039 meta_data, dlen);
1116 } 1040 }
1117 GNUNET_free (data); 1041 GNUNET_free (data);
1118 return md; 1042 return md;
1119} 1043}
1120 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
1121 1223
1122/* end of container_meta_data.c */ 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;
diff --git a/src/include/gnunet_bio_lib.h b/src/include/gnunet_bio_lib.h
index e165b9d90..6d42f554c 100644
--- a/src/include/gnunet_bio_lib.h
+++ b/src/include/gnunet_bio_lib.h
@@ -125,19 +125,6 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
125 size_t max_length); 125 size_t max_length);
126 126
127 127
128/**
129 * Read a metadata container.
130 *
131 * @param h handle to an open file
132 * @param what describes what is being read (for error message creation)
133 * @param result the buffer to store a pointer to the (allocated) metadata
134 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
135 */
136int
137GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
138 const char *what,
139 struct GNUNET_CONTAINER_MetaData **result);
140
141 128
142/** 129/**
143 * Read a float. 130 * Read a float.
@@ -294,19 +281,6 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
294 const char *s); 281 const char *s);
295 282
296 283
297/**
298 * Write a metadata container.
299 *
300 * @param h the IO handle to write to
301 * @param what what is being written (for error message creation)
302 * @param m metadata to write
303 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
304 */
305int
306GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
307 const char *what,
308 const struct GNUNET_CONTAINER_MetaData *m);
309
310 284
311/** 285/**
312 * Write a float. 286 * Write a float.
@@ -453,17 +427,6 @@ GNUNET_BIO_read_spec_string (const char *what,
453 size_t max_length); 427 size_t max_length);
454 428
455 429
456/**
457 * Create the specification to read a metadata container.
458 *
459 * @param what describes what is being read (for error message creation)
460 * @param result the buffer to store a pointer to the (allocated) metadata
461 * @return the read spec
462 */
463struct GNUNET_BIO_ReadSpec
464GNUNET_BIO_read_spec_meta_data (const char *what,
465 struct GNUNET_CONTAINER_MetaData **result);
466
467 430
468/** 431/**
469 * Create the specification to read an (u)int32_t. 432 * Create the specification to read an (u)int32_t.
@@ -610,18 +573,6 @@ GNUNET_BIO_write_spec_string (const char *what,
610 573
611 574
612/** 575/**
613 * Create the specification to write a metadata container.
614 *
615 * @param what what is being written (for error message creation)
616 * @param m metadata to write
617 * @return the write spec
618 */
619struct GNUNET_BIO_WriteSpec
620GNUNET_BIO_write_spec_meta_data (const char *what,
621 const struct GNUNET_CONTAINER_MetaData *m);
622
623
624/**
625 * Create the specification to write an (u)int32_t. 576 * Create the specification to write an (u)int32_t.
626 * 577 *
627 * @param what describes what is being written (for error message creation) 578 * @param what describes what is being written (for error message creation)
diff --git a/src/include/gnunet_config.h.in b/src/include/gnunet_config.h.in
index 5b0d69a03..ce7c5a894 100644
--- a/src/include/gnunet_config.h.in
+++ b/src/include/gnunet_config.h.in
@@ -48,7 +48,4 @@
48/* Set to 1 if GnuTLS has DANE support */ 48/* Set to 1 if GnuTLS has DANE support */
49#define GNUNET_CURL_GNUTLS @curl_gnutls@ 49#define GNUNET_CURL_GNUTLS @curl_gnutls@
50 50
51/* Set to 1 is we have the byteswap header */
52#define GNUNET_HAVE_BYTESWAP_H @have_byteswap@
53
54#endif 51#endif
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h
index 55774a209..1d39f813b 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -48,8 +48,6 @@
48 * 48 *
49 * @see [Documentation](https://gnunet.org/mdll-api) 49 * @see [Documentation](https://gnunet.org/mdll-api)
50 * 50 *
51 * @defgroup metadata Metadata
52 * GNU libextractor key-value pairs
53 * 51 *
54 * @} 52 * @}
55 */ 53 */
@@ -102,114 +100,6 @@ char *
102GNUNET_decompress (const char *input, size_t input_size, size_t output_size); 100GNUNET_decompress (const char *input, size_t input_size, size_t output_size);
103 101
104 102
105#if HAVE_EXTRACTOR_H
106
107#include <extractor.h>
108
109#else
110
111/* definitions from extractor.h we need for the build */
112
113/**
114 * Enumeration defining various sources of keywords. See also
115 * http://dublincore.org/documents/1998/09/dces/
116 */
117enum EXTRACTOR_MetaType
118{
119 EXTRACTOR_METATYPE_RESERVED = 0,
120 EXTRACTOR_METATYPE_MIMETYPE = 1,
121 EXTRACTOR_METATYPE_FILENAME = 2,
122 EXTRACTOR_METATYPE_COMMENT = 3,
123 EXTRACTOR_METATYPE_TITLE = 4,
124 EXTRACTOR_METATYPE_BOOK_TITLE = 5,
125 EXTRACTOR_METATYPE_JOURNAL_NAME = 8,
126 EXTRACTOR_METATYPE_AUTHOR_NAME = 13,
127 EXTRACTOR_METATYPE_PUBLICATION_DATE = 24,
128 EXTRACTOR_METATYPE_URL = 29,
129 EXTRACTOR_METATYPE_URI = 30,
130 EXTRACTOR_METATYPE_ISRC = 31,
131 EXTRACTOR_METATYPE_UNKNOWN = 45,
132 EXTRACTOR_METATYPE_DESCRIPTION = 46,
133 EXTRACTOR_METATYPE_KEYWORDS = 49,
134 EXTRACTOR_METATYPE_SUBJECT = 52,
135 EXTRACTOR_METATYPE_PACKAGE_NAME = 69,
136 EXTRACTOR_METATYPE_THUMBNAIL = 114,
137 EXTRACTOR_METATYPE_ALBUM = 129,
138 EXTRACTOR_METATYPE_ARTIST = 130,
139 EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162,
140 EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174,
141 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180,
142};
143
144/**
145 * Format in which the extracted meta data is presented.
146 */
147enum EXTRACTOR_MetaFormat
148{
149 /**
150 * Format is unknown.
151 */
152 EXTRACTOR_METAFORMAT_UNKNOWN = 0,
153
154 /**
155 * 0-terminated, UTF-8 encoded string. "data_len"
156 * is strlen(data)+1.
157 */
158 EXTRACTOR_METAFORMAT_UTF8 = 1,
159
160 /**
161 * Some kind of binary format, see given Mime type.
162 */
163 EXTRACTOR_METAFORMAT_BINARY = 2,
164
165 /**
166 * 0-terminated string. The specific encoding is unknown.
167 * "data_len" is strlen (data)+1.
168 */
169 EXTRACTOR_METAFORMAT_C_STRING = 3
170};
171
172
173/**
174 * Type of a function that libextractor calls for each
175 * meta data item found.
176 *
177 * @param cls closure (user-defined)
178 * @param plugin_name name of the plugin that produced this value;
179 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
180 * used in the main libextractor library and yielding
181 * meta data).
182 * @param type libextractor-type describing the meta data
183 * @param format basic format information about @a data
184 * @param data_mime_type mime-type of @a data (not of the original file);
185 * can be NULL (if mime-type is not known)
186 * @param data actual meta-data found
187 * @param data_len number of bytes in @a data
188 * @return 0 to continue extracting, 1 to abort
189 */
190typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls,
191 const char *plugin_name,
192 enum EXTRACTOR_MetaType type,
193 enum EXTRACTOR_MetaFormat format,
194 const char *data_mime_type,
195 const char *data,
196 size_t data_len);
197
198#endif
199
200#ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
201/* hack for LE < 0.6.3 */
202#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME 180
203#endif
204
205#ifdef __cplusplus
206extern "C" {
207#if 0 /* keep Emacsens' auto-indent happy */
208}
209#endif
210#endif
211
212
213/* ******************* bloomfilter ***************** */ 103/* ******************* bloomfilter ***************** */
214 104
215/** 105/**
@@ -435,285 +325,6 @@ GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf,
435 unsigned int k); 325 unsigned int k);
436 326
437 327
438/* ****************** metadata ******************* */
439
440/**
441 * @ingroup metadata
442 * Meta data to associate with a file, directory or namespace.
443 */
444struct GNUNET_CONTAINER_MetaData;
445
446
447/**
448 * @ingroup metadata
449 * Create a fresh meta data container.
450 *
451 * @return empty meta-data container
452 */
453struct GNUNET_CONTAINER_MetaData *
454GNUNET_CONTAINER_meta_data_create (void);
455
456
457/**
458 * @ingroup metadata
459 * Duplicate a MetaData token.
460 *
461 * @param md what to duplicate
462 * @return duplicate meta-data container
463 */
464struct GNUNET_CONTAINER_MetaData *
465GNUNET_CONTAINER_meta_data_duplicate (
466 const struct GNUNET_CONTAINER_MetaData *md);
467
468
469/**
470 * @ingroup metadata
471 * Free meta data.
472 *
473 * @param md what to free
474 */
475void
476GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md);
477
478
479/**
480 * @ingroup metadata
481 * Test if two MDs are equal. We consider them equal if
482 * the meta types, formats and content match (we do not
483 * include the mime types and plugins names in this
484 * consideration).
485 *
486 * @param md1 first value to check
487 * @param md2 other value to check
488 * @return #GNUNET_YES if they are equal
489 */
490int
491GNUNET_CONTAINER_meta_data_test_equal (
492 const struct GNUNET_CONTAINER_MetaData *md1,
493 const struct GNUNET_CONTAINER_MetaData *md2);
494
495
496/**
497 * @ingroup metadata
498 * Extend metadata.
499 *
500 * @param md metadata to extend
501 * @param plugin_name name of the plugin that produced this value;
502 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
503 * used in the main libextractor library and yielding
504 * meta data).
505 * @param type libextractor-type describing the meta data
506 * @param format basic format information about data
507 * @param data_mime_type mime-type of data (not of the original file);
508 * can be NULL (if mime-type is not known)
509 * @param data actual meta-data found
510 * @param data_size number of bytes in data
511 * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exists
512 * data_mime_type and plugin_name are not considered for "exists" checks
513 */
514int
515GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
516 const char *plugin_name,
517 enum EXTRACTOR_MetaType type,
518 enum EXTRACTOR_MetaFormat format,
519 const char *data_mime_type,
520 const char *data,
521 size_t data_size);
522
523
524/**
525 * @ingroup metadata
526 * Extend metadata. Merges the meta data from the second argument
527 * into the first, discarding duplicate key-value pairs.
528 *
529 * @param md metadata to extend
530 * @param in metadata to merge
531 */
532void
533GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md,
534 const struct GNUNET_CONTAINER_MetaData *in);
535
536
537/**
538 * @ingroup metadata
539 * Remove an item.
540 *
541 * @param md metadata to manipulate
542 * @param type type of the item to remove
543 * @param data specific value to remove, NULL to remove all
544 * entries of the given type
545 * @param data_size number of bytes in data
546 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the item does not exist in md
547 */
548int
549GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
550 enum EXTRACTOR_MetaType type,
551 const char *data,
552 size_t data_size);
553
554
555/**
556 * @ingroup metadata
557 * Remove all items in the container.
558 *
559 * @param md metadata to manipulate
560 */
561void
562GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md);
563
564
565/**
566 * @ingroup metadata
567 * Add the current time as the publication date
568 * to the meta-data.
569 *
570 * @param md metadata to modify
571 */
572void
573GNUNET_CONTAINER_meta_data_add_publication_date (
574 struct GNUNET_CONTAINER_MetaData *md);
575
576
577/**
578 * @ingroup metadata
579 * Iterate over MD entries.
580 *
581 * @param md metadata to inspect
582 * @param iter function to call on each entry, return 0 to continue to iterate
583 * and 1 to abort iteration in this function (GNU libextractor API!)
584 * @param iter_cls closure for @a iter
585 * @return number of entries
586 */
587int
588GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md,
589 EXTRACTOR_MetaDataProcessor iter,
590 void *iter_cls);
591
592
593/**
594 * @ingroup metadata
595 * Get the first MD entry of the given type. Caller
596 * is responsible for freeing the return value.
597 * Also, only meta data items that are strings (0-terminated)
598 * are returned by this function.
599 *
600 * @param md metadata to inspect
601 * @param type type to look for
602 * @return NULL if no entry was found
603 */
604char *
605GNUNET_CONTAINER_meta_data_get_by_type (
606 const struct GNUNET_CONTAINER_MetaData *md,
607 enum EXTRACTOR_MetaType type);
608
609
610/**
611 * @ingroup metadata
612 * Get the first matching MD entry of the given types. Caller is
613 * responsible for freeing the return value. Also, only meta data
614 * items that are strings (0-terminated) are returned by this
615 * function.
616 *
617 * @param md metadata to inspect
618 * @param ... -1-terminated list of types
619 * @return NULL if we do not have any such entry,
620 * otherwise client is responsible for freeing the value!
621 */
622char *
623GNUNET_CONTAINER_meta_data_get_first_by_types (
624 const struct GNUNET_CONTAINER_MetaData *md,
625 ...);
626
627/**
628 * @ingroup metadata
629 * Get a thumbnail from the meta-data (if present). Only matches meta
630 * data with mime type "image" and binary format.
631 *
632 * @param md metadata to inspect
633 * @param thumb will be set to the thumbnail data. Must be
634 * freed by the caller!
635 * @return number of bytes in thumbnail, 0 if not available
636 */
637size_t
638GNUNET_CONTAINER_meta_data_get_thumbnail (
639 const struct GNUNET_CONTAINER_MetaData *md,
640 unsigned char **thumb);
641
642
643/**
644 * @ingroup metadata
645 * Options for metadata serialization.
646 */
647enum GNUNET_CONTAINER_MetaDataSerializationOptions
648{
649 /**
650 * @ingroup metadata
651 * Serialize all of the data.
652 */
653 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0,
654
655 /**
656 * @ingroup metadata
657 * If not enough space is available, it is acceptable
658 * to only serialize some of the metadata.
659 */
660 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1,
661
662 /**
663 * @ingroup metadata
664 * Speed is of the essence, do not allow compression.
665 */
666 GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2
667};
668
669
670/**
671 * @ingroup metadata
672 * Serialize meta-data to target.
673 *
674 * @param md metadata to serialize
675 * @param target where to write the serialized metadata;
676 * *target can be NULL, in which case memory is allocated
677 * @param max maximum number of bytes available
678 * @param opt is it ok to just write SOME of the
679 * meta-data to match the size constraint,
680 * possibly discarding some data?
681 * @return number of bytes written on success,
682 * -1 on error (typically: not enough
683 * space)
684 */
685ssize_t
686GNUNET_CONTAINER_meta_data_serialize (
687 const struct GNUNET_CONTAINER_MetaData *md,
688 char **target,
689 size_t max,
690 enum GNUNET_CONTAINER_MetaDataSerializationOptions opt);
691
692
693/**
694 * @ingroup metadata
695 * Get the size of the full meta-data in serialized form.
696 *
697 * @param md metadata to inspect
698 * @return number of bytes needed for serialization, -1 on error
699 */
700ssize_t
701GNUNET_CONTAINER_meta_data_get_serialized_size (
702 const struct GNUNET_CONTAINER_MetaData *md);
703
704
705/**
706 * @ingroup metadata
707 * Deserialize meta-data. Initializes md.
708 *
709 * @param input serialized meta-data.
710 * @param size number of bytes available
711 * @return MD on success, NULL on error (e.g.
712 * bad format)
713 */
714struct GNUNET_CONTAINER_MetaData *
715GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size);
716
717 328
718/* ******************************* HashMap **************************** */ 329/* ******************************* HashMap **************************** */
719 330
diff --git a/src/include/gnunet_extractor_compat.h b/src/include/gnunet_extractor_compat.h
new file mode 100644
index 000000000..d69525c9d
--- /dev/null
+++ b/src/include/gnunet_extractor_compat.h
@@ -0,0 +1,149 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 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 * @author Martin Schanzenbach
22 *
23 * @file
24 * libextractor compatibility insanity helper header
25 *
26 * @{
27 */
28#ifndef GNUNET_EXTRACTOR_COMPAT_H
29#define GNUNET_EXTRACTOR_COMPAT_H
30
31
32#ifdef __cplusplus
33extern "C"
34{
35#if 0 /* keep Emacsens' auto-indent happy */
36}
37#endif
38#endif
39
40#if HAVE_EXTRACTOR_H
41
42#include <extractor.h>
43
44#else
45
46/* definitions from extractor.h we need for the build */
47
48/**
49 * Enumeration defining various sources of keywords. See also
50 * http://dublincore.org/documents/1998/09/dces/
51 */
52enum EXTRACTOR_MetaType
53{
54 EXTRACTOR_METATYPE_RESERVED = 0,
55 EXTRACTOR_METATYPE_MIMETYPE = 1,
56 EXTRACTOR_METATYPE_FILENAME = 2,
57 EXTRACTOR_METATYPE_COMMENT = 3,
58 EXTRACTOR_METATYPE_TITLE = 4,
59 EXTRACTOR_METATYPE_BOOK_TITLE = 5,
60 EXTRACTOR_METATYPE_JOURNAL_NAME = 8,
61 EXTRACTOR_METATYPE_AUTHOR_NAME = 13,
62 EXTRACTOR_METATYPE_PUBLICATION_DATE = 24,
63 EXTRACTOR_METATYPE_URL = 29,
64 EXTRACTOR_METATYPE_URI = 30,
65 EXTRACTOR_METATYPE_ISRC = 31,
66 EXTRACTOR_METATYPE_UNKNOWN = 45,
67 EXTRACTOR_METATYPE_DESCRIPTION = 46,
68 EXTRACTOR_METATYPE_KEYWORDS = 49,
69 EXTRACTOR_METATYPE_SUBJECT = 52,
70 EXTRACTOR_METATYPE_PACKAGE_NAME = 69,
71 EXTRACTOR_METATYPE_THUMBNAIL = 114,
72 EXTRACTOR_METATYPE_ALBUM = 129,
73 EXTRACTOR_METATYPE_ARTIST = 130,
74 EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162,
75 EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174,
76 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180,
77};
78
79/**
80 * Format in which the extracted meta data is presented.
81 */
82enum EXTRACTOR_MetaFormat
83{
84 /**
85 * Format is unknown.
86 */
87 EXTRACTOR_METAFORMAT_UNKNOWN = 0,
88
89 /**
90 * 0-terminated, UTF-8 encoded string. "data_len"
91 * is strlen(data)+1.
92 */
93 EXTRACTOR_METAFORMAT_UTF8 = 1,
94
95 /**
96 * Some kind of binary format, see given Mime type.
97 */
98 EXTRACTOR_METAFORMAT_BINARY = 2,
99
100 /**
101 * 0-terminated string. The specific encoding is unknown.
102 * "data_len" is strlen (data)+1.
103 */
104 EXTRACTOR_METAFORMAT_C_STRING = 3
105};
106
107
108/**
109 * Type of a function that libextractor calls for each
110 * meta data item found.
111 *
112 * @param cls closure (user-defined)
113 * @param plugin_name name of the plugin that produced this value;
114 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
115 * used in the main libextractor library and yielding
116 * meta data).
117 * @param type libextractor-type describing the meta data
118 * @param format basic format information about @a data
119 * @param data_mime_type mime-type of @a data (not of the original file);
120 * can be NULL (if mime-type is not known)
121 * @param data actual meta-data found
122 * @param data_len number of bytes in @a data
123 * @return 0 to continue extracting, 1 to abort
124 */
125typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls,
126 const char *plugin_name,
127 enum EXTRACTOR_MetaType type,
128 enum EXTRACTOR_MetaFormat format,
129 const char *data_mime_type,
130 const char *data,
131 size_t data_len);
132
133#endif
134
135#ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
136/* hack for LE < 0.6.3 */
137#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME 180
138#endif
139
140#if 0 /* keep Emacsens' auto-indent happy */
141{
142#endif
143#ifdef __cplusplus
144}
145#endif
146
147#endif
148
149/** @} */ /* end of group */
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index 6b46f1553..53ca6a9ec 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -37,6 +37,7 @@
37#define GNUNET_FS_LIB_H 37#define GNUNET_FS_LIB_H
38 38
39 39
40#include "gnunet_common.h"
40#include "gnunet_util_lib.h" 41#include "gnunet_util_lib.h"
41 42
42#ifdef __cplusplus 43#ifdef __cplusplus
@@ -92,6 +93,12 @@ extern "C"
92 */ 93 */
93struct GNUNET_FS_Uri; 94struct GNUNET_FS_Uri;
94 95
96/**
97 * @ingroup metadata
98 * Meta data to associate with a file, directory or namespace.
99 */
100struct GNUNET_FS_MetaData;
101
95 102
96/** 103/**
97 * Iterator over keywords 104 * Iterator over keywords
@@ -436,7 +443,7 @@ GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri);
436 * @return NULL on error, otherwise a KSK URI 443 * @return NULL on error, otherwise a KSK URI
437 */ 444 */
438struct GNUNET_FS_Uri * 445struct GNUNET_FS_Uri *
439GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData 446GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_FS_MetaData
440 *md); 447 *md);
441 448
442 449
@@ -472,7 +479,7 @@ GNUNET_FS_GETOPT_METADATA (char shortName,
472 const char *name, 479 const char *name,
473 const char *argumentHelp, 480 const char *argumentHelp,
474 const char *description, 481 const char *description,
475 struct GNUNET_CONTAINER_MetaData **meta); 482 struct GNUNET_FS_MetaData **meta);
476 483
477/** 484/**
478 * Command-line option parser function that allows the user to specify 485 * Command-line option parser function that allows the user to specify
@@ -481,7 +488,7 @@ GNUNET_FS_GETOPT_METADATA (char shortName,
481 * the metadata must be passed as the "scls" argument. 488 * the metadata must be passed as the "scls" argument.
482 * 489 *
483 * @param ctx command line processor context 490 * @param ctx command line processor context
484 * @param scls must be of type `struct GNUNET_CONTAINER_MetaData **` 491 * @param scls must be of type `struct GNUNET_FS_MetaData **`
485 * @param option name of the option (typically 'k') 492 * @param option name of the option (typically 'k')
486 * @param value command line argument given 493 * @param value command line argument given
487 * @return #GNUNET_OK on success 494 * @return #GNUNET_OK on success
@@ -1099,7 +1106,7 @@ struct GNUNET_FS_ProgressInfo
1099 /** 1106 /**
1100 * Known metadata for the download. 1107 * Known metadata for the download.
1101 */ 1108 */
1102 const struct GNUNET_CONTAINER_MetaData *meta; 1109 const struct GNUNET_FS_MetaData *meta;
1103 } start; 1110 } start;
1104 1111
1105 /** 1112 /**
@@ -1111,7 +1118,7 @@ struct GNUNET_FS_ProgressInfo
1111 /** 1118 /**
1112 * Known metadata for the download. 1119 * Known metadata for the download.
1113 */ 1120 */
1114 const struct GNUNET_CONTAINER_MetaData *meta; 1121 const struct GNUNET_FS_MetaData *meta;
1115 1122
1116 /** 1123 /**
1117 * Error message, NULL if we have not encountered any error yet. 1124 * Error message, NULL if we have not encountered any error yet.
@@ -1196,7 +1203,7 @@ struct GNUNET_FS_ProgressInfo
1196 /** 1203 /**
1197 * Metadata for the search result. 1204 * Metadata for the search result.
1198 */ 1205 */
1199 const struct GNUNET_CONTAINER_MetaData *meta; 1206 const struct GNUNET_FS_MetaData *meta;
1200 1207
1201 /** 1208 /**
1202 * URI for the search result. 1209 * URI for the search result.
@@ -1224,7 +1231,7 @@ struct GNUNET_FS_ProgressInfo
1224 /** 1231 /**
1225 * Metadata for the search result. 1232 * Metadata for the search result.
1226 */ 1233 */
1227 const struct GNUNET_CONTAINER_MetaData *meta; 1234 const struct GNUNET_FS_MetaData *meta;
1228 1235
1229 /** 1236 /**
1230 * URI for the search result. 1237 * URI for the search result.
@@ -1271,7 +1278,7 @@ struct GNUNET_FS_ProgressInfo
1271 /** 1278 /**
1272 * Metadata for the search result. 1279 * Metadata for the search result.
1273 */ 1280 */
1274 const struct GNUNET_CONTAINER_MetaData *meta; 1281 const struct GNUNET_FS_MetaData *meta;
1275 1282
1276 /** 1283 /**
1277 * URI for the search result. 1284 * URI for the search result.
@@ -1323,7 +1330,7 @@ struct GNUNET_FS_ProgressInfo
1323 /** 1330 /**
1324 * Metadata for the search result. 1331 * Metadata for the search result.
1325 */ 1332 */
1326 const struct GNUNET_CONTAINER_MetaData *meta; 1333 const struct GNUNET_FS_MetaData *meta;
1327 1334
1328 /** 1335 /**
1329 * URI for the search result. 1336 * URI for the search result.
@@ -1351,7 +1358,7 @@ struct GNUNET_FS_ProgressInfo
1351 /** 1358 /**
1352 * Metadata for the search result. 1359 * Metadata for the search result.
1353 */ 1360 */
1354 const struct GNUNET_CONTAINER_MetaData *meta; 1361 const struct GNUNET_FS_MetaData *meta;
1355 1362
1356 /** 1363 /**
1357 * URI for the search result. 1364 * URI for the search result.
@@ -1406,7 +1413,7 @@ struct GNUNET_FS_ProgressInfo
1406 /** 1413 /**
1407 * Metadata for the namespace. 1414 * Metadata for the namespace.
1408 */ 1415 */
1409 const struct GNUNET_CONTAINER_MetaData *meta; 1416 const struct GNUNET_FS_MetaData *meta;
1410 1417
1411 /** 1418 /**
1412 * Public key of the namespace. 1419 * Public key of the namespace.
@@ -1706,7 +1713,7 @@ typedef int
1706(*GNUNET_FS_FileInformationProcessor) (void *cls, 1713(*GNUNET_FS_FileInformationProcessor) (void *cls,
1707 struct GNUNET_FS_FileInformation *fi, 1714 struct GNUNET_FS_FileInformation *fi,
1708 uint64_t length, 1715 uint64_t length,
1709 struct GNUNET_CONTAINER_MetaData *meta, 1716 struct GNUNET_FS_MetaData *meta,
1710 struct GNUNET_FS_Uri **uri, 1717 struct GNUNET_FS_Uri **uri,
1711 struct GNUNET_FS_BlockOptions *bo, 1718 struct GNUNET_FS_BlockOptions *bo,
1712 int *do_index, 1719 int *do_index,
@@ -1771,7 +1778,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
1771 const struct 1778 const struct
1772 GNUNET_FS_Uri *keywords, 1779 GNUNET_FS_Uri *keywords,
1773 const struct 1780 const struct
1774 GNUNET_CONTAINER_MetaData *meta, 1781 GNUNET_FS_MetaData *meta,
1775 int do_index, 1782 int do_index,
1776 const struct 1783 const struct
1777 GNUNET_FS_BlockOptions *bo); 1784 GNUNET_FS_BlockOptions *bo);
@@ -1801,7 +1808,7 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
1801 const struct 1808 const struct
1802 GNUNET_FS_Uri *keywords, 1809 GNUNET_FS_Uri *keywords,
1803 const struct 1810 const struct
1804 GNUNET_CONTAINER_MetaData *meta, 1811 GNUNET_FS_MetaData *meta,
1805 int do_index, 1812 int do_index,
1806 const struct 1813 const struct
1807 GNUNET_FS_BlockOptions *bo); 1814 GNUNET_FS_BlockOptions *bo);
@@ -1860,7 +1867,7 @@ GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
1860 const struct GNUNET_FS_Uri 1867 const struct GNUNET_FS_Uri
1861 *keywords, 1868 *keywords,
1862 const struct 1869 const struct
1863 GNUNET_CONTAINER_MetaData *meta, 1870 GNUNET_FS_MetaData *meta,
1864 int do_index, 1871 int do_index,
1865 const struct 1872 const struct
1866 GNUNET_FS_BlockOptions *bo); 1873 GNUNET_FS_BlockOptions *bo);
@@ -1884,7 +1891,7 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h,
1884 const struct GNUNET_FS_Uri 1891 const struct GNUNET_FS_Uri
1885 *keywords, 1892 *keywords,
1886 const struct 1893 const struct
1887 GNUNET_CONTAINER_MetaData 1894 GNUNET_FS_MetaData
1888 *meta, 1895 *meta,
1889 const struct 1896 const struct
1890 GNUNET_FS_BlockOptions *bo, 1897 GNUNET_FS_BlockOptions *bo,
@@ -2043,7 +2050,7 @@ struct GNUNET_FS_PublishKskContext;
2043struct GNUNET_FS_PublishKskContext * 2050struct GNUNET_FS_PublishKskContext *
2044GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, 2051GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
2045 const struct GNUNET_FS_Uri *ksk_uri, 2052 const struct GNUNET_FS_Uri *ksk_uri,
2046 const struct GNUNET_CONTAINER_MetaData *meta, 2053 const struct GNUNET_FS_MetaData *meta,
2047 const struct GNUNET_FS_Uri *uri, 2054 const struct GNUNET_FS_Uri *uri,
2048 const struct GNUNET_FS_BlockOptions *bo, 2055 const struct GNUNET_FS_BlockOptions *bo,
2049 enum GNUNET_FS_PublishOptions options, 2056 enum GNUNET_FS_PublishOptions options,
@@ -2085,7 +2092,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
2085 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, 2092 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
2086 const char *identifier, 2093 const char *identifier,
2087 const char *update, 2094 const char *update,
2088 const struct GNUNET_CONTAINER_MetaData *meta, 2095 const struct GNUNET_FS_MetaData *meta,
2089 const struct GNUNET_FS_Uri *uri, 2096 const struct GNUNET_FS_Uri *uri,
2090 const struct GNUNET_FS_BlockOptions *bo, 2097 const struct GNUNET_FS_BlockOptions *bo,
2091 enum GNUNET_FS_PublishOptions options, 2098 enum GNUNET_FS_PublishOptions options,
@@ -2181,7 +2188,7 @@ typedef void (*GNUNET_FS_IdentifierProcessor) (void *cls,
2181 const struct 2188 const struct
2182 GNUNET_FS_Uri *last_uri, 2189 GNUNET_FS_Uri *last_uri,
2183 const struct 2190 const struct
2184 GNUNET_CONTAINER_MetaData * 2191 GNUNET_FS_MetaData *
2185 last_meta, 2192 last_meta,
2186 const char *next_id); 2193 const char *next_id);
2187 2194
@@ -2291,7 +2298,7 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc);
2291struct GNUNET_FS_SearchResult * 2298struct GNUNET_FS_SearchResult *
2292GNUNET_FS_probe (struct GNUNET_FS_Handle *h, 2299GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
2293 const struct GNUNET_FS_Uri *uri, 2300 const struct GNUNET_FS_Uri *uri,
2294 const struct GNUNET_CONTAINER_MetaData *meta, 2301 const struct GNUNET_FS_MetaData *meta,
2295 void *client_info, 2302 void *client_info,
2296 uint32_t anonymity); 2303 uint32_t anonymity);
2297 2304
@@ -2379,7 +2386,7 @@ enum GNUNET_FS_DownloadOptions
2379struct GNUNET_FS_DownloadContext * 2386struct GNUNET_FS_DownloadContext *
2380GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, 2387GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
2381 const struct GNUNET_FS_Uri *uri, 2388 const struct GNUNET_FS_Uri *uri,
2382 const struct GNUNET_CONTAINER_MetaData *meta, 2389 const struct GNUNET_FS_MetaData *meta,
2383 const char *filename, const char *tempname, 2390 const char *filename, const char *tempname,
2384 uint64_t offset, uint64_t length, uint32_t anonymity, 2391 uint64_t offset, uint64_t length, uint32_t anonymity,
2385 enum GNUNET_FS_DownloadOptions options, void *cctx, 2392 enum GNUNET_FS_DownloadOptions options, void *cctx,
@@ -2473,7 +2480,7 @@ GNUNET_FS_download_resume (struct GNUNET_FS_DownloadContext *dc);
2473 * we have no mime-type information (treat as #GNUNET_NO) 2480 * we have no mime-type information (treat as #GNUNET_NO)
2474 */ 2481 */
2475int 2482int
2476GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData 2483GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_FS_MetaData
2477 *md); 2484 *md);
2478 2485
2479 2486
@@ -2484,7 +2491,7 @@ GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData
2484 * @param md metadata to add mimetype to 2491 * @param md metadata to add mimetype to
2485 */ 2492 */
2486void 2493void
2487GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md); 2494GNUNET_FS_meta_data_make_directory (struct GNUNET_FS_MetaData *md);
2488 2495
2489 2496
2490/** 2497/**
@@ -2495,7 +2502,7 @@ GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md);
2495 */ 2502 */
2496char * 2503char *
2497GNUNET_FS_meta_data_suggest_filename (const struct 2504GNUNET_FS_meta_data_suggest_filename (const struct
2498 GNUNET_CONTAINER_MetaData *md); 2505 GNUNET_FS_MetaData *md);
2499 2506
2500 2507
2501/** 2508/**
@@ -2518,7 +2525,7 @@ typedef void (*GNUNET_FS_DirectoryEntryProcessor) (void *cls,
2518 const struct GNUNET_FS_Uri * 2525 const struct GNUNET_FS_Uri *
2519 uri, 2526 uri,
2520 const struct 2527 const struct
2521 GNUNET_CONTAINER_MetaData * 2528 GNUNET_FS_MetaData *
2522 meta, size_t length, 2529 meta, size_t length,
2523 const void *data); 2530 const void *data);
2524 2531
@@ -2561,7 +2568,7 @@ struct GNUNET_FS_DirectoryBuilder;
2561 * @param mdir metadata for the directory 2568 * @param mdir metadata for the directory
2562 */ 2569 */
2563struct GNUNET_FS_DirectoryBuilder * 2570struct GNUNET_FS_DirectoryBuilder *
2564GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData 2571GNUNET_FS_directory_builder_create (const struct GNUNET_FS_MetaData
2565 *mdir); 2572 *mdir);
2566 2573
2567 2574
@@ -2578,7 +2585,7 @@ GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData
2578void 2585void
2579GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld, 2586GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
2580 const struct GNUNET_FS_Uri *uri, 2587 const struct GNUNET_FS_Uri *uri,
2581 const struct GNUNET_CONTAINER_MetaData *md, 2588 const struct GNUNET_FS_MetaData *md,
2582 const void *data); 2589 const void *data);
2583 2590
2584 2591
@@ -2693,7 +2700,7 @@ struct GNUNET_FS_ShareTreeItem
2693 /** 2700 /**
2694 * Metadata for this file or directory 2701 * Metadata for this file or directory
2695 */ 2702 */
2696 struct GNUNET_CONTAINER_MetaData *meta; 2703 struct GNUNET_FS_MetaData *meta;
2697 2704
2698 /** 2705 /**
2699 * Keywords for this file or directory (derived from metadata). 2706 * Keywords for this file or directory (derived from metadata).
@@ -2782,6 +2789,336 @@ GNUNET_FS_share_tree_trim (struct GNUNET_FS_ShareTreeItem *toplevel);
2782void 2789void
2783GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel); 2790GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel);
2784 2791
2792/**
2793 * Meta data processing
2794 * @defgroup metadata Metadata
2795 * GNU libextractor key-value pairs
2796 */
2797
2798
2799/* ****************** metadata ******************* */
2800
2801
2802/**
2803 * @ingroup metadata
2804 * Create a fresh meta data container.
2805 *
2806 * @return empty meta-data container
2807 */
2808struct GNUNET_FS_MetaData *
2809GNUNET_FS_meta_data_create (void);
2810
2811
2812/**
2813 * @ingroup metadata
2814 * Duplicate a MetaData token.
2815 *
2816 * @param md what to duplicate
2817 * @return duplicate meta-data container
2818 */
2819struct GNUNET_FS_MetaData *
2820GNUNET_FS_meta_data_duplicate (
2821 const struct GNUNET_FS_MetaData *md);
2822
2823
2824/**
2825 * @ingroup metadata
2826 * Free meta data.
2827 *
2828 * @param md what to free
2829 */
2830void
2831GNUNET_FS_meta_data_destroy (struct GNUNET_FS_MetaData *md);
2832
2833
2834/**
2835 * @ingroup metadata
2836 * Test if two MDs are equal. We consider them equal if
2837 * the meta types, formats and content match (we do not
2838 * include the mime types and plugins names in this
2839 * consideration).
2840 *
2841 * @param md1 first value to check
2842 * @param md2 other value to check
2843 * @return #GNUNET_YES if they are equal
2844 */
2845int
2846GNUNET_FS_meta_data_test_equal (
2847 const struct GNUNET_FS_MetaData *md1,
2848 const struct GNUNET_FS_MetaData *md2);
2849
2850
2851/**
2852 * @ingroup metadata
2853 * Extend metadata.
2854 *
2855 * @param md metadata to extend
2856 * @param plugin_name name of the plugin that produced this value;
2857 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
2858 * used in the main libextractor library and yielding
2859 * meta data).
2860 * @param type libextractor-type describing the meta data
2861 * @param format basic format information about data
2862 * @param data_mime_type mime-type of data (not of the original file);
2863 * can be NULL (if mime-type is not known)
2864 * @param data actual meta-data found
2865 * @param data_size number of bytes in data
2866 * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exists
2867 * data_mime_type and plugin_name are not considered for "exists" checks
2868 */
2869int
2870GNUNET_FS_meta_data_insert (struct GNUNET_FS_MetaData *md,
2871 const char *plugin_name,
2872 enum EXTRACTOR_MetaType type,
2873 enum EXTRACTOR_MetaFormat format,
2874 const char *data_mime_type,
2875 const char *data,
2876 size_t data_size);
2877
2878
2879/**
2880 * @ingroup metadata
2881 * Extend metadata. Merges the meta data from the second argument
2882 * into the first, discarding duplicate key-value pairs.
2883 *
2884 * @param md metadata to extend
2885 * @param in metadata to merge
2886 */
2887void
2888GNUNET_FS_meta_data_merge (struct GNUNET_FS_MetaData *md,
2889 const struct GNUNET_FS_MetaData *in);
2890
2891
2892/**
2893 * @ingroup metadata
2894 * Remove an item.
2895 *
2896 * @param md metadata to manipulate
2897 * @param type type of the item to remove
2898 * @param data specific value to remove, NULL to remove all
2899 * entries of the given type
2900 * @param data_size number of bytes in data
2901 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the item does not exist in md
2902 */
2903int
2904GNUNET_FS_meta_data_delete (struct GNUNET_FS_MetaData *md,
2905 enum EXTRACTOR_MetaType type,
2906 const char *data,
2907 size_t data_size);
2908
2909
2910/**
2911 * @ingroup metadata
2912 * Remove all items in the container.
2913 *
2914 * @param md metadata to manipulate
2915 */
2916void
2917GNUNET_FS_meta_data_clear (struct GNUNET_FS_MetaData *md);
2918
2919
2920/**
2921 * @ingroup metadata
2922 * Add the current time as the publication date
2923 * to the meta-data.
2924 *
2925 * @param md metadata to modify
2926 */
2927void
2928GNUNET_FS_meta_data_add_publication_date (
2929 struct GNUNET_FS_MetaData *md);
2930
2931
2932/**
2933 * @ingroup metadata
2934 * Iterate over MD entries.
2935 *
2936 * @param md metadata to inspect
2937 * @param iter function to call on each entry, return 0 to continue to iterate
2938 * and 1 to abort iteration in this function (GNU libextractor API!)
2939 * @param iter_cls closure for @a iter
2940 * @return number of entries
2941 */
2942int
2943GNUNET_FS_meta_data_iterate (const struct GNUNET_FS_MetaData *md,
2944 EXTRACTOR_MetaDataProcessor iter,
2945 void *iter_cls);
2946
2947
2948/**
2949 * @ingroup metadata
2950 * Get the first MD entry of the given type. Caller
2951 * is responsible for freeing the return value.
2952 * Also, only meta data items that are strings (0-terminated)
2953 * are returned by this function.
2954 *
2955 * @param md metadata to inspect
2956 * @param type type to look for
2957 * @return NULL if no entry was found
2958 */
2959char *
2960GNUNET_FS_meta_data_get_by_type (
2961 const struct GNUNET_FS_MetaData *md,
2962 enum EXTRACTOR_MetaType type);
2963
2964
2965/**
2966 * @ingroup metadata
2967 * Get the first matching MD entry of the given types. Caller is
2968 * responsible for freeing the return value. Also, only meta data
2969 * items that are strings (0-terminated) are returned by this
2970 * function.
2971 *
2972 * @param md metadata to inspect
2973 * @param ... -1-terminated list of types
2974 * @return NULL if we do not have any such entry,
2975 * otherwise client is responsible for freeing the value!
2976 */
2977char *
2978GNUNET_FS_meta_data_get_first_by_types (
2979 const struct GNUNET_FS_MetaData *md,
2980 ...);
2981
2982/**
2983 * @ingroup metadata
2984 * Get a thumbnail from the meta-data (if present). Only matches meta
2985 * data with mime type "image" and binary format.
2986 *
2987 * @param md metadata to inspect
2988 * @param thumb will be set to the thumbnail data. Must be
2989 * freed by the caller!
2990 * @return number of bytes in thumbnail, 0 if not available
2991 */
2992size_t
2993GNUNET_FS_meta_data_get_thumbnail (
2994 const struct GNUNET_FS_MetaData *md,
2995 unsigned char **thumb);
2996
2997
2998/**
2999 * @ingroup metadata
3000 * Options for metadata serialization.
3001 */
3002enum GNUNET_FS_MetaDataSerializationOptions
3003{
3004 /**
3005 * @ingroup metadata
3006 * Serialize all of the data.
3007 */
3008 GNUNET_FS_META_DATA_SERIALIZE_FULL = 0,
3009
3010 /**
3011 * @ingroup metadata
3012 * If not enough space is available, it is acceptable
3013 * to only serialize some of the metadata.
3014 */
3015 GNUNET_FS_META_DATA_SERIALIZE_PART = 1,
3016
3017 /**
3018 * @ingroup metadata
3019 * Speed is of the essence, do not allow compression.
3020 */
3021 GNUNET_FS_META_DATA_SERIALIZE_NO_COMPRESS = 2
3022};
3023
3024
3025/**
3026 * @ingroup metadata
3027 * Serialize meta-data to target.
3028 *
3029 * @param md metadata to serialize
3030 * @param target where to write the serialized metadata;
3031 * *target can be NULL, in which case memory is allocated
3032 * @param max maximum number of bytes available
3033 * @param opt is it ok to just write SOME of the
3034 * meta-data to match the size constraint,
3035 * possibly discarding some data?
3036 * @return number of bytes written on success,
3037 * -1 on error (typically: not enough
3038 * space)
3039 */
3040ssize_t
3041GNUNET_FS_meta_data_serialize (
3042 const struct GNUNET_FS_MetaData *md,
3043 char **target,
3044 size_t max,
3045 enum GNUNET_FS_MetaDataSerializationOptions opt);
3046
3047
3048/**
3049 * @ingroup metadata
3050 * Get the size of the full meta-data in serialized form.
3051 *
3052 * @param md metadata to inspect
3053 * @return number of bytes needed for serialization, -1 on error
3054 */
3055ssize_t
3056GNUNET_FS_meta_data_get_serialized_size (
3057 const struct GNUNET_FS_MetaData *md);
3058
3059
3060/**
3061 * @ingroup metadata
3062 * Deserialize meta-data. Initializes md.
3063 *
3064 * @param input serialized meta-data.
3065 * @param size number of bytes available
3066 * @return MD on success, NULL on error (e.g.
3067 * bad format)
3068 */
3069struct GNUNET_FS_MetaData *
3070GNUNET_FS_meta_data_deserialize (const char *input, size_t size);
3071
3072/**
3073 * Write a metadata container.
3074 *
3075 * @param h the IO handle to write to
3076 * @param what what is being written (for error message creation)
3077 * @param m metadata to write
3078 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
3079 */
3080enum GNUNET_GenericReturnValue
3081GNUNET_FS_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
3082 const char *what,
3083 const struct GNUNET_FS_MetaData *m);
3084
3085/**
3086 * Create the specification to read a metadata container.
3087 *
3088 * @param what describes what is being read (for error message creation)
3089 * @param result the buffer to store a pointer to the (allocated) metadata
3090 * @return the read spec
3091 */
3092struct GNUNET_BIO_ReadSpec
3093GNUNET_FS_read_spec_meta_data (const char *what,
3094 struct GNUNET_FS_MetaData **result);
3095
3096
3097
3098/**
3099 * Create the specification to write a metadata container.
3100 *
3101 * @param what what is being written (for error message creation)
3102 * @param m metadata to write
3103 * @return the write spec
3104 */
3105struct GNUNET_BIO_WriteSpec
3106GNUNET_FS_write_spec_meta_data (const char *what,
3107 const struct GNUNET_FS_MetaData *m);
3108
3109/**
3110 * Read a metadata container.
3111 *
3112 * @param h handle to an open file
3113 * @param what describes what is being read (for error message creation)
3114 * @param result the buffer to store a pointer to the (allocated) metadata
3115 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
3116 */
3117enum GNUNET_GenericReturnValue
3118GNUNET_FS_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
3119 const char *what,
3120 struct GNUNET_FS_MetaData **result);
3121
2785 3122
2786#if 0 /* keep Emacsens' auto-indent happy */ 3123#if 0 /* keep Emacsens' auto-indent happy */
2787{ 3124{
diff --git a/src/include/gnunet_mysql_compat.h b/src/include/gnunet_mysql_compat.h
new file mode 100644
index 000000000..bb1e8de8a
--- /dev/null
+++ b/src/include/gnunet_mysql_compat.h
@@ -0,0 +1,63 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 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 * @author Martin Schanzenbach
22 *
23 * @file
24 * MySQL/MariaDB compatibility insanity helper header
25 *
26 * @defgroup mysql MySQL library
27 * Helper library to access a MySQL database.
28 * @{
29 */
30#ifndef GNUNET_MYSQL_COMPAT_H
31#define GNUNET_MYSQL_COMPAT_H
32
33
34#include <mysql/mysql.h>
35
36#ifdef __cplusplus
37extern "C"
38{
39#if 0 /* keep Emacsens' auto-indent happy */
40}
41#endif
42#endif
43
44#ifndef LIBMARIADB
45#if MYSQL_VERSION_ID < 80000
46#define MYSQL_BOOL bool;
47#else
48#define MYSQL_BOOL my_bool; //MySQL < 8 wants this
49#endif
50#else
51#define MYSQL_BOOL my_bool //MariaDB still uses my_bool
52#endif
53
54#if 0 /* keep Emacsens' auto-indent happy */
55{
56#endif
57#ifdef __cplusplus
58}
59#endif
60
61#endif
62
63/** @} */ /* end of group */
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h
index 52fa5c373..337552a0c 100644
--- a/src/include/gnunet_util_lib.h
+++ b/src/include/gnunet_util_lib.h
@@ -92,6 +92,43 @@ extern "C"
92#include "gnunet_child_management_lib.h" 92#include "gnunet_child_management_lib.h"
93#include "gnunet_error_codes.h" 93#include "gnunet_error_codes.h"
94 94
95/**
96 * Try to compress the given block of data using libz. Only returns
97 * the compressed block if compression worked and the new block is
98 * actually smaller. Decompress using #GNUNET_decompress().
99 *
100 * @param data block to compress; if compression
101 * resulted in a smaller block, the first
102 * bytes of data are updated to the compressed
103 * data
104 * @param old_size number of bytes in data
105 * @param[out] result set to the compressed data, if compression worked
106 * @param[out] new_size set to size of result, if compression worked
107 * @return #GNUNET_YES if compression reduce the size,
108 * #GNUNET_NO if compression did not help
109 */
110int
111GNUNET_try_compression (const char *data,
112 size_t old_size,
113 char **result,
114 size_t *new_size);
115
116/**
117 * Decompress input, return the decompressed data as output. Dual to
118 * #GNUNET_try_compression(). Caller must set @a output_size to the
119 * number of bytes that were originally compressed.
120 *
121 * @param input compressed data
122 * @param input_size number of bytes in input
123 * @param output_size expected size of the output
124 * @return NULL on error, buffer of @a output_size decompressed bytes otherwise
125 */
126char *
127GNUNET_decompress (const char *input,
128 size_t input_size,
129 size_t output_size);
130
131
95#if 0 /* keep Emacsens' auto-indent happy */ 132#if 0 /* keep Emacsens' auto-indent happy */
96{ 133{
97#endif 134#endif
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 90f111cad..284a7806d 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -48,12 +48,12 @@ libgnunetutil_la_SOURCES = \
48 common_allocation.c \ 48 common_allocation.c \
49 common_endian.c \ 49 common_endian.c \
50 common_logging.c \ 50 common_logging.c \
51 compress.c \
51 configuration.c \ 52 configuration.c \
52 configuration_helper.c \ 53 configuration_helper.c \
53 consttime_memcmp.c \ 54 consttime_memcmp.c \
54 container_bloomfilter.c \ 55 container_bloomfilter.c \
55 container_heap.c \ 56 container_heap.c \
56 container_meta_data.c \
57 container_multihashmap.c \ 57 container_multihashmap.c \
58 container_multishortmap.c \ 58 container_multishortmap.c \
59 container_multiuuidmap.c \ 59 container_multiuuidmap.c \
@@ -423,11 +423,6 @@ test_container_dll_SOURCES = \
423test_container_dll_LDADD = \ 423test_container_dll_LDADD = \
424 libgnunetutil.la 424 libgnunetutil.la
425 425
426test_container_meta_data_SOURCES = \
427 test_container_meta_data.c
428test_container_meta_data_LDADD = \
429 libgnunetutil.la
430
431test_container_multihashmap_SOURCES = \ 426test_container_multihashmap_SOURCES = \
432 test_container_multihashmap.c 427 test_container_multihashmap.c
433test_container_multihashmap_LDADD = \ 428test_container_multihashmap_LDADD = \
diff --git a/src/util/bio.c b/src/util/bio.c
index 1abe6e324..a19e4f3ba 100644
--- a/src/util/bio.c
+++ b/src/util/bio.c
@@ -41,12 +41,6 @@
41 */ 41 */
42#define BIO_BUFFER_SIZE 65536 42#define BIO_BUFFER_SIZE 65536
43 43
44/**
45 * Maximum size allowed for meta data written/read from disk.
46 * File-sharing limits to 64k, so this should be rather generous.
47 */
48#define MAX_META_DATA (1024 * 1024)
49
50 44
51/** 45/**
52 * Enum used internally to know how buffering is handled. 46 * Enum used internally to know how buffering is handled.
@@ -160,7 +154,7 @@ GNUNET_BIO_read_open_buffer (void *buffer, size_t size)
160 * 154 *
161 * @param h file handle 155 * @param h file handle
162 * @param emsg set to the (allocated) error message 156 * @param emsg set to the (allocated) error message
163 * if the handle has an error message, the return 157 * if the handle has an error message, the return
164 * value is #GNUNET_SYSERR 158 * value is #GNUNET_SYSERR
165 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 159 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
166 */ 160 */
@@ -379,60 +373,6 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
379} 373}
380 374
381 375
382/**
383 * Read a metadata container.
384 *
385 * @param h handle to an open file
386 * @param what describes what is being read (for error message creation)
387 * @param result the buffer to store a pointer to the (allocated) metadata
388 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
389 */
390int
391GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
392 const char *what,
393 struct GNUNET_CONTAINER_MetaData **result)
394{
395 uint32_t size;
396 char *buf;
397 struct GNUNET_CONTAINER_MetaData *meta;
398
399 if (GNUNET_OK != GNUNET_BIO_read_int32 (h,
400 _ ("metadata length"),
401 (int32_t *) &size))
402 return GNUNET_SYSERR;
403 if (0 == size)
404 {
405 *result = NULL;
406 return GNUNET_OK;
407 }
408 if (MAX_META_DATA < size)
409 {
410 GNUNET_asprintf (
411 &h->emsg,
412 _ ("Serialized metadata `%s' larger than allowed (%u > %u)"),
413 what,
414 size,
415 MAX_META_DATA);
416 return GNUNET_SYSERR;
417 }
418 buf = GNUNET_malloc (size);
419 if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, size))
420 {
421 GNUNET_free (buf);
422 return GNUNET_SYSERR;
423 }
424 meta = GNUNET_CONTAINER_meta_data_deserialize (buf, size);
425 if (NULL == meta)
426 {
427 GNUNET_free (buf);
428 GNUNET_asprintf (&h->emsg, _ ("Failed to deserialize metadata `%s'"), what);
429 return GNUNET_SYSERR;
430 }
431 GNUNET_free (buf);
432 *result = meta;
433 return GNUNET_OK;
434}
435
436 376
437/** 377/**
438 * Read a float. 378 * Read a float.
@@ -846,51 +786,6 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
846} 786}
847 787
848 788
849/**
850 * Write a metadata container.
851 *
852 * @param h the IO handle to write to
853 * @param what what is being written (for error message creation)
854 * @param m metadata to write
855 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
856 */
857int
858GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
859 const char *what,
860 const struct GNUNET_CONTAINER_MetaData *m)
861{
862 ssize_t size;
863 char *buf;
864
865 if (m == NULL)
866 return GNUNET_BIO_write_int32 (h, _ ("metadata length"), 0);
867 buf = NULL;
868 size = GNUNET_CONTAINER_meta_data_serialize (
869 m,
870 &buf,
871 MAX_META_DATA,
872 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
873 if (-1 == size)
874 {
875 GNUNET_free (buf);
876 GNUNET_free (h->emsg);
877 GNUNET_asprintf (&h->emsg,
878 _ ("Failed to serialize metadata `%s'"),
879 what);
880 return GNUNET_SYSERR;
881 }
882 if ((GNUNET_OK != GNUNET_BIO_write_int32 (h,
883 _ ("metadata length"),
884 (uint32_t) size))
885 || (GNUNET_OK != GNUNET_BIO_write (h, what, buf, size)))
886 {
887 GNUNET_free (buf);
888 return GNUNET_SYSERR;
889 }
890 GNUNET_free (buf);
891 return GNUNET_OK;
892}
893
894 789
895/** 790/**
896 * Write a float. 791 * Write a float.
@@ -1060,51 +955,6 @@ GNUNET_BIO_read_spec_string (const char *what,
1060 955
1061 956
1062/** 957/**
1063 * Function used internally to read a metadata container from within a read
1064 * spec.
1065 *
1066 * @param cls ignored, always NULL
1067 * @param h the IO handle to read from
1068 * @param what what is being read (for error message creation)
1069 * @param target where to store the data
1070 * @param target_size ignored
1071 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1072 */
1073static int
1074read_spec_handler_meta_data (void *cls,
1075 struct GNUNET_BIO_ReadHandle *h,
1076 const char *what,
1077 void *target,
1078 size_t target_size)
1079{
1080 struct GNUNET_CONTAINER_MetaData **result = target;
1081 return GNUNET_BIO_read_meta_data (h, what, result);
1082}
1083
1084
1085/**
1086 * Create the specification to read a metadata container.
1087 *
1088 * @param what describes what is being read (for error message creation)
1089 * @param result the buffer to store a pointer to the (allocated) metadata
1090 * @return the read spec
1091 */
1092struct GNUNET_BIO_ReadSpec
1093GNUNET_BIO_read_spec_meta_data (const char *what,
1094 struct GNUNET_CONTAINER_MetaData **result)
1095{
1096 struct GNUNET_BIO_ReadSpec rs = {
1097 .rh = &read_spec_handler_meta_data,
1098 .cls = NULL,
1099 .target = result,
1100 .size = 0,
1101 };
1102
1103 return rs;
1104}
1105
1106
1107/**
1108 * Function used internally to read an (u)int32_t from within a read spec. 958 * Function used internally to read an (u)int32_t from within a read spec.
1109 * 959 *
1110 * @param cls ignored, always NULL 960 * @param cls ignored, always NULL
@@ -1350,52 +1200,6 @@ GNUNET_BIO_write_spec_string (const char *what,
1350 1200
1351 1201
1352/** 1202/**
1353 * Function used internally to write a metadata container from within a write
1354 * spec.
1355 *
1356 * @param cls ignored, always NULL
1357 * @param h the IO handle to write to
1358 * @param what what is being written (for error message creation)
1359 * @param source the data to write
1360 * @param source_size ignored
1361 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
1362 */
1363static int
1364write_spec_handler_meta_data (void *cls,
1365 struct GNUNET_BIO_WriteHandle *h,
1366 const char *what,
1367 void *source,
1368 size_t source_size)
1369{
1370 const struct GNUNET_CONTAINER_MetaData *m = source;
1371 return GNUNET_BIO_write_meta_data (h, what, m);
1372}
1373
1374
1375/**
1376 * Create the specification to write a metadata container.
1377 *
1378 * @param what what is being written (for error message creation)
1379 * @param m metadata to write
1380 * @return the write spec
1381 */
1382struct GNUNET_BIO_WriteSpec
1383GNUNET_BIO_write_spec_meta_data (const char *what,
1384 const struct GNUNET_CONTAINER_MetaData *m)
1385{
1386 struct GNUNET_BIO_WriteSpec ws = {
1387 .wh = &write_spec_handler_meta_data,
1388 .cls = NULL,
1389 .what = what,
1390 .source = (void *) m,
1391 .source_size = 0,
1392 };
1393
1394 return ws;
1395}
1396
1397
1398/**
1399 * Function used internally to write an (u)int32_t from within a write spec. 1203 * Function used internally to write an (u)int32_t from within a write spec.
1400 * 1204 *
1401 * @param cls ignored, always NULL 1205 * @param cls ignored, always NULL
diff --git a/src/util/compress.c b/src/util/compress.c
new file mode 100644
index 000000000..73fa25bd9
--- /dev/null
+++ b/src/util/compress.c
@@ -0,0 +1,91 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 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/compress.c
23 * @brief Simple (de)compression logic
24 * @author Philipp Toelke
25 * @author Martin Schanzenbach
26 */
27
28#include "platform.h"
29#include "gnunet_util_lib.h"
30#include <zlib.h>
31
32int
33GNUNET_try_compression (const char *data,
34 size_t old_size,
35 char **result,
36 size_t *new_size)
37{
38 char *tmp;
39 uLongf dlen;
40
41 *result = NULL;
42 *new_size = 0;
43#ifdef compressBound
44 dlen = compressBound (old_size);
45#else
46 dlen = old_size + (old_size / 100) + 20;
47 /* documentation says 100.1% oldSize + 12 bytes, but we
48 * should be able to overshoot by more to be safe */
49#endif
50 tmp = GNUNET_malloc (dlen);
51 if (Z_OK ==
52 compress2 ((Bytef *) tmp,
53 &dlen,
54 (const Bytef *) data,
55 old_size, 9))
56 {
57 if (dlen < old_size)
58 {
59 *result = tmp;
60 *new_size = dlen;
61 return GNUNET_YES;
62 }
63 }
64 GNUNET_free (tmp);
65 return GNUNET_NO;
66}
67
68
69char *
70GNUNET_decompress (const char *input,
71 size_t input_size,
72 size_t output_size)
73{
74 char *output;
75 uLongf olen;
76
77 olen = output_size;
78 output = GNUNET_malloc (olen);
79 if (Z_OK ==
80 uncompress ((Bytef *) output,
81 &olen,
82 (const Bytef *) input,
83 input_size))
84 return output;
85 GNUNET_free (output);
86 return NULL;
87}
88
89
90
91/* end of compress.c */
diff --git a/src/util/crypto_crc.c b/src/util/crypto_crc.c
index d33a19db2..9328f2b84 100644
--- a/src/util/crypto_crc.c
+++ b/src/util/crypto_crc.c
@@ -84,7 +84,7 @@ crc_init ()
84 * property of detecting all burst errors of length 32 bits or less. 84 * property of detecting all burst errors of length 32 bits or less.
85 */ 85 */
86static GNUNET_uLong 86static GNUNET_uLong
87crc32 (GNUNET_uLong crc, const char *buf, size_t len) 87gn_crc32 (GNUNET_uLong crc, const char *buf, size_t len)
88{ 88{
89 crc_init (); 89 crc_init ();
90 GNUNET_assert (crc_table[255] != 0); 90 GNUNET_assert (crc_table[255] != 0);
@@ -100,8 +100,8 @@ GNUNET_CRYPTO_crc32_n (const void *buf, size_t len)
100{ 100{
101 GNUNET_uLong crc; 101 GNUNET_uLong crc;
102 102
103 crc = crc32 (0L, Z_NULL, 0); 103 crc = gn_crc32 (0L, Z_NULL, 0);
104 crc = crc32 (crc, (char *) buf, len); 104 crc = gn_crc32 (crc, (char *) buf, len);
105 return crc; 105 return crc;
106} 106}
107 107
diff --git a/src/util/test_container_meta_data.c b/src/util/test_container_meta_data.c
deleted file mode 100644
index 54b0dd100..000000000
--- a/src/util/test_container_meta_data.c
+++ /dev/null
@@ -1,376 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2003, 2004, 2006, 2009, 2010 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_container_meta_data.c
23 * @brief Test for container_meta_data.c
24 * @author Christian Grothoff
25 */
26
27
28#include "platform.h"
29#include "gnunet_util_lib.h"
30
31#define ABORT(m) { fprintf (stderr, "Error at %s:%d\n", __FILE__, __LINE__); \
32 if (m != NULL) GNUNET_CONTAINER_meta_data_destroy (m); \
33 return 1; }
34
35
36static int
37testMeta (int i)
38{
39 struct GNUNET_CONTAINER_MetaData *m;
40 char val[256];
41 char *sval;
42 int j;
43 unsigned int size;
44
45 m = GNUNET_CONTAINER_meta_data_create ();
46 if (GNUNET_OK !=
47 GNUNET_CONTAINER_meta_data_insert (m, "<test>", EXTRACTOR_METATYPE_TITLE,
48 EXTRACTOR_METAFORMAT_UTF8,
49 "text/plain", "TestTitle",
50 strlen ("TestTitle") + 1))
51 ABORT (m);
52 if (GNUNET_OK !=
53 GNUNET_CONTAINER_meta_data_insert (m, "<test>",
54 EXTRACTOR_METATYPE_AUTHOR_NAME,
55 EXTRACTOR_METAFORMAT_UTF8,
56 "text/plain", "TestTitle",
57 strlen ("TestTitle") + 1))
58 ABORT (m);
59 if (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (m, "<test>",
60 EXTRACTOR_METATYPE_TITLE,
61 EXTRACTOR_METAFORMAT_UTF8,
62 "text/plain",
63 "TestTitle", strlen (
64 "TestTitle") + 1)) /* dup! */
65 ABORT (m);
66 if (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (m, "<test>",
67 EXTRACTOR_METATYPE_AUTHOR_NAME,
68 EXTRACTOR_METAFORMAT_UTF8,
69 "text/plain",
70 "TestTitle", strlen (
71 "TestTitle") + 1)) /* dup! */
72 ABORT (m);
73 if (2 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
74 ABORT (m);
75 if (GNUNET_OK !=
76 GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME,
77 "TestTitle", strlen ("TestTitle") + 1))
78 ABORT (m);
79 if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m,
80 EXTRACTOR_METATYPE_AUTHOR_NAME,
81 "TestTitle", strlen (
82 "TestTitle") + 1)) /* already gone */
83 ABORT (m);
84 if (1 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
85 ABORT (m);
86 if (GNUNET_OK !=
87 GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE,
88 "TestTitle", strlen ("TestTitle") + 1))
89 ABORT (m);
90 if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m,
91 EXTRACTOR_METATYPE_TITLE,
92 "TestTitle", strlen (
93 "TestTitle") + 1)) /* already gone */
94 ABORT (m);
95 if (0 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
96 ABORT (m);
97 for (j = 0; j < i; j++)
98 {
99 GNUNET_snprintf (val, sizeof(val), "%s.%d",
100 "A teststring that should compress well.", j);
101 if (GNUNET_OK !=
102 GNUNET_CONTAINER_meta_data_insert (m, "<test>",
103 EXTRACTOR_METATYPE_UNKNOWN,
104 EXTRACTOR_METAFORMAT_UTF8,
105 "text/plain", val, strlen (val) + 1))
106 ABORT (m);
107 }
108 if (i != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
109 ABORT (m);
110
111 size = GNUNET_CONTAINER_meta_data_get_serialized_size (m);
112 sval = NULL;
113 if (size !=
114 GNUNET_CONTAINER_meta_data_serialize (m, &sval, size,
115 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL))
116 {
117 GNUNET_free (sval);
118 ABORT (m);
119 }
120 GNUNET_CONTAINER_meta_data_destroy (m);
121 m = GNUNET_CONTAINER_meta_data_deserialize (sval, size);
122 GNUNET_free (sval);
123 if (m == NULL)
124 ABORT (m);
125 for (j = 0; j < i; j++)
126 {
127 GNUNET_snprintf (val,
128 sizeof(val),
129 "%s.%d",
130 "A teststring that should compress well.",
131 j);
132 if (GNUNET_OK !=
133 GNUNET_CONTAINER_meta_data_delete (m,
134 EXTRACTOR_METATYPE_UNKNOWN,
135 val,
136 strlen (val) + 1))
137 {
138 ABORT (m);
139 }
140 }
141 if (0 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
142 ABORT (m);
143 GNUNET_CONTAINER_meta_data_destroy (m);
144 return 0;
145}
146
147
148static int
149testMetaMore (int i)
150{
151 struct GNUNET_CONTAINER_MetaData *meta;
152 int q;
153 char txt[128];
154 char *data;
155 unsigned long long size;
156
157 meta = GNUNET_CONTAINER_meta_data_create ();
158 for (q = 0; q <= i; q++)
159 {
160 GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
161 GNUNET_CONTAINER_meta_data_insert (meta, "<test>",
162 q
163 % 42 /* EXTRACTOR_metatype_get_max () */,
164 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
165 txt, strlen (txt) + 1);
166 }
167 size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
168 data = GNUNET_malloc (size * 4);
169 if (size !=
170 GNUNET_CONTAINER_meta_data_serialize (meta, &data, size * 4,
171 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL))
172 {
173 GNUNET_free (data);
174 ABORT (meta);
175 }
176 GNUNET_CONTAINER_meta_data_destroy (meta);
177 GNUNET_free (data);
178 return 0;
179}
180
181
182static int
183testMetaLink ()
184{
185 struct GNUNET_CONTAINER_MetaData *m;
186 char *val;
187 unsigned int size;
188
189 m = GNUNET_CONTAINER_meta_data_create ();
190 if (GNUNET_OK !=
191 GNUNET_CONTAINER_meta_data_insert (m, "<test>",
192 EXTRACTOR_METATYPE_UNKNOWN,
193 EXTRACTOR_METAFORMAT_UTF8,
194 "text/plain", "link",
195 strlen ("link") + 1))
196 ABORT (m);
197 if (GNUNET_OK !=
198 GNUNET_CONTAINER_meta_data_insert (m, "<test>",
199 EXTRACTOR_METATYPE_FILENAME,
200 EXTRACTOR_METAFORMAT_UTF8,
201 "text/plain", "lib-link.m4",
202 strlen ("lib-link.m4") + 1))
203 ABORT (m);
204 val = NULL;
205 size =
206 GNUNET_CONTAINER_meta_data_serialize (m, &val, (size_t) -1,
207 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
208 GNUNET_CONTAINER_meta_data_destroy (m);
209 m = GNUNET_CONTAINER_meta_data_deserialize (val, size);
210 GNUNET_free (val);
211 if (m == NULL)
212 ABORT (m);
213 GNUNET_CONTAINER_meta_data_destroy (m);
214 return 0;
215}
216
217
218static int
219check ()
220{
221 struct GNUNET_CONTAINER_MetaData *meta;
222 struct GNUNET_CONTAINER_MetaData *meta2;
223 int q;
224 int i = 100;
225 char txt[128];
226 char *str;
227 unsigned char *thumb;
228
229 meta = GNUNET_CONTAINER_meta_data_create ();
230 meta2 = GNUNET_CONTAINER_meta_data_create ();
231 for (q = 0; q <= i; q++)
232 {
233 GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
234 GNUNET_CONTAINER_meta_data_insert (meta, "<test>",
235 EXTRACTOR_METATYPE_UNKNOWN,
236 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
237 "TestTitle", strlen ("TestTitle") + 1);
238 GNUNET_CONTAINER_meta_data_insert (meta2, "<test>",
239 EXTRACTOR_METATYPE_UNKNOWN,
240 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
241 "TestTitle", strlen ("TestTitle") + 1);
242 }
243
244 // check meta_data_test_equal
245 if (GNUNET_YES != GNUNET_CONTAINER_meta_data_test_equal (meta, meta2))
246 {
247 GNUNET_CONTAINER_meta_data_destroy (meta2);
248 ABORT (meta);
249 }
250
251 // check meta_data_clear
252 GNUNET_CONTAINER_meta_data_clear (meta2);
253 if (0 != GNUNET_CONTAINER_meta_data_iterate (meta2, NULL, NULL))
254 {
255 GNUNET_CONTAINER_meta_data_destroy (meta2);
256 ABORT (meta);
257 }
258 // check equal branch in meta_data_test_equal
259 if (GNUNET_YES != GNUNET_CONTAINER_meta_data_test_equal (meta, meta))
260 {
261 GNUNET_CONTAINER_meta_data_destroy (meta2);
262 ABORT (meta);
263 }
264 // check "count" branch in meta_data_test_equal
265 if (GNUNET_NO != GNUNET_CONTAINER_meta_data_test_equal (meta, meta2))
266 {
267 GNUNET_CONTAINER_meta_data_destroy (meta2);
268 ABORT (meta);
269 }
270
271 // check meta_data_add_publication_date
272 GNUNET_CONTAINER_meta_data_add_publication_date (meta2);
273
274 // check meta_data_merge
275 GNUNET_CONTAINER_meta_data_clear (meta2);
276 GNUNET_CONTAINER_meta_data_merge (meta2, meta);
277 if (100 == GNUNET_CONTAINER_meta_data_iterate (meta2, NULL, NULL))
278 {
279 GNUNET_CONTAINER_meta_data_destroy (meta2);
280 ABORT (meta);
281 }
282
283 // check meta_data_get_by_type
284 GNUNET_CONTAINER_meta_data_clear (meta2);
285 if (NULL !=
286 (str =
287 GNUNET_CONTAINER_meta_data_get_by_type (meta2,
288 EXTRACTOR_METATYPE_UNKNOWN)))
289 {
290 GNUNET_CONTAINER_meta_data_destroy (meta2);
291 GNUNET_free (str);
292 ABORT (meta);
293 }
294
295 str =
296 GNUNET_CONTAINER_meta_data_get_by_type (meta, EXTRACTOR_METATYPE_UNKNOWN);
297 GNUNET_assert (NULL != str);
298 if (str[0] != 'T')
299 {
300 GNUNET_CONTAINER_meta_data_destroy (meta2);
301 GNUNET_free (str);
302 ABORT (meta);
303 }
304 GNUNET_free (str);
305
306 // check branch
307 if (NULL !=
308 (str =
309 GNUNET_CONTAINER_meta_data_get_by_type (meta,
310 EXTRACTOR_METATYPE_PUBLICATION_DATE)))
311 {
312 GNUNET_free (str);
313 GNUNET_CONTAINER_meta_data_destroy (meta2);
314 ABORT (meta);
315 }
316
317 // check meta_data_get_first_by_types
318 str =
319 GNUNET_CONTAINER_meta_data_get_first_by_types (meta,
320 EXTRACTOR_METATYPE_UNKNOWN,
321 -1);
322 GNUNET_assert (NULL != str);
323 if (str[0] != 'T')
324 {
325 GNUNET_CONTAINER_meta_data_destroy (meta2);
326 GNUNET_free (str);
327 ABORT (meta);
328 }
329 GNUNET_free (str);
330
331 // check meta_data_get_thumbnail
332 if (GNUNET_CONTAINER_meta_data_get_thumbnail (meta, &thumb) != 0)
333 {
334 GNUNET_free (thumb);
335 GNUNET_CONTAINER_meta_data_destroy (meta2);
336 ABORT (meta);
337 }
338 GNUNET_CONTAINER_meta_data_destroy (meta2);
339 // check meta_data_duplicate
340 meta2 = GNUNET_CONTAINER_meta_data_duplicate (meta);
341 if (200 == GNUNET_CONTAINER_meta_data_iterate (meta2, NULL, NULL))
342 {
343 GNUNET_CONTAINER_meta_data_destroy (meta2);
344 ABORT (meta);
345 }
346 GNUNET_CONTAINER_meta_data_destroy (meta2);
347 GNUNET_CONTAINER_meta_data_destroy (meta);
348 return 0;
349}
350
351
352int
353main (int argc, char *argv[])
354{
355 int failureCount = 0;
356 int i;
357
358 GNUNET_log_setup ("test-container-meta-data", "WARNING", NULL);
359 for (i = 0; i < 255; i++)
360 failureCount += testMeta (i);
361 for (i = 1; i < 255; i++)
362 failureCount += testMetaMore (i);
363 failureCount += testMetaLink ();
364
365 int ret = check ();
366
367 if (ret == 1)
368 return 1;
369
370 if (failureCount != 0)
371 return 1;
372 return 0;
373}
374
375
376/* end of test_container_meta_data.c */