zip: Provide fallback if zip_discard() is unavailable
zip_discard() was introduced in libzip 0.11, which some systems do not have yet. Provide a fallback replacement for zip_discard(), and reduce the requirement to libzip 0.10 again. This fixes bug #674.
This commit is contained in:
parent
014512254a
commit
a6dc3dacab
2
README
2
README
|
@ -37,7 +37,7 @@ Requirements for the C library:
|
|||
- libtool (only needed when building from git)
|
||||
- pkg-config >= 0.22
|
||||
- libglib >= 2.32.0
|
||||
- libzip >= 0.11
|
||||
- libzip >= 0.10
|
||||
- libserialport >= 0.1.1 (optional, used by some drivers)
|
||||
- librevisa >= 0.0.20130412 (optional, used by some drivers)
|
||||
- libusb-1.0 >= 1.0.16 (optional, used by some drivers)
|
||||
|
|
|
@ -431,7 +431,7 @@ AM_CONDITIONAL([BINDINGS_JAVA], [test "x$BINDINGS_JAVA" = xyes])
|
|||
##############################
|
||||
|
||||
# Add mandatory dependencies to module list.
|
||||
SR_APPEND([SR_PKGLIBS], ['libzip >= 0.11'])
|
||||
SR_APPEND([SR_PKGLIBS], ['libzip >= 0.10'])
|
||||
AC_SUBST([SR_PKGLIBS])
|
||||
|
||||
# Retrieve the compile and link flags for all modules combined.
|
||||
|
@ -449,11 +449,16 @@ AM_COND_IF([BINDINGS_CXX], [
|
|||
# Check for specific libusb features, now that we know the CFLAGS.
|
||||
AC_LANG([C])
|
||||
sr_save_cflags=$CFLAGS
|
||||
sr_save_libs=$LIBS
|
||||
CFLAGS="$LIBSIGROK_CFLAGS $CFLAGS"
|
||||
LIBS="$LIBSIGROK_LIBS $LIBS"
|
||||
AC_CHECK_TYPES([libusb_os_handle],
|
||||
[sr_have_libusb_os_handle=yes], [sr_have_libusb_os_handle=no],
|
||||
[[#include <libusb.h>]])
|
||||
AC_CHECK_FUNCS([zip_discard])
|
||||
LIBS=$sr_save_libs
|
||||
CFLAGS=$sr_save_cflags
|
||||
|
||||
AM_COND_IF([NEED_USB], [AS_CASE([$sr_have_libusb_os_handle:$host_os], [no:mingw*],
|
||||
[AC_MSG_ERROR([Windows builds require the event-abstraction branch of libusb])])])
|
||||
|
||||
|
@ -499,7 +504,7 @@ Compile configuration:
|
|||
|
||||
Detected libraries (required):
|
||||
- glib-2.0 >= 2.32.0.............. $sr_glib_version
|
||||
- libzip >= 0.11.................. $sr_libzip_version
|
||||
- libzip >= 0.10.................. $sr_libzip_version
|
||||
|
||||
Detected libraries (optional):
|
||||
$sr_pkglibs_summary
|
||||
|
|
|
@ -754,6 +754,12 @@ SR_PRIV void sr_packet_free(struct sr_datafeed_packet *packet);
|
|||
|
||||
/*--- session_file.c --------------------------------------------------------*/
|
||||
|
||||
#if !HAVE_ZIP_DISCARD
|
||||
/* Replace zip_discard() if not available. */
|
||||
#define zip_discard(zip) sr_zip_discard(zip)
|
||||
SR_PRIV void sr_zip_discard(struct zip *archive);
|
||||
#endif
|
||||
|
||||
SR_PRIV GKeyFile *sr_sessionfile_read_metadata(struct zip *archive,
|
||||
const struct zip_stat *entry);
|
||||
|
||||
|
|
|
@ -46,6 +46,16 @@
|
|||
extern SR_PRIV struct sr_dev_driver session_driver;
|
||||
static int session_driver_initialized = 0;
|
||||
|
||||
#if !HAVE_ZIP_DISCARD
|
||||
/* Replacement for zip_discard() if it isn't available.
|
||||
*/
|
||||
SR_PRIV void sr_zip_discard(struct zip *archive)
|
||||
{
|
||||
if (zip_unchange_all(archive) < 0 || zip_close(archive) < 0)
|
||||
sr_err("Failed to discard ZIP archive: %s", zip_strerror(archive));
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Read metadata entries from a session archive.
|
||||
* @param[in] archive An open ZIP archive.
|
||||
* @param[in] entry Stat buffer filled in for the metadata archive member.
|
||||
|
|
Loading…
Reference in New Issue