[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: Large refactor in order to restore some
From: |
gnunet |
Subject: |
[gnunet] branch master updated: Large refactor in order to restore some sanity with respect to private defines used in headers |
Date: |
Sun, 04 Dec 2022 15:26:33 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 395bc9345 Large refactor in order to restore some sanity with respect
to private defines used in headers
395bc9345 is described below
commit 395bc9345a005a55e29a7882fdcc82f35c06d2e5
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Sun Dec 4 23:26:25 2022 +0900
Large refactor in order to restore some sanity with respect to private
defines used in headers
---
po/POTFILES.in | 2 +-
src/fs/Makefile.am | 18 +-
src/fs/fs.h | 1 +
src/fs/fs_api.c | 21 +-
src/fs/fs_api.h | 7 +-
src/fs/fs_directory.c | 65 +--
src/fs/fs_dirmetascan.c | 27 +-
src/fs/fs_download.c | 21 +-
src/fs/fs_file_information.c | 33 +-
src/fs/fs_getopt.c | 43 +-
src/fs/fs_list_indexed.c | 1 +
src/fs/fs_misc.c | 45 +--
src/fs/fs_namespace.c | 23 +-
src/fs/fs_publish.c | 11 +-
src/fs/fs_publish_ksk.c | 9 +-
src/fs/fs_publish_ublock.c | 8 +-
src/fs/fs_publish_ublock.h | 3 +-
src/fs/fs_search.c | 39 +-
src/fs/fs_sharetree.c | 33 +-
src/fs/fs_unindex.c | 1 +
src/fs/fs_uri.c | 13 +-
src/fs/gnunet-daemon-fsprofiler.c | 1 +
src/fs/gnunet-directory.c | 9 +-
src/fs/gnunet-download.c | 1 +
src/fs/gnunet-fs.c | 1 +
src/fs/gnunet-helper-fs-publish.c | 45 +--
src/fs/gnunet-publish.c | 27 +-
src/fs/gnunet-search.c | 123 +++---
src/fs/gnunet-unindex.c | 1 +
src/{util/container_meta_data.c => fs/meta_data.c} | 440 +++++++++++++--------
src/fs/plugin_block_fs.c | 1 +
src/fs/test_fs_directory.c | 10 +-
src/fs/test_fs_download.c | 2 +-
src/fs/test_fs_download_persistence.c | 2 +-
src/fs/test_fs_file_information.c | 4 +-
src/fs/test_fs_list_indexed.c | 2 +-
src/fs/test_fs_meta_data.c | 379 ++++++++++++++++++
src/fs/test_fs_namespace.c | 6 +-
src/fs/test_fs_namespace_list_updateable.c | 8 +-
src/fs/test_fs_publish.c | 2 +-
src/fs/test_fs_publish_persistence.c | 2 +-
src/fs/test_fs_search.c | 2 +-
src/fs/test_fs_search_persistence.c | 2 +-
src/fs/test_fs_search_probes.c | 2 +-
src/fs/test_fs_search_with_and.c | 2 +-
src/fs/test_fs_unindex.c | 2 +-
src/fs/test_fs_unindex_persistence.c | 2 +-
src/include/gnunet_bio_lib.h | 49 ---
src/include/gnunet_config.h.in | 3 -
src/include/gnunet_container_lib.h | 389 ------------------
src/include/gnunet_extractor_compat.h | 149 +++++++
src/include/gnunet_fs_service.h | 393 ++++++++++++++++--
src/include/gnunet_mysql_compat.h | 63 +++
src/include/gnunet_util_lib.h | 37 ++
src/util/Makefile.am | 7 +-
src/util/bio.c | 198 +---------
src/util/compress.c | 91 +++++
src/util/crypto_crc.c | 6 +-
src/util/test_container_meta_data.c | 376 ------------------
59 files changed, 1721 insertions(+), 1542 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 416fff5f2..97e203b0c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -157,6 +157,7 @@ src/fs/gnunet-service-fs_pr.c
src/fs/gnunet-service-fs_push.c
src/fs/gnunet-service-fs_put.c
src/fs/gnunet-unindex.c
+src/fs/meta_data.c
src/fs/plugin_block_fs.c
src/gns/gns_api.c
src/gns/gns_tld_api.c
@@ -520,7 +521,6 @@ src/util/configuration_helper.c
src/util/consttime_memcmp.c
src/util/container_bloomfilter.c
src/util/container_heap.c
-src/util/container_meta_data.c
src/util/container_multihashmap.c
src/util/container_multihashmap32.c
src/util/container_multipeermap.c
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 = \
fs_sharetree.c \
fs_tree.c fs_tree.h \
fs_unindex.c \
- fs_uri.c
+ fs_uri.c \
+ meta_data.c
libgnunetfs_la_LIBADD = \
$(top_builddir)/src/datastore/libgnunetdatastore.la \
@@ -148,8 +149,9 @@ endif
gnunet_helper_fs_publish_SOURCES = \
gnunet-helper-fs-publish.c
gnunet_helper_fs_publish_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(GN_LIBINTL)
+ libgnunetfs.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
if HAVE_LIBEXTRACTOR
gnunet_helper_fs_publish_LDADD += \
@@ -249,6 +251,7 @@ check_PROGRAMS = \
test_fs_unindex \
test_fs_unindex_persistence \
test_fs_uri \
+ test_fs_meta_data \
test_gnunet_service_fs_migration \
test_gnunet_service_fs_p2p \
test_gnunet_service_fs_p2p_cadet \
@@ -294,6 +297,7 @@ TESTS = \
test_fs_unindex_persistence \
test_fs_uri \
test_fs_test_lib \
+ test_fs_meta_data \
test_gnunet_service_fs_migration \
test_gnunet_service_fs_p2p \
test_gnunet_service_fs_p2p_cadet \
@@ -446,6 +450,13 @@ test_fs_unindex_persistence_LDADD = \
libgnunetfs.la \
$(top_builddir)/src/util/libgnunetutil.la
+test_fs_meta_data_SOURCES = \
+ test_fs_meta_data.c
+test_fs_meta_data_LDADD = \
+ libgnunetfs.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+
test_fs_uri_SOURCES = \
test_fs_uri.c
test_fs_uri_LDADD = \
@@ -520,7 +531,6 @@ perf_gnunet_service_fs_p2p_respect_LDADD = \
libgnunetfs.la \
$(top_builddir)/src/util/libgnunetutil.la
-
test_gnunet_fs_psd.py: test_gnunet_fs_psd.py.in Makefile
$(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
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 @@
#include "gnunet_constants.h"
#include "gnunet_datastore_service.h"
#include "gnunet_dht_service.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_block_lib.h"
#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 @@
#include "platform.h"
#include "gnunet_util_lib.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
#include "fs_tree.h"
@@ -902,7 +903,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
chks = NULL;
skss = NULL;
filename = NULL;
- if ((GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "metadata", &ret->meta)) ||
+ if ((GNUNET_OK != GNUNET_FS_read_meta_data (rh, "metadata", &ret->meta)) ||
(GNUNET_OK != GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024))
||
((NULL != ksks) &&
((NULL == (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL))) ||
@@ -1370,7 +1371,7 @@ GNUNET_FS_file_information_sync_ (struct
GNUNET_FS_FileInformation *fi)
skss = NULL;
struct GNUNET_BIO_WriteSpec ws1[] = {
GNUNET_BIO_write_spec_object ("b", &b, sizeof (b)),
- GNUNET_BIO_write_spec_meta_data ("meta", fi->meta),
+ GNUNET_FS_write_spec_meta_data ("meta", fi->meta),
GNUNET_BIO_write_spec_string ("ksks", ksks),
GNUNET_BIO_write_spec_string ("chks", chks),
GNUNET_BIO_write_spec_string ("skss", skss),
@@ -1571,7 +1572,7 @@ static int
fip_signal_resume (void *cls,
struct GNUNET_FS_FileInformation *fi,
uint64_t length,
- struct GNUNET_CONTAINER_MetaData *meta,
+ struct GNUNET_FS_MetaData *meta,
struct GNUNET_FS_Uri **uri,
struct GNUNET_FS_BlockOptions *bo,
int *do_index,
@@ -2081,7 +2082,7 @@ GNUNET_FS_download_sync_ (struct
GNUNET_FS_DownloadContext *dc)
uris = GNUNET_FS_uri_to_string (dc->uri);
struct GNUNET_BIO_WriteSpec ws1[] = {
GNUNET_BIO_write_spec_string ("uris", uris),
- GNUNET_BIO_write_spec_meta_data ("metadata", dc->meta),
+ GNUNET_FS_write_spec_meta_data ("metadata", dc->meta),
GNUNET_BIO_write_spec_string ("emsg", dc->emsg),
GNUNET_BIO_write_spec_string ("filename", dc->filename),
GNUNET_BIO_write_spec_string ("temp filename", dc->temp_filename),
@@ -2184,7 +2185,7 @@ GNUNET_FS_search_result_sync_ (struct
GNUNET_FS_SearchResult *sr)
(sr->update_search != NULL)
? sr->update_search->serialization
: NULL),
- GNUNET_BIO_write_spec_meta_data ("metadata", sr->meta),
+ GNUNET_FS_write_spec_meta_data ("metadata", sr->meta),
GNUNET_BIO_write_spec_object ("key", &sr->key,
sizeof(struct GNUNET_HashCode)),
GNUNET_BIO_write_spec_int32 ("mandatory missing",
@@ -2558,7 +2559,7 @@ deserialize_search_result (void *cls, const char
*filename)
GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) ||
(GNUNET_OK !=
GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) ||
- (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta))
||
+ (GNUNET_OK != GNUNET_FS_read_meta_data (rh, "result-meta", &sr->meta)) ||
(GNUNET_OK != GNUNET_BIO_read (rh,
"result-key",
&sr->key,
@@ -2655,7 +2656,7 @@ cleanup:
if (NULL != sr->uri)
GNUNET_FS_uri_destroy (sr->uri);
if (NULL != sr->meta)
- GNUNET_CONTAINER_meta_data_destroy (sr->meta);
+ GNUNET_FS_meta_data_destroy (sr->meta);
GNUNET_free (sr->serialization);
GNUNET_free (sr);
if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
@@ -2778,7 +2779,7 @@ free_result (void *cls, const struct GNUNET_HashCode
*key, void *value)
free_search_context (sr->update_search);
GNUNET_assert (NULL == sr->update_search);
}
- GNUNET_CONTAINER_meta_data_destroy (sr->meta);
+ GNUNET_FS_meta_data_destroy (sr->meta);
GNUNET_FS_uri_destroy (sr->uri);
GNUNET_free (sr);
return GNUNET_YES;
@@ -2876,7 +2877,7 @@ free_download_context (struct GNUNET_FS_DownloadContext
*dc)
struct GNUNET_FS_DownloadContext *dcc;
if (NULL != dc->meta)
- GNUNET_CONTAINER_meta_data_destroy (dc->meta);
+ GNUNET_FS_meta_data_destroy (dc->meta);
if (NULL != dc->uri)
GNUNET_FS_uri_destroy (dc->uri);
GNUNET_free (dc->temp_filename);
@@ -2925,7 +2926,7 @@ deserialize_download (struct GNUNET_FS_Handle *h,
dc->h = h;
dc->serialization = GNUNET_strdup (serialization);
struct GNUNET_BIO_ReadSpec rs[] = {
- GNUNET_BIO_read_spec_meta_data ("download-meta", &dc->meta),
+ GNUNET_FS_read_spec_meta_data ("download-meta", &dc->meta),
GNUNET_BIO_read_spec_string ("download-emsg", &dc->emsg, 10 * 1024),
GNUNET_BIO_read_spec_string ("download-fn", &dc->filename, 10 * 1024),
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 @@
#include "gnunet_constants.h"
#include "gnunet_datastore_service.h"
#include "gnunet_dht_service.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_block_lib.h"
#include "block_fs.h"
@@ -249,7 +250,7 @@ struct GNUNET_FS_FileInformation
/**
* Metadata to use for the file.
*/
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
/**
* Keywords to use for KBlocks.
@@ -525,7 +526,7 @@ struct GNUNET_FS_SearchResult
/**
* Metadata for the search result.
*/
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
/**
* Client info for this search result.
@@ -1801,7 +1802,7 @@ struct GNUNET_FS_DownloadContext
/**
* Known meta-data for the file (can be NULL).
*/
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
/**
* 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 @@
* into memory
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
@@ -52,15 +53,15 @@
*/
int
GNUNET_FS_meta_data_test_for_directory (const struct
- GNUNET_CONTAINER_MetaData *md)
+ GNUNET_FS_MetaData *md)
{
char *mime;
int ret;
if (NULL == md)
return GNUNET_SYSERR;
- mime = GNUNET_CONTAINER_meta_data_get_by_type (md,
- EXTRACTOR_METATYPE_MIMETYPE);
+ mime = GNUNET_FS_meta_data_get_by_type (md,
+ EXTRACTOR_METATYPE_MIMETYPE);
if (NULL == mime)
return GNUNET_SYSERR;
ret = (0 == strcasecmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES :
@@ -77,19 +78,19 @@ GNUNET_FS_meta_data_test_for_directory (const struct
* @param md metadata to add mimetype to
*/
void
-GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md)
+GNUNET_FS_meta_data_make_directory (struct GNUNET_FS_MetaData *md)
{
char *mime;
mime =
- GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
+ GNUNET_FS_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
if (mime != NULL)
{
GNUNET_break (0 == strcmp (mime, GNUNET_FS_DIRECTORY_MIME));
GNUNET_free (mime);
return;
}
- GNUNET_CONTAINER_meta_data_insert (md, "<gnunet>",
+ GNUNET_FS_meta_data_insert (md, "<gnunet>",
EXTRACTOR_METATYPE_MIMETYPE,
EXTRACTOR_METAFORMAT_UTF8, "text/plain",
GNUNET_FS_DIRECTORY_MIME,
@@ -192,7 +193,7 @@ GNUNET_FS_directory_list_contents (size_t size,
uint32_t mdSize;
uint64_t epos;
struct GNUNET_FS_Uri *uri;
- struct GNUNET_CONTAINER_MetaData *md;
+ struct GNUNET_FS_MetaData *md;
char *filename;
if ((offset == 0) &&
@@ -215,8 +216,8 @@ GNUNET_FS_directory_list_contents (size_t size,
_ ("MAGIC mismatch. This is not a GNUnet directory.\n"));
return GNUNET_SYSERR;
}
- md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[8 + sizeof(uint32_t)],
- mdSize);
+ md = GNUNET_FS_meta_data_deserialize (&cdata[8 + sizeof(uint32_t)],
+ mdSize);
if (md == NULL)
{
GNUNET_break (0);
@@ -228,7 +229,7 @@ GNUNET_FS_directory_list_contents (size_t size,
md,
0,
NULL);
- GNUNET_CONTAINER_meta_data_destroy (md);
+ GNUNET_FS_meta_data_destroy (md);
pos = 8 + sizeof(uint32_t) + mdSize;
}
while (pos < size)
@@ -283,7 +284,7 @@ GNUNET_FS_directory_list_contents (size_t size,
return GNUNET_NO; /* malformed - or partial download */
}
- md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[pos],
+ md = GNUNET_FS_meta_data_deserialize (&cdata[pos],
mdSize);
if (NULL == md)
{
@@ -293,11 +294,11 @@ GNUNET_FS_directory_list_contents (size_t size,
}
pos += mdSize;
filename =
- GNUNET_CONTAINER_meta_data_get_by_type (md,
+ GNUNET_FS_meta_data_get_by_type (md,
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
full_data.size = 0;
full_data.data = NULL;
- GNUNET_CONTAINER_meta_data_iterate (md,
+ GNUNET_FS_meta_data_iterate (md,
&find_full_data,
&full_data);
if (NULL != dep)
@@ -311,7 +312,7 @@ GNUNET_FS_directory_list_contents (size_t size,
}
GNUNET_free (full_data.data);
GNUNET_free (filename);
- GNUNET_CONTAINER_meta_data_destroy (md);
+ GNUNET_FS_meta_data_destroy (md);
GNUNET_FS_uri_destroy (uri);
}
return GNUNET_OK;
@@ -342,7 +343,7 @@ struct GNUNET_FS_DirectoryBuilder
/**
* Meta-data for the directory itself.
*/
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
/**
* Head of linked list of entries.
@@ -362,16 +363,16 @@ struct GNUNET_FS_DirectoryBuilder
* @param mdir metadata for the directory
*/
struct GNUNET_FS_DirectoryBuilder *
-GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData
+GNUNET_FS_directory_builder_create (const struct GNUNET_FS_MetaData
*mdir)
{
struct GNUNET_FS_DirectoryBuilder *ret;
ret = GNUNET_new (struct GNUNET_FS_DirectoryBuilder);
if (mdir != NULL)
- ret->meta = GNUNET_CONTAINER_meta_data_duplicate (mdir);
+ ret->meta = GNUNET_FS_meta_data_duplicate (mdir);
else
- ret->meta = GNUNET_CONTAINER_meta_data_create ();
+ ret->meta = GNUNET_FS_meta_data_create ();
GNUNET_FS_meta_data_make_directory (ret->meta);
return ret;
}
@@ -390,7 +391,7 @@ GNUNET_FS_directory_builder_create (const struct
GNUNET_CONTAINER_MetaData
void
GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *md,
+ const struct GNUNET_FS_MetaData *md,
const void *data)
{
struct GNUNET_FS_Uri *curi;
@@ -404,8 +405,8 @@ GNUNET_FS_directory_builder_add (struct
GNUNET_FS_DirectoryBuilder *bld,
char *serialized;
char *sptr;
size_t slen;
- struct GNUNET_CONTAINER_MetaData *meta;
- const struct GNUNET_CONTAINER_MetaData *meta_use;
+ struct GNUNET_FS_MetaData *meta;
+ const struct GNUNET_FS_MetaData *meta_use;
GNUNET_assert (! GNUNET_FS_uri_test_ksk (uri));
if (NULL != data)
@@ -431,17 +432,17 @@ GNUNET_FS_directory_builder_add (struct
GNUNET_FS_DirectoryBuilder *bld,
fsize = 0; /* too large */
uris = GNUNET_FS_uri_to_string (uri);
slen = strlen (uris) + 1;
- mds = GNUNET_CONTAINER_meta_data_get_serialized_size (md);
+ mds = GNUNET_FS_meta_data_get_serialized_size (md);
meta_use = md;
meta = NULL;
if (fsize > 0)
{
- meta = GNUNET_CONTAINER_meta_data_duplicate (md);
- GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>",
+ meta = GNUNET_FS_meta_data_duplicate (md);
+ GNUNET_FS_meta_data_insert (meta, "<gnunet>",
EXTRACTOR_METATYPE_GNUNET_FULL_DATA,
EXTRACTOR_METAFORMAT_BINARY, NULL, data,
fsize);
- mdxs = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
+ mdxs = GNUNET_FS_meta_data_get_serialized_size (meta);
if ((slen + sizeof(uint32_t) + mdxs - 1) / DBLOCK_SIZE ==
(slen + sizeof(uint32_t) + mds - 1) / DBLOCK_SIZE)
{
@@ -461,10 +462,10 @@ GNUNET_FS_directory_builder_add (struct
GNUNET_FS_DirectoryBuilder *bld,
GNUNET_free (uris);
sptr = &serialized[slen + sizeof(uint32_t)];
ret =
- GNUNET_CONTAINER_meta_data_serialize (meta_use, &sptr, mds,
-
GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
+ GNUNET_FS_meta_data_serialize (meta_use, &sptr, mds,
+ GNUNET_FS_META_DATA_SERIALIZE_PART);
if (NULL != meta)
- GNUNET_CONTAINER_meta_data_destroy (meta);
+ GNUNET_FS_meta_data_destroy (meta);
if (ret == -1)
mds = 0;
else
@@ -593,7 +594,7 @@ GNUNET_FS_directory_builder_finish (struct
GNUNET_FS_DirectoryBuilder *bld,
uint32_t big;
size = strlen (GNUNET_DIRECTORY_MAGIC) + sizeof(uint32_t);
- size += GNUNET_CONTAINER_meta_data_get_serialized_size (bld->meta);
+ size += GNUNET_FS_meta_data_get_serialized_size (bld->meta);
sizes = NULL;
perm = NULL;
bes = NULL;
@@ -643,10 +644,10 @@ GNUNET_FS_directory_builder_finish (struct
GNUNET_FS_DirectoryBuilder *bld,
sptr = &data[off + sizeof(uint32_t)];
ret =
- GNUNET_CONTAINER_meta_data_serialize (bld->meta,
+ GNUNET_FS_meta_data_serialize (bld->meta,
&sptr,
size - off - sizeof(uint32_t),
-
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
+ GNUNET_FS_META_DATA_SERIALIZE_FULL);
GNUNET_assert (ret != -1);
big = htonl (ret);
GNUNET_memcpy (&data[off],
@@ -666,7 +667,7 @@ GNUNET_FS_directory_builder_finish (struct
GNUNET_FS_DirectoryBuilder *bld,
GNUNET_free (perm);
GNUNET_free (bes);
GNUNET_assert (off == size);
- GNUNET_CONTAINER_meta_data_destroy (bld->meta);
+ GNUNET_FS_meta_data_destroy (bld->meta);
GNUNET_free (bld);
return GNUNET_OK;
}
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 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_scheduler_lib.h"
#include <pthread.h>
@@ -359,26 +360,26 @@ process_helper_msgs (void *cls, const struct
GNUNET_MessageHeader *msg)
GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED);
if (0 < left)
{
- ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize (end, left);
+ ds->pos->meta = GNUNET_FS_meta_data_deserialize (end, left);
if (NULL == ds->pos->meta)
{
GNUNET_break (0);
break;
}
/* having full filenames is too dangerous; always make sure we clean
them up */
- GNUNET_CONTAINER_meta_data_delete (ds->pos->meta,
- EXTRACTOR_METATYPE_FILENAME,
- NULL,
- 0);
+ GNUNET_FS_meta_data_delete (ds->pos->meta,
+ EXTRACTOR_METATYPE_FILENAME,
+ NULL,
+ 0);
/* instead, put in our 'safer' original filename */
- GNUNET_CONTAINER_meta_data_insert (ds->pos->meta,
- "<libgnunetfs>",
-
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- ds->pos->short_filename,
- strlen (ds->pos->short_filename)
- + 1);
+ GNUNET_FS_meta_data_insert (ds->pos->meta,
+ "<libgnunetfs>",
+
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ ds->pos->short_filename,
+ strlen (ds->pos->short_filename)
+ + 1);
}
ds->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (
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 @@
*/
#include "platform.h"
#include "gnunet_constants.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
#include "fs_tree.h"
@@ -280,7 +281,7 @@ static void
trigger_recursive_download (void *cls,
const char *filename,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
size_t length,
const void *data);
@@ -850,7 +851,7 @@ static void
trigger_recursive_download (void *cls,
const char *filename,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
size_t length,
const void *data)
{
@@ -968,7 +969,7 @@ trigger_recursive_download (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Triggering recursive download of size %llu with %u bytes MD\n",
(unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri),
- (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size (
+ (unsigned int) GNUNET_FS_meta_data_get_serialized_size (
meta));
GNUNET_FS_download_start (dc->h,
uri,
@@ -1907,8 +1908,8 @@ GNUNET_FS_download_start_task_ (void *cls)
GNUNET_ERROR_TYPE_DEBUG,
"Trying to find embedded meta data for download of size %llu with %u
bytes MD\n",
(unsigned long long) GNUNET_FS_uri_chk_get_file_size (dc->uri),
- (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size
(dc->meta));
- GNUNET_CONTAINER_meta_data_iterate (dc->meta, &match_full_data, dc);
+ (unsigned int) GNUNET_FS_meta_data_get_serialized_size (dc->meta));
+ GNUNET_FS_meta_data_iterate (dc->meta, &match_full_data, dc);
if (BRS_DOWNLOAD_UP == dc->top_request->state)
{
if (NULL != dc->rfh)
@@ -1996,7 +1997,7 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
dc->active = NULL;
}
GNUNET_free (dc->filename);
- GNUNET_CONTAINER_meta_data_destroy (dc->meta);
+ GNUNET_FS_meta_data_destroy (dc->meta);
GNUNET_FS_uri_destroy (dc->uri);
GNUNET_free (dc->temp_filename);
GNUNET_free (dc->serialization);
@@ -2027,7 +2028,7 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
struct GNUNET_FS_DownloadContext *
create_download_context (struct GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
const char *filename,
const char *tempname,
uint64_t offset,
@@ -2053,7 +2054,7 @@ create_download_context (struct GNUNET_FS_Handle *h,
(unsigned long long) offset);
dc->h = h;
dc->uri = GNUNET_FS_uri_dup (uri);
- dc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
+ dc->meta = GNUNET_FS_meta_data_duplicate (meta);
dc->client_info = cctx;
dc->start_time = GNUNET_TIME_absolute_get ();
if (NULL != filename)
@@ -2098,7 +2099,7 @@ create_download_context (struct GNUNET_FS_Handle *h,
struct GNUNET_FS_DownloadContext *
GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
const char *filename,
const char *tempname,
uint64_t offset,
@@ -2319,7 +2320,7 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext
*dc, int do_delete)
}
GNUNET_free (dc->filename);
}
- GNUNET_CONTAINER_meta_data_destroy (dc->meta);
+ GNUNET_FS_meta_data_destroy (dc->meta);
GNUNET_FS_uri_destroy (dc->uri);
if (NULL != dc->temp_filename)
{
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)
* @return "filename" field of the structure (can be NULL)
*/
const char *
-GNUNET_FS_file_information_get_filename (const struct
GNUNET_FS_FileInformation *s)
+GNUNET_FS_file_information_get_filename (const struct
+ GNUNET_FS_FileInformation *s)
{
return s->filename;
}
@@ -89,7 +90,7 @@ GNUNET_FS_file_information_create_from_file (
void *client_info,
const char *filename,
const struct GNUNET_FS_Uri *keywords,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
int do_index,
const struct GNUNET_FS_BlockOptions *bo)
{
@@ -132,13 +133,13 @@ GNUNET_FS_file_information_create_from_file (
/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
* this should be changed to EXTRACTOR_METAFORMAT_UTF8
*/
- GNUNET_CONTAINER_meta_data_insert (ret->meta,
- "<gnunet>",
-
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- fn,
- strlen (fn) + 1);
+ GNUNET_FS_meta_data_insert (ret->meta,
+ "<gnunet>",
+ EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ fn,
+ strlen (fn) + 1);
return ret;
}
@@ -150,7 +151,7 @@ GNUNET_FS_file_information_create_from_data (
uint64_t length,
void *data,
const struct GNUNET_FS_Uri *keywords,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
int do_index,
const struct GNUNET_FS_BlockOptions *bo)
{
@@ -180,7 +181,7 @@ GNUNET_FS_file_information_create_from_reader (
GNUNET_FS_DataReader reader,
void *reader_cls,
const struct GNUNET_FS_Uri *keywords,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
int do_index,
const struct GNUNET_FS_BlockOptions *bo)
{
@@ -194,9 +195,9 @@ GNUNET_FS_file_information_create_from_reader (
ret = GNUNET_new (struct GNUNET_FS_FileInformation);
ret->h = h;
ret->client_info = client_info;
- ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
+ ret->meta = GNUNET_FS_meta_data_duplicate (meta);
if (ret->meta == NULL)
- ret->meta = GNUNET_CONTAINER_meta_data_create ();
+ ret->meta = GNUNET_FS_meta_data_create ();
ret->keywords = (keywords == NULL) ? NULL : GNUNET_FS_uri_dup (keywords);
ret->data.file.reader = reader;
ret->data.file.reader_cls = reader_cls;
@@ -226,7 +227,7 @@ GNUNET_FS_file_information_create_empty_directory (
struct GNUNET_FS_Handle *h,
void *client_info,
const struct GNUNET_FS_Uri *keywords,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
const struct GNUNET_FS_BlockOptions *bo,
const char *filename)
{
@@ -235,7 +236,7 @@ GNUNET_FS_file_information_create_empty_directory (
ret = GNUNET_new (struct GNUNET_FS_FileInformation);
ret->h = h;
ret->client_info = client_info;
- ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
+ ret->meta = GNUNET_FS_meta_data_duplicate (meta);
ret->keywords = GNUNET_FS_uri_dup (keywords);
ret->bo = *bo;
ret->is_directory = GNUNET_YES;
@@ -392,7 +393,7 @@ GNUNET_FS_file_information_destroy (struct
GNUNET_FS_FileInformation *fi,
if (NULL != fi->keywords)
GNUNET_FS_uri_destroy (fi->keywords);
if (NULL != fi->meta)
- GNUNET_CONTAINER_meta_data_destroy (fi->meta);
+ GNUNET_FS_meta_data_destroy (fi->meta);
GNUNET_free (fi->serialization);
if (NULL != fi->te)
{
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 @@
* @author Igor Wronsky, Christian Grothoff
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
@@ -163,20 +164,20 @@ getopt_set_metadata (struct
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
const char *option,
const char *value)
{
- struct GNUNET_CONTAINER_MetaData **mm = scls;
+ struct GNUNET_FS_MetaData **mm = scls;
#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR
enum EXTRACTOR_MetaType type;
const char *typename;
const char *typename_i18n;
#endif
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
char *tmp;
meta = *mm;
if (meta == NULL)
{
- meta = GNUNET_CONTAINER_meta_data_create ();
+ meta = GNUNET_FS_meta_data_create ();
*mm = meta;
}
@@ -196,12 +197,12 @@ getopt_set_metadata (struct
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
(tmp[strlen (typename)] == ':') &&
(0 == strncmp (typename, tmp, strlen (typename))))
{
- GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- &tmp[strlen (typename) + 1],
- strlen (&tmp[strlen (typename) + 1])
- + 1);
+ GNUNET_FS_meta_data_insert (meta, "<gnunet>", type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ &tmp[strlen (typename) + 1],
+ strlen (&tmp[strlen (typename) + 1])
+ + 1);
GNUNET_free (tmp);
tmp = NULL;
break;
@@ -210,13 +211,13 @@ getopt_set_metadata (struct
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
(tmp[strlen (typename_i18n)] == ':') &&
(0 == strncmp (typename_i18n, tmp, strlen (typename_i18n))))
{
- GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- &tmp[strlen (typename_i18n) + 1],
- strlen (&tmp
- [strlen (typename_i18n) + 1])
- + 1);
+ GNUNET_FS_meta_data_insert (meta, "<gnunet>", type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ &tmp[strlen (typename_i18n) + 1],
+ strlen (&tmp
+ [strlen (typename_i18n) + 1])
+ + 1);
GNUNET_free (tmp);
tmp = NULL;
break;
@@ -226,10 +227,10 @@ getopt_set_metadata (struct
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
if (NULL != tmp)
{
- GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>",
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8, "text/plain",
- tmp, strlen (tmp) + 1);
+ GNUNET_FS_meta_data_insert (meta, "<gnunet>",
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain",
+ tmp, strlen (tmp) + 1);
GNUNET_free (tmp);
printf (_
(
@@ -254,7 +255,7 @@ GNUNET_FS_GETOPT_METADATA (char shortName,
const char *name,
const char *argumentHelp,
const char *description,
- struct GNUNET_CONTAINER_MetaData **meta)
+ struct GNUNET_FS_MetaData **meta)
{
struct GNUNET_GETOPT_CommandLineOption clo = {
.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 @@
#include "platform.h"
#include "gnunet_constants.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_protocols.h"
#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 @@
*/
#include "platform.h"
#include "gnunet_constants.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
@@ -35,7 +36,7 @@
* @return NULL if meta data is useless for suggesting a filename
*/
char *
-GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData
+GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_FS_MetaData
*md)
{
static const char *mimeMap[][2] = {
@@ -111,13 +112,13 @@ GNUNET_FS_meta_data_suggest_filename (const struct
GNUNET_CONTAINER_MetaData
const char *ext;
ret =
- GNUNET_CONTAINER_meta_data_get_by_type (md,
-
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
+ GNUNET_FS_meta_data_get_by_type (md,
+
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
if (ret != NULL)
return ret;
ext = NULL;
mime =
- GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
+ GNUNET_FS_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
if (mime != NULL)
{
i = 0;
@@ -131,24 +132,24 @@ GNUNET_FS_meta_data_suggest_filename (const struct
GNUNET_CONTAINER_MetaData
GNUNET_free (mime);
}
base =
- GNUNET_CONTAINER_meta_data_get_first_by_types (md,
- EXTRACTOR_METATYPE_TITLE,
-
EXTRACTOR_METATYPE_BOOK_TITLE,
-
EXTRACTOR_METATYPE_ORIGINAL_TITLE,
-
EXTRACTOR_METATYPE_PACKAGE_NAME,
- EXTRACTOR_METATYPE_URL,
- EXTRACTOR_METATYPE_URI,
-
EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METATYPE_ISRC,
-
EXTRACTOR_METATYPE_JOURNAL_NAME,
-
EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METATYPE_ALBUM,
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METATYPE_UNKNOWN,
- -1);
+ GNUNET_FS_meta_data_get_first_by_types (md,
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METATYPE_BOOK_TITLE,
+ EXTRACTOR_METATYPE_ORIGINAL_TITLE,
+ EXTRACTOR_METATYPE_PACKAGE_NAME,
+ EXTRACTOR_METATYPE_URL,
+ EXTRACTOR_METATYPE_URI,
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METATYPE_ISRC,
+ EXTRACTOR_METATYPE_JOURNAL_NAME,
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ EXTRACTOR_METATYPE_SUBJECT,
+ EXTRACTOR_METATYPE_ALBUM,
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METATYPE_UNKNOWN,
+ -1);
if ((base == NULL) && (ext == NULL))
return NULL;
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 @@
#include "gnunet_constants.h"
#include "gnunet_signatures.h"
#include "gnunet_util_lib.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
#include "fs_publish_ublock.h"
@@ -52,7 +53,7 @@ struct NamespaceUpdateNode
/**
* Metadata for this entry.
*/
- struct GNUNET_CONTAINER_MetaData *md;
+ struct GNUNET_FS_MetaData *md;
/**
* URI of this entry in the namespace.
@@ -167,7 +168,7 @@ free_update_information_graph (struct
GNUNET_FS_UpdateInformationGraph *uig)
for (i = 0; i < uig->update_node_count; i++)
{
nsn = uig->update_nodes[i];
- GNUNET_CONTAINER_meta_data_destroy (nsn->md);
+ GNUNET_FS_meta_data_destroy (nsn->md);
GNUNET_FS_uri_destroy (nsn->uri);
GNUNET_free (nsn->id);
GNUNET_free (nsn->update);
@@ -215,7 +216,7 @@ write_update_information_graph (struct
GNUNET_FS_UpdateInformationGraph *uig)
uris = GNUNET_FS_uri_to_string (n->uri);
struct GNUNET_BIO_WriteSpec ws[] = {
GNUNET_BIO_write_spec_string ("fs-namespace-node-id", n->id),
- GNUNET_BIO_write_spec_meta_data ("fs-namespace-node-meta", n->md),
+ GNUNET_FS_write_spec_meta_data ("fs-namespace-node-meta", n->md),
GNUNET_BIO_write_spec_string ("fs-namespace-node-update", n->update),
GNUNET_BIO_write_spec_string ("fs-namespace-uris", uris),
GNUNET_BIO_write_spec_end (),
@@ -227,7 +228,7 @@ write_update_information_graph (struct
GNUNET_FS_UpdateInformationGraph *uig)
}
GNUNET_free (uris);
}
-END:
+ END:
if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_ ("Failed to write `%s': %s\n"),
@@ -293,7 +294,7 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
n = GNUNET_new (struct NamespaceUpdateNode);
struct GNUNET_BIO_ReadSpec rs[] = {
GNUNET_BIO_read_spec_string ("identifier", &n->id, 1024),
- GNUNET_BIO_read_spec_meta_data ("meta", &n->md),
+ GNUNET_FS_read_spec_meta_data ("meta", &n->md),
GNUNET_BIO_read_spec_string ("update-id", &n->update, 1024),
GNUNET_BIO_read_spec_string ("uri", &uris, 1024 * 2),
GNUNET_BIO_read_spec_end (),
@@ -304,7 +305,7 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
GNUNET_free (n->id);
GNUNET_free (n->update);
if (n->md != NULL)
- GNUNET_CONTAINER_meta_data_destroy (n->md);
+ GNUNET_FS_meta_data_destroy (n->md);
GNUNET_free (n);
break;
}
@@ -316,14 +317,14 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
GNUNET_free (emsg);
GNUNET_free (n->id);
GNUNET_free (n->update);
- GNUNET_CONTAINER_meta_data_destroy (n->md);
+ GNUNET_FS_meta_data_destroy (n->md);
GNUNET_free (n);
break;
}
uig->update_nodes[i] = n;
}
uig->update_node_count = i;
-END:
+ END:
if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -428,7 +429,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
const char *identifier,
const char *update,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
const struct GNUNET_FS_Uri *uri,
const struct GNUNET_FS_BlockOptions *bo,
enum GNUNET_FS_PublishOptions options,
@@ -463,7 +464,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
psc->nsn = GNUNET_new (struct NamespaceUpdateNode);
psc->nsn->id = GNUNET_strdup (identifier);
psc->nsn->update = GNUNET_strdup (update);
- psc->nsn->md = GNUNET_CONTAINER_meta_data_duplicate (meta);
+ psc->nsn->md = GNUNET_FS_meta_data_duplicate (meta);
psc->nsn->uri = GNUNET_FS_uri_dup (uri);
}
psc->uc = GNUNET_FS_publish_ublock_ (h,
@@ -502,7 +503,7 @@ GNUNET_FS_publish_sks_cancel (struct
GNUNET_FS_PublishSksContext *psc)
GNUNET_FS_uri_destroy (psc->uri);
if (NULL != psc->nsn)
{
- GNUNET_CONTAINER_meta_data_destroy (psc->nsn->md);
+ GNUNET_FS_meta_data_destroy (psc->nsn->md);
GNUNET_FS_uri_destroy (psc->nsn->uri);
GNUNET_free (psc->nsn->id);
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 @@
#include "gnunet_constants.h"
#include "gnunet_signatures.h"
#include "gnunet_util_lib.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
#include "fs_tree.h"
@@ -1098,8 +1099,8 @@ GNUNET_FS_publish_main_ (void *cls)
* related files as well! */
while (NULL != p->dir)
{
- fn = GNUNET_CONTAINER_meta_data_get_by_type (p->meta,
-
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
+ fn = GNUNET_FS_meta_data_get_by_type (p->meta,
+
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
p = p->dir;
if (fn != NULL)
{
@@ -1193,7 +1194,7 @@ static int
fip_signal_start (void *cls,
struct GNUNET_FS_FileInformation *fi,
uint64_t length,
- struct GNUNET_CONTAINER_MetaData *meta,
+ struct GNUNET_FS_MetaData *meta,
struct GNUNET_FS_Uri **uri,
struct GNUNET_FS_BlockOptions *bo,
int *do_index,
@@ -1319,7 +1320,7 @@ static int
fip_signal_suspend (void *cls,
struct GNUNET_FS_FileInformation *fi,
uint64_t length,
- struct GNUNET_CONTAINER_MetaData *meta,
+ struct GNUNET_FS_MetaData *meta,
struct GNUNET_FS_Uri **uri,
struct GNUNET_FS_BlockOptions *bo,
int *do_index,
@@ -1523,7 +1524,7 @@ static int
fip_signal_stop (void *cls,
struct GNUNET_FS_FileInformation *fi,
uint64_t length,
- struct GNUNET_CONTAINER_MetaData *meta,
+ struct GNUNET_FS_MetaData *meta,
struct GNUNET_FS_Uri **uri,
struct GNUNET_FS_BlockOptions *bo,
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 @@
#include "gnunet_constants.h"
#include "gnunet_signatures.h"
#include "gnunet_util_lib.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
#include "fs_tree.h"
@@ -53,7 +54,7 @@ struct GNUNET_FS_PublishKskContext
/**
* Metadata to use.
*/
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
/**
* Global FS context.
@@ -186,7 +187,7 @@ publish_ksk_cont (void *cls)
struct GNUNET_FS_PublishKskContext *
GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri *ksk_uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
const struct GNUNET_FS_Uri *uri,
const struct GNUNET_FS_BlockOptions *bo,
enum GNUNET_FS_PublishOptions options,
@@ -201,7 +202,7 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
pkc->options = options;
pkc->cont = cont;
pkc->cont_cls = cont_cls;
- pkc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
+ pkc->meta = GNUNET_FS_meta_data_duplicate (meta);
if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
{
pkc->dsh = GNUNET_DATASTORE_connect (h->cfg);
@@ -244,7 +245,7 @@ GNUNET_FS_publish_ksk_cancel (struct
GNUNET_FS_PublishKskContext *pkc)
GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
pkc->dsh = NULL;
}
- GNUNET_CONTAINER_meta_data_destroy (pkc->meta);
+ GNUNET_FS_meta_data_destroy (pkc->meta);
GNUNET_FS_uri_destroy (pkc->ksk_uri);
GNUNET_FS_uri_destroy (pkc->uri);
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,
const char *label,
const char *ulabel,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
const struct GNUNET_FS_Uri *uri,
const struct GNUNET_FS_BlockOptions *bo,
enum GNUNET_FS_PublishOptions options,
@@ -181,7 +181,7 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
if (NULL == meta)
mdsize = 0;
else
- mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
+ mdsize = GNUNET_FS_meta_data_get_serialized_size (meta);
GNUNET_assert (mdsize >= 0);
uris = GNUNET_FS_uri_to_string (uri);
slen = strlen (uris) + 1;
@@ -206,8 +206,8 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
sptr = kbe;
if (NULL != meta)
mdsize =
- GNUNET_CONTAINER_meta_data_serialize (meta, &sptr, mdsize,
-
GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
+ GNUNET_FS_meta_data_serialize (meta, &sptr, mdsize,
+ GNUNET_FS_META_DATA_SERIALIZE_PART);
if (-1 == mdsize)
{
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 @@
#include "gnunet_util_lib.h"
#include "gnunet_datastore_service.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_identity_service.h"
@@ -90,7 +91,7 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
const char *label,
const char *ulabel,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
const struct GNUNET_FS_Uri *uri,
const struct GNUNET_FS_BlockOptions *bo,
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 @@
*/
#include "platform.h"
#include "gnunet_constants.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_protocols.h"
#include "fs_api.h"
@@ -487,7 +488,7 @@ GNUNET_FS_search_start_probe_ (struct
GNUNET_FS_SearchResult *sr)
struct GNUNET_FS_SearchResult *
GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
void *client_info,
uint32_t anonymity)
{
@@ -498,7 +499,7 @@ GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
sr = GNUNET_new (struct GNUNET_FS_SearchResult);
sr->h = h;
sr->uri = GNUNET_FS_uri_dup (uri);
- sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
+ sr->meta = GNUNET_FS_meta_data_duplicate (meta);
sr->client_info = client_info;
sr->anonymity = anonymity;
GNUNET_FS_search_start_probe_ (sr);
@@ -543,7 +544,7 @@ GNUNET_FS_probe_stop (struct GNUNET_FS_SearchResult *sr)
GNUNET_assert (NULL == sr->sc);
GNUNET_FS_search_stop_probe_ (sr);
GNUNET_FS_uri_destroy (sr->uri);
- GNUNET_CONTAINER_meta_data_destroy (sr->meta);
+ GNUNET_FS_meta_data_destroy (sr->meta);
client_info = sr->client_info;
GNUNET_free (sr);
return client_info;
@@ -564,7 +565,7 @@ static void
process_ksk_result (struct GNUNET_FS_SearchContext *sc,
struct SearchRequestEntry *ent,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta)
+ const struct GNUNET_FS_MetaData *meta)
{
struct GNUNET_HashCode key;
struct GNUNET_FS_SearchResult *sr;
@@ -602,7 +603,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
sr->sc = sc;
sr->anonymity = sc->anonymity;
sr->uri = GNUNET_FS_uri_dup (uri);
- sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
+ sr->meta = GNUNET_FS_meta_data_duplicate (meta);
sr->mandatory_missing = sc->mandatory_count;
sr->key = key;
sr->keyword_bitmap = GNUNET_malloc ((sc->uri->data.ksk.keywordCount + 7)
@@ -612,7 +613,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
}
else
{
- GNUNET_CONTAINER_meta_data_merge (sr->meta, meta);
+ GNUNET_FS_meta_data_merge (sr->meta, meta);
}
GNUNET_break (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_put (ent->results,
@@ -685,7 +686,7 @@ static void
process_sks_result (struct GNUNET_FS_SearchContext *sc,
const char *id_update,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta)
+ const struct GNUNET_FS_MetaData *meta)
{
struct GNUNET_FS_Uri uu;
struct GNUNET_HashCode key;
@@ -713,7 +714,7 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc,
sr->sc = sc;
sr->anonymity = sc->anonymity;
sr->uri = GNUNET_FS_uri_dup (uri);
- sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
+ sr->meta = GNUNET_FS_meta_data_duplicate (meta);
sr->key = key;
GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &key, sr,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
@@ -800,7 +801,7 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
size_t j;
char pt[size - sizeof(struct UBlock)];
const char *eos;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *uri;
char *emsg;
int i;
@@ -835,9 +836,9 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
}
j = eos - pt + 1;
if (sizeof(pt) == j)
- meta = GNUNET_CONTAINER_meta_data_create ();
+ meta = GNUNET_FS_meta_data_create ();
else
- meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[j], sizeof(pt) - j);
+ meta = GNUNET_FS_meta_data_deserialize (&pt[j], sizeof(pt) - j);
if (NULL == meta)
{
GNUNET_break_op (0); /* ublock malformed */
@@ -850,7 +851,7 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
meta);
/* clean up */
- GNUNET_CONTAINER_meta_data_destroy (meta);
+ GNUNET_FS_meta_data_destroy (meta);
GNUNET_FS_uri_destroy (uri);
}
@@ -872,7 +873,7 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
size_t len = size - sizeof(struct UBlock);
char pt[len];
struct GNUNET_FS_Uri *uri;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
const char *id;
const char *uris;
size_t off;
@@ -888,8 +889,8 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
GNUNET_break_op (0); /* ublock malformed */
return;
}
- if (NULL == (meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[off], len
- - off)))
+ if (NULL == (meta = GNUNET_FS_meta_data_deserialize (&pt[off], len
+ - off)))
{
GNUNET_break_op (0); /* ublock malformed */
return;
@@ -901,14 +902,14 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
uris, emsg);
GNUNET_break_op (0); /* ublock malformed */
GNUNET_free (emsg);
- GNUNET_CONTAINER_meta_data_destroy (meta);
+ GNUNET_FS_meta_data_destroy (meta);
return;
}
/* process */
process_sks_result (sc, id, uri, meta);
/* clean up */
GNUNET_FS_uri_destroy (uri);
- GNUNET_CONTAINER_meta_data_destroy (meta);
+ GNUNET_FS_meta_data_destroy (meta);
}
@@ -1543,7 +1544,7 @@ search_result_suspend (void *cls,
GNUNET_break (NULL == sr->client_info);
GNUNET_free (sr->serialization);
GNUNET_FS_uri_destroy (sr->uri);
- GNUNET_CONTAINER_meta_data_destroy (sr->meta);
+ GNUNET_FS_meta_data_destroy (sr->meta);
GNUNET_free (sr->keyword_bitmap);
GNUNET_free (sr);
return GNUNET_OK;
@@ -1749,7 +1750,7 @@ search_result_free (void *cls,
GNUNET_break (NULL == sr->client_info);
GNUNET_free (sr->serialization);
GNUNET_FS_uri_destroy (sr->uri);
- GNUNET_CONTAINER_meta_data_destroy (sr->meta);
+ GNUNET_FS_meta_data_destroy (sr->meta);
GNUNET_free (sr->keyword_bitmap);
GNUNET_free (sr);
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 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_scheduler_lib.h"
#include <pthread.h>
@@ -308,13 +309,13 @@ migrate_and_drop_metadata (void *cls, const struct
GNUNET_HashCode *key,
if (counter->count >= tc->move_threshold)
{
if (NULL == tc->pos->meta)
- tc->pos->meta = GNUNET_CONTAINER_meta_data_create ();
- GNUNET_CONTAINER_meta_data_insert (tc->pos->meta,
- counter->plugin_name,
- counter->type,
- counter->format,
- counter->data_mime_type, counter->data,
- counter->data_size);
+ tc->pos->meta = GNUNET_FS_meta_data_create ();
+ GNUNET_FS_meta_data_insert (tc->pos->meta,
+ counter->plugin_name,
+ counter->type,
+ counter->format,
+ counter->data_mime_type, counter->data,
+ counter->data_size);
}
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (tc->metacounter,
@@ -356,12 +357,12 @@ share_tree_trim (struct TrimContext *tc,
{
/* only use filename if it doesn't match $USER */
if (NULL == tree->meta)
- tree->meta = GNUNET_CONTAINER_meta_data_create ();
- GNUNET_CONTAINER_meta_data_insert (tree->meta, "<libgnunetfs>",
-
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain", tree->short_filename,
- strlen (tree->short_filename) + 1);
+ tree->meta = GNUNET_FS_meta_data_create ();
+ GNUNET_FS_meta_data_insert (tree->meta, "<libgnunetfs>",
+ EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain", tree->short_filename,
+ strlen (tree->short_filename) + 1);
}
}
@@ -372,8 +373,8 @@ share_tree_trim (struct TrimContext *tc,
for (pos = tree->children_head; NULL != pos; pos = pos->next)
{
if (NULL != pos->meta)
- GNUNET_CONTAINER_meta_data_iterate (pos->meta, &add_to_meta_counter,
- tc->metacounter);
+ GNUNET_FS_meta_data_iterate (pos->meta, &add_to_meta_counter,
+ tc->metacounter);
if (NULL != pos->ksk_uri)
GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter,
tc->keywordcounter);
@@ -444,7 +445,7 @@ GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem
*toplevel)
toplevel->parent->children_tail,
toplevel);
if (NULL != toplevel->meta)
- GNUNET_CONTAINER_meta_data_destroy (toplevel->meta);
+ GNUNET_FS_meta_data_destroy (toplevel->meta);
if (NULL != toplevel->ksk_uri)
GNUNET_FS_uri_destroy (toplevel->ksk_uri);
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 @@
*/
#include "platform.h"
#include "gnunet_constants.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_protocols.h"
#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 @@
*
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_signatures.h"
#include "fs_api.h"
@@ -343,7 +344,7 @@ uri_ksk_parse (const char *s, char **emsg)
ret->data.ksk.keywordCount = iret;
ret->data.ksk.keywords = keywords;
return ret;
-CLEANUP:
+ CLEANUP:
for (i = 0; i < max; i++)
GNUNET_free (keywords[i]);
GNUNET_free (keywords);
@@ -620,7 +621,7 @@ uri_loc_parse (const char *s, char **emsg)
uri->data.loc.contentSignature = sig;
return uri;
-ERR:
+ ERR:
return NULL;
}
@@ -1768,7 +1769,7 @@ gather_uri_data (void *cls,
*/
struct GNUNET_FS_Uri *
GNUNET_FS_uri_ksk_create_from_meta_data (
- const struct GNUNET_CONTAINER_MetaData *md)
+ const struct GNUNET_FS_MetaData *md)
{
struct GNUNET_FS_Uri *ret;
char *filename;
@@ -1782,10 +1783,10 @@ GNUNET_FS_uri_ksk_create_from_meta_data (
return NULL;
ret = GNUNET_new (struct GNUNET_FS_Uri);
ret->type = GNUNET_FS_URI_KSK;
- ent = GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL);
+ ent = GNUNET_FS_meta_data_iterate (md, NULL, NULL);
if (ent > 0)
{
- full_name = GNUNET_CONTAINER_meta_data_get_first_by_types (
+ full_name = GNUNET_FS_meta_data_get_first_by_types (
md,
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
-1);
@@ -1801,7 +1802,7 @@ GNUNET_FS_uri_ksk_create_from_meta_data (
plus theoretically one more for mime... */
ret->data.ksk.keywords =
GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3, char *);
- GNUNET_CONTAINER_meta_data_iterate (md, &gather_uri_data, ret);
+ GNUNET_FS_meta_data_iterate (md, &gather_uri_data, ret);
}
if (tok_keywords > 0)
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 @@
* - how to signal driver that we're done?
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_statistics_service.h"
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 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
static int ret;
@@ -90,20 +91,20 @@ static void
print_entry (void *cls,
const char *filename,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
size_t length,
const void *data)
{
char *string;
char *name;
- name = GNUNET_CONTAINER_meta_data_get_by_type (
+ name = GNUNET_FS_meta_data_get_by_type (
meta,
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
if (uri == NULL)
{
printf (_ ("Directory `%s' meta data:\n"), name ? name : "");
- GNUNET_CONTAINER_meta_data_iterate (meta, &item_printer, NULL);
+ GNUNET_FS_meta_data_iterate (meta, &item_printer, NULL);
printf ("\n");
printf (_ ("Directory `%s' contents:\n"), name ? name : "");
GNUNET_free (name);
@@ -112,7 +113,7 @@ print_entry (void *cls,
string = GNUNET_FS_uri_to_string (uri);
printf ("%s (%s):\n", name ? name : "", string);
GNUNET_free (string);
- GNUNET_CONTAINER_meta_data_iterate (meta, &item_printer, NULL);
+ GNUNET_FS_meta_data_iterate (meta, &item_printer, NULL);
printf ("\n");
GNUNET_free (name);
}
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 @@
* @author Igor Wronsky
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
static 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 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
/**
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 @@
* and report the results to stdout.
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
@@ -120,7 +121,7 @@ add_to_md (void *cls,
const char *data,
size_t data_len)
{
- struct GNUNET_CONTAINER_MetaData *md = cls;
+ struct GNUNET_FS_MetaData *md = cls;
if (((EXTRACTOR_METAFORMAT_UTF8 == format) ||
(EXTRACTOR_METAFORMAT_C_STRING == format)) &&
@@ -129,23 +130,23 @@ add_to_md (void *cls,
char zdata[data_len + 1];
GNUNET_memcpy (zdata, data, data_len);
zdata[data_len] = '\0';
- (void) GNUNET_CONTAINER_meta_data_insert (md,
- plugin_name,
- type,
- format,
- data_mime_type,
- zdata,
- data_len + 1);
+ (void) GNUNET_FS_meta_data_insert (md,
+ plugin_name,
+ type,
+ format,
+ data_mime_type,
+ zdata,
+ data_len + 1);
}
else
{
- (void) GNUNET_CONTAINER_meta_data_insert (md,
- plugin_name,
- type,
- format,
- data_mime_type,
- data,
- data_len);
+ (void) GNUNET_FS_meta_data_insert (md,
+ plugin_name,
+ type,
+ format,
+ data_mime_type,
+ data,
+ data_len);
}
return 0;
}
@@ -373,7 +374,7 @@ preprocess_file (const char *filename, struct ScanTreeNode
**dst)
static int
extract_files (struct ScanTreeNode *item)
{
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
ssize_t size;
size_t slen;
@@ -390,16 +391,16 @@ extract_files (struct ScanTreeNode *item)
}
/* this is the expensive operation, *afterwards* we'll check for aborts */
- meta = GNUNET_CONTAINER_meta_data_create ();
+ meta = GNUNET_FS_meta_data_create ();
#if HAVE_LIBEXTRACTOR
EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta);
#endif
slen = strlen (item->filename) + 1;
- size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
+ size = GNUNET_FS_meta_data_get_serialized_size (meta);
if (-1 == size)
{
/* no meta data */
- GNUNET_CONTAINER_meta_data_destroy (meta);
+ GNUNET_FS_meta_data_destroy (meta);
if (GNUNET_OK !=
write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
item->filename,
@@ -417,17 +418,17 @@ extract_files (struct ScanTreeNode *item)
char *dst = &buf[slen];
GNUNET_memcpy (buf, item->filename, slen);
- size = GNUNET_CONTAINER_meta_data_serialize (
+ size = GNUNET_FS_meta_data_serialize (
meta,
&dst,
size,
- GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
+ GNUNET_FS_META_DATA_SERIALIZE_PART);
if (size < 0)
{
GNUNET_break (0);
size = 0;
}
- GNUNET_CONTAINER_meta_data_destroy (meta);
+ GNUNET_FS_meta_data_destroy (meta);
if (GNUNET_OK !=
write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
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 @@
* @author Igor Wronsky
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "gnunet_identity_service.h"
@@ -57,7 +58,7 @@ static struct GNUNET_FS_PublishContext *pc;
/**
* Meta-data provided via command-line option.
*/
-static struct GNUNET_CONTAINER_MetaData *meta;
+static struct GNUNET_FS_MetaData *meta;
/**
* Keywords provided via command-line option.
@@ -175,7 +176,7 @@ do_stop_task (void *cls)
}
if (NULL != meta)
{
- GNUNET_CONTAINER_meta_data_destroy (meta);
+ GNUNET_FS_meta_data_destroy (meta);
meta = NULL;
}
if (NULL != uri)
@@ -376,7 +377,7 @@ static int
publish_inspector (void *cls,
struct GNUNET_FS_FileInformation *fi,
uint64_t length,
- struct GNUNET_CONTAINER_MetaData *m,
+ struct GNUNET_FS_MetaData *m,
struct GNUNET_FS_Uri **uri,
struct GNUNET_FS_BlockOptions *bo,
int *do_index,
@@ -410,20 +411,20 @@ publish_inspector (void *cls,
}
if (NULL != meta)
{
- GNUNET_CONTAINER_meta_data_merge (m, meta);
- GNUNET_CONTAINER_meta_data_destroy (meta);
+ GNUNET_FS_meta_data_merge (m, meta);
+ GNUNET_FS_meta_data_destroy (meta);
meta = NULL;
}
if (enable_creation_time)
- GNUNET_CONTAINER_meta_data_add_publication_date (m);
+ GNUNET_FS_meta_data_add_publication_date (m);
if (extract_only)
{
- fn = GNUNET_CONTAINER_meta_data_get_by_type (
+ fn = GNUNET_FS_meta_data_get_by_type (
m,
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
fs = GNUNET_STRINGS_byte_size_fancy (length);
fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs);
- GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL);
+ GNUNET_FS_meta_data_iterate (m, &meta_printer, NULL);
fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs);
GNUNET_free (fn);
GNUNET_free (fs);
@@ -521,11 +522,11 @@ get_file_information (struct GNUNET_FS_ShareTreeItem
*item)
if (GNUNET_YES == item->is_directory)
{
if (NULL == item->meta)
- item->meta = GNUNET_CONTAINER_meta_data_create ();
- GNUNET_CONTAINER_meta_data_delete (item->meta,
- EXTRACTOR_METATYPE_MIMETYPE,
- NULL,
- 0);
+ item->meta = GNUNET_FS_meta_data_create ();
+ GNUNET_FS_meta_data_delete (item->meta,
+ EXTRACTOR_METATYPE_MIMETYPE,
+ NULL,
+ 0);
GNUNET_FS_meta_data_make_directory (item->meta);
if (NULL == item->ksk_uri)
{
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 @@
#include <ctype.h>
#include <inttypes.h>
#include <limits.h>
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#define GNUNET_SEARCH_log(kind, ...) \
- GNUNET_log_from(kind, "gnunet-search", __VA_ARGS__)
+ GNUNET_log_from (kind, "gnunet-search", __VA_ARGS__)
/* The default settings that we use for the printed output */
@@ -61,14 +62,16 @@
#define GENERIC_FILE_MIMETYPE "application/octet-stream"
-enum GNUNET_SEARCH_MetadataPrinterFlags {
+enum GNUNET_SEARCH_MetadataPrinterFlags
+{
METADATA_PRINTER_FLAG_NONE = 0,
METADATA_PRINTER_FLAG_ONE_RUN = 1,
METADATA_PRINTER_FLAG_HAVE_TYPE = 2
};
-struct GNUNET_SEARCH_MetadataPrinterInfo {
+struct GNUNET_SEARCH_MetadataPrinterInfo
+{
unsigned int counter;
unsigned int flags;
int type;
@@ -132,7 +135,7 @@ static const char *
print_escape_sequence (const char *const esc)
{
unsigned int probe;
- const char * cursor = esc + 1;
+ const char *cursor = esc + 1;
char tmp;
switch (*cursor)
{
@@ -150,7 +153,7 @@ print_escape_sequence (const char *const esc)
/* Possibly hexadecimal code point */
case 'x':
probe = 0;
- while (probe < 256 && isxdigit((tmp = *++cursor)))
+ while (probe < 256 && isxdigit ((tmp = *++cursor)))
probe = (probe << 4) + tmp - (tmp > 96 ? 87 : tmp > 64 ? 55 : 48);
goto maybe_codepoint;
@@ -167,7 +170,7 @@ print_escape_sequence (const char *const esc)
default: printf ("\\%c", *cursor); return cursor + 1;
}
-maybe_codepoint:
+ maybe_codepoint:
if (probe < 256)
putchar (probe);
else
@@ -212,31 +215,31 @@ item_printer (void *const cls,
return 0;
const char *cursor = meta_format_string;
- const char *next_spec = strchr(cursor, '%');
- const char *next_esc = strchr(cursor, '\\');
+ const char *next_spec = strchr (cursor, '%');
+ const char *next_esc = strchr (cursor, '\\');
-parse_format:
+ parse_format:
/* If an escape sequence exists before the next format specifier... */
- if (next_esc && (!next_spec || next_esc < next_spec))
+ if (next_esc && (! next_spec || next_esc < next_spec))
{
if (next_esc > cursor)
fwrite (cursor, 1, next_esc - cursor, stdout);
cursor = print_escape_sequence (next_esc);
- next_esc = strchr(cursor, '\\');
+ next_esc = strchr (cursor, '\\');
goto parse_format;
}
/* If a format specifier exists before the next escape sequence... */
- if (next_spec && (!next_esc || next_spec < next_esc))
+ if (next_spec && (! next_esc || next_spec < next_esc))
{
if (next_spec > cursor)
fwrite (cursor, 1, next_spec - cursor, stdout);
switch (*++next_spec)
{
- case '%': putchar('%'); break;
+ case '%': putchar ('%'); break;
case 'i': printf ("%d", type); break;
case 'l': printf ("%lu", (long unsigned int) data_size); break;
case 'n': printf ("%u", info->counter); break;
@@ -249,11 +252,11 @@ parse_format:
break;
#endif
case 'w': printf ("%s", plugin_name); break;
- case '\0': putchar('%'); return 0;
+ case '\0': putchar ('%'); return 0;
default: printf ("%%%c", *next_spec); break;
}
cursor = next_spec + 1;
- next_spec = strchr(cursor, '%');
+ next_spec = strchr (cursor, '%');
goto parse_format;
}
@@ -270,7 +273,7 @@ parse_format:
*
* @param filename the filename for this result
* @param uri the `struct GNUNET_FS_Uri` this result refers to
- * @param metadata the `struct GNUNET_CONTAINER_MetaData` associated with this
+ * @param metadata the `struct GNUNET_FS_MetaData` associated with this
result
* @param resultnum the result number
* @param is_directory GNUNET_YES if this is a directory, otherwise GNUNET_NO
@@ -279,34 +282,34 @@ parse_format:
static void
print_search_result (const char *const filename,
const struct GNUNET_FS_Uri *const uri,
- const struct GNUNET_CONTAINER_MetaData *const metadata,
+ const struct GNUNET_FS_MetaData *const metadata,
const unsigned int resultnum,
const int is_directory)
{
const char *cursor = GNUNET_YES == is_directory ?
- dir_format_string
+ dir_format_string
: format_string;
- const char *next_spec = strchr(cursor, '%');
- const char *next_esc = strchr(cursor, '\\');
+ const char *next_spec = strchr (cursor, '%');
+ const char *next_esc = strchr (cursor, '\\');
char *placeholder;
struct GNUNET_SEARCH_MetadataPrinterInfo info;
-parse_format:
+ parse_format:
/* If an escape sequence exists before the next format specifier... */
- if (next_esc && (!next_spec || next_esc < next_spec))
+ if (next_esc && (! next_spec || next_esc < next_spec))
{
if (next_esc > cursor)
fwrite (cursor, 1, next_esc - cursor, stdout);
cursor = print_escape_sequence (next_esc);
- next_esc = strchr(cursor, '\\');
+ next_esc = strchr (cursor, '\\');
goto parse_format;
}
/* If a format specifier exists before the next escape sequence... */
- if (next_spec && (!next_esc || next_spec < next_esc))
+ if (next_spec && (! next_esc || next_spec < next_esc))
{
if (next_spec > cursor)
fwrite (cursor, 1, next_spec - cursor, stdout);
@@ -317,9 +320,9 @@ parse_format:
case 'a':
info.flags = METADATA_PRINTER_FLAG_NONE;
-iterate_meta:
+ iterate_meta:
info.counter = 0;
- GNUNET_CONTAINER_meta_data_iterate (metadata, &item_printer, &info);
+ GNUNET_FS_meta_data_iterate (metadata, &item_printer, &info);
break;
/* File's name */
case 'f':
@@ -337,11 +340,11 @@ iterate_meta:
/* File name's length */
case 'l':
printf ("%lu",
- (long unsigned int) ( GNUNET_YES == is_directory ?
- strlen(filename) +
- (sizeof(GNUNET_FS_DIRECTORY_EXT) - 1)
+ (long unsigned int) (GNUNET_YES == is_directory ?
+ strlen (filename)
+ + (sizeof(GNUNET_FS_DIRECTORY_EXT) - 1)
:
- strlen(filename)));
+ strlen (filename)));
break;
/* File's mime type */
case 'm':
@@ -350,7 +353,7 @@ iterate_meta:
printf ("%s", GNUNET_FS_DIRECTORY_MIME);
break;
}
- placeholder = GNUNET_CONTAINER_meta_data_get_by_type (
+ placeholder = GNUNET_FS_meta_data_get_by_type (
metadata,
EXTRACTOR_METATYPE_MIMETYPE);
printf ("%s", placeholder ? placeholder : GENERIC_FILE_MIMETYPE);
@@ -376,7 +379,7 @@ iterate_meta:
case '5': case '6': case '7': case '8': case '9':
cursor = next_spec;
info.type = *cursor - 48;
- while (isdigit(*++cursor) && info.type < (INT_MAX - *cursor + 48) / 10)
+ while (isdigit (*++cursor) && info.type < (INT_MAX - *cursor + 48) / 10)
info.type = info.type * 10 + *cursor - 48;
if (info.type == 0 || *cursor != '#')
goto not_a_specifier;
@@ -391,21 +394,21 @@ iterate_meta:
/* Only the first metadata field of type `info.type` */
case 'j':
next_spec = cursor;
- info.flags = METADATA_PRINTER_FLAG_HAVE_TYPE |
- METADATA_PRINTER_FLAG_ONE_RUN;
+ info.flags = METADATA_PRINTER_FLAG_HAVE_TYPE
+ | METADATA_PRINTER_FLAG_ONE_RUN;
goto iterate_meta;
}
goto not_a_specifier;
/* All other cases */
- case '%': putchar('%'); break;
- case '\0': putchar('%'); return;
+ case '%': putchar ('%'); break;
+ case '\0': putchar ('%'); return;
-not_a_specifier:
+ not_a_specifier:
default: printf ("%%%c", *next_spec); break;
}
cursor = next_spec + 1;
- next_spec = strchr(cursor, '%');
+ next_spec = strchr (cursor, '%');
goto parse_format;
}
@@ -439,10 +442,10 @@ clean_task (void *const cls)
GNUNET_DISK_PERM_USER_READ
| GNUNET_DISK_PERM_USER_WRITE))
{
- GNUNET_SEARCH_log(GNUNET_ERROR_TYPE_ERROR,
- _ ("Failed to write directory with search results to "
- "`%s'\n"),
- output_filename);
+ GNUNET_SEARCH_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Failed to write directory with search results to "
+ "`%s'\n"),
+ output_filename);
}
GNUNET_free (ddata);
GNUNET_free (output_filename);
@@ -490,7 +493,7 @@ progress_cb (void *const cls,
break;
cnt++;
- filename = GNUNET_CONTAINER_meta_data_get_by_type (
+ filename = GNUNET_FS_meta_data_get_by_type (
info->value.search.specifics.result.meta,
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
is_directory = GNUNET_FS_meta_data_test_for_directory (
@@ -501,12 +504,12 @@ progress_cb (void *const cls,
filename[strlen (filename) - 1] = '\0';
GNUNET_DISK_filename_canonicalize (filename);
}
- print_search_result ( filename ?
- filename
+ print_search_result (filename ?
+ filename
: is_directory ?
- GENERIC_DIRECTORY_NAME
+ GENERIC_DIRECTORY_NAME
:
- GENERIC_FILE_NAME,
+ GENERIC_FILE_NAME,
info->value.search.specifics.result.uri,
info->value.search.specifics.result.meta,
cnt,
@@ -528,9 +531,9 @@ progress_cb (void *const cls,
break;
case GNUNET_FS_STATUS_SEARCH_ERROR:
- GNUNET_SEARCH_log(GNUNET_ERROR_TYPE_ERROR,
- _ ("Error searching: %s.\n"),
- info->value.search.specifics.error.message);
+ GNUNET_SEARCH_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Error searching: %s.\n"),
+ info->value.search.specifics.error.message);
GNUNET_SCHEDULER_shutdown ();
break;
@@ -539,9 +542,9 @@ progress_cb (void *const cls,
break;
default:
- GNUNET_SEARCH_log(GNUNET_ERROR_TYPE_ERROR,
- _ ("Unexpected status: %d\n"),
- info->status);
+ GNUNET_SEARCH_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Unexpected status: %d\n"),
+ info->status);
break;
}
return NULL;
@@ -600,7 +603,7 @@ run (void *const cls,
ret = 1;
return;
}
- if (silent_mode && !output_filename)
+ if (silent_mode && ! output_filename)
{
fprintf (stderr, _ ("An output file is mandatory for silent mode.\n"));
ret = 1;
@@ -627,7 +630,7 @@ run (void *const cls,
ret = 1;
return;
}
- if (!GNUNET_FS_uri_test_ksk (uri) && !GNUNET_FS_uri_test_sks (uri))
+ if (! GNUNET_FS_uri_test_ksk (uri) && ! GNUNET_FS_uri_test_sks (uri))
{
fprintf (stderr,
"%s",
@@ -640,7 +643,7 @@ run (void *const cls,
}
if (bookmark_only)
{
- char * bmstr = GNUNET_FS_uri_to_string (uri);
+ char *bmstr = GNUNET_FS_uri_to_string (uri);
printf ("%s\n", bmstr);
GNUNET_free (bmstr);
GNUNET_FS_uri_destroy (uri);
@@ -779,15 +782,15 @@ main (int argc, char *const *argv)
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 12;
- if (GNUNET_SYSERR ==
+ if (GNUNET_SYSERR ==
GNUNET_PROGRAM_run (argc,
argv,
"gnunet-search [OPTIONS] KEYWORD1 KEYWORD2 ...",
gettext_noop ("Search for files that have been "
"published on GNUnet\n"),
- options,
- &run,
- NULL))
+ options,
+ &run,
+ NULL))
ret = 1;
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 @@
* @author Igor Wronsky
*/
#include "platform.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
static int ret;
diff --git a/src/util/container_meta_data.c b/src/fs/meta_data.c
similarity index 69%
rename from src/util/container_meta_data.c
rename to 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 @@
/*
This file is part of GNUnet.
- Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 GNUnet e.V.
+ Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2022 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -19,104 +19,28 @@
*/
/**
- * @file util/container_meta_data.c
+ * @file fs/meta_data.c
* @brief Storing of meta data
* @author Christian Grothoff
+ * @author Martin Schanzenbach
*/
#include "platform.h"
#include "gnunet_util_lib.h"
-#if HAVE_EXTRACTOR_H
-#include <extractor.h>
-#endif
-#include <zlib.h>
-
-#define LOG(kind, ...) GNUNET_log_from (kind, "util-container-meta-data", \
- __VA_ARGS__)
-
+#include "gnunet_extractor_compat.h"
+#include "gnunet_fs_service.h"
/**
- * Try to compress the given block of data using libz. Only returns
- * the compressed block if compression worked and the new block is
- * actually smaller. Decompress using #GNUNET_decompress().
- *
- * @param data block to compress; if compression
- * resulted in a smaller block, the first
- * bytes of data are updated to the compressed
- * data
- * @param old_size number of bytes in data
- * @param[out] result set to the compressed data, if compression worked
- * @param[out] new_size set to size of result, if compression worked
- * @return #GNUNET_YES if compression reduce the size,
- * #GNUNET_NO if compression did not help
+ * Maximum size allowed for meta data written/read from disk.
+ * File-sharing limits to 64k, so this should be rather generous.
*/
-int
-GNUNET_try_compression (const char *data,
- size_t old_size,
- char **result,
- size_t *new_size)
-{
- char *tmp;
- uLongf dlen;
-
- *result = NULL;
- *new_size = 0;
-#ifdef compressBound
- dlen = compressBound (old_size);
-#else
- dlen = old_size + (old_size / 100) + 20;
- /* documentation says 100.1% oldSize + 12 bytes, but we
- * should be able to overshoot by more to be safe */
-#endif
- tmp = GNUNET_malloc (dlen);
- if (Z_OK ==
- compress2 ((Bytef *) tmp,
- &dlen,
- (const Bytef *) data,
- old_size, 9))
- {
- if (dlen < old_size)
- {
- *result = tmp;
- *new_size = dlen;
- return GNUNET_YES;
- }
- }
- GNUNET_free (tmp);
- return GNUNET_NO;
-}
+#define MAX_META_DATA (1024 * 1024)
-/**
- * Decompress input, return the decompressed data as output. Dual to
- * #GNUNET_try_compression(). Caller must set @a output_size to the
- * number of bytes that were originally compressed.
- *
- * @param input compressed data
- * @param input_size number of bytes in input
- * @param output_size expected size of the output
- * @return NULL on error, buffer of @a output_size decompressed bytes otherwise
- */
-char *
-GNUNET_decompress (const char *input,
- size_t input_size,
- size_t output_size)
-{
- char *output;
- uLongf olen;
-
- olen = output_size;
- output = GNUNET_malloc (olen);
- if (Z_OK ==
- uncompress ((Bytef *) output,
- &olen,
- (const Bytef *) input,
- input_size))
- return output;
- GNUNET_free (output);
- return NULL;
-}
+#define LOG(kind, ...) GNUNET_log_from (kind, "fs-meta-data", \
+ __VA_ARGS__)
+
/**
@@ -168,7 +92,7 @@ struct MetaItem
/**
* Meta data to associate with a file, directory or namespace.
*/
-struct GNUNET_CONTAINER_MetaData
+struct GNUNET_FS_MetaData
{
/**
* Head of linked list of the meta data items.
@@ -199,14 +123,14 @@ struct GNUNET_CONTAINER_MetaData
/**
- * Create a fresh struct CONTAINER_MetaData token.
+ * Create a fresh struct FS_MetaData token.
*
* @return empty meta-data container
*/
-struct GNUNET_CONTAINER_MetaData *
-GNUNET_CONTAINER_meta_data_create ()
+struct GNUNET_FS_MetaData *
+GNUNET_FS_meta_data_create ()
{
- return GNUNET_new (struct GNUNET_CONTAINER_MetaData);
+ return GNUNET_new (struct GNUNET_FS_MetaData);
}
@@ -232,7 +156,7 @@ meta_item_free (struct MetaItem *mi)
* @param md meta data that changed
*/
static void
-invalidate_sbuf (struct GNUNET_CONTAINER_MetaData *md)
+invalidate_sbuf (struct GNUNET_FS_MetaData *md)
{
if (NULL == md->sbuf)
return;
@@ -243,7 +167,7 @@ invalidate_sbuf (struct GNUNET_CONTAINER_MetaData *md)
void
-GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md)
+GNUNET_FS_meta_data_destroy (struct GNUNET_FS_MetaData *md)
{
struct MetaItem *pos;
@@ -260,7 +184,7 @@ GNUNET_CONTAINER_meta_data_destroy (struct
GNUNET_CONTAINER_MetaData *md)
void
-GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md)
+GNUNET_FS_meta_data_clear (struct GNUNET_FS_MetaData *md)
{
struct MetaItem *mi;
@@ -272,15 +196,15 @@ GNUNET_CONTAINER_meta_data_clear (struct
GNUNET_CONTAINER_MetaData *md)
meta_item_free (mi);
}
GNUNET_free (md->sbuf);
- memset (md, 0, sizeof(struct GNUNET_CONTAINER_MetaData));
+ memset (md, 0, sizeof(struct GNUNET_FS_MetaData));
}
int
-GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData
- *md1,
- const struct GNUNET_CONTAINER_MetaData
- *md2)
+GNUNET_FS_meta_data_test_equal (const struct GNUNET_FS_MetaData
+ *md1,
+ const struct GNUNET_FS_MetaData
+ *md2)
{
struct MetaItem *i;
struct MetaItem *j;
@@ -331,12 +255,12 @@ GNUNET_CONTAINER_meta_data_test_equal (const struct
GNUNET_CONTAINER_MetaData
* data_mime_type and plugin_name are not considered for "exists"
checks
*/
int
-GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type, const char
*data,
- size_t data_size)
+GNUNET_FS_meta_data_insert (struct GNUNET_FS_MetaData *md,
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type, const char *data,
+ size_t data_size)
{
struct MetaItem *pos;
struct MetaItem *mi;
@@ -406,7 +330,7 @@ GNUNET_CONTAINER_meta_data_insert (struct
GNUNET_CONTAINER_MetaData *md,
/**
* Merge given meta data.
*
- * @param cls the `struct GNUNET_CONTAINER_MetaData` to merge into
+ * @param cls the `struct GNUNET_FS_MetaData` to merge into
* @param plugin_name name of the plugin that produced this value;
* special values can be used (e.g. '<zlib>' for zlib being
* used in the main libextractor library and yielding
@@ -424,26 +348,26 @@ merge_helper (void *cls, const char *plugin_name, enum
EXTRACTOR_MetaType type,
enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
const char *data, size_t data_size)
{
- struct GNUNET_CONTAINER_MetaData *md = cls;
+ struct GNUNET_FS_MetaData *md = cls;
- (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format,
- data_mime_type, data, data_size);
+ (void) GNUNET_FS_meta_data_insert (md, plugin_name, type, format,
+ data_mime_type, data, data_size);
return 0;
}
void
-GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md,
- const struct GNUNET_CONTAINER_MetaData *in)
+GNUNET_FS_meta_data_merge (struct GNUNET_FS_MetaData *md,
+ const struct GNUNET_FS_MetaData *in)
{
- GNUNET_CONTAINER_meta_data_iterate (in, &merge_helper, md);
+ GNUNET_FS_meta_data_iterate (in, &merge_helper, md);
}
int
-GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
- enum EXTRACTOR_MetaType type,
- const char *data, size_t data_size)
+GNUNET_FS_meta_data_delete (struct GNUNET_FS_MetaData *md,
+ enum EXTRACTOR_MetaType type,
+ const char *data, size_t data_size)
{
struct MetaItem *pos;
@@ -468,21 +392,21 @@ GNUNET_CONTAINER_meta_data_delete (struct
GNUNET_CONTAINER_MetaData *md,
void
-GNUNET_CONTAINER_meta_data_add_publication_date (struct
- GNUNET_CONTAINER_MetaData *md)
+GNUNET_FS_meta_data_add_publication_date (struct
+ GNUNET_FS_MetaData *md)
{
const char *dat;
struct GNUNET_TIME_Absolute t;
t = GNUNET_TIME_absolute_get ();
- GNUNET_CONTAINER_meta_data_delete (md,
- EXTRACTOR_METATYPE_PUBLICATION_DATE,
- NULL, 0);
+ GNUNET_FS_meta_data_delete (md,
+ EXTRACTOR_METATYPE_PUBLICATION_DATE,
+ NULL, 0);
dat = GNUNET_STRINGS_absolute_time_to_string (t);
- GNUNET_CONTAINER_meta_data_insert (md, "<gnunet>",
- EXTRACTOR_METATYPE_PUBLICATION_DATE,
- EXTRACTOR_METAFORMAT_UTF8, "text/plain",
- dat, strlen (dat) + 1);
+ GNUNET_FS_meta_data_insert (md, "<gnunet>",
+ EXTRACTOR_METATYPE_PUBLICATION_DATE,
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain",
+ dat, strlen (dat) + 1);
}
@@ -495,9 +419,9 @@ GNUNET_CONTAINER_meta_data_add_publication_date (struct
* @return number of entries
*/
int
-GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md,
- EXTRACTOR_MetaDataProcessor iter,
- void *iter_cls)
+GNUNET_FS_meta_data_iterate (const struct GNUNET_FS_MetaData *md,
+ EXTRACTOR_MetaDataProcessor iter,
+ void *iter_cls)
{
struct MetaItem *pos;
@@ -515,9 +439,9 @@ GNUNET_CONTAINER_meta_data_iterate (const struct
GNUNET_CONTAINER_MetaData *md,
char *
-GNUNET_CONTAINER_meta_data_get_by_type (const struct
- GNUNET_CONTAINER_MetaData *md,
- enum EXTRACTOR_MetaType type)
+GNUNET_FS_meta_data_get_by_type (const struct
+ GNUNET_FS_MetaData *md,
+ enum EXTRACTOR_MetaType type)
{
struct MetaItem *pos;
@@ -533,9 +457,9 @@ GNUNET_CONTAINER_meta_data_get_by_type (const struct
char *
-GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
- GNUNET_CONTAINER_MetaData *md,
- ...)
+GNUNET_FS_meta_data_get_first_by_types (const struct
+ GNUNET_FS_MetaData *md,
+ ...)
{
char *ret;
va_list args;
@@ -550,7 +474,7 @@ GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
type = va_arg (args, int);
if (-1 == type)
break;
- if (NULL != (ret = GNUNET_CONTAINER_meta_data_get_by_type (md, type)))
+ if (NULL != (ret = GNUNET_FS_meta_data_get_by_type (md, type)))
break;
}
va_end (args);
@@ -567,8 +491,8 @@ GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
* @return number of bytes in thumbnail, 0 if not available
*/
size_t
-GNUNET_CONTAINER_meta_data_get_thumbnail (const struct
GNUNET_CONTAINER_MetaData
- *md, unsigned char **thumb)
+GNUNET_FS_meta_data_get_thumbnail (const struct GNUNET_FS_MetaData
+ *md, unsigned char **thumb)
{
struct MetaItem *pos;
struct MetaItem *match;
@@ -598,25 +522,25 @@ GNUNET_CONTAINER_meta_data_get_thumbnail (const struct
GNUNET_CONTAINER_MetaData
/**
- * Duplicate a `struct GNUNET_CONTAINER_MetaData`.
+ * Duplicate a `struct GNUNET_FS_MetaData`.
*
* @param md what to duplicate
* @return duplicate meta-data container
*/
-struct GNUNET_CONTAINER_MetaData *
-GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData
- *md)
+struct GNUNET_FS_MetaData *
+GNUNET_FS_meta_data_duplicate (const struct GNUNET_FS_MetaData
+ *md)
{
- struct GNUNET_CONTAINER_MetaData *ret;
+ struct GNUNET_FS_MetaData *ret;
struct MetaItem *pos;
if (NULL == md)
return NULL;
- ret = GNUNET_CONTAINER_meta_data_create ();
+ ret = GNUNET_FS_meta_data_create ();
for (pos = md->items_tail; NULL != pos; pos = pos->prev)
- GNUNET_CONTAINER_meta_data_insert (ret, pos->plugin_name, pos->type,
- pos->format, pos->mime_type, pos->data,
- pos->data_size);
+ GNUNET_FS_meta_data_insert (ret, pos->plugin_name, pos->type,
+ pos->format, pos->mime_type, pos->data,
+ pos->data_size);
return ret;
}
@@ -714,13 +638,13 @@ struct MetaDataEntry
* space)
*/
ssize_t
-GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
- *md, char **target, size_t max,
- enum
-
GNUNET_CONTAINER_MetaDataSerializationOptions
- opt)
+GNUNET_FS_meta_data_serialize (const struct GNUNET_FS_MetaData
+ *md, char **target, size_t max,
+ enum
+ GNUNET_FS_MetaDataSerializationOptions
+ opt)
{
- struct GNUNET_CONTAINER_MetaData *vmd;
+ struct GNUNET_FS_MetaData *vmd;
struct MetaItem *pos;
struct MetaDataHeader ihdr;
struct MetaDataHeader *hdr;
@@ -754,7 +678,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct
GNUNET_CONTAINER_MetaData
GNUNET_memcpy (*target, md->sbuf, md->sbuf_size);
return md->sbuf_size;
}
- if (0 == (opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_PART))
+ if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_PART))
return GNUNET_SYSERR; /* can say that this will fail */
/* need to compute a partial serialization, sbuf useless ... */
}
@@ -821,7 +745,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct
GNUNET_CONTAINER_MetaData
for (pos = md->items_head; NULL != pos; pos = pos->next)
{
comp = GNUNET_NO;
- if (0 == (opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS))
+ if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_NO_COMPRESS))
comp = GNUNET_try_compression ((const char *) &ent[i],
left,
&cdata,
@@ -832,7 +756,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct
GNUNET_CONTAINER_MetaData
/* fill 'sbuf'; this "modifies" md, but since this is only
* an internal cache we will cast away the 'const' instead
* of making the API look strange. */
- vmd = (struct GNUNET_CONTAINER_MetaData *) md;
+ vmd = (struct GNUNET_FS_MetaData *) md;
hdr = GNUNET_malloc (left + sizeof(struct MetaDataHeader));
hdr->size = htonl (left);
hdr->entries = htonl (md->item_count);
@@ -897,7 +821,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct
GNUNET_CONTAINER_MetaData
return rlen;
}
- if (0 == (opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_PART))
+ if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_PART))
{
/* does not fit! */
GNUNET_free (ent);
@@ -935,8 +859,8 @@ GNUNET_CONTAINER_meta_data_serialize (const struct
GNUNET_CONTAINER_MetaData
ssize_t
-GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
- GNUNET_CONTAINER_MetaData *md)
+GNUNET_FS_meta_data_get_serialized_size (const struct
+ GNUNET_FS_MetaData *md)
{
ssize_t ret;
char *ptr;
@@ -945,8 +869,8 @@ GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
return md->sbuf_size;
ptr = NULL;
ret =
- GNUNET_CONTAINER_meta_data_serialize (md, &ptr, GNUNET_MAX_MALLOC_CHECKED,
-
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
+ GNUNET_FS_meta_data_serialize (md, &ptr, GNUNET_MAX_MALLOC_CHECKED,
+ GNUNET_FS_META_DATA_SERIALIZE_FULL);
if (-1 != ret)
GNUNET_free (ptr);
return ret;
@@ -961,10 +885,10 @@ GNUNET_CONTAINER_meta_data_get_serialized_size (const
struct
* @return MD on success, NULL on error (i.e.
* bad format)
*/
-struct GNUNET_CONTAINER_MetaData *
-GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size)
+struct GNUNET_FS_MetaData *
+GNUNET_FS_meta_data_deserialize (const char *input, size_t size)
{
- struct GNUNET_CONTAINER_MetaData *md;
+ struct GNUNET_FS_MetaData *md;
struct MetaDataHeader hdr;
struct MetaDataEntry ent;
uint32_t ic;
@@ -1039,7 +963,7 @@ GNUNET_CONTAINER_meta_data_deserialize (const char *input,
size_t size)
}
}
- md = GNUNET_CONTAINER_meta_data_create ();
+ md = GNUNET_FS_meta_data_create ();
left = dataSize - ic * sizeof(struct MetaDataEntry);
mdata = &cdata[ic * sizeof(struct MetaDataEntry)];
for (i = 0; i < ic; i++)
@@ -1109,14 +1033,192 @@ GNUNET_CONTAINER_meta_data_deserialize (const char
*input, size_t size)
mime_type = NULL;
else
mime_type = &mdata[left];
- GNUNET_CONTAINER_meta_data_insert (md, plugin_name,
- (enum EXTRACTOR_MetaType)
- ntohl (ent.type), format, mime_type,
- meta_data, dlen);
+ GNUNET_FS_meta_data_insert (md, plugin_name,
+ (enum EXTRACTOR_MetaType)
+ ntohl (ent.type), format, mime_type,
+ meta_data, dlen);
}
GNUNET_free (data);
return md;
}
+/**
+ * Read a metadata container.
+ *
+ * @param h handle to an open file
+ * @param what describes what is being read (for error message creation)
+ * @param result the buffer to store a pointer to the (allocated) metadata
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
+ */
+int
+GNUNET_FS_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
+ const char *what,
+ struct GNUNET_FS_MetaData **result)
+{
+ uint32_t size;
+ char *buf;
+ struct GNUNET_FS_MetaData *meta;
+
+ if (GNUNET_OK != GNUNET_BIO_read_int32 (h,
+ _ ("metadata length"),
+ (int32_t *) &size))
+ return GNUNET_SYSERR;
+ if (0 == size)
+ {
+ *result = NULL;
+ return GNUNET_OK;
+ }
+ if (MAX_META_DATA < size)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Serialized metadata `%s' larger than allowed (%u > %u)"),
+ what,
+ size,
+ MAX_META_DATA);
+ return GNUNET_SYSERR;
+ }
+ buf = GNUNET_malloc (size);
+ if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, size))
+ {
+ GNUNET_free (buf);
+ return GNUNET_SYSERR;
+ }
+ meta = GNUNET_FS_meta_data_deserialize (buf, size);
+ if (NULL == meta)
+ {
+ GNUNET_free (buf);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Failed to deserialize metadata `%s'"), what);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free (buf);
+ *result = meta;
+ return GNUNET_OK;
+}
+
+/**
+ * Write a metadata container.
+ *
+ * @param h the IO handle to write to
+ * @param what what is being written (for error message creation)
+ * @param m metadata to write
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_FS_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
+ const char *what,
+ const struct GNUNET_FS_MetaData *m)
+{
+ ssize_t size;
+ char *buf;
+
+ if (m == NULL)
+ return GNUNET_BIO_write_int32 (h, _ ("metadata length"), 0);
+ buf = NULL;
+ size = GNUNET_FS_meta_data_serialize (m,
+ &buf,
+ MAX_META_DATA,
+ GNUNET_FS_META_DATA_SERIALIZE_PART);
+ if (-1 == size)
+ {
+ GNUNET_free (buf);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Failed to serialize metadata `%s'"),
+ what);
+ return GNUNET_SYSERR;
+ }
+ if ((GNUNET_OK != GNUNET_BIO_write_int32 (h,
+ _ ("metadata length"),
+ (uint32_t) size))
+ || (GNUNET_OK != GNUNET_BIO_write (h, what, buf, size)))
+ {
+ GNUNET_free (buf);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free (buf);
+ return GNUNET_OK;
+}
+
+/**
+ * Function used internally to read a metadata container from within a read
+ * spec.
+ *
+ * @param cls ignored, always NULL
+ * @param h the IO handle to read from
+ * @param what what is being read (for error message creation)
+ * @param target where to store the data
+ * @param target_size ignored
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+static int
+read_spec_handler_meta_data (void *cls,
+ struct GNUNET_BIO_ReadHandle *h,
+ const char *what,
+ void *target,
+ size_t target_size)
+{
+ struct GNUNET_FS_MetaData **result = target;
+ return GNUNET_FS_read_meta_data (h, what, result);
+}
+
+/**
+ * Create the specification to read a metadata container.
+ *
+ * @param what describes what is being read (for error message creation)
+ * @param result the buffer to store a pointer to the (allocated) metadata
+ * @return the read spec
+ */
+struct GNUNET_BIO_ReadSpec
+GNUNET_FS_read_spec_meta_data (const char *what,
+ struct GNUNET_FS_MetaData **result)
+{
+ struct GNUNET_BIO_ReadSpec rs = {
+ .rh = &read_spec_handler_meta_data,
+ .cls = NULL,
+ .target = result,
+ .size = 0,
+ };
+
+ return rs;
+}
+
+/**
+ * Function used internally to write a metadata container from within a write
+ * spec.
+ *
+ * @param cls ignored, always NULL
+ * @param h the IO handle to write to
+ * @param what what is being written (for error message creation)
+ * @param source the data to write
+ * @param source_size ignored
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
+ */
+static int
+write_spec_handler_meta_data (void *cls,
+ struct GNUNET_BIO_WriteHandle *h,
+ const char *what,
+ void *source,
+ size_t source_size)
+{
+ const struct GNUNET_FS_MetaData *m = source;
+ return GNUNET_FS_write_meta_data (h, what, m);
+}
+
+
+struct GNUNET_BIO_WriteSpec
+GNUNET_FS_write_spec_meta_data (const char *what,
+ const struct GNUNET_FS_MetaData *m)
+{
+ struct GNUNET_BIO_WriteSpec ws = {
+ .wh = &write_spec_handler_meta_data,
+ .cls = NULL,
+ .what = what,
+ .source = (void *) m,
+ .source_size = 0,
+ };
+
+ return ws;
+}
+
-/* end of container_meta_data.c */
+/* 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 @@
*/
#include "platform.h"
#include "gnunet_block_plugin.h"
+#include "gnunet_extractor_compat.h"
#include "gnunet_fs_service.h"
#include "block_fs.h"
#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 @@
struct PCLS
{
struct GNUNET_FS_Uri **uri;
- struct GNUNET_CONTAINER_MetaData **md;
+ struct GNUNET_FS_MetaData **md;
unsigned int pos;
unsigned int max;
};
static void
processor (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *md, size_t length,
+ const struct GNUNET_FS_MetaData *md, size_t length,
const void *data)
{
struct PCLS *p = cls;
@@ -71,8 +71,8 @@ testDirectory (unsigned int i)
char *data;
size_t dlen;
struct GNUNET_FS_Uri **uris;
- struct GNUNET_CONTAINER_MetaData **mds;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData **mds;
+ struct GNUNET_FS_MetaData *meta;
struct PCLS cls;
char *emsg;
int p;
@@ -85,7 +85,7 @@ testDirectory (unsigned int i)
cls.max = i;
uris = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri *) * i);
- mds = GNUNET_malloc (sizeof(struct GNUNET_CONTAINER_MetaData *) * i);
+ mds = GNUNET_malloc (sizeof(struct GNUNET_FS_MetaData *) * i);
meta = GNUNET_CONTAINER_meta_data_create ();
GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE,
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,
"down_bar",
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_FileInformation *fi;
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,
"down_bar",
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_FileInformation *fi;
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 @@
static int
mycleaner (void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length,
- struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri,
+ struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri,
struct GNUNET_FS_BlockOptions *bo, int *do_index, void
**client_info)
{
return GNUNET_OK;
@@ -67,7 +67,7 @@ run (void *cls, char *const *args, const char *cfgfile,
char *fn1;
char *fn2;
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_FileInformation *fi1;
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,
"down_bar",
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_FileInformation *fi1;
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 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2003, 2004, 2006, 2009, 2010, 2022 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file util/test_fs_meta_data.c
+ * @brief Test for fs_meta_data.c
+ * @author Christian Grothoff
+ * @author Martin Schanzenbach
+ */
+
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_extractor_compat.h"
+#include "gnunet_fs_service.h"
+
+#define ABORT(m) { fprintf (stderr, "Error at %s:%d\n", __FILE__, __LINE__); \
+ if (m != NULL) GNUNET_FS_meta_data_destroy (m); \
+ return 1; }
+
+
+static int
+testMeta (int i)
+{
+ struct GNUNET_FS_MetaData *m;
+ char val[256];
+ char *sval;
+ int j;
+ unsigned int size;
+
+ m = GNUNET_FS_meta_data_create ();
+ if (GNUNET_OK !=
+ GNUNET_FS_meta_data_insert (m, "<test>", EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain", "TestTitle",
+ strlen ("TestTitle") + 1))
+ ABORT (m);
+ if (GNUNET_OK !=
+ GNUNET_FS_meta_data_insert (m, "<test>",
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain", "TestTitle",
+ strlen ("TestTitle") + 1))
+ ABORT (m);
+ if (GNUNET_OK == GNUNET_FS_meta_data_insert (m, "<test>",
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "TestTitle", strlen (
+ "TestTitle") + 1))
/* dup! */
+ ABORT (m);
+ if (GNUNET_OK == GNUNET_FS_meta_data_insert (m, "<test>",
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "TestTitle", strlen (
+ "TestTitle") + 1))
/* dup! */
+ ABORT (m);
+ if (2 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
+ ABORT (m);
+ if (GNUNET_OK !=
+ GNUNET_FS_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME,
+ "TestTitle", strlen ("TestTitle") + 1))
+ ABORT (m);
+ if (GNUNET_OK == GNUNET_FS_meta_data_delete (m,
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ "TestTitle", strlen (
+ "TestTitle") + 1))
/* already gone */
+ ABORT (m);
+ if (1 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
+ ABORT (m);
+ if (GNUNET_OK !=
+ GNUNET_FS_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE,
+ "TestTitle", strlen ("TestTitle") + 1))
+ ABORT (m);
+ if (GNUNET_OK == GNUNET_FS_meta_data_delete (m,
+ EXTRACTOR_METATYPE_TITLE,
+ "TestTitle", strlen (
+ "TestTitle") + 1))
/* already gone */
+ ABORT (m);
+ if (0 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
+ ABORT (m);
+ for (j = 0; j < i; j++)
+ {
+ GNUNET_snprintf (val, sizeof(val), "%s.%d",
+ "A teststring that should compress well.", j);
+ if (GNUNET_OK !=
+ GNUNET_FS_meta_data_insert (m, "<test>",
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain", val, strlen (val) + 1))
+ ABORT (m);
+ }
+ if (i != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
+ ABORT (m);
+
+ size = GNUNET_FS_meta_data_get_serialized_size (m);
+ sval = NULL;
+ if (size !=
+ GNUNET_FS_meta_data_serialize (m, &sval, size,
+ GNUNET_FS_META_DATA_SERIALIZE_FULL))
+ {
+ GNUNET_free (sval);
+ ABORT (m);
+ }
+ GNUNET_FS_meta_data_destroy (m);
+ m = GNUNET_FS_meta_data_deserialize (sval, size);
+ GNUNET_free (sval);
+ if (m == NULL)
+ ABORT (m);
+ for (j = 0; j < i; j++)
+ {
+ GNUNET_snprintf (val,
+ sizeof(val),
+ "%s.%d",
+ "A teststring that should compress well.",
+ j);
+ if (GNUNET_OK !=
+ GNUNET_FS_meta_data_delete (m,
+ EXTRACTOR_METATYPE_UNKNOWN,
+ val,
+ strlen (val) + 1))
+ {
+ ABORT (m);
+ }
+ }
+ if (0 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
+ ABORT (m);
+ GNUNET_FS_meta_data_destroy (m);
+ return 0;
+}
+
+
+static int
+testMetaMore (int i)
+{
+ struct GNUNET_FS_MetaData *meta;
+ int q;
+ char txt[128];
+ char *data;
+ unsigned long long size;
+
+ meta = GNUNET_FS_meta_data_create ();
+ for (q = 0; q <= i; q++)
+ {
+ GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
+ GNUNET_FS_meta_data_insert (meta, "<test>",
+ q
+ % 42 /* EXTRACTOR_metatype_get_max () */,
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain",
+ txt, strlen (txt) + 1);
+ }
+ size = GNUNET_FS_meta_data_get_serialized_size (meta);
+ data = GNUNET_malloc (size * 4);
+ if (size !=
+ GNUNET_FS_meta_data_serialize (meta, &data, size * 4,
+ GNUNET_FS_META_DATA_SERIALIZE_FULL))
+ {
+ GNUNET_free (data);
+ ABORT (meta);
+ }
+ GNUNET_FS_meta_data_destroy (meta);
+ GNUNET_free (data);
+ return 0;
+}
+
+
+static int
+testMetaLink ()
+{
+ struct GNUNET_FS_MetaData *m;
+ char *val;
+ unsigned int size;
+
+ m = GNUNET_FS_meta_data_create ();
+ if (GNUNET_OK !=
+ GNUNET_FS_meta_data_insert (m, "<test>",
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain", "link",
+ strlen ("link") + 1))
+ ABORT (m);
+ if (GNUNET_OK !=
+ GNUNET_FS_meta_data_insert (m, "<test>",
+ EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain", "lib-link.m4",
+ strlen ("lib-link.m4") + 1))
+ ABORT (m);
+ val = NULL;
+ size =
+ GNUNET_FS_meta_data_serialize (m, &val, (size_t) -1,
+ GNUNET_FS_META_DATA_SERIALIZE_FULL);
+ GNUNET_FS_meta_data_destroy (m);
+ m = GNUNET_FS_meta_data_deserialize (val, size);
+ GNUNET_free (val);
+ if (m == NULL)
+ ABORT (m);
+ GNUNET_FS_meta_data_destroy (m);
+ return 0;
+}
+
+
+static int
+check ()
+{
+ struct GNUNET_FS_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta2;
+ int q;
+ int i = 100;
+ char txt[128];
+ char *str;
+ unsigned char *thumb;
+
+ meta = GNUNET_FS_meta_data_create ();
+ meta2 = GNUNET_FS_meta_data_create ();
+ for (q = 0; q <= i; q++)
+ {
+ GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
+ GNUNET_FS_meta_data_insert (meta, "<test>",
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain",
+ "TestTitle", strlen ("TestTitle") + 1);
+ GNUNET_FS_meta_data_insert (meta2, "<test>",
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain",
+ "TestTitle", strlen ("TestTitle") + 1);
+ }
+
+ // check meta_data_test_equal
+ if (GNUNET_YES != GNUNET_FS_meta_data_test_equal (meta, meta2))
+ {
+ GNUNET_FS_meta_data_destroy (meta2);
+ ABORT (meta);
+ }
+
+ // check meta_data_clear
+ GNUNET_FS_meta_data_clear (meta2);
+ if (0 != GNUNET_FS_meta_data_iterate (meta2, NULL, NULL))
+ {
+ GNUNET_FS_meta_data_destroy (meta2);
+ ABORT (meta);
+ }
+ // check equal branch in meta_data_test_equal
+ if (GNUNET_YES != GNUNET_FS_meta_data_test_equal (meta, meta))
+ {
+ GNUNET_FS_meta_data_destroy (meta2);
+ ABORT (meta);
+ }
+ // check "count" branch in meta_data_test_equal
+ if (GNUNET_NO != GNUNET_FS_meta_data_test_equal (meta, meta2))
+ {
+ GNUNET_FS_meta_data_destroy (meta2);
+ ABORT (meta);
+ }
+
+ // check meta_data_add_publication_date
+ GNUNET_FS_meta_data_add_publication_date (meta2);
+
+ // check meta_data_merge
+ GNUNET_FS_meta_data_clear (meta2);
+ GNUNET_FS_meta_data_merge (meta2, meta);
+ if (100 == GNUNET_FS_meta_data_iterate (meta2, NULL, NULL))
+ {
+ GNUNET_FS_meta_data_destroy (meta2);
+ ABORT (meta);
+ }
+
+ // check meta_data_get_by_type
+ GNUNET_FS_meta_data_clear (meta2);
+ if (NULL !=
+ (str =
+ GNUNET_FS_meta_data_get_by_type (meta2,
+ EXTRACTOR_METATYPE_UNKNOWN)))
+ {
+ GNUNET_FS_meta_data_destroy (meta2);
+ GNUNET_free (str);
+ ABORT (meta);
+ }
+
+ str =
+ GNUNET_FS_meta_data_get_by_type (meta, EXTRACTOR_METATYPE_UNKNOWN);
+ GNUNET_assert (NULL != str);
+ if (str[0] != 'T')
+ {
+ GNUNET_FS_meta_data_destroy (meta2);
+ GNUNET_free (str);
+ ABORT (meta);
+ }
+ GNUNET_free (str);
+
+ // check branch
+ if (NULL !=
+ (str =
+ GNUNET_FS_meta_data_get_by_type (meta,
+
EXTRACTOR_METATYPE_PUBLICATION_DATE)))
+ {
+ GNUNET_free (str);
+ GNUNET_FS_meta_data_destroy (meta2);
+ ABORT (meta);
+ }
+
+ // check meta_data_get_first_by_types
+ str =
+ GNUNET_FS_meta_data_get_first_by_types (meta,
+ EXTRACTOR_METATYPE_UNKNOWN,
+ -1);
+ GNUNET_assert (NULL != str);
+ if (str[0] != 'T')
+ {
+ GNUNET_FS_meta_data_destroy (meta2);
+ GNUNET_free (str);
+ ABORT (meta);
+ }
+ GNUNET_free (str);
+
+ // check meta_data_get_thumbnail
+ if (GNUNET_FS_meta_data_get_thumbnail (meta, &thumb) != 0)
+ {
+ GNUNET_free (thumb);
+ GNUNET_FS_meta_data_destroy (meta2);
+ ABORT (meta);
+ }
+ GNUNET_FS_meta_data_destroy (meta2);
+ // check meta_data_duplicate
+ meta2 = GNUNET_FS_meta_data_duplicate (meta);
+ if (200 == GNUNET_FS_meta_data_iterate (meta2, NULL, NULL))
+ {
+ GNUNET_FS_meta_data_destroy (meta2);
+ ABORT (meta);
+ }
+ GNUNET_FS_meta_data_destroy (meta2);
+ GNUNET_FS_meta_data_destroy (meta);
+ return 0;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int failureCount = 0;
+ int i;
+
+ GNUNET_log_setup ("test-container-meta-data", "WARNING", NULL);
+ for (i = 0; i < 255; i++)
+ failureCount += testMeta (i);
+ for (i = 1; i < 255; i++)
+ failureCount += testMetaMore (i);
+ failureCount += testMetaLink ();
+
+ int ret = check ();
+
+ if (ret == 1)
+ return 1;
+
+ if (failureCount != 0)
+ return 1;
+ return 0;
+}
+
+
+/* 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)
static void
sks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
{
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *ksk_uri;
char *msg;
struct GNUNET_FS_BlockOptions bo;
@@ -238,7 +238,7 @@ sks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const
char *emsg)
static void
adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
{
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_CRYPTO_EcdsaPrivateKey ns;
struct GNUNET_FS_BlockOptions bo;
@@ -270,7 +270,7 @@ static void
testNamespace (void)
{
struct GNUNET_FS_BlockOptions bo;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *ksk_uri;
struct GNUNET_FS_Uri *sks_uri;
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;
static struct GNUNET_CRYPTO_EcdsaPrivateKey ns;
-static struct GNUNET_CONTAINER_MetaData *meta;
+static struct GNUNET_FS_MetaData *meta;
static struct GNUNET_FS_Uri *uri_this;
@@ -66,7 +66,7 @@ do_shutdown ()
static void
check_next (void *cls, const char *last_id,
const struct GNUNET_FS_Uri *last_uri,
- const struct GNUNET_CONTAINER_MetaData *last_meta,
+ const struct GNUNET_FS_MetaData *last_meta,
const char *next_id)
{
GNUNET_break (0 == strcmp (last_id, "next"));
@@ -78,7 +78,7 @@ check_next (void *cls, const char *last_id,
static void
check_this_next (void *cls, const char *last_id,
const struct GNUNET_FS_Uri *last_uri,
- const struct GNUNET_CONTAINER_MetaData *last_meta,
+ const struct GNUNET_FS_MetaData *last_meta,
const char *next_id)
{
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)
static void
check_this (void *cls, const char *last_id,
const struct GNUNET_FS_Uri *last_uri,
- const struct GNUNET_CONTAINER_MetaData *last_meta,
+ const struct GNUNET_FS_MetaData *last_meta,
const char *next_id)
{
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,
"down_bar",
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_FileInformation *fi1;
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,
"down_bar",
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_FileInformation *fi1;
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,
"down_bar"
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_BlockOptions bo;
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,
"down_bar"
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_FileInformation *fi;
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,
"down_bar"
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_BlockOptions bo;
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,
"down_bar"
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_BlockOptions bo;
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,
"down_bar",
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_FileInformation *fi;
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,
"down_bar",
};
char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
struct GNUNET_FS_Uri *kuri;
struct GNUNET_FS_FileInformation *fi;
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,
size_t max_length);
-/**
- * Read a metadata container.
- *
- * @param h handle to an open file
- * @param what describes what is being read (for error message creation)
- * @param result the buffer to store a pointer to the (allocated) metadata
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
- */
-int
-GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
- const char *what,
- struct GNUNET_CONTAINER_MetaData **result);
-
/**
* Read a float.
@@ -294,19 +281,6 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
const char *s);
-/**
- * Write a metadata container.
- *
- * @param h the IO handle to write to
- * @param what what is being written (for error message creation)
- * @param m metadata to write
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-int
-GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
- const char *what,
- const struct GNUNET_CONTAINER_MetaData *m);
-
/**
* Write a float.
@@ -453,17 +427,6 @@ GNUNET_BIO_read_spec_string (const char *what,
size_t max_length);
-/**
- * Create the specification to read a metadata container.
- *
- * @param what describes what is being read (for error message creation)
- * @param result the buffer to store a pointer to the (allocated) metadata
- * @return the read spec
- */
-struct GNUNET_BIO_ReadSpec
-GNUNET_BIO_read_spec_meta_data (const char *what,
- struct GNUNET_CONTAINER_MetaData **result);
-
/**
* Create the specification to read an (u)int32_t.
@@ -609,18 +572,6 @@ GNUNET_BIO_write_spec_string (const char *what,
const char *s);
-/**
- * Create the specification to write a metadata container.
- *
- * @param what what is being written (for error message creation)
- * @param m metadata to write
- * @return the write spec
- */
-struct GNUNET_BIO_WriteSpec
-GNUNET_BIO_write_spec_meta_data (const char *what,
- const struct GNUNET_CONTAINER_MetaData *m);
-
-
/**
* Create the specification to write an (u)int32_t.
*
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 @@
/* Set to 1 if GnuTLS has DANE support */
#define GNUNET_CURL_GNUTLS @curl_gnutls@
-/* Set to 1 is we have the byteswap header */
-#define GNUNET_HAVE_BYTESWAP_H @have_byteswap@
-
#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 @@
*
* @see [Documentation](https://gnunet.org/mdll-api)
*
- * @defgroup metadata Metadata
- * GNU libextractor key-value pairs
*
* @}
*/
@@ -102,114 +100,6 @@ char *
GNUNET_decompress (const char *input, size_t input_size, size_t output_size);
-#if HAVE_EXTRACTOR_H
-
-#include <extractor.h>
-
-#else
-
-/* definitions from extractor.h we need for the build */
-
-/**
- * Enumeration defining various sources of keywords. See also
- * http://dublincore.org/documents/1998/09/dces/
- */
-enum EXTRACTOR_MetaType
-{
- EXTRACTOR_METATYPE_RESERVED = 0,
- EXTRACTOR_METATYPE_MIMETYPE = 1,
- EXTRACTOR_METATYPE_FILENAME = 2,
- EXTRACTOR_METATYPE_COMMENT = 3,
- EXTRACTOR_METATYPE_TITLE = 4,
- EXTRACTOR_METATYPE_BOOK_TITLE = 5,
- EXTRACTOR_METATYPE_JOURNAL_NAME = 8,
- EXTRACTOR_METATYPE_AUTHOR_NAME = 13,
- EXTRACTOR_METATYPE_PUBLICATION_DATE = 24,
- EXTRACTOR_METATYPE_URL = 29,
- EXTRACTOR_METATYPE_URI = 30,
- EXTRACTOR_METATYPE_ISRC = 31,
- EXTRACTOR_METATYPE_UNKNOWN = 45,
- EXTRACTOR_METATYPE_DESCRIPTION = 46,
- EXTRACTOR_METATYPE_KEYWORDS = 49,
- EXTRACTOR_METATYPE_SUBJECT = 52,
- EXTRACTOR_METATYPE_PACKAGE_NAME = 69,
- EXTRACTOR_METATYPE_THUMBNAIL = 114,
- EXTRACTOR_METATYPE_ALBUM = 129,
- EXTRACTOR_METATYPE_ARTIST = 130,
- EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162,
- EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174,
- EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180,
-};
-
-/**
- * Format in which the extracted meta data is presented.
- */
-enum EXTRACTOR_MetaFormat
-{
- /**
- * Format is unknown.
- */
- EXTRACTOR_METAFORMAT_UNKNOWN = 0,
-
- /**
- * 0-terminated, UTF-8 encoded string. "data_len"
- * is strlen(data)+1.
- */
- EXTRACTOR_METAFORMAT_UTF8 = 1,
-
- /**
- * Some kind of binary format, see given Mime type.
- */
- EXTRACTOR_METAFORMAT_BINARY = 2,
-
- /**
- * 0-terminated string. The specific encoding is unknown.
- * "data_len" is strlen (data)+1.
- */
- EXTRACTOR_METAFORMAT_C_STRING = 3
-};
-
-
-/**
- * Type of a function that libextractor calls for each
- * meta data item found.
- *
- * @param cls closure (user-defined)
- * @param plugin_name name of the plugin that produced this value;
- * special values can be used (e.g. '<zlib>' for zlib being
- * used in the main libextractor library and yielding
- * meta data).
- * @param type libextractor-type describing the meta data
- * @param format basic format information about @a data
- * @param data_mime_type mime-type of @a data (not of the original file);
- * can be NULL (if mime-type is not known)
- * @param data actual meta-data found
- * @param data_len number of bytes in @a data
- * @return 0 to continue extracting, 1 to abort
- */
-typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len);
-
-#endif
-
-#ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
-/* hack for LE < 0.6.3 */
-#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME 180
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-
/* ******************* bloomfilter ***************** */
/**
@@ -435,285 +325,6 @@ GNUNET_CONTAINER_bloomfilter_resize (struct
GNUNET_CONTAINER_BloomFilter *bf,
unsigned int k);
-/* ****************** metadata ******************* */
-
-/**
- * @ingroup metadata
- * Meta data to associate with a file, directory or namespace.
- */
-struct GNUNET_CONTAINER_MetaData;
-
-
-/**
- * @ingroup metadata
- * Create a fresh meta data container.
- *
- * @return empty meta-data container
- */
-struct GNUNET_CONTAINER_MetaData *
-GNUNET_CONTAINER_meta_data_create (void);
-
-
-/**
- * @ingroup metadata
- * Duplicate a MetaData token.
- *
- * @param md what to duplicate
- * @return duplicate meta-data container
- */
-struct GNUNET_CONTAINER_MetaData *
-GNUNET_CONTAINER_meta_data_duplicate (
- const struct GNUNET_CONTAINER_MetaData *md);
-
-
-/**
- * @ingroup metadata
- * Free meta data.
- *
- * @param md what to free
- */
-void
-GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md);
-
-
-/**
- * @ingroup metadata
- * Test if two MDs are equal. We consider them equal if
- * the meta types, formats and content match (we do not
- * include the mime types and plugins names in this
- * consideration).
- *
- * @param md1 first value to check
- * @param md2 other value to check
- * @return #GNUNET_YES if they are equal
- */
-int
-GNUNET_CONTAINER_meta_data_test_equal (
- const struct GNUNET_CONTAINER_MetaData *md1,
- const struct GNUNET_CONTAINER_MetaData *md2);
-
-
-/**
- * @ingroup metadata
- * Extend metadata.
- *
- * @param md metadata to extend
- * @param plugin_name name of the plugin that produced this value;
- * special values can be used (e.g. '<zlib>' for zlib being
- * used in the main libextractor library and yielding
- * meta data).
- * @param type libextractor-type describing the meta data
- * @param format basic format information about data
- * @param data_mime_type mime-type of data (not of the original file);
- * can be NULL (if mime-type is not known)
- * @param data actual meta-data found
- * @param data_size number of bytes in data
- * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exists
- * data_mime_type and plugin_name are not considered for "exists"
checks
- */
-int
-GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_size);
-
-
-/**
- * @ingroup metadata
- * Extend metadata. Merges the meta data from the second argument
- * into the first, discarding duplicate key-value pairs.
- *
- * @param md metadata to extend
- * @param in metadata to merge
- */
-void
-GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md,
- const struct GNUNET_CONTAINER_MetaData *in);
-
-
-/**
- * @ingroup metadata
- * Remove an item.
- *
- * @param md metadata to manipulate
- * @param type type of the item to remove
- * @param data specific value to remove, NULL to remove all
- * entries of the given type
- * @param data_size number of bytes in data
- * @return #GNUNET_OK on success, #GNUNET_SYSERR if the item does not exist in
md
- */
-int
-GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
- enum EXTRACTOR_MetaType type,
- const char *data,
- size_t data_size);
-
-
-/**
- * @ingroup metadata
- * Remove all items in the container.
- *
- * @param md metadata to manipulate
- */
-void
-GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md);
-
-
-/**
- * @ingroup metadata
- * Add the current time as the publication date
- * to the meta-data.
- *
- * @param md metadata to modify
- */
-void
-GNUNET_CONTAINER_meta_data_add_publication_date (
- struct GNUNET_CONTAINER_MetaData *md);
-
-
-/**
- * @ingroup metadata
- * Iterate over MD entries.
- *
- * @param md metadata to inspect
- * @param iter function to call on each entry, return 0 to continue to iterate
- * and 1 to abort iteration in this function (GNU libextractor
API!)
- * @param iter_cls closure for @a iter
- * @return number of entries
- */
-int
-GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md,
- EXTRACTOR_MetaDataProcessor iter,
- void *iter_cls);
-
-
-/**
- * @ingroup metadata
- * Get the first MD entry of the given type. Caller
- * is responsible for freeing the return value.
- * Also, only meta data items that are strings (0-terminated)
- * are returned by this function.
- *
- * @param md metadata to inspect
- * @param type type to look for
- * @return NULL if no entry was found
- */
-char *
-GNUNET_CONTAINER_meta_data_get_by_type (
- const struct GNUNET_CONTAINER_MetaData *md,
- enum EXTRACTOR_MetaType type);
-
-
-/**
- * @ingroup metadata
- * Get the first matching MD entry of the given types. Caller is
- * responsible for freeing the return value. Also, only meta data
- * items that are strings (0-terminated) are returned by this
- * function.
- *
- * @param md metadata to inspect
- * @param ... -1-terminated list of types
- * @return NULL if we do not have any such entry,
- * otherwise client is responsible for freeing the value!
- */
-char *
-GNUNET_CONTAINER_meta_data_get_first_by_types (
- const struct GNUNET_CONTAINER_MetaData *md,
- ...);
-
-/**
- * @ingroup metadata
- * Get a thumbnail from the meta-data (if present). Only matches meta
- * data with mime type "image" and binary format.
- *
- * @param md metadata to inspect
- * @param thumb will be set to the thumbnail data. Must be
- * freed by the caller!
- * @return number of bytes in thumbnail, 0 if not available
- */
-size_t
-GNUNET_CONTAINER_meta_data_get_thumbnail (
- const struct GNUNET_CONTAINER_MetaData *md,
- unsigned char **thumb);
-
-
-/**
- * @ingroup metadata
- * Options for metadata serialization.
- */
-enum GNUNET_CONTAINER_MetaDataSerializationOptions
-{
- /**
- * @ingroup metadata
- * Serialize all of the data.
- */
- GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0,
-
- /**
- * @ingroup metadata
- * If not enough space is available, it is acceptable
- * to only serialize some of the metadata.
- */
- GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1,
-
- /**
- * @ingroup metadata
- * Speed is of the essence, do not allow compression.
- */
- GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2
-};
-
-
-/**
- * @ingroup metadata
- * Serialize meta-data to target.
- *
- * @param md metadata to serialize
- * @param target where to write the serialized metadata;
- * *target can be NULL, in which case memory is allocated
- * @param max maximum number of bytes available
- * @param opt is it ok to just write SOME of the
- * meta-data to match the size constraint,
- * possibly discarding some data?
- * @return number of bytes written on success,
- * -1 on error (typically: not enough
- * space)
- */
-ssize_t
-GNUNET_CONTAINER_meta_data_serialize (
- const struct GNUNET_CONTAINER_MetaData *md,
- char **target,
- size_t max,
- enum GNUNET_CONTAINER_MetaDataSerializationOptions opt);
-
-
-/**
- * @ingroup metadata
- * Get the size of the full meta-data in serialized form.
- *
- * @param md metadata to inspect
- * @return number of bytes needed for serialization, -1 on error
- */
-ssize_t
-GNUNET_CONTAINER_meta_data_get_serialized_size (
- const struct GNUNET_CONTAINER_MetaData *md);
-
-
-/**
- * @ingroup metadata
- * Deserialize meta-data. Initializes md.
- *
- * @param input serialized meta-data.
- * @param size number of bytes available
- * @return MD on success, NULL on error (e.g.
- * bad format)
- */
-struct GNUNET_CONTAINER_MetaData *
-GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size);
-
/* ******************************* HashMap **************************** */
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 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2022 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+/**
+ * @author Martin Schanzenbach
+ *
+ * @file
+ * libextractor compatibility insanity helper header
+ *
+ * @{
+ */
+#ifndef GNUNET_EXTRACTOR_COMPAT_H
+#define GNUNET_EXTRACTOR_COMPAT_H
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+#if HAVE_EXTRACTOR_H
+
+#include <extractor.h>
+
+#else
+
+/* definitions from extractor.h we need for the build */
+
+/**
+ * Enumeration defining various sources of keywords. See also
+ * http://dublincore.org/documents/1998/09/dces/
+ */
+enum EXTRACTOR_MetaType
+{
+ EXTRACTOR_METATYPE_RESERVED = 0,
+ EXTRACTOR_METATYPE_MIMETYPE = 1,
+ EXTRACTOR_METATYPE_FILENAME = 2,
+ EXTRACTOR_METATYPE_COMMENT = 3,
+ EXTRACTOR_METATYPE_TITLE = 4,
+ EXTRACTOR_METATYPE_BOOK_TITLE = 5,
+ EXTRACTOR_METATYPE_JOURNAL_NAME = 8,
+ EXTRACTOR_METATYPE_AUTHOR_NAME = 13,
+ EXTRACTOR_METATYPE_PUBLICATION_DATE = 24,
+ EXTRACTOR_METATYPE_URL = 29,
+ EXTRACTOR_METATYPE_URI = 30,
+ EXTRACTOR_METATYPE_ISRC = 31,
+ EXTRACTOR_METATYPE_UNKNOWN = 45,
+ EXTRACTOR_METATYPE_DESCRIPTION = 46,
+ EXTRACTOR_METATYPE_KEYWORDS = 49,
+ EXTRACTOR_METATYPE_SUBJECT = 52,
+ EXTRACTOR_METATYPE_PACKAGE_NAME = 69,
+ EXTRACTOR_METATYPE_THUMBNAIL = 114,
+ EXTRACTOR_METATYPE_ALBUM = 129,
+ EXTRACTOR_METATYPE_ARTIST = 130,
+ EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162,
+ EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174,
+ EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180,
+};
+
+/**
+ * Format in which the extracted meta data is presented.
+ */
+enum EXTRACTOR_MetaFormat
+{
+ /**
+ * Format is unknown.
+ */
+ EXTRACTOR_METAFORMAT_UNKNOWN = 0,
+
+ /**
+ * 0-terminated, UTF-8 encoded string. "data_len"
+ * is strlen(data)+1.
+ */
+ EXTRACTOR_METAFORMAT_UTF8 = 1,
+
+ /**
+ * Some kind of binary format, see given Mime type.
+ */
+ EXTRACTOR_METAFORMAT_BINARY = 2,
+
+ /**
+ * 0-terminated string. The specific encoding is unknown.
+ * "data_len" is strlen (data)+1.
+ */
+ EXTRACTOR_METAFORMAT_C_STRING = 3
+};
+
+
+/**
+ * Type of a function that libextractor calls for each
+ * meta data item found.
+ *
+ * @param cls closure (user-defined)
+ * @param plugin_name name of the plugin that produced this value;
+ * special values can be used (e.g. '<zlib>' for zlib being
+ * used in the main libextractor library and yielding
+ * meta data).
+ * @param type libextractor-type describing the meta data
+ * @param format basic format information about @a data
+ * @param data_mime_type mime-type of @a data (not of the original file);
+ * can be NULL (if mime-type is not known)
+ * @param data actual meta-data found
+ * @param data_len number of bytes in @a data
+ * @return 0 to continue extracting, 1 to abort
+ */
+typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls,
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len);
+
+#endif
+
+#ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
+/* hack for LE < 0.6.3 */
+#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME 180
+#endif
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/** @} */ /* 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 @@
#define GNUNET_FS_LIB_H
+#include "gnunet_common.h"
#include "gnunet_util_lib.h"
#ifdef __cplusplus
@@ -92,6 +93,12 @@ extern "C"
*/
struct GNUNET_FS_Uri;
+/**
+ * @ingroup metadata
+ * Meta data to associate with a file, directory or namespace.
+ */
+struct GNUNET_FS_MetaData;
+
/**
* Iterator over keywords
@@ -436,7 +443,7 @@ GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri);
* @return NULL on error, otherwise a KSK URI
*/
struct GNUNET_FS_Uri *
-GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData
+GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_FS_MetaData
*md);
@@ -472,7 +479,7 @@ GNUNET_FS_GETOPT_METADATA (char shortName,
const char *name,
const char *argumentHelp,
const char *description,
- struct GNUNET_CONTAINER_MetaData **meta);
+ struct GNUNET_FS_MetaData **meta);
/**
* Command-line option parser function that allows the user to specify
@@ -481,7 +488,7 @@ GNUNET_FS_GETOPT_METADATA (char shortName,
* the metadata must be passed as the "scls" argument.
*
* @param ctx command line processor context
- * @param scls must be of type `struct GNUNET_CONTAINER_MetaData **`
+ * @param scls must be of type `struct GNUNET_FS_MetaData **`
* @param option name of the option (typically 'k')
* @param value command line argument given
* @return #GNUNET_OK on success
@@ -1099,7 +1106,7 @@ struct GNUNET_FS_ProgressInfo
/**
* Known metadata for the download.
*/
- const struct GNUNET_CONTAINER_MetaData *meta;
+ const struct GNUNET_FS_MetaData *meta;
} start;
/**
@@ -1111,7 +1118,7 @@ struct GNUNET_FS_ProgressInfo
/**
* Known metadata for the download.
*/
- const struct GNUNET_CONTAINER_MetaData *meta;
+ const struct GNUNET_FS_MetaData *meta;
/**
* Error message, NULL if we have not encountered any error yet.
@@ -1196,7 +1203,7 @@ struct GNUNET_FS_ProgressInfo
/**
* Metadata for the search result.
*/
- const struct GNUNET_CONTAINER_MetaData *meta;
+ const struct GNUNET_FS_MetaData *meta;
/**
* URI for the search result.
@@ -1224,7 +1231,7 @@ struct GNUNET_FS_ProgressInfo
/**
* Metadata for the search result.
*/
- const struct GNUNET_CONTAINER_MetaData *meta;
+ const struct GNUNET_FS_MetaData *meta;
/**
* URI for the search result.
@@ -1271,7 +1278,7 @@ struct GNUNET_FS_ProgressInfo
/**
* Metadata for the search result.
*/
- const struct GNUNET_CONTAINER_MetaData *meta;
+ const struct GNUNET_FS_MetaData *meta;
/**
* URI for the search result.
@@ -1323,7 +1330,7 @@ struct GNUNET_FS_ProgressInfo
/**
* Metadata for the search result.
*/
- const struct GNUNET_CONTAINER_MetaData *meta;
+ const struct GNUNET_FS_MetaData *meta;
/**
* URI for the search result.
@@ -1351,7 +1358,7 @@ struct GNUNET_FS_ProgressInfo
/**
* Metadata for the search result.
*/
- const struct GNUNET_CONTAINER_MetaData *meta;
+ const struct GNUNET_FS_MetaData *meta;
/**
* URI for the search result.
@@ -1406,7 +1413,7 @@ struct GNUNET_FS_ProgressInfo
/**
* Metadata for the namespace.
*/
- const struct GNUNET_CONTAINER_MetaData *meta;
+ const struct GNUNET_FS_MetaData *meta;
/**
* Public key of the namespace.
@@ -1706,7 +1713,7 @@ typedef int
(*GNUNET_FS_FileInformationProcessor) (void *cls,
struct GNUNET_FS_FileInformation *fi,
uint64_t length,
- struct GNUNET_CONTAINER_MetaData *meta,
+ struct GNUNET_FS_MetaData *meta,
struct GNUNET_FS_Uri **uri,
struct GNUNET_FS_BlockOptions *bo,
int *do_index,
@@ -1771,7 +1778,7 @@ GNUNET_FS_file_information_create_from_file (struct
GNUNET_FS_Handle *h,
const struct
GNUNET_FS_Uri *keywords,
const struct
- GNUNET_CONTAINER_MetaData *meta,
+ GNUNET_FS_MetaData *meta,
int do_index,
const struct
GNUNET_FS_BlockOptions *bo);
@@ -1801,7 +1808,7 @@ GNUNET_FS_file_information_create_from_data (struct
GNUNET_FS_Handle *h,
const struct
GNUNET_FS_Uri *keywords,
const struct
- GNUNET_CONTAINER_MetaData *meta,
+ GNUNET_FS_MetaData *meta,
int do_index,
const struct
GNUNET_FS_BlockOptions *bo);
@@ -1860,7 +1867,7 @@ GNUNET_FS_file_information_create_from_reader (struct
GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri
*keywords,
const struct
- GNUNET_CONTAINER_MetaData *meta,
+ GNUNET_FS_MetaData *meta,
int do_index,
const struct
GNUNET_FS_BlockOptions *bo);
@@ -1884,7 +1891,7 @@ GNUNET_FS_file_information_create_empty_directory (struct
GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri
*keywords,
const struct
- GNUNET_CONTAINER_MetaData
+ GNUNET_FS_MetaData
*meta,
const struct
GNUNET_FS_BlockOptions *bo,
@@ -2043,7 +2050,7 @@ struct GNUNET_FS_PublishKskContext;
struct GNUNET_FS_PublishKskContext *
GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri *ksk_uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
const struct GNUNET_FS_Uri *uri,
const struct GNUNET_FS_BlockOptions *bo,
enum GNUNET_FS_PublishOptions options,
@@ -2085,7 +2092,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
const char *identifier,
const char *update,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
const struct GNUNET_FS_Uri *uri,
const struct GNUNET_FS_BlockOptions *bo,
enum GNUNET_FS_PublishOptions options,
@@ -2181,7 +2188,7 @@ typedef void (*GNUNET_FS_IdentifierProcessor) (void *cls,
const struct
GNUNET_FS_Uri *last_uri,
const struct
- GNUNET_CONTAINER_MetaData *
+ GNUNET_FS_MetaData *
last_meta,
const char *next_id);
@@ -2291,7 +2298,7 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext
*sc);
struct GNUNET_FS_SearchResult *
GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
void *client_info,
uint32_t anonymity);
@@ -2379,7 +2386,7 @@ enum GNUNET_FS_DownloadOptions
struct GNUNET_FS_DownloadContext *
GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_MetaData *meta,
const char *filename, const char *tempname,
uint64_t offset, uint64_t length, uint32_t anonymity,
enum GNUNET_FS_DownloadOptions options, void *cctx,
@@ -2473,7 +2480,7 @@ GNUNET_FS_download_resume (struct
GNUNET_FS_DownloadContext *dc);
* we have no mime-type information (treat as #GNUNET_NO)
*/
int
-GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData
+GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_FS_MetaData
*md);
@@ -2484,7 +2491,7 @@ GNUNET_FS_meta_data_test_for_directory (const struct
GNUNET_CONTAINER_MetaData
* @param md metadata to add mimetype to
*/
void
-GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md);
+GNUNET_FS_meta_data_make_directory (struct GNUNET_FS_MetaData *md);
/**
@@ -2495,7 +2502,7 @@ GNUNET_FS_meta_data_make_directory (struct
GNUNET_CONTAINER_MetaData *md);
*/
char *
GNUNET_FS_meta_data_suggest_filename (const struct
- GNUNET_CONTAINER_MetaData *md);
+ GNUNET_FS_MetaData *md);
/**
@@ -2518,7 +2525,7 @@ typedef void (*GNUNET_FS_DirectoryEntryProcessor) (void
*cls,
const struct GNUNET_FS_Uri *
uri,
const struct
- GNUNET_CONTAINER_MetaData *
+ GNUNET_FS_MetaData *
meta, size_t length,
const void *data);
@@ -2561,7 +2568,7 @@ struct GNUNET_FS_DirectoryBuilder;
* @param mdir metadata for the directory
*/
struct GNUNET_FS_DirectoryBuilder *
-GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData
+GNUNET_FS_directory_builder_create (const struct GNUNET_FS_MetaData
*mdir);
@@ -2578,7 +2585,7 @@ GNUNET_FS_directory_builder_create (const struct
GNUNET_CONTAINER_MetaData
void
GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *md,
+ const struct GNUNET_FS_MetaData *md,
const void *data);
@@ -2693,7 +2700,7 @@ struct GNUNET_FS_ShareTreeItem
/**
* Metadata for this file or directory
*/
- struct GNUNET_CONTAINER_MetaData *meta;
+ struct GNUNET_FS_MetaData *meta;
/**
* Keywords for this file or directory (derived from metadata).
@@ -2782,6 +2789,336 @@ GNUNET_FS_share_tree_trim (struct
GNUNET_FS_ShareTreeItem *toplevel);
void
GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel);
+/**
+ * Meta data processing
+ * @defgroup metadata Metadata
+ * GNU libextractor key-value pairs
+ */
+
+
+/* ****************** metadata ******************* */
+
+
+/**
+ * @ingroup metadata
+ * Create a fresh meta data container.
+ *
+ * @return empty meta-data container
+ */
+struct GNUNET_FS_MetaData *
+GNUNET_FS_meta_data_create (void);
+
+
+/**
+ * @ingroup metadata
+ * Duplicate a MetaData token.
+ *
+ * @param md what to duplicate
+ * @return duplicate meta-data container
+ */
+struct GNUNET_FS_MetaData *
+GNUNET_FS_meta_data_duplicate (
+ const struct GNUNET_FS_MetaData *md);
+
+
+/**
+ * @ingroup metadata
+ * Free meta data.
+ *
+ * @param md what to free
+ */
+void
+GNUNET_FS_meta_data_destroy (struct GNUNET_FS_MetaData *md);
+
+
+/**
+ * @ingroup metadata
+ * Test if two MDs are equal. We consider them equal if
+ * the meta types, formats and content match (we do not
+ * include the mime types and plugins names in this
+ * consideration).
+ *
+ * @param md1 first value to check
+ * @param md2 other value to check
+ * @return #GNUNET_YES if they are equal
+ */
+int
+GNUNET_FS_meta_data_test_equal (
+ const struct GNUNET_FS_MetaData *md1,
+ const struct GNUNET_FS_MetaData *md2);
+
+
+/**
+ * @ingroup metadata
+ * Extend metadata.
+ *
+ * @param md metadata to extend
+ * @param plugin_name name of the plugin that produced this value;
+ * special values can be used (e.g. '<zlib>' for zlib being
+ * used in the main libextractor library and yielding
+ * meta data).
+ * @param type libextractor-type describing the meta data
+ * @param format basic format information about data
+ * @param data_mime_type mime-type of data (not of the original file);
+ * can be NULL (if mime-type is not known)
+ * @param data actual meta-data found
+ * @param data_size number of bytes in data
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exists
+ * data_mime_type and plugin_name are not considered for "exists"
checks
+ */
+int
+GNUNET_FS_meta_data_insert (struct GNUNET_FS_MetaData *md,
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_size);
+
+
+/**
+ * @ingroup metadata
+ * Extend metadata. Merges the meta data from the second argument
+ * into the first, discarding duplicate key-value pairs.
+ *
+ * @param md metadata to extend
+ * @param in metadata to merge
+ */
+void
+GNUNET_FS_meta_data_merge (struct GNUNET_FS_MetaData *md,
+ const struct GNUNET_FS_MetaData *in);
+
+
+/**
+ * @ingroup metadata
+ * Remove an item.
+ *
+ * @param md metadata to manipulate
+ * @param type type of the item to remove
+ * @param data specific value to remove, NULL to remove all
+ * entries of the given type
+ * @param data_size number of bytes in data
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if the item does not exist in
md
+ */
+int
+GNUNET_FS_meta_data_delete (struct GNUNET_FS_MetaData *md,
+ enum EXTRACTOR_MetaType type,
+ const char *data,
+ size_t data_size);
+
+
+/**
+ * @ingroup metadata
+ * Remove all items in the container.
+ *
+ * @param md metadata to manipulate
+ */
+void
+GNUNET_FS_meta_data_clear (struct GNUNET_FS_MetaData *md);
+
+
+/**
+ * @ingroup metadata
+ * Add the current time as the publication date
+ * to the meta-data.
+ *
+ * @param md metadata to modify
+ */
+void
+GNUNET_FS_meta_data_add_publication_date (
+ struct GNUNET_FS_MetaData *md);
+
+
+/**
+ * @ingroup metadata
+ * Iterate over MD entries.
+ *
+ * @param md metadata to inspect
+ * @param iter function to call on each entry, return 0 to continue to iterate
+ * and 1 to abort iteration in this function (GNU libextractor
API!)
+ * @param iter_cls closure for @a iter
+ * @return number of entries
+ */
+int
+GNUNET_FS_meta_data_iterate (const struct GNUNET_FS_MetaData *md,
+ EXTRACTOR_MetaDataProcessor iter,
+ void *iter_cls);
+
+
+/**
+ * @ingroup metadata
+ * Get the first MD entry of the given type. Caller
+ * is responsible for freeing the return value.
+ * Also, only meta data items that are strings (0-terminated)
+ * are returned by this function.
+ *
+ * @param md metadata to inspect
+ * @param type type to look for
+ * @return NULL if no entry was found
+ */
+char *
+GNUNET_FS_meta_data_get_by_type (
+ const struct GNUNET_FS_MetaData *md,
+ enum EXTRACTOR_MetaType type);
+
+
+/**
+ * @ingroup metadata
+ * Get the first matching MD entry of the given types. Caller is
+ * responsible for freeing the return value. Also, only meta data
+ * items that are strings (0-terminated) are returned by this
+ * function.
+ *
+ * @param md metadata to inspect
+ * @param ... -1-terminated list of types
+ * @return NULL if we do not have any such entry,
+ * otherwise client is responsible for freeing the value!
+ */
+char *
+GNUNET_FS_meta_data_get_first_by_types (
+ const struct GNUNET_FS_MetaData *md,
+ ...);
+
+/**
+ * @ingroup metadata
+ * Get a thumbnail from the meta-data (if present). Only matches meta
+ * data with mime type "image" and binary format.
+ *
+ * @param md metadata to inspect
+ * @param thumb will be set to the thumbnail data. Must be
+ * freed by the caller!
+ * @return number of bytes in thumbnail, 0 if not available
+ */
+size_t
+GNUNET_FS_meta_data_get_thumbnail (
+ const struct GNUNET_FS_MetaData *md,
+ unsigned char **thumb);
+
+
+/**
+ * @ingroup metadata
+ * Options for metadata serialization.
+ */
+enum GNUNET_FS_MetaDataSerializationOptions
+{
+ /**
+ * @ingroup metadata
+ * Serialize all of the data.
+ */
+ GNUNET_FS_META_DATA_SERIALIZE_FULL = 0,
+
+ /**
+ * @ingroup metadata
+ * If not enough space is available, it is acceptable
+ * to only serialize some of the metadata.
+ */
+ GNUNET_FS_META_DATA_SERIALIZE_PART = 1,
+
+ /**
+ * @ingroup metadata
+ * Speed is of the essence, do not allow compression.
+ */
+ GNUNET_FS_META_DATA_SERIALIZE_NO_COMPRESS = 2
+};
+
+
+/**
+ * @ingroup metadata
+ * Serialize meta-data to target.
+ *
+ * @param md metadata to serialize
+ * @param target where to write the serialized metadata;
+ * *target can be NULL, in which case memory is allocated
+ * @param max maximum number of bytes available
+ * @param opt is it ok to just write SOME of the
+ * meta-data to match the size constraint,
+ * possibly discarding some data?
+ * @return number of bytes written on success,
+ * -1 on error (typically: not enough
+ * space)
+ */
+ssize_t
+GNUNET_FS_meta_data_serialize (
+ const struct GNUNET_FS_MetaData *md,
+ char **target,
+ size_t max,
+ enum GNUNET_FS_MetaDataSerializationOptions opt);
+
+
+/**
+ * @ingroup metadata
+ * Get the size of the full meta-data in serialized form.
+ *
+ * @param md metadata to inspect
+ * @return number of bytes needed for serialization, -1 on error
+ */
+ssize_t
+GNUNET_FS_meta_data_get_serialized_size (
+ const struct GNUNET_FS_MetaData *md);
+
+
+/**
+ * @ingroup metadata
+ * Deserialize meta-data. Initializes md.
+ *
+ * @param input serialized meta-data.
+ * @param size number of bytes available
+ * @return MD on success, NULL on error (e.g.
+ * bad format)
+ */
+struct GNUNET_FS_MetaData *
+GNUNET_FS_meta_data_deserialize (const char *input, size_t size);
+
+/**
+ * Write a metadata container.
+ *
+ * @param h the IO handle to write to
+ * @param what what is being written (for error message creation)
+ * @param m metadata to write
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_FS_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
+ const char *what,
+ const struct GNUNET_FS_MetaData *m);
+
+/**
+ * Create the specification to read a metadata container.
+ *
+ * @param what describes what is being read (for error message creation)
+ * @param result the buffer to store a pointer to the (allocated) metadata
+ * @return the read spec
+ */
+struct GNUNET_BIO_ReadSpec
+GNUNET_FS_read_spec_meta_data (const char *what,
+ struct GNUNET_FS_MetaData **result);
+
+
+
+/**
+ * Create the specification to write a metadata container.
+ *
+ * @param what what is being written (for error message creation)
+ * @param m metadata to write
+ * @return the write spec
+ */
+struct GNUNET_BIO_WriteSpec
+GNUNET_FS_write_spec_meta_data (const char *what,
+ const struct GNUNET_FS_MetaData *m);
+
+/**
+ * Read a metadata container.
+ *
+ * @param h handle to an open file
+ * @param what describes what is being read (for error message creation)
+ * @param result the buffer to store a pointer to the (allocated) metadata
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_FS_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
+ const char *what,
+ struct GNUNET_FS_MetaData **result);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
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 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2022 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+/**
+ * @author Martin Schanzenbach
+ *
+ * @file
+ * MySQL/MariaDB compatibility insanity helper header
+ *
+ * @defgroup mysql MySQL library
+ * Helper library to access a MySQL database.
+ * @{
+ */
+#ifndef GNUNET_MYSQL_COMPAT_H
+#define GNUNET_MYSQL_COMPAT_H
+
+
+#include <mysql/mysql.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+#ifndef LIBMARIADB
+#if MYSQL_VERSION_ID < 80000
+#define MYSQL_BOOL bool;
+#else
+#define MYSQL_BOOL my_bool; //MySQL < 8 wants this
+#endif
+#else
+#define MYSQL_BOOL my_bool //MariaDB still uses my_bool
+#endif
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/** @} */ /* 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"
#include "gnunet_child_management_lib.h"
#include "gnunet_error_codes.h"
+/**
+ * Try to compress the given block of data using libz. Only returns
+ * the compressed block if compression worked and the new block is
+ * actually smaller. Decompress using #GNUNET_decompress().
+ *
+ * @param data block to compress; if compression
+ * resulted in a smaller block, the first
+ * bytes of data are updated to the compressed
+ * data
+ * @param old_size number of bytes in data
+ * @param[out] result set to the compressed data, if compression worked
+ * @param[out] new_size set to size of result, if compression worked
+ * @return #GNUNET_YES if compression reduce the size,
+ * #GNUNET_NO if compression did not help
+ */
+int
+GNUNET_try_compression (const char *data,
+ size_t old_size,
+ char **result,
+ size_t *new_size);
+
+/**
+ * Decompress input, return the decompressed data as output. Dual to
+ * #GNUNET_try_compression(). Caller must set @a output_size to the
+ * number of bytes that were originally compressed.
+ *
+ * @param input compressed data
+ * @param input_size number of bytes in input
+ * @param output_size expected size of the output
+ * @return NULL on error, buffer of @a output_size decompressed bytes otherwise
+ */
+char *
+GNUNET_decompress (const char *input,
+ size_t input_size,
+ size_t output_size);
+
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#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 = \
common_allocation.c \
common_endian.c \
common_logging.c \
+ compress.c \
configuration.c \
configuration_helper.c \
consttime_memcmp.c \
container_bloomfilter.c \
container_heap.c \
- container_meta_data.c \
container_multihashmap.c \
container_multishortmap.c \
container_multiuuidmap.c \
@@ -423,11 +423,6 @@ test_container_dll_SOURCES = \
test_container_dll_LDADD = \
libgnunetutil.la
-test_container_meta_data_SOURCES = \
- test_container_meta_data.c
-test_container_meta_data_LDADD = \
- libgnunetutil.la
-
test_container_multihashmap_SOURCES = \
test_container_multihashmap.c
test_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 @@
*/
#define BIO_BUFFER_SIZE 65536
-/**
- * Maximum size allowed for meta data written/read from disk.
- * File-sharing limits to 64k, so this should be rather generous.
- */
-#define MAX_META_DATA (1024 * 1024)
-
/**
* Enum used internally to know how buffering is handled.
@@ -160,7 +154,7 @@ GNUNET_BIO_read_open_buffer (void *buffer, size_t size)
*
* @param h file handle
* @param emsg set to the (allocated) error message
- * if the handle has an error message, the return
+ * if the handle has an error message, the return
* value is #GNUNET_SYSERR
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
@@ -379,60 +373,6 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
}
-/**
- * Read a metadata container.
- *
- * @param h handle to an open file
- * @param what describes what is being read (for error message creation)
- * @param result the buffer to store a pointer to the (allocated) metadata
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
- */
-int
-GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
- const char *what,
- struct GNUNET_CONTAINER_MetaData **result)
-{
- uint32_t size;
- char *buf;
- struct GNUNET_CONTAINER_MetaData *meta;
-
- if (GNUNET_OK != GNUNET_BIO_read_int32 (h,
- _ ("metadata length"),
- (int32_t *) &size))
- return GNUNET_SYSERR;
- if (0 == size)
- {
- *result = NULL;
- return GNUNET_OK;
- }
- if (MAX_META_DATA < size)
- {
- GNUNET_asprintf (
- &h->emsg,
- _ ("Serialized metadata `%s' larger than allowed (%u > %u)"),
- what,
- size,
- MAX_META_DATA);
- return GNUNET_SYSERR;
- }
- buf = GNUNET_malloc (size);
- if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, size))
- {
- GNUNET_free (buf);
- return GNUNET_SYSERR;
- }
- meta = GNUNET_CONTAINER_meta_data_deserialize (buf, size);
- if (NULL == meta)
- {
- GNUNET_free (buf);
- GNUNET_asprintf (&h->emsg, _ ("Failed to deserialize metadata `%s'"),
what);
- return GNUNET_SYSERR;
- }
- GNUNET_free (buf);
- *result = meta;
- return GNUNET_OK;
-}
-
/**
* Read a float.
@@ -846,51 +786,6 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
}
-/**
- * Write a metadata container.
- *
- * @param h the IO handle to write to
- * @param what what is being written (for error message creation)
- * @param m metadata to write
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-int
-GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
- const char *what,
- const struct GNUNET_CONTAINER_MetaData *m)
-{
- ssize_t size;
- char *buf;
-
- if (m == NULL)
- return GNUNET_BIO_write_int32 (h, _ ("metadata length"), 0);
- buf = NULL;
- size = GNUNET_CONTAINER_meta_data_serialize (
- m,
- &buf,
- MAX_META_DATA,
- GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
- if (-1 == size)
- {
- GNUNET_free (buf);
- GNUNET_free (h->emsg);
- GNUNET_asprintf (&h->emsg,
- _ ("Failed to serialize metadata `%s'"),
- what);
- return GNUNET_SYSERR;
- }
- if ((GNUNET_OK != GNUNET_BIO_write_int32 (h,
- _ ("metadata length"),
- (uint32_t) size))
- || (GNUNET_OK != GNUNET_BIO_write (h, what, buf, size)))
- {
- GNUNET_free (buf);
- return GNUNET_SYSERR;
- }
- GNUNET_free (buf);
- return GNUNET_OK;
-}
-
/**
* Write a float.
@@ -1059,51 +954,6 @@ GNUNET_BIO_read_spec_string (const char *what,
}
-/**
- * Function used internally to read a metadata container from within a read
- * spec.
- *
- * @param cls ignored, always NULL
- * @param h the IO handle to read from
- * @param what what is being read (for error message creation)
- * @param target where to store the data
- * @param target_size ignored
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-static int
-read_spec_handler_meta_data (void *cls,
- struct GNUNET_BIO_ReadHandle *h,
- const char *what,
- void *target,
- size_t target_size)
-{
- struct GNUNET_CONTAINER_MetaData **result = target;
- return GNUNET_BIO_read_meta_data (h, what, result);
-}
-
-
-/**
- * Create the specification to read a metadata container.
- *
- * @param what describes what is being read (for error message creation)
- * @param result the buffer to store a pointer to the (allocated) metadata
- * @return the read spec
- */
-struct GNUNET_BIO_ReadSpec
-GNUNET_BIO_read_spec_meta_data (const char *what,
- struct GNUNET_CONTAINER_MetaData **result)
-{
- struct GNUNET_BIO_ReadSpec rs = {
- .rh = &read_spec_handler_meta_data,
- .cls = NULL,
- .target = result,
- .size = 0,
- };
-
- return rs;
-}
-
-
/**
* Function used internally to read an (u)int32_t from within a read spec.
*
@@ -1349,52 +1199,6 @@ GNUNET_BIO_write_spec_string (const char *what,
}
-/**
- * Function used internally to write a metadata container from within a write
- * spec.
- *
- * @param cls ignored, always NULL
- * @param h the IO handle to write to
- * @param what what is being written (for error message creation)
- * @param source the data to write
- * @param source_size ignored
- * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
- */
-static int
-write_spec_handler_meta_data (void *cls,
- struct GNUNET_BIO_WriteHandle *h,
- const char *what,
- void *source,
- size_t source_size)
-{
- const struct GNUNET_CONTAINER_MetaData *m = source;
- return GNUNET_BIO_write_meta_data (h, what, m);
-}
-
-
-/**
- * Create the specification to write a metadata container.
- *
- * @param what what is being written (for error message creation)
- * @param m metadata to write
- * @return the write spec
- */
-struct GNUNET_BIO_WriteSpec
-GNUNET_BIO_write_spec_meta_data (const char *what,
- const struct GNUNET_CONTAINER_MetaData *m)
-{
- struct GNUNET_BIO_WriteSpec ws = {
- .wh = &write_spec_handler_meta_data,
- .cls = NULL,
- .what = what,
- .source = (void *) m,
- .source_size = 0,
- };
-
- return ws;
-}
-
-
/**
* Function used internally to write an (u)int32_t from within a write spec.
*
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 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2022 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file util/compress.c
+ * @brief Simple (de)compression logic
+ * @author Philipp Toelke
+ * @author Martin Schanzenbach
+ */
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include <zlib.h>
+
+int
+GNUNET_try_compression (const char *data,
+ size_t old_size,
+ char **result,
+ size_t *new_size)
+{
+ char *tmp;
+ uLongf dlen;
+
+ *result = NULL;
+ *new_size = 0;
+#ifdef compressBound
+ dlen = compressBound (old_size);
+#else
+ dlen = old_size + (old_size / 100) + 20;
+ /* documentation says 100.1% oldSize + 12 bytes, but we
+ * should be able to overshoot by more to be safe */
+#endif
+ tmp = GNUNET_malloc (dlen);
+ if (Z_OK ==
+ compress2 ((Bytef *) tmp,
+ &dlen,
+ (const Bytef *) data,
+ old_size, 9))
+ {
+ if (dlen < old_size)
+ {
+ *result = tmp;
+ *new_size = dlen;
+ return GNUNET_YES;
+ }
+ }
+ GNUNET_free (tmp);
+ return GNUNET_NO;
+}
+
+
+char *
+GNUNET_decompress (const char *input,
+ size_t input_size,
+ size_t output_size)
+{
+ char *output;
+ uLongf olen;
+
+ olen = output_size;
+ output = GNUNET_malloc (olen);
+ if (Z_OK ==
+ uncompress ((Bytef *) output,
+ &olen,
+ (const Bytef *) input,
+ input_size))
+ return output;
+ GNUNET_free (output);
+ return NULL;
+}
+
+
+
+/* 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 ()
* property of detecting all burst errors of length 32 bits or less.
*/
static GNUNET_uLong
-crc32 (GNUNET_uLong crc, const char *buf, size_t len)
+gn_crc32 (GNUNET_uLong crc, const char *buf, size_t len)
{
crc_init ();
GNUNET_assert (crc_table[255] != 0);
@@ -100,8 +100,8 @@ GNUNET_CRYPTO_crc32_n (const void *buf, size_t len)
{
GNUNET_uLong crc;
- crc = crc32 (0L, Z_NULL, 0);
- crc = crc32 (crc, (char *) buf, len);
+ crc = gn_crc32 (0L, Z_NULL, 0);
+ crc = gn_crc32 (crc, (char *) buf, len);
return crc;
}
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 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2003, 2004, 2006, 2009, 2010 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file util/test_container_meta_data.c
- * @brief Test for container_meta_data.c
- * @author Christian Grothoff
- */
-
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-
-#define ABORT(m) { fprintf (stderr, "Error at %s:%d\n", __FILE__, __LINE__); \
- if (m != NULL) GNUNET_CONTAINER_meta_data_destroy (m); \
- return 1; }
-
-
-static int
-testMeta (int i)
-{
- struct GNUNET_CONTAINER_MetaData *m;
- char val[256];
- char *sval;
- int j;
- unsigned int size;
-
- m = GNUNET_CONTAINER_meta_data_create ();
- if (GNUNET_OK !=
- GNUNET_CONTAINER_meta_data_insert (m, "<test>", EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain", "TestTitle",
- strlen ("TestTitle") + 1))
- ABORT (m);
- if (GNUNET_OK !=
- GNUNET_CONTAINER_meta_data_insert (m, "<test>",
- EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain", "TestTitle",
- strlen ("TestTitle") + 1))
- ABORT (m);
- if (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (m, "<test>",
- EXTRACTOR_METATYPE_TITLE,
-
EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "TestTitle", strlen (
- "TestTitle") + 1))
/* dup! */
- ABORT (m);
- if (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (m, "<test>",
-
EXTRACTOR_METATYPE_AUTHOR_NAME,
-
EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "TestTitle", strlen (
- "TestTitle") + 1))
/* dup! */
- ABORT (m);
- if (2 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
- ABORT (m);
- if (GNUNET_OK !=
- GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME,
- "TestTitle", strlen ("TestTitle") +
1))
- ABORT (m);
- if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m,
-
EXTRACTOR_METATYPE_AUTHOR_NAME,
- "TestTitle", strlen (
- "TestTitle") + 1))
/* already gone */
- ABORT (m);
- if (1 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
- ABORT (m);
- if (GNUNET_OK !=
- GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE,
- "TestTitle", strlen ("TestTitle") +
1))
- ABORT (m);
- if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m,
- EXTRACTOR_METATYPE_TITLE,
- "TestTitle", strlen (
- "TestTitle") + 1))
/* already gone */
- ABORT (m);
- if (0 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
- ABORT (m);
- for (j = 0; j < i; j++)
- {
- GNUNET_snprintf (val, sizeof(val), "%s.%d",
- "A teststring that should compress well.", j);
- if (GNUNET_OK !=
- GNUNET_CONTAINER_meta_data_insert (m, "<test>",
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain", val, strlen (val) +
1))
- ABORT (m);
- }
- if (i != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
- ABORT (m);
-
- size = GNUNET_CONTAINER_meta_data_get_serialized_size (m);
- sval = NULL;
- if (size !=
- GNUNET_CONTAINER_meta_data_serialize (m, &sval, size,
-
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL))
- {
- GNUNET_free (sval);
- ABORT (m);
- }
- GNUNET_CONTAINER_meta_data_destroy (m);
- m = GNUNET_CONTAINER_meta_data_deserialize (sval, size);
- GNUNET_free (sval);
- if (m == NULL)
- ABORT (m);
- for (j = 0; j < i; j++)
- {
- GNUNET_snprintf (val,
- sizeof(val),
- "%s.%d",
- "A teststring that should compress well.",
- j);
- if (GNUNET_OK !=
- GNUNET_CONTAINER_meta_data_delete (m,
- EXTRACTOR_METATYPE_UNKNOWN,
- val,
- strlen (val) + 1))
- {
- ABORT (m);
- }
- }
- if (0 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
- ABORT (m);
- GNUNET_CONTAINER_meta_data_destroy (m);
- return 0;
-}
-
-
-static int
-testMetaMore (int i)
-{
- struct GNUNET_CONTAINER_MetaData *meta;
- int q;
- char txt[128];
- char *data;
- unsigned long long size;
-
- meta = GNUNET_CONTAINER_meta_data_create ();
- for (q = 0; q <= i; q++)
- {
- GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
- GNUNET_CONTAINER_meta_data_insert (meta, "<test>",
- q
- % 42 /* EXTRACTOR_metatype_get_max ()
*/,
- EXTRACTOR_METAFORMAT_UTF8, "text/plain",
- txt, strlen (txt) + 1);
- }
- size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
- data = GNUNET_malloc (size * 4);
- if (size !=
- GNUNET_CONTAINER_meta_data_serialize (meta, &data, size * 4,
-
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL))
- {
- GNUNET_free (data);
- ABORT (meta);
- }
- GNUNET_CONTAINER_meta_data_destroy (meta);
- GNUNET_free (data);
- return 0;
-}
-
-
-static int
-testMetaLink ()
-{
- struct GNUNET_CONTAINER_MetaData *m;
- char *val;
- unsigned int size;
-
- m = GNUNET_CONTAINER_meta_data_create ();
- if (GNUNET_OK !=
- GNUNET_CONTAINER_meta_data_insert (m, "<test>",
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain", "link",
- strlen ("link") + 1))
- ABORT (m);
- if (GNUNET_OK !=
- GNUNET_CONTAINER_meta_data_insert (m, "<test>",
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain", "lib-link.m4",
- strlen ("lib-link.m4") + 1))
- ABORT (m);
- val = NULL;
- size =
- GNUNET_CONTAINER_meta_data_serialize (m, &val, (size_t) -1,
-
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
- GNUNET_CONTAINER_meta_data_destroy (m);
- m = GNUNET_CONTAINER_meta_data_deserialize (val, size);
- GNUNET_free (val);
- if (m == NULL)
- ABORT (m);
- GNUNET_CONTAINER_meta_data_destroy (m);
- return 0;
-}
-
-
-static int
-check ()
-{
- struct GNUNET_CONTAINER_MetaData *meta;
- struct GNUNET_CONTAINER_MetaData *meta2;
- int q;
- int i = 100;
- char txt[128];
- char *str;
- unsigned char *thumb;
-
- meta = GNUNET_CONTAINER_meta_data_create ();
- meta2 = GNUNET_CONTAINER_meta_data_create ();
- for (q = 0; q <= i; q++)
- {
- GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
- GNUNET_CONTAINER_meta_data_insert (meta, "<test>",
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8, "text/plain",
- "TestTitle", strlen ("TestTitle") + 1);
- GNUNET_CONTAINER_meta_data_insert (meta2, "<test>",
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8, "text/plain",
- "TestTitle", strlen ("TestTitle") + 1);
- }
-
- // check meta_data_test_equal
- if (GNUNET_YES != GNUNET_CONTAINER_meta_data_test_equal (meta, meta2))
- {
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- ABORT (meta);
- }
-
- // check meta_data_clear
- GNUNET_CONTAINER_meta_data_clear (meta2);
- if (0 != GNUNET_CONTAINER_meta_data_iterate (meta2, NULL, NULL))
- {
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- ABORT (meta);
- }
- // check equal branch in meta_data_test_equal
- if (GNUNET_YES != GNUNET_CONTAINER_meta_data_test_equal (meta, meta))
- {
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- ABORT (meta);
- }
- // check "count" branch in meta_data_test_equal
- if (GNUNET_NO != GNUNET_CONTAINER_meta_data_test_equal (meta, meta2))
- {
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- ABORT (meta);
- }
-
- // check meta_data_add_publication_date
- GNUNET_CONTAINER_meta_data_add_publication_date (meta2);
-
- // check meta_data_merge
- GNUNET_CONTAINER_meta_data_clear (meta2);
- GNUNET_CONTAINER_meta_data_merge (meta2, meta);
- if (100 == GNUNET_CONTAINER_meta_data_iterate (meta2, NULL, NULL))
- {
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- ABORT (meta);
- }
-
- // check meta_data_get_by_type
- GNUNET_CONTAINER_meta_data_clear (meta2);
- if (NULL !=
- (str =
- GNUNET_CONTAINER_meta_data_get_by_type (meta2,
- EXTRACTOR_METATYPE_UNKNOWN)))
- {
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- GNUNET_free (str);
- ABORT (meta);
- }
-
- str =
- GNUNET_CONTAINER_meta_data_get_by_type (meta, EXTRACTOR_METATYPE_UNKNOWN);
- GNUNET_assert (NULL != str);
- if (str[0] != 'T')
- {
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- GNUNET_free (str);
- ABORT (meta);
- }
- GNUNET_free (str);
-
- // check branch
- if (NULL !=
- (str =
- GNUNET_CONTAINER_meta_data_get_by_type (meta,
-
EXTRACTOR_METATYPE_PUBLICATION_DATE)))
- {
- GNUNET_free (str);
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- ABORT (meta);
- }
-
- // check meta_data_get_first_by_types
- str =
- GNUNET_CONTAINER_meta_data_get_first_by_types (meta,
- EXTRACTOR_METATYPE_UNKNOWN,
- -1);
- GNUNET_assert (NULL != str);
- if (str[0] != 'T')
- {
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- GNUNET_free (str);
- ABORT (meta);
- }
- GNUNET_free (str);
-
- // check meta_data_get_thumbnail
- if (GNUNET_CONTAINER_meta_data_get_thumbnail (meta, &thumb) != 0)
- {
- GNUNET_free (thumb);
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- ABORT (meta);
- }
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- // check meta_data_duplicate
- meta2 = GNUNET_CONTAINER_meta_data_duplicate (meta);
- if (200 == GNUNET_CONTAINER_meta_data_iterate (meta2, NULL, NULL))
- {
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- ABORT (meta);
- }
- GNUNET_CONTAINER_meta_data_destroy (meta2);
- GNUNET_CONTAINER_meta_data_destroy (meta);
- return 0;
-}
-
-
-int
-main (int argc, char *argv[])
-{
- int failureCount = 0;
- int i;
-
- GNUNET_log_setup ("test-container-meta-data", "WARNING", NULL);
- for (i = 0; i < 255; i++)
- failureCount += testMeta (i);
- for (i = 1; i < 255; i++)
- failureCount += testMetaMore (i);
- failureCount += testMetaLink ();
-
- int ret = check ();
-
- if (ret == 1)
- return 1;
-
- if (failureCount != 0)
- return 1;
- return 0;
-}
-
-
-/* end of test_container_meta_data.c */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: Large refactor in order to restore some sanity with respect to private defines used in headers,
gnunet <=