Skip to content

Commit

Permalink
updating libzip to 1.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gangatp committed Dec 18, 2023
1 parent daded40 commit 3bee0c5
Show file tree
Hide file tree
Showing 140 changed files with 2,351 additions and 1,329 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "submodules/cpp-base64"]
path = submodules/cpp-base64
url = https://github.com/ReneNyffenegger/cpp-base64.git
[submodule "submodules/libzip"]
path = submodules/libzip
url = https://github.com/nih-at/libzip.git
40 changes: 34 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,49 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/I
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Include)

if (USE_INCLUDED_LIBZIP)
target_compile_options(${PROJECT_NAME} PRIVATE "-DZIP_STATIC")
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Include/Libraries/libzip)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/libzip/Include)
if(MSVC)
target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS)
target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_NONSTDC_NO_DEPRECATE)
endif()
if(WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE advapi32)
# disable win32 build failing 'initializing': conversion from 'zip_uint64_t' to 'size_t', possible loss of data
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
target_compile_options(${PROJECT_NAME} PRIVATE /wd4244)
endif()
endif()

# create libzip autogenerated platform specific headers
if(NOT EXISTS ${CMAKE_BINARY_DIR}/libzip)
execute_process(
COMMAND ${CMAKE_COMMAND} "-DZLIB_INCLUDE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/submodules/zlib"
"-DZLIB_LIBRARY=zlibstatic" "-DENABLE_COMMONCRYPTO=OFF" "-DENABLE_GNUTLS=OFF" "-DENABLE_MBEDTLS=OFF"
"-DENABLE_OPENSSL=OFF" "-DENABLE_WINDOWS_CRYPTO=OFF"
"-DENABLE_BZIP2=OFF" "-DENABLE_LZMA=OFF" "-DENABLE_ZSTD=OFF"
"-DBUILD_TOOLS=OFF" "-DBUILD_REGRESS=OFF"
"-DBUILD_EXAMPLES=OFF" "-DBUILD_DOC=OFF" "-DBUILD_SHARED_LIBS=OFF" "-DLIBZIP_DO_INSTALL=OFF"
"-S" "${CMAKE_CURRENT_SOURCE_DIR}/submodules/libzip" "-B" "${CMAKE_CURRENT_BINARY_DIR}/libzip"
RESULT_VARIABLE CMD_ERROR
OUTPUT_QUIET)
MESSAGE( STATUS "CMD_ERROR:" ${CMD_ERROR})
endif()
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/libzip)

if (UNIX OR MINGW)
target_compile_options(${PROJECT_NAME} PRIVATE "-DHAVE_FSEEKO")
target_compile_options(${PROJECT_NAME} PRIVATE "-DHAVE_FTELLO")
target_compile_options(${PROJECT_NAME} PRIVATE "-DHAVE_STRCASECMP")
target_compile_options(${PROJECT_NAME} PRIVATE "-DHAVE_UNISTD_H")
target_compile_options(${PROJECT_NAME} PRIVATE "-DHAVE_FSEEKO")
target_compile_options(${PROJECT_NAME} PRIVATE "-DHAVE_FTELLO")
target_compile_options(${PROJECT_NAME} PRIVATE "-DHAVE_STRCASECMP")
target_compile_options(${PROJECT_NAME} PRIVATE "-DHAVE_UNISTD_H")
endif()

else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBZIP REQUIRED libzip)
target_link_libraries(${PROJECT_NAME} ${LIBZIP_LIBRARIES})
endif()


if (USE_INCLUDED_ZLIB)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/zlib/Include)
else()
Expand Down
2 changes: 1 addition & 1 deletion Include/Common/OPC/NMR_OpcPackageReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ NMR_OpcPackageReader.h defines an OPC Package reader in a portable way.
#include "Common/OPC/NMR_OpcPackageRelationship.h"
#include "Common/3MF_ProgressMonitor.h"
#include "Common/NMR_ModelWarnings.h"
#include "Libraries/libzip/zip.h"
#include "zip.h"
#include <list>
#include <vector>
#include <map>
Expand Down
2 changes: 1 addition & 1 deletion Include/Common/Platform/NMR_ImportStream_ZIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This is a stream class for importing from a libZIP object.
#define __NMR_IMPORTSTREAM_ZIP

#include "Common/Platform/NMR_ImportStream.h"
#include "Libraries/libzip/zip.h"
#include "zip.h"

#define IMPORTSTREAM_ZIP_CHUNKSIZE (1024 * 1024)

Expand Down
62 changes: 0 additions & 62 deletions Include/Libraries/libzip/config.h

This file was deleted.

51 changes: 0 additions & 51 deletions Include/Libraries/libzip/zipconf.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

/*
compat.h -- compatibility defines.
Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <[email protected]>
The authors can be contacted at <[email protected]>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -41,6 +41,9 @@
/* to have *_MAX definitions for all types when compiling with g++ */
#define __STDC_LIMIT_MACROS

/* to have ISO C secure library functions */
#define __STDC_WANT_LIB_EXT1__ 1

#ifdef _WIN32
#ifndef ZIP_EXTERN
#ifndef ZIP_STATIC
Expand Down Expand Up @@ -94,9 +97,12 @@ typedef char bool;
#if !defined(HAVE_FILENO) && defined(HAVE__FILENO)
#define fileno _fileno
#endif
#if defined(HAVE__SNPRINTF)
#if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF)
#define snprintf _snprintf
#endif
#if !defined(HAVE__SNWPRINTF_S)
#define _snwprintf_s(buf, bufsz, len, fmt, ...) (_snwprintf((buf), (len), (fmt), __VA_ARGS__))
#endif
#if defined(HAVE__STRDUP)
#if !defined(HAVE_STRDUP) || defined(_WIN32)
#undef strdup
Expand Down Expand Up @@ -125,6 +131,33 @@ typedef char bool;
#define ftello(s) ((long)ftell((s)))
#endif

#ifdef HAVE_LOCALTIME_S
#ifdef _WIN32
/* Windows is incompatible to the C11 standard, hurray! */
#define zip_localtime(t, tm) (localtime_s((tm), (t)) == 0 ? tm : NULL)
#else
#define zip_localtime localtime_s
#endif
#else
#ifdef HAVE_LOCALTIME_R
#define zip_localtime localtime_r
#else
#define zip_localtime(t, tm) (localtime(t))
#endif
#endif

#ifndef HAVE_MEMCPY_S
#define memcpy_s(dest, destsz, src, count) (memcpy((dest), (src), (count)) == NULL)
#endif

#ifndef HAVE_SNPRINTF_S
#ifdef HAVE__SNPRINTF_S
#define snprintf_s(buf, bufsz, fmt, ...) (_snprintf_s((buf), (bufsz), (bufsz), (fmt), __VA_ARGS__))
#else
#define snprintf_s snprintf
#endif
#endif

#if !defined(HAVE_STRCASECMP)
#if defined(HAVE__STRICMP)
#define strcasecmp _stricmp
Expand All @@ -133,6 +166,19 @@ typedef char bool;
#endif
#endif

#ifndef HAVE_STRNCPY_S
#define strncpy_s(dest, destsz, src, count) (strncpy((dest), (src), (count)), 0)
#endif

#ifndef HAVE_STRERROR_S
#define strerrorlen_s(errnum) (strlen(strerror(errnum)))
#define strerror_s(buf, bufsz, errnum) ((void)strncpy_s((buf), (bufsz), strerror(errnum), (bufsz)), (buf)[(bufsz)-1] = '\0', strerrorlen_s(errnum) >= (bufsz))
#else
#ifndef HAVE_STRERRORLEN_S
#define strerrorlen_s(errnum) 8192
#endif
#endif

#if SIZEOF_OFF_T == 8
#define ZIP_OFF_MAX ZIP_INT64_MAX
#define ZIP_OFF_MIN ZIP_INT64_MIN
Expand Down
Loading

0 comments on commit 3bee0c5

Please sign in to comment.