libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit ac313dfda84664ef8a3748a50223cfd7e2803e0b
parent 7bb9fe0a1bb0bedaf371627f66085fe3095083d7
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 19 Oct 2013 14:32:32 +0000

-releasing LE 1.2

Diffstat:
MChangeLog | 4++++
Mconfigure.ac | 24++++++++++++------------
Msrc/include/extractor.h | 56++++++++++++++++++++++++++++----------------------------
Msrc/main/extractor_ipc_gnu.c | 48++++++++++++++++++++++++------------------------
4 files changed, 68 insertions(+), 64 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Sat Oct 19 16:30:37 CEST 2013 + Increase select() timeout, handle timeout case better. + Releasing GNU libextractor 1.2. -CG + Mon Sep 23 14:42:58 CEST 2013 Required external installation of libltdl. Check for presence of tidyNodeGetValue in libtidy. -CG diff --git a/configure.ac b/configure.ac @@ -1,6 +1,6 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([libextractor], [1.1], [bug-libextractor@gnu.org]) +AC_INIT([libextractor], [1.2], [bug-libextractor@gnu.org]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) AH_TOP([#define _GNU_SOURCE 1]) @@ -9,7 +9,7 @@ AC_CANONICAL_HOST AC_CANONICAL_SYSTEM LIB_VERSION_CURRENT=4 -LIB_VERSION_REVISION=2 +LIB_VERSION_REVISION=3 LIB_VERSION_AGE=1 AC_SUBST(LIB_VERSION_CURRENT) AC_SUBST(LIB_VERSION_REVISION) @@ -40,7 +40,7 @@ case "$target_os" in *linux-gnu) AC_DEFINE(GNU_LINUX,1,[This is a GNU/Linux system]) AC_DEFINE_UNQUOTED(GNU_LINUX,1,[This is a GNU/Linux system]) - AM_CONDITIONAL(HAVE_GNU_LD, true) + AM_CONDITIONAL(HAVE_GNU_LD, true) AM_CONDITIONAL(SOMEBSD, false) AM_CONDITIONAL(WINDOWS, false) XTRA_CPPLIBS=-lstdc++ @@ -88,7 +88,7 @@ darwin*) AM_CONDITIONAL(HAVE_GNU_LD, false) AM_CONDITIONAL(SOMEBSD, false) AM_CONDITIONAL(WINDOWS, false) - CFLAGS="-no-cpp-precomp -fno-common $CFLAGS" + CFLAGS="-no-cpp-precomp -fno-common $CFLAGS" LIBEXT=.so ;; cygwin*) @@ -132,7 +132,7 @@ mingw*) ], [AC_MSG_RESULT([--with-plibc not specified]) LDFLAGS="-L/usr/lib $LDFLAGS" - CPPFLAGS="-I/usr/include $CPPFLAGS" + CPPFLAGS="-I/usr/include $CPPFLAGS" AC_CHECK_HEADERS([plibc.h], AC_CHECK_LIB([plibc], [plibc_init], EXT_LIB_PATH="-L$with_plibc/lib $EXT_LIB_PATH" @@ -195,7 +195,7 @@ AM_CONDITIONAL(MINGW, test "$build_os" = "mingw32") # use '-fno-strict-aliasing', but only if the compiler can take it -if gcc -fno-strict-aliasing -S -o /dev/null -xc /dev/null >/dev/null 2>&1; +if gcc -fno-strict-aliasing -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then CFLAGS="-fno-strict-aliasing $CFLAGS" fi @@ -687,7 +687,7 @@ then AC_DEFINE([FRAMEWORK_BUILD], 1, [Build a Mac OS X Framework]) LE_INTLINCL='-I$(top_srcdir)/src/intlemu' LE_LIBINTL='$(top_builddir)/src/intlemu/libintlemu.la -framework CoreFoundation' - AC_LIB_APPENDTOVAR([CPPFLAGS], [$LE_INTLINCL]) + AC_LIB_APPENDTOVAR([CPPFLAGS], [$LE_INTLINCL]) fi @@ -697,7 +697,7 @@ LE_PLUGIN_LDFLAGS="-export-dynamic -avoid-version -module -no-undefined" # TODO insert a proper check here AC_CACHE_CHECK([whether -export-symbols-regex works], - gn_cv_export_symbols_regex_works, + gn_cv_export_symbols_regex_works, [ case "$host_os" in mingw*) gn_cv_export_symbols_regex_works=no;; @@ -731,10 +731,10 @@ AC_SUBST(PACKAGE_VERSION_NOALPHA) # gcov compilation AC_MSG_CHECKING(whether to compile with support for code coverage analysis) -AC_ARG_ENABLE([coverage], +AC_ARG_ENABLE([coverage], AS_HELP_STRING([--enable-coverage], [compile the library with code coverage support]), - [use_gcov=${enableval}], + [use_gcov=${enableval}], [use_gcov=no]) AC_MSG_RESULT($use_gcov) AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"]) @@ -742,7 +742,7 @@ AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"]) AC_CONFIG_FILES([Makefile -po/Makefile.in +po/Makefile.in m4/Makefile contrib/macosx/Info.plist contrib/macosx/Pkg-Info.plist @@ -799,7 +799,7 @@ then AC_MSG_NOTICE([NOTICE: FFmpeg thumbnailer plugin disabled]) fi -if test "x$without_gtk" = "xtrue" +if test "x$without_gtk" = "xtrue" then AC_MSG_NOTICE([NOTICE: libgtk3+ not found, gtk thumbnail support disabled]) fi diff --git a/src/include/extractor.h b/src/include/extractor.h @@ -35,7 +35,7 @@ extern "C" { * 0.2.6-1 => 0x00020601 * 4.5.2-0 => 0x04050200 */ -#define EXTRACTOR_VERSION 0x01010001 +#define EXTRACTOR_VERSION 0x01020000 #include <stdio.h> @@ -112,7 +112,7 @@ enum EXTRACTOR_MetaFormat * @defgroup types meta data types * @{ */ -enum EXTRACTOR_MetaType +enum EXTRACTOR_MetaType { /* fundamental types */ EXTRACTOR_METATYPE_RESERVED = 0, @@ -126,7 +126,7 @@ enum EXTRACTOR_MetaType EXTRACTOR_METATYPE_BOOK_EDITION = 6, EXTRACTOR_METATYPE_BOOK_CHAPTER_NUMBER = 7, EXTRACTOR_METATYPE_JOURNAL_NAME = 8, - EXTRACTOR_METATYPE_JOURNAL_VOLUME = 9, + EXTRACTOR_METATYPE_JOURNAL_VOLUME = 9, EXTRACTOR_METATYPE_JOURNAL_NUMBER = 10, EXTRACTOR_METATYPE_PAGE_COUNT = 11, EXTRACTOR_METATYPE_PAGE_RANGE = 12, @@ -149,7 +149,7 @@ enum EXTRACTOR_MetaType EXTRACTOR_METATYPE_URL = 29, /* "unique" document identifiers */ - EXTRACTOR_METATYPE_URI = 30, + EXTRACTOR_METATYPE_URI = 30, EXTRACTOR_METATYPE_ISRC = 31, EXTRACTOR_METATYPE_HASH_MD4 = 32, EXTRACTOR_METATYPE_HASH_MD5 = 33, @@ -181,8 +181,8 @@ enum EXTRACTOR_MetaType EXTRACTOR_METATYPE_FORMAT_VERSION = 55, /* processing history */ - EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE = 56, - EXTRACTOR_METATYPE_UNKNOWN_DATE = 57, + EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE = 56, + EXTRACTOR_METATYPE_UNKNOWN_DATE = 57, EXTRACTOR_METATYPE_CREATION_DATE = 58, EXTRACTOR_METATYPE_MODIFICATION_DATE = 59, EXTRACTOR_METATYPE_LAST_PRINTED = 60, @@ -223,7 +223,7 @@ enum EXTRACTOR_MetaType EXTRACTOR_METATYPE_RESOURCE_TYPE = 92, EXTRACTOR_METATYPE_LIBRARY_SEARCH_PATH = 93, EXTRACTOR_METATYPE_LIBRARY_DEPENDENCY = 94, - + /* photography specifics */ EXTRACTOR_METATYPE_CAMERA_MAKE = 95, EXTRACTOR_METATYPE_CAMERA_MODEL = 96, @@ -244,8 +244,8 @@ enum EXTRACTOR_MetaType EXTRACTOR_METATYPE_MAGNIFICATION = 111, /* image specifics */ - EXTRACTOR_METATYPE_IMAGE_DIMENSIONS = 112, - EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE = 113, + EXTRACTOR_METATYPE_IMAGE_DIMENSIONS = 112, + EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE = 113, EXTRACTOR_METATYPE_THUMBNAIL = 114, EXTRACTOR_METATYPE_IMAGE_RESOLUTION = 115, EXTRACTOR_METATYPE_SOURCE = 116, @@ -307,8 +307,8 @@ enum EXTRACTOR_MetaType EXTRACTOR_METATYPE_POPULARITY_METER = 168, EXTRACTOR_METATYPE_LICENSEE = 169, EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST = 170, - EXTRACTOR_METATYPE_MOOD = 171, - EXTRACTOR_METATYPE_SUBTITLE = 172, + EXTRACTOR_METATYPE_MOOD = 171, + EXTRACTOR_METATYPE_SUBTITLE = 172, /* GNUnet specific values (never extracted) */ EXTRACTOR_METATYPE_GNUNET_DISPLAY_TYPE = 173, @@ -434,13 +434,13 @@ EXTRACTOR_metatype_get_max (void); * 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 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, @@ -465,7 +465,7 @@ struct EXTRACTOR_ExtractContext * Configuration string for the plugin. */ const char *config; - + /** * Obtain a pointer to up to @a size bytes of data from the file to process. * @@ -479,17 +479,17 @@ struct EXTRACTOR_ExtractContext void **data, size_t size); - + /** * Seek in the file. Use `SEEK_CUR` for @a whence and @a pos of 0 to * obtain the current position in the file. - * + * * @param cls the @e cls member of this struct * @param pos position to seek (see 'man lseek') * @param whence how to see (absolute to start, relative, absolute to end) * @return new absolute position, -1 on error (i.e. desired position * does not exist) - */ + */ int64_t (*seek) (void *cls, int64_t pos, int whence); @@ -497,10 +497,10 @@ struct EXTRACTOR_ExtractContext /** * Determine the overall size of the file. - * + * * @param cls the @a cls member of this struct * @return overall file size, `UINT64_MAX` on error (i.e. IPC failure) - */ + */ uint64_t (*get_size) (void *cls); /** @@ -533,13 +533,13 @@ struct EXTRACTOR_PluginList; * Load the default set of plugins. The default can be changed * by setting the LIBEXTRACTOR_LIBRARIES environment variable; * If it is set to "env", then this function will return - * #EXTRACTOR_plugin_add_config (NULL, env, flags). + * #EXTRACTOR_plugin_add_config (NULL, env, flags). * * If LIBEXTRACTOR_LIBRARIES is not set, the function will attempt - * to locate the installed plugins and load all of them. + * to locate the installed plugins and load all of them. * The directory where the code will search for plugins is typically * automatically determined; it can be specified explicitly using the - * "LIBEXTRACTOR_PREFIX" environment variable. + * "LIBEXTRACTOR_PREFIX" environment variable. * * This environment variable must be set to the precise directory with * the plugins (i.e. "/usr/lib/libextractor", not "/usr"). Note that @@ -550,7 +550,7 @@ struct EXTRACTOR_PluginList; * @param flags options for all of the plugins loaded * @return the default set of plugins, NULL if no plugins were found */ -struct EXTRACTOR_PluginList * +struct EXTRACTOR_PluginList * EXTRACTOR_plugin_add_defaults (enum EXTRACTOR_Options flags); @@ -590,7 +590,7 @@ EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList *prev, const char *config, enum EXTRACTOR_Options flags); - + /** * Remove a plugin from a list. * @@ -608,7 +608,7 @@ EXTRACTOR_plugin_remove (struct EXTRACTOR_PluginList *prev, * * @param plugin the list of plugins */ -void +void EXTRACTOR_plugin_remove_all (struct EXTRACTOR_PluginList *plugins); @@ -636,19 +636,19 @@ EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins, * Simple #EXTRACTOR_MetaDataProcessor implementation that simply * prints the extracted meta data to the given file. Only prints * those keywords that are in UTF-8 format. - * + * * @param handle the file to write to (`stdout`, `stderr`), must NOT be NULL, * must be of type `FILE *`. * @param plugin_name name of the plugin that produced this value * @param type libextractor-type describing the meta data - * @param format basic format information about data + * @param format basic format information about 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 non-zero if printing failed, otherwise 0. */ -int +int EXTRACTOR_meta_data_print (void *handle, const char *plugin_name, enum EXTRACTOR_MetaType type, diff --git a/src/main/extractor_ipc_gnu.c b/src/main/extractor_ipc_gnu.c @@ -45,22 +45,22 @@ struct EXTRACTOR_SharedMemory { /** * Pointer to the mapped region of the shm (covers the whole shm) - */ + */ void *shm_ptr; /** * Allocated size of the shm - */ + */ size_t shm_size; /** * POSIX id of the shm into which data is uncompressed - */ + */ int shm_id; /** * Name of the shm - */ + */ char shm_name[MAX_SHM_NAME + 1]; /** @@ -84,7 +84,7 @@ struct EXTRACTOR_Channel char *mdata; /** - * Size of the 'mdata' buffer. + * Size of the @e mdata buffer. */ size_t mdata_size; @@ -147,10 +147,10 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size) tpath = "/tmp/"; #else tpath = "/"; /* Linux */ -#endif +#endif snprintf (shm->shm_name, - MAX_SHM_NAME, - "%sLE-%u-%u", + MAX_SHM_NAME, + "%sLE-%u-%u", tpath, getpid (), (unsigned int) RANDOM()); if (-1 == (shm->shm_id = shm_open (shm->shm_name, @@ -161,8 +161,8 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size) return NULL; } if ( (0 != ftruncate (shm->shm_id, size)) || - (NULL == (shm->shm_ptr = mmap (NULL, size, - PROT_WRITE, MAP_SHARED, + (NULL == (shm->shm_ptr = mmap (NULL, size, + PROT_WRITE, MAP_SHARED, shm->shm_id, 0))) || (((void*) -1) == shm->shm_ptr) ) { @@ -174,7 +174,7 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size) } shm->shm_size = size; shm->rc = 0; - return shm; + return shm; } @@ -202,7 +202,7 @@ EXTRACTOR_IPC_shared_memory_change_rc_ (struct EXTRACTOR_SharedMemory *shm, */ void EXTRACTOR_IPC_shared_memory_destroy_ (struct EXTRACTOR_SharedMemory *shm) -{ +{ munmap (shm->shm_ptr, shm->shm_size); (void) close (shm->shm_id); (void) shm_unlink (shm->shm_name); @@ -262,7 +262,7 @@ EXTRACTOR_datasource_get_pos_ (struct EXTRACTOR_Datasource *ds) * @param plugin the plugin * @param shm memory to share with the process * @return NULL on error, otherwise IPC channel - */ + */ struct EXTRACTOR_Channel * EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin, struct EXTRACTOR_SharedMemory *shm) @@ -284,8 +284,8 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin, { LOG_STRERROR ("malloc"); free (channel); - return NULL; - } + return NULL; + } channel->shm = shm; channel->plugin = plugin; channel->size = 0; @@ -337,7 +337,7 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin, LOG_STRERROR ("malloc"); EXTRACTOR_IPC_channel_destroy_ (channel); return NULL; - } + } init->opcode = MESSAGE_INIT_STATE; init->reserved = 0; init->reserved2 = 0; @@ -427,10 +427,10 @@ EXTRACTOR_IPC_channel_send_ (struct EXTRACTOR_Channel *channel, * broken. * * @param channels array of channels, channels that break may be set to NULL - * @param num_channels length of the 'channels' array + * @param num_channels length of the @a channels array * @param proc function to call to process messages (may be called * more than once) - * @param proc_cls closure for 'proc' + * @param proc_cls closure for @a proc * @return -1 on error, 1 on success */ int @@ -464,8 +464,8 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels, return 1; /* nothing left to do! */ } tv.tv_sec = 0; - tv.tv_usec = 100000; /* 100 ms */ - if (0 >= select (max + 1, &to_check, NULL, NULL, &tv)) + tv.tv_usec = 250000; /* 250 ms */ + if (0 > select (max + 1, &to_check, NULL, NULL, &tv)) { /* an error or timeout -> something's wrong or all plugins hung up */ if (EINTR != errno) @@ -486,7 +486,7 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels, { LOG ("Inbound message from channel too large, aborting\n"); EXTRACTOR_IPC_channel_destroy_ (channel); - channels[i] = NULL; + channels[i] = NULL; } channel->mdata_size *= 2; if (channel->mdata_size > MAX_META_DATA) @@ -496,7 +496,7 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels, { LOG_STRERROR ("realloc"); EXTRACTOR_IPC_channel_destroy_ (channel); - channels[i] = NULL; + channels[i] = NULL; } channel->mdata = ndata; } @@ -505,8 +505,8 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels, channel->mdata_size - channel->size)) ) || (0 == iret) || (-1 == (ret = EXTRACTOR_IPC_process_reply_ (channel->plugin, - channel->mdata, - channel->size + iret, + channel->mdata, + channel->size + iret, proc, proc_cls)) ) ) { if (-1 == iret)