From 93fba12ad8159dc6b683f9e7ce9f0528a11047f5 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 30 May 2015 18:35:02 +0000 Subject: make libextractor actually optional, both for GNUnet and GNUnet-taler builds --- README | 6 +- configure.ac | 23 +++++--- po/POTFILES.in | 4 ++ src/fs/Makefile.am | 64 ++++++++++++++++---- src/fs/fs_file_information.c | 2 + src/fs/fs_getopt.c | 15 +++-- src/fs/gnunet-directory.c | 21 +++++-- src/fs/gnunet-helper-fs-publish.c | 35 +++++++++-- src/fs/gnunet-publish.c | 4 ++ src/fs/gnunet-search.c | 6 ++ src/fs/test_fs_directory.c | 8 ++- src/include/Makefile.am | 3 - src/include/gnunet_configuration_lib.h | 1 + src/include/gnunet_container_lib.h | 94 ++++++++++++++++++++++++++++++ src/include/gnunet_crypto_lib.h | 6 +- src/include/gnunet_util_taler_wallet_lib.h | 1 - src/util/Makefile.am | 3 - src/util/common_allocation.c | 2 +- src/util/common_endian.c | 2 +- src/util/common_logging.c | 10 +--- src/util/configuration.c | 5 +- src/util/container_heap.c | 2 +- src/util/container_meta_data.c | 9 ++- src/util/container_multihashmap.c | 2 +- src/util/container_multihashmap32.c | 2 +- src/util/crypto_crc.c | 2 +- src/util/crypto_ecc.c | 3 +- src/util/crypto_hash.c | 3 +- src/util/crypto_mpi.c | 2 +- src/util/crypto_random.c | 2 +- src/util/crypto_rsa.c | 8 +-- src/util/crypto_symmetric.c | 2 +- src/util/disk.c | 3 +- src/util/disk.h | 3 +- src/util/strings.c | 3 +- src/util/test_container_meta_data.c | 14 +++++ src/util/time.c | 3 +- 37 files changed, 301 insertions(+), 77 deletions(-) diff --git a/README b/README index 98d77b907..ffc06b687 100644 --- a/README +++ b/README @@ -28,14 +28,13 @@ packages. Hence please make sure to use the versions listed below. These are the direct dependencies for running GNUnet: -- libextractor >= 0.6.1 -- libmicrohttpd >= 0.9.33 +- libmicrohttpd >= 0.9.40 - libgcrypt >= 1.6 - libgnurl >= 7.35.0 (available from https://gnunet.org/gnurl) - libunistring >= 0.9.2 - gnutls >= 3.2.12 - libidn >= 1.0 -- libglpk >= 4.45 +- libextractor >= 0.6.1 (highly recommended) - openssl >= 1.0 (binary, used to generate X.509 certificate) - libltdl >= 2.2 (part of GNU libtool) - sqlite >= 3.8 (default database, required) @@ -46,6 +45,7 @@ These are the direct dependencies for running GNUnet: - libogg >= 1.3.0 (optional for experimental conversation tool) - python-zbar >= 0.10 (optional for gnunet-qr) - TeX Live >= 2012 (optional for gnunet-bcd) +- libglpk >= 4.45 (optional for experimental code) Recommended autotools for compiling the SVN version are: - autoconf >= 2.59 diff --git a/configure.ac b/configure.ac index 039652b78..ebbb69465 100644 --- a/configure.ac +++ b/configure.ac @@ -557,11 +557,6 @@ AC_ARG_ENABLE([taler-wallet], AC_MSG_RESULT($taler_only) AM_CONDITIONAL([TALER_ONLY], [test "x$taler_only" = "xyes"]) -if test "$taler_only" != yes -then - - - # test for libextractor extractor=0 AC_MSG_CHECKING(for libextractor) @@ -590,14 +585,22 @@ AC_ARG_WITH(extractor, AC_CHECK_HEADERS(extractor.h, AC_CHECK_LIB([extractor], [EXTRACTOR_plugin_add_defaults], extractor=1))]) +# restore LIBS +LIBS=$SAVE_LIBS + if test "$extractor" != 1 then - AC_MSG_ERROR([GNUnet requires libextractor]) + AM_CONDITIONAL(HAVE_LIBEXTRACTOR, false) + AC_DEFINE([HAVE_LIBEXTRACTOR],[0],[Lacking libextractor]) +else + AM_CONDITIONAL(HAVE_LIBEXTRACTOR, true) + AC_DEFINE([HAVE_LIBEXTRACTOR],[1],[Have libextractor]) fi -# restore LIBS -LIBS=$SAVE_LIBS +if test "$taler_only" != yes +then + # Check for libltdl header (#2999) ltdl=0 AC_MSG_CHECKING(for libltdl) @@ -1674,6 +1677,10 @@ then fi fi +if test "$extractor" != 1 +then + AC_MSG_WARN([NOTICE: libextractor not found, but various file-sharing functions require it]) +fi AC_MSG_NOTICE([NOTICE: Database support is set to MySQL: $mysql, SQLite: $sqlite, Postgres: $postgres]) diff --git a/po/POTFILES.in b/po/POTFILES.in index b350ea996..34bdaedd8 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -391,6 +391,7 @@ src/util/common_allocation.c src/util/common_endian.c src/util/common_logging.c src/util/configuration.c +src/util/configuration_loader.c src/util/connection.c src/util/container_bloomfilter.c src/util/container_heap.c @@ -400,7 +401,9 @@ src/util/container_multihashmap.c src/util/container_multipeermap.c src/util/crypto_crc.c src/util/crypto_ecc.c +src/util/crypto_ecc_setup.c src/util/crypto_hash.c +src/util/crypto_hash_file.c src/util/crypto_hkdf.c src/util/crypto_kdf.c src/util/crypto_mpi.c @@ -409,6 +412,7 @@ src/util/crypto_random.c src/util/crypto_rsa.c src/util/crypto_symmetric.c src/util/disk.c +src/util/disk_iterator.c src/util/getopt.c src/util/getopt_helpers.c src/util/gnunet-config.c diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index 8ac42c18d..736339aab 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am @@ -51,7 +51,12 @@ libgnunetfs_la_SOURCES = \ libgnunetfs_la_LIBADD = \ $(top_builddir)/src/datastore/libgnunetdatastore.la \ $(top_builddir)/src/util/libgnunetutil.la \ - $(GN_LIBINTL) $(XLIB) $(LIBGCRYPT_LIBS) -lunistring -lextractor + $(GN_LIBINTL) $(XLIB) $(LIBGCRYPT_LIBS) -lunistring + +if HAVE_LIBEXTRACTOR +libgnunetfs_la_LIBADD += \ + -lextractor +endif libgnunetfs_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ @@ -92,9 +97,13 @@ gnunet_directory_SOURCES = \ gnunet_directory_LDADD = \ libgnunetfs.la \ $(top_builddir)/src/util/libgnunetutil.la \ - -lextractor \ $(GN_LIBINTL) +if HAVE_LIBEXTRACTOR +gnunet_directory_LDADD += \ + -lextractor +endif + gnunet_fs_profiler_SOURCES = \ gnunet-fs-profiler.c gnunet_fs_profiler_LDADD = \ @@ -107,9 +116,13 @@ gnunet_fs_SOURCES = \ gnunet_fs_LDADD = \ libgnunetfs.la \ $(top_builddir)/src/util/libgnunetutil.la \ - -lextractor \ $(GN_LIBINTL) +if HAVE_LIBEXTRACTOR +gnunet_fs_LDADD += \ + -lextractor +endif + gnunet_download_SOURCES = \ gnunet-download.c gnunet_download_LDADD = \ @@ -123,31 +136,48 @@ gnunet_publish_LDADD = \ $(top_builddir)/src/identity/libgnunetidentity.la \ libgnunetfs.la \ $(top_builddir)/src/util/libgnunetutil.la \ - -lextractor \ $(GN_LIBINTL) +if HAVE_LIBEXTRACTOR +gnunet_publish_LDADD += \ + -lextractor +endif + gnunet_auto_share_SOURCES = \ gnunet-auto-share.c gnunet_auto_share_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ - -lextractor \ $(GN_LIBINTL) +if HAVE_LIBEXTRACTOR +gnunet_auto_share_LDADD += \ + -lextractor +endif + gnunet_helper_fs_publish_SOURCES = \ gnunet-helper-fs-publish.c gnunet_helper_fs_publish_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ - -lextractor \ $(GN_LIBINTL) +if HAVE_LIBEXTRACTOR +gnunet_helper_fs_publish_LDADD += \ + -lextractor +endif + gnunet_search_SOURCES = \ gnunet-search.c gnunet_search_LDADD = \ libgnunetfs.la \ $(top_builddir)/src/util/libgnunetutil.la \ - -lextractor \ $(GN_LIBINTL) +if HAVE_LIBEXTRACTOR +gnunet_search_LDADD += \ + -lextractor +endif + + gnunet_daemon_fsprofiler_SOURCES = \ gnunet-daemon-fsprofiler.c gnunet_daemon_fsprofiler_LDADD = \ @@ -243,9 +273,13 @@ test_plugin_block_fs_LDADD = \ if HAVE_PYTHON check_SCRIPTS = \ - test_gnunet_fs_psd.py \ test_gnunet_fs_rec.py \ test_gnunet_fs_idx.py + +if HAVE_LIBEXTRACTOR +check_SCRIPTS += \ + test_gnunet_fs_psd.py +endif endif if ENABLE_MONKEY @@ -289,10 +323,15 @@ endif test_fs_directory_SOURCES = \ test_fs_directory.c test_fs_directory_LDADD = \ - -lextractor \ libgnunetfs.la \ $(top_builddir)/src/util/libgnunetutil.la +if HAVE_LIBEXTRACTOR +test_fs_directory_LDADD += \ + -lextractor +endif + + test_fs_download_SOURCES = \ test_fs_download.c test_fs_download_LDADD = \ @@ -324,10 +363,15 @@ test_fs_download_persistence_LDADD = \ test_fs_file_information_SOURCES = \ test_fs_file_information.c test_fs_file_information_LDADD = \ - -lextractor \ libgnunetfs.la \ $(top_builddir)/src/util/libgnunetutil.la +if HAVE_LIBEXTRACTOR +test_fs_file_information_LDADD += \ + -lextractor +endif + + test_fs_getopt_SOURCES = \ test_fs_getopt.c test_fs_getopt_LDADD = \ diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index ffe2d191d..b787ca8fd 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c @@ -24,7 +24,9 @@ * @author Christian Grothoff */ #include "platform.h" +#if HAVE_EXTRACTOR_H #include +#endif #include "gnunet_fs_service.h" #include "fs_api.h" #include "fs_tree.h" diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c index d2ee34a94..86fc9578c 100644 --- a/src/fs/fs_getopt.c +++ b/src/fs/fs_getopt.c @@ -118,17 +118,20 @@ GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext * @param scls must be of type "struct GNUNET_MetaData **" * @param option name of the option (typically 'k') * @param value command line argument given - * @return GNUNET_OK on success + * @return #GNUNET_OK on success */ int -GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext - *ctx, void *scls, const char *option, +GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, + void *scls, + const char *option, const char *value) { struct GNUNET_CONTAINER_MetaData **mm = scls; +#if HAVE_EXTRACTOR_H enum EXTRACTOR_MetaType type; const char *typename; const char *typename_i18n; +#endif struct GNUNET_CONTAINER_MetaData *meta; char *tmp; @@ -144,7 +147,7 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext */ /*tmp = GNUNET_STRINGS_to_utf8 (value, strlen (value), locale_charset ());*/ tmp = GNUNET_strdup (value); - +#if HAVE_EXTRACTOR_H type = EXTRACTOR_metatype_get_max (); while (type > 0) { @@ -181,7 +184,9 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext break; } } - if (tmp != NULL) +#endif + + if (NULL != tmp) { GNUNET_CONTAINER_meta_data_insert (meta, "", EXTRACTOR_METATYPE_UNKNOWN, diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c index 536766abb..c06e1aca2 100644 --- a/src/fs/gnunet-directory.c +++ b/src/fs/gnunet-directory.c @@ -36,13 +36,17 @@ static int ret; * @param format format of data * @param data_mime_type mime type of data * @param data value of the meta data - * @param data_size number of bytes in data + * @param data_size number of bytes in @a data * @return always 0 (to continue iterating) */ static int -item_printer (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) +item_printer (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) { if (type == EXTRACTOR_METATYPE_GNUNET_FULL_DATA) { @@ -55,9 +59,16 @@ item_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, return 0; if (type == EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME) return 0; +#if HAVE_LIBEXTRACTOR printf ("\t%20s: %s\n", dgettext (LIBEXTRACTOR_GETTEXT_DOMAIN, - EXTRACTOR_metatype_to_string (type)), data); + EXTRACTOR_metatype_to_string (type)), + data); +#else + printf ("\t%20d: %s\n", + type, + data); +#endif return 0; } diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c index 2e63b12a8..6c2c76fe9 100644 --- a/src/fs/gnunet-helper-fs-publish.c +++ b/src/fs/gnunet-helper-fs-publish.c @@ -82,10 +82,12 @@ struct ScanTreeNode }; +#if HAVE_LIBEXTRACTOR /** * List of libextractor plugins to use for extracting. */ static struct EXTRACTOR_PluginList *plugins; +#endif /** * File descriptor we use for IPC with the parent. @@ -93,6 +95,7 @@ static struct EXTRACTOR_PluginList *plugins; static int output_stream; +#if HAVE_LIBEXTRACTOR /** * Add meta data that libextractor finds to our meta data * container. @@ -111,9 +114,13 @@ static int output_stream; * @return always 0 to continue extracting */ static int -add_to_md (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) +add_to_md (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) { struct GNUNET_CONTAINER_MetaData *md = cls; @@ -134,6 +141,7 @@ add_to_md (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, } return 0; } +#endif /** @@ -151,7 +159,7 @@ free_tree (struct ScanTreeNode *tree) if (NULL != tree->parent) GNUNET_CONTAINER_DLL_remove (tree->parent->children_head, tree->parent->children_tail, - tree); + tree); GNUNET_free (tree->filename); GNUNET_free (tree); } @@ -383,7 +391,13 @@ extract_files (struct ScanTreeNode *item) /* this is the expensive operation, *afterwards* we'll check for aborts */ meta = GNUNET_CONTAINER_meta_data_create (); - EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta); +#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); if (-1 == size) @@ -525,10 +539,12 @@ main (int argc, if ( (NULL == ex) || (0 != strcmp (ex, "-")) ) { +#if HAVE_LIBEXTRACTOR plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); if (NULL != ex) plugins = EXTRACTOR_plugin_add_config (plugins, ex, EXTRACTOR_OPTION_DEFAULT_POLICY); +#endif } /* scan tree to find out how much work there is to be done */ @@ -536,7 +552,9 @@ main (int argc, &root)) { (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); +#if HAVE_LIBEXTRACTOR EXTRACTOR_plugin_remove_all (plugins); +#endif #if WINDOWS GNUNET_free ((void*) argv); #endif @@ -547,7 +565,9 @@ main (int argc, if (GNUNET_OK != write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0)) { +#if HAVE_LIBEXTRACTOR EXTRACTOR_plugin_remove_all (plugins); +#endif #if WINDOWS GNUNET_free ((void*) argv); #endif @@ -560,7 +580,9 @@ main (int argc, { (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); free_tree (root); +#if HAVE_LIBEXTRACTOR EXTRACTOR_plugin_remove_all (plugins); +#endif #if WINDOWS GNUNET_free ((void*) argv); #endif @@ -570,7 +592,9 @@ main (int argc, } /* enable "clean" shutdown by telling parent that we are done */ (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0); +#if HAVE_LIBEXTRACTOR EXTRACTOR_plugin_remove_all (plugins); +#endif #if WINDOWS GNUNET_free ((void*) argv); #endif @@ -578,4 +602,3 @@ main (int argc, } /* end of gnunet-helper-fs-publish.c */ - diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index b213218e4..7844acd96 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c @@ -348,7 +348,11 @@ meta_printer (void *cls, return 0; if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type) return 0; +#if HAVE_LIBEXTRACTOR FPRINTF (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data); +#else + FPRINTF (stdout, "\t%d - %s\n", type, data); +#endif return 0; } diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index 395fb9ffe..9065922e1 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c @@ -82,9 +82,15 @@ item_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, return 0; if (type == EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME) return 0; +#if HAVE_LIBEXTRACTOR printf ("\t%20s: %s\n", dgettext (LIBEXTRACTOR_GETTEXT_DOMAIN, EXTRACTOR_metatype_to_string (type)), data); +#else + printf ("\t%20d: %s\n", + type, + data); +#endif return 0; } diff --git a/src/fs/test_fs_directory.c b/src/fs/test_fs_directory.c index bdbaf906f..4960b8922 100644 --- a/src/fs/test_fs_directory.c +++ b/src/fs/test_fs_directory.c @@ -17,15 +17,15 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * @file fs/test_fs_directory.c * @brief Test for fs_directory.c * @author Christian Grothoff */ - #include "platform.h" +#if HAVE_EXTRACTOR_H #include +#endif #include "gnunet_util_lib.h" #include "gnunet_fs_service.h" #include "fs_api.h" @@ -99,7 +99,11 @@ testDirectory (unsigned int i) { GNUNET_snprintf (txt, sizeof (txt), "%u -- %u\n", p, q); GNUNET_CONTAINER_meta_data_insert (mds[p], "", +#if HAVE_EXTRACTOR_H q % EXTRACTOR_metatype_get_max (), +#else + q % 128, +#endif EXTRACTOR_METAFORMAT_UTF8, "text/plain", txt, strlen (txt) + 1); } diff --git a/src/include/Makefile.am b/src/include/Makefile.am index c8e40bc27..af6d02ada 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -17,11 +17,8 @@ if TALER_ONLY gnunetinclude_HEADERS = \ platform.h plibc.h $(WINPROC) gettext.h \ gnunet_common.h \ - gnunet_configuration_lib.h \ gnunet_container_lib.h \ gnunet_crypto_lib.h \ - gnunet_disk_lib.h \ - gnunet_scheduler_lib.h \ gnunet_strings_lib.h \ gnunet_time_lib.h \ gnunet_util_taler_wallet_lib.h diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h index 2aaaac583..0939424a3 100644 --- a/src/include/gnunet_configuration_lib.h +++ b/src/include/gnunet_configuration_lib.h @@ -28,6 +28,7 @@ #ifndef GNUNET_CONFIGURATION_LIB_H #define GNUNET_CONFIGURATION_LIB_H +#include "gnunet_time_lib.h" #ifdef __cplusplus extern "C" diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index 778e5b84b..590c6a2fa 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h @@ -35,8 +35,102 @@ /* add error and config prototypes */ #include "gnunet_crypto_lib.h" + +#if HAVE_EXTRACTOR_H + #include +#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 (i.e. '<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 diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index ff337e797..99508af43 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h @@ -54,9 +54,13 @@ struct GNUNET_HashCode; struct GNUNET_PeerIdentity; #include "gnunet_common.h" -#include "gnunet_scheduler_lib.h" #include +/** + * We need this enum here, but not the entire scheduler API. + * For the full definition, see gnunet_scheduler_lib.h. + */ +enum GNUNET_SCHEDULER_Priority; /** * @brief A 512-bit hashcode diff --git a/src/include/gnunet_util_taler_wallet_lib.h b/src/include/gnunet_util_taler_wallet_lib.h index ff3b2613b..a1db60de5 100644 --- a/src/include/gnunet_util_taler_wallet_lib.h +++ b/src/include/gnunet_util_taler_wallet_lib.h @@ -43,7 +43,6 @@ extern "C" #include "gnunet_crypto_lib.h" #include "gnunet_container_lib.h" -#include "gnunet_disk_lib.h" #include "gnunet_strings_lib.h" #if 0 /* keep Emacsens' auto-indent happy */ diff --git a/src/util/Makefile.am b/src/util/Makefile.am index a2482fc87..916a588fa 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -128,7 +128,6 @@ libgnunetutil_taler_wallet_la_SOURCES = \ common_allocation.c \ common_endian.c \ common_logging.c \ - configuration.c \ container_heap.c \ container_multihashmap.c \ container_multihashmap32.c \ @@ -141,8 +140,6 @@ libgnunetutil_taler_wallet_la_SOURCES = \ crypto_mpi.c \ crypto_random.c \ crypto_rsa.c \ - disk.c \ - disk.h \ strings.c \ time.c diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 5280d73b2..4fdc05f10 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c @@ -24,7 +24,7 @@ * @author Christian Grothoff */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" #if HAVE_MALLOC_H #include #endif diff --git a/src/util/common_endian.c b/src/util/common_endian.c index 4a8a01664..e6c34250a 100644 --- a/src/util/common_endian.c +++ b/src/util/common_endian.c @@ -26,7 +26,7 @@ */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" #define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__) diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 695b49913..492d00dc6 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -24,7 +24,8 @@ * @author Christian Grothoff */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" +#include "gnunet_strings_lib.h" #include @@ -328,7 +329,6 @@ setup_log_file (const struct tm *tm) { static char last_fn[PATH_MAX + 1]; char fn[PATH_MAX + 1]; - int dirwarn; int altlog_fd; int dup_return; FILE *altlog; @@ -352,7 +352,6 @@ setup_log_file (const struct tm *tm) return GNUNET_OK; /* no change */ log_rotate (last_fn); strcpy (last_fn, fn); - dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); #if WINDOWS altlog_fd = OPEN (fn, O_APPEND | O_BINARY | @@ -386,16 +385,13 @@ setup_log_file (const struct tm *tm) if (-1 == altlog_fd) { GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn); - if (dirwarn) - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Failed to create or access directory for log file `%s'\n"), - fn); return GNUNET_SYSERR; } GNUNET_stderr = altlog; return GNUNET_OK; } + /** * Utility function - adds a parsed definition to logdefs array. * diff --git a/src/util/configuration.c b/src/util/configuration.c index f61b43d57..3c7570981 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -25,7 +25,10 @@ */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" +#include "gnunet_strings_lib.h" +#include "gnunet_configuration_lib.h" +#include "gnunet_disk_lib.h" #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) diff --git a/src/util/container_heap.c b/src/util/container_heap.c index 8c3de6c26..ad96af01d 100644 --- a/src/util/container_heap.c +++ b/src/util/container_heap.c @@ -26,7 +26,7 @@ */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_container_lib.h" #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) diff --git a/src/util/container_meta_data.c b/src/util/container_meta_data.c index 622b45334..5cef31f37 100644 --- a/src/util/container_meta_data.c +++ b/src/util/container_meta_data.c @@ -26,7 +26,9 @@ #include "platform.h" #include "gnunet_util_lib.h" +#if HAVE_EXTRACTOR_H #include +#endif #include #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) @@ -432,7 +434,8 @@ GNUNET_CONTAINER_meta_data_add_publication_date (struct struct GNUNET_TIME_Absolute t; t = GNUNET_TIME_absolute_get (); - GNUNET_CONTAINER_meta_data_delete (md, EXTRACTOR_METATYPE_PUBLICATION_DATE, + GNUNET_CONTAINER_meta_data_delete (md, + EXTRACTOR_METATYPE_PUBLICATION_DATE, NULL, 0); dat = GNUNET_STRINGS_absolute_time_to_string (t); GNUNET_CONTAINER_meta_data_insert (md, "", @@ -481,8 +484,8 @@ GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md, * @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) +GNUNET_CONTAINER_meta_data_get_by_type (const struct GNUNET_CONTAINER_MetaData *md, + enum EXTRACTOR_MetaType type) { struct MetaItem *pos; diff --git a/src/util/container_multihashmap.c b/src/util/container_multihashmap.c index df6dd5704..46379b34e 100644 --- a/src/util/container_multihashmap.c +++ b/src/util/container_multihashmap.c @@ -24,7 +24,7 @@ */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_container_lib.h" #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) diff --git a/src/util/container_multihashmap32.c b/src/util/container_multihashmap32.c index 00dee18cd..d7b8413c4 100644 --- a/src/util/container_multihashmap32.c +++ b/src/util/container_multihashmap32.c @@ -26,7 +26,7 @@ */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_container_lib.h" #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) diff --git a/src/util/crypto_crc.c b/src/util/crypto_crc.c index 252cdad05..5a8357478 100644 --- a/src/util/crypto_crc.c +++ b/src/util/crypto_crc.c @@ -28,7 +28,7 @@ * @author Christian Grothoff */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index 87c787185..adeaf77c8 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c @@ -25,7 +25,8 @@ */ #include "platform.h" #include -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" +#include "gnunet_strings_lib.h" #define EXTRA_CHECKS 0 diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index e9f25bf84..8e5730ffd 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c @@ -24,7 +24,8 @@ * @author Christian Grothoff */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" +#include "gnunet_strings_lib.h" #include #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) diff --git a/src/util/crypto_mpi.c b/src/util/crypto_mpi.c index 806a35da8..ad64778fd 100644 --- a/src/util/crypto_mpi.c +++ b/src/util/crypto_mpi.c @@ -26,7 +26,7 @@ */ #include "platform.h" #include -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c index 2960af17e..f9a0664e2 100644 --- a/src/util/crypto_random.c +++ b/src/util/crypto_random.c @@ -25,7 +25,7 @@ * @author Christian Grothoff */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" #include #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 0b21b40b4..b8e29146f 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c @@ -22,7 +22,7 @@ */ #include "platform.h" #include -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) @@ -413,7 +413,7 @@ GNUNET_CRYPTO_rsa_blinding_key_create (unsigned int len) /** * Compare the values of two blinding keys. - * + * * @param b1 one key * @param b2 the other key * @return 0 if the two are equal @@ -443,7 +443,7 @@ GNUNET_CRYPTO_rsa_signature_cmp (struct GNUNET_CRYPTO_rsa_Signature *s1, size_t z1; size_t z2; int ret; - + z1 = GNUNET_CRYPTO_rsa_signature_encode (s1, &b1); z2 = GNUNET_CRYPTO_rsa_signature_encode (s2, @@ -476,7 +476,7 @@ GNUNET_CRYPTO_rsa_public_key_cmp (struct GNUNET_CRYPTO_rsa_PublicKey *p1, size_t z1; size_t z2; int ret; - + z1 = GNUNET_CRYPTO_rsa_public_key_encode (p1, &b1); z2 = GNUNET_CRYPTO_rsa_public_key_encode (p2, diff --git a/src/util/crypto_symmetric.c b/src/util/crypto_symmetric.c index 455166546..6465d5eb6 100644 --- a/src/util/crypto_symmetric.c +++ b/src/util/crypto_symmetric.c @@ -26,7 +26,7 @@ */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" #include #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) diff --git a/src/util/disk.c b/src/util/disk.c index a56966d04..c9f6408e8 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -24,8 +24,9 @@ * @author Nils Durner */ #include "platform.h" -#include "gnunet_util_lib.h" #include "disk.h" +#include "gnunet_strings_lib.h" +#include "gnunet_disk_lib.h" #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) diff --git a/src/util/disk.h b/src/util/disk.h index 1dfec216f..2592bd8c0 100644 --- a/src/util/disk.h +++ b/src/util/disk.h @@ -26,7 +26,8 @@ #ifndef GNUNET_DISK_H_ #define GNUNET_DISK_H_ -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" +#include "gnunet_disk_lib.h" /** * Retrieve OS file handle diff --git a/src/util/strings.c b/src/util/strings.c index 379f3f5a3..407a135d1 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -29,7 +29,8 @@ #if HAVE_ICONV #include #endif -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" +#include "gnunet_strings_lib.h" #include #include #include diff --git a/src/util/test_container_meta_data.c b/src/util/test_container_meta_data.c index a3729fc9f..df6587efd 100644 --- a/src/util/test_container_meta_data.c +++ b/src/util/test_container_meta_data.c @@ -27,6 +27,8 @@ #include "platform.h" #include "gnunet_util_lib.h" +#if HAVE_EXTRACTOR_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 @@ -343,4 +345,16 @@ main (int argc, char *argv[]) return 0; } +#else + +int +main (int argc, char *argv[]) +{ + fprintf (stderr, + "GNU libextractor not found, skipping test.\n"); + return 0; +} + +#endif + /* end of test_container_meta_data.c */ diff --git a/src/util/time.c b/src/util/time.c index 01a3cddd5..78dd4c6d2 100644 --- a/src/util/time.c +++ b/src/util/time.c @@ -24,7 +24,8 @@ * @brief functions for handling time and time arithmetic */ #include "platform.h" -#include "gnunet_util_lib.h" +#include "gnunet_crypto_lib.h" +#include "gnunet_time_lib.h" #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) -- cgit v1.2.3