From 3638ac2300bc7464b30cf26bf3c7be5beea82503 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 6 May 2015 14:43:47 +0200 Subject: [PATCH] don't use deprecated libzip call --- ext/zip/php_zip.c | 28 ++++++++++++++++++++++++++++ ext/zip/zip_stream.c | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 991ab90220..f8b6a88fd7 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -395,18 +395,36 @@ static int php_zip_parse_options(zval *options, zend_long *remove_all_path, char static int php_zip_status(struct zip *za) /* {{{ */ { +#if LIBZIP_VERSION_MAJOR < 1 int zep, syp; zip_error_get(za, &zep, &syp); +#else + int zep; + zip_error_t *err; + + err = zip_get_error(za); + zep = zip_error_code_zip(err); + zip_error_fini(err); +#endif return zep; } /* }}} */ static int php_zip_status_sys(struct zip *za) /* {{{ */ { +#if LIBZIP_VERSION_MAJOR < 1 int zep, syp; zip_error_get(za, &zep, &syp); +#else + int syp; + zip_error_t *err; + + err = zip_get_error(za); + syp = zip_error_code_system(err); + zip_error_fini(err); +#endif return syp; } /* }}} */ @@ -1505,8 +1523,12 @@ static ZIPARCHIVE_METHOD(getStatusString) { struct zip *intern; zval *self = getThis(); +#if LIBZIP_VERSION_MAJOR < 1 int zep, syp, len; char error_string[128]; +#else + zip_error_t *err; +#endif if (!self) { RETURN_FALSE; @@ -1514,10 +1536,16 @@ static ZIPARCHIVE_METHOD(getStatusString) ZIP_FROM_OBJECT(intern, self); +#if LIBZIP_VERSION_MAJOR < 1 zip_error_get(intern, &zep, &syp); len = zip_error_to_str(error_string, 128, zep, syp); RETVAL_STRINGL(error_string, len); +#else + err = zip_get_error(intern); + RETVAL_STRING(zip_error_strerror(err), 1); + zip_error_fini(err); +#endif } /* }}} */ diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index 18707eed27..3ae3e34f13 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -52,10 +52,18 @@ static size_t php_zip_ops_read(php_stream *stream, char *buf, size_t count) if (self->za && self->zf) { n = zip_fread(self->zf, buf, count); if (n < 0) { +#if LIBZIP_VERSION_MAJOR < 1 int ze, se; zip_file_error_get(self->zf, &ze, &se); stream->eof = 1; php_error_docref(NULL, E_WARNING, "Zip stream error: %s", zip_file_strerror(self->zf)); +#else + zip_error_t *err; + err = zip_file_get_error(self->zf); + stream->eof = 1; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Zip stream error: %s", zip_error_strerror(err)); + zip_error_fini(err); +#endif return 0; } /* cast count to signed value to avoid possibly negative n -- 2.40.0