diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2025-01-01 10:37:56 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2025-01-01 10:37:56 +0100 |
commit | 138e5e7c1dfba4717a4e6d5abb1abb0f82d6f49f (patch) | |
tree | fd6bc3d389d162a9f555a415e410e84cd7988492 /src/Common/libzip/compat.h | |
parent | fcc6302e6139b5b4714c91fd91d215c77af7695c (diff) | |
download | VeraCrypt-138e5e7c1dfba4717a4e6d5abb1abb0f82d6f49f.tar.gz VeraCrypt-138e5e7c1dfba4717a4e6d5abb1abb0f82d6f49f.zip |
Diffstat (limited to 'src/Common/libzip/compat.h')
-rw-r--r-- | src/Common/libzip/compat.h | 78 |
1 files changed, 54 insertions, 24 deletions
diff --git a/src/Common/libzip/compat.h b/src/Common/libzip/compat.h index 296ee59e..2cbc19f8 100644 --- a/src/Common/libzip/compat.h +++ b/src/Common/libzip/compat.h @@ -3,7 +3,7 @@ /* compat.h -- compatibility defines. - Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <info@libzip.org> @@ -126,14 +126,65 @@ typedef char bool; #endif #endif -#ifndef HAVE_FSEEKO -#define fseeko(s, o, w) (fseek((s), (long int)(o), (w))) + +#if defined(HAVE__FSEEKI64) && defined(HAVE__FSTAT64) && defined(HAVE__FTELLI64) +/* Windows API using int64 */ +typedef zip_int64_t zip_off_t; +typedef struct _stat64 zip_os_stat_t; +#define zip_os_stat _stat64 +#define zip_os_fstat _fstat64 +#define zip_os_fseek _fseeki64 +#define zip_os_ftell _ftelli64 +#define ZIP_FSEEK_MAX ZIP_INT64_MAX +#define ZIP_FSEEK_MIN ZIP_INT64_MIN +#else + +/* Normal API */ +#include <sys/stat.h> +typedef struct stat zip_os_stat_t; +#define zip_os_fstat fstat +#define zip_os_stat stat + +#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO) +/* Using off_t */ +typedef off_t zip_off_t; +#if SIZEOF_OFF_T == 8 +#define ZIP_OFF_MAX ZIP_INT64_MAX +#define ZIP_OFF_MIN ZIP_INT64_MIN +#elif SIZEOF_OFF_T == 4 +#define ZIP_OFF_MAX ZIP_INT32_MAX +#define ZIP_OFF_MIN ZIP_INT32_MIN +#elif SIZEOF_OFF_T == 2 +#define ZIP_OFF_MAX ZIP_INT16_MAX +#define ZIP_OFF_MIN ZIP_INT16_MIN +#else +#error unsupported size of off_t +#endif + +#define ZIP_FSEEK_MAX ZIP_OFF_MAX +#define ZIP_FSEEK_MIN ZIP_OFF_MIN + +#define zip_os_fseek fseeko +#define zip_os_ftell ftello +#else + +/* Using long */ +typedef long zip_off_t; +#include <limits.h> +#define ZIP_FSEEK_MAX LONG_MAX +#define ZIP_FSEEK_MIN LONG_MIN + +#define zip_os_fseek fseek +#define zip_os_ftell ftell +#endif + #endif #ifndef HAVE_FTELLO #define ftello(s) ((long)ftell((s))) #endif + #ifdef HAVE_LOCALTIME_S #ifdef _WIN32 /* Windows is incompatible to the C11 standard, hurray! */ @@ -182,27 +233,6 @@ typedef char bool; #endif #endif -#if SIZEOF_OFF_T == 8 -#define ZIP_OFF_MAX ZIP_INT64_MAX -#define ZIP_OFF_MIN ZIP_INT64_MIN -#elif SIZEOF_OFF_T == 4 -#define ZIP_OFF_MAX ZIP_INT32_MAX -#define ZIP_OFF_MIN ZIP_INT32_MIN -#elif SIZEOF_OFF_T == 2 -#define ZIP_OFF_MAX ZIP_INT16_MAX -#define ZIP_OFF_MIN ZIP_INT16_MIN -#else -#error unsupported size of off_t -#endif - -#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO) -#define ZIP_FSEEK_MAX ZIP_OFF_MAX -#define ZIP_FSEEK_MIN ZIP_OFF_MIN -#else -#include <limits.h> -#define ZIP_FSEEK_MAX LONG_MAX -#define ZIP_FSEEK_MIN LONG_MIN -#endif #ifndef SIZE_MAX #if SIZEOF_SIZE_T == 8 |