Initial community commit
This commit is contained in:
59
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/config.h
vendored
Normal file
59
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/config.h
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef HAD_CONFIG_H
|
||||
#define HAD_CONFIG_H
|
||||
#ifndef _HAD_ZIPCONF_H
|
||||
#include "zipconf.h"
|
||||
#endif
|
||||
/* BEGIN DEFINES */
|
||||
#define HAVE__CLOSE
|
||||
#define HAVE__DUP
|
||||
#define HAVE__FDOPEN
|
||||
#define HAVE__FILENO
|
||||
#define HAVE__OPEN
|
||||
#define HAVE__SNPRINTF
|
||||
#define HAVE__STRDUP
|
||||
#define HAVE__STRICMP
|
||||
/* #undef HAVE_FSEEKO */
|
||||
/* #undef HAVE_FTELLO */
|
||||
#define HAVE_OPEN
|
||||
/* #undef HAVE_MKSTEMP */
|
||||
/* #undef HAVE_SNPRINTF */
|
||||
/* #undef HAVE_STRCASECMP */
|
||||
#define HAVE_STRDUP
|
||||
/* #undef HAVE_STRUCT_TM_TM_ZONE */
|
||||
#ifdef _WIN32
|
||||
#define HAVE_MOVEFILEEXA
|
||||
#endif
|
||||
/* #undef HAVE_STRINGS_H */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
#define __INT8_LIBZIP 1
|
||||
#define INT8_T_LIBZIP 1
|
||||
#define UINT8_T_LIBZIP 1
|
||||
#define __INT16_LIBZIP 2
|
||||
#define INT16_T_LIBZIP 2
|
||||
#define UINT16_T_LIBZIP 2
|
||||
#define __INT32_LIBZIP 4
|
||||
#define INT32_T_LIBZIP 4
|
||||
#define UINT32_T_LIBZIP 4
|
||||
#define __INT64_LIBZIP 8
|
||||
#define INT64_T_LIBZIP 8
|
||||
#define UINT64_T_LIBZIP 8
|
||||
#define SIZEOF_OFF_T 4
|
||||
#define SIZE_T_LIBZIP 8
|
||||
/* #undef SSIZE_T_LIBZIP */
|
||||
/* END DEFINES */
|
||||
#define PACKAGE "libzip"
|
||||
#define VERSION "0.11.2"
|
||||
|
||||
#ifndef HAVE_SSIZE_T_LIBZIP
|
||||
# if SIZE_T_LIBZIP == INT_LIBZIP
|
||||
typedef int ssize_t;
|
||||
# elif SIZE_T_LIBZIP == LONG_LIBZIP
|
||||
typedef long ssize_t;
|
||||
# elif SIZE_T_LIBZIP == LONG_LONG_LIBZIP
|
||||
typedef long long ssize_t;
|
||||
# else
|
||||
#error no suitable type for ssize_t found
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* HAD_CONFIG_H */
|
||||
514
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/include/zconf.h
vendored
Normal file
514
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/include/zconf.h
vendored
Normal file
@@ -0,0 +1,514 @@
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef ZCONF_H
|
||||
#define ZCONF_H
|
||||
/* #undef Z_PREFIX */
|
||||
/* #undef Z_HAVE_UNISTD_H */
|
||||
|
||||
/*
|
||||
* If you *really* need a unique prefix for all types and library functions,
|
||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||
* this permanently in zconf.h using "./configure --zprefix".
|
||||
*/
|
||||
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||
# define Z_PREFIX_SET
|
||||
|
||||
/* all linked symbols */
|
||||
# define _dist_code z__dist_code
|
||||
# define _length_code z__length_code
|
||||
# define _tr_align z__tr_align
|
||||
# define _tr_flush_bits z__tr_flush_bits
|
||||
# define _tr_flush_block z__tr_flush_block
|
||||
# define _tr_init z__tr_init
|
||||
# define _tr_stored_block z__tr_stored_block
|
||||
# define _tr_tally z__tr_tally
|
||||
# define adler32 z_adler32
|
||||
# define adler32_combine z_adler32_combine
|
||||
# define adler32_combine64 z_adler32_combine64
|
||||
# ifndef Z_SOLO
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# endif
|
||||
# define crc32 z_crc32
|
||||
# define crc32_combine z_crc32_combine
|
||||
# define crc32_combine64 z_crc32_combine64
|
||||
# define deflate z_deflate
|
||||
# define deflateBound z_deflateBound
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflatePending z_deflatePending
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflateResetKeep z_deflateResetKeep
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateSetHeader z_deflateSetHeader
|
||||
# define deflateTune z_deflateTune
|
||||
# define deflate_copyright z_deflate_copyright
|
||||
# define get_crc_table z_get_crc_table
|
||||
# ifndef Z_SOLO
|
||||
# define gz_error z_gz_error
|
||||
# define gz_intmax z_gz_intmax
|
||||
# define gz_strwinerror z_gz_strwinerror
|
||||
# define gzbuffer z_gzbuffer
|
||||
# define gzclearerr z_gzclearerr
|
||||
# define gzclose z_gzclose
|
||||
# define gzclose_r z_gzclose_r
|
||||
# define gzclose_w z_gzclose_w
|
||||
# define gzdirect z_gzdirect
|
||||
# define gzdopen z_gzdopen
|
||||
# define gzeof z_gzeof
|
||||
# define gzerror z_gzerror
|
||||
# define gzflush z_gzflush
|
||||
# define gzgetc z_gzgetc
|
||||
# define gzgetc_ z_gzgetc_
|
||||
# define gzgets z_gzgets
|
||||
# define gzoffset z_gzoffset
|
||||
# define gzoffset64 z_gzoffset64
|
||||
# define gzopen z_gzopen
|
||||
# define gzopen64 z_gzopen64
|
||||
# ifdef _WIN32
|
||||
# define gzopen_w z_gzopen_w
|
||||
# endif
|
||||
# define gzprintf z_gzprintf
|
||||
# define gzvprintf z_gzvprintf
|
||||
# define gzputc z_gzputc
|
||||
# define gzputs z_gzputs
|
||||
# define gzread z_gzread
|
||||
# define gzrewind z_gzrewind
|
||||
# define gzseek z_gzseek
|
||||
# define gzseek64 z_gzseek64
|
||||
# define gzsetparams z_gzsetparams
|
||||
# define gztell z_gztell
|
||||
# define gztell64 z_gztell64
|
||||
# define gzungetc z_gzungetc
|
||||
# define gzwrite z_gzwrite
|
||||
# endif
|
||||
# define inflate z_inflate
|
||||
# define inflateBack z_inflateBack
|
||||
# define inflateBackEnd z_inflateBackEnd
|
||||
# define inflateBackInit_ z_inflateBackInit_
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define inflateGetHeader z_inflateGetHeader
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflateMark z_inflateMark
|
||||
# define inflatePrime z_inflatePrime
|
||||
# define inflateReset z_inflateReset
|
||||
# define inflateReset2 z_inflateReset2
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateGetDictionary z_inflateGetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateUndermine z_inflateUndermine
|
||||
# define inflateResetKeep z_inflateResetKeep
|
||||
# define inflate_copyright z_inflate_copyright
|
||||
# define inflate_fast z_inflate_fast
|
||||
# define inflate_table z_inflate_table
|
||||
# ifndef Z_SOLO
|
||||
# define uncompress z_uncompress
|
||||
# endif
|
||||
# define zError z_zError
|
||||
# ifndef Z_SOLO
|
||||
# define zcalloc z_zcalloc
|
||||
# define zcfree z_zcfree
|
||||
# endif
|
||||
# define zlibCompileFlags z_zlibCompileFlags
|
||||
# define zlibVersion z_zlibVersion
|
||||
|
||||
/* all zlib typedefs in zlib.h and zconf.h */
|
||||
# define Byte z_Byte
|
||||
# define Bytef z_Bytef
|
||||
# define alloc_func z_alloc_func
|
||||
# define charf z_charf
|
||||
# define free_func z_free_func
|
||||
# ifndef Z_SOLO
|
||||
# define gzFile z_gzFile
|
||||
# endif
|
||||
# define gz_header z_gz_header
|
||||
# define gz_headerp z_gz_headerp
|
||||
# define in_func z_in_func
|
||||
# define intf z_intf
|
||||
# define out_func z_out_func
|
||||
# define uInt z_uInt
|
||||
# define uIntf z_uIntf
|
||||
# define uLong z_uLong
|
||||
# define uLongf z_uLongf
|
||||
# define voidp z_voidp
|
||||
# define voidpc z_voidpc
|
||||
# define voidpf z_voidpf
|
||||
|
||||
/* all zlib structs in zlib.h and zconf.h */
|
||||
# define gz_header_s z_gz_header_s
|
||||
# define internal_state z_internal_state
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
#endif
|
||||
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
||||
# define OS2
|
||||
#endif
|
||||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||
# define WINDOWS
|
||||
#endif
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
||||
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
||||
# ifndef SYS16BIT
|
||||
# define SYS16BIT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# define MAXSEG_64K
|
||||
#endif
|
||||
#ifdef MSDOS
|
||||
# define UNALIGNED_OK
|
||||
#endif
|
||||
|
||||
#ifdef __STDC_VERSION__
|
||||
# ifndef STDC
|
||||
# define STDC
|
||||
# endif
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
# ifndef STDC99
|
||||
# define STDC99
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||
# define const /* note: need a more gentle solution here */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||
# define z_const const
|
||||
#else
|
||||
# define z_const
|
||||
#endif
|
||||
|
||||
/* Some Mac compilers merge all .h files incorrectly: */
|
||||
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
|
||||
# define NO_DUMMY_DECL
|
||||
#endif
|
||||
|
||||
/* Maximum value for memLevel in deflateInit2 */
|
||||
#ifndef MAX_MEM_LEVEL
|
||||
# ifdef MAXSEG_64K
|
||||
# define MAX_MEM_LEVEL 8
|
||||
# else
|
||||
# define MAX_MEM_LEVEL 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||
* created by gzip. (Files created by minigzip can still be extracted by
|
||||
* gzip.)
|
||||
*/
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
||||
/* The memory requirements for deflate are (in bytes):
|
||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||
the default memory requirements from 256K to 128K, compile with
|
||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||
Of course this will generally degrade compression (there's no free lunch).
|
||||
|
||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# ifdef STDC
|
||||
# define OF(args) args
|
||||
# else
|
||||
# define OF(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef Z_ARG /* function prototypes for stdarg */
|
||||
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# define Z_ARG(args) args
|
||||
# else
|
||||
# define Z_ARG(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||
* model programming (small or medium model with some far allocations).
|
||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||
* just define FAR to be empty.
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# if defined(M_I86SM) || defined(M_I86MM)
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
/* Turbo C small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef __BORLANDC__
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(WIN32)
|
||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||
* This is not mandatory, but it offers a little performance increase.
|
||||
*/
|
||||
# ifdef ZLIB_DLL
|
||||
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXTERN extern
|
||||
(dllexport)
|
||||
# else
|
||||
# define ZEXTERN extern __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
# endif /* ZLIB_DLL */
|
||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||
* define ZLIB_WINAPI.
|
||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||
*/
|
||||
# ifdef ZLIB_WINAPI
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
# endif
|
||||
# include <windows.h>
|
||||
/* No need for _export, use ZLIB.DEF instead. */
|
||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||
# define ZEXPORT WINAPI
|
||||
# ifdef WIN32
|
||||
# define ZEXPORTVA WINAPIV
|
||||
# else
|
||||
# define ZEXPORTVA FAR CDECL
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__BEOS__)
|
||||
# ifdef ZLIB_DLL
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXPORT __declspec(dllexport)
|
||||
# define ZEXPORTVA __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXPORT __declspec(dllimport)
|
||||
# define ZEXPORTVA __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ZEXTERN
|
||||
# define ZEXTERN extern
|
||||
#endif
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT
|
||||
#endif
|
||||
#ifndef ZEXPORTVA
|
||||
# define ZEXPORTVA
|
||||
#endif
|
||||
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
#if !defined(__MACTYPES__)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
#ifdef SMALL_MEDIUM
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
typedef uInt FAR uIntf;
|
||||
typedef uLong FAR uLongf;
|
||||
|
||||
#ifdef STDC
|
||||
typedef void const *voidpc;
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
#else
|
||||
typedef Byte const *voidpc;
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||
# include <limits.h>
|
||||
# if (UINT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned
|
||||
# elif (ULONG_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned long
|
||||
# elif (USHRT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned short
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Z_U4
|
||||
typedef Z_U4 z_crc_t;
|
||||
#else
|
||||
typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_STDARG_H
|
||||
#endif
|
||||
|
||||
#ifdef STDC
|
||||
# ifndef Z_SOLO
|
||||
# include <sys/types.h> /* for off_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# ifndef Z_SOLO
|
||||
# include <stdarg.h> /* for va_list */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef Z_SOLO
|
||||
# include <stddef.h> /* for wchar_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||
* though the former does not conform to the LFS document), but considering
|
||||
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||
* equivalently requesting no 64-bit operations
|
||||
*/
|
||||
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||
# undef _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
#ifndef Z_SOLO
|
||||
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
# ifndef z_off_t
|
||||
# define z_off_t off_t
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||
# define Z_LFS64
|
||||
#endif
|
||||
|
||||
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||
# define Z_LARGE64
|
||||
#endif
|
||||
|
||||
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||
# define Z_WANT64
|
||||
#endif
|
||||
|
||||
#if !defined(SEEK_SET) && !defined(Z_SOLO)
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
# define SEEK_CUR 1 /* Seek from current position. */
|
||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
# define z_off64_t off64_t
|
||||
#else
|
||||
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
|
||||
# define z_off64_t __int64
|
||||
# else
|
||||
# define z_off64_t z_off_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
#pragma map(deflateInit_,"DEIN")
|
||||
#pragma map(deflateInit2_,"DEIN2")
|
||||
#pragma map(deflateEnd,"DEEND")
|
||||
#pragma map(deflateBound,"DEBND")
|
||||
#pragma map(inflateInit_,"ININ")
|
||||
#pragma map(inflateInit2_,"ININ2")
|
||||
#pragma map(inflateEnd,"INEND")
|
||||
#pragma map(inflateSync,"INSY")
|
||||
#pragma map(inflateSetDictionary,"INSEDI")
|
||||
#pragma map(compressBound,"CMBND")
|
||||
#pragma map(inflate_table,"INTABL")
|
||||
#pragma map(inflate_fast,"INFA")
|
||||
#pragma map(inflate_copyright,"INCOPY")
|
||||
#endif
|
||||
|
||||
#endif /* ZCONF_H */
|
||||
120
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/include/zipconf.h
vendored
Normal file
120
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/include/zipconf.h
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
#ifndef _HAD_ZIPCONF_H
|
||||
#define _HAD_ZIPCONF_H
|
||||
|
||||
/*
|
||||
zipconf.h -- platform specific include file
|
||||
|
||||
This file was generated automatically by CMake
|
||||
based on ../cmake-zipconf.h.in.
|
||||
*/
|
||||
|
||||
/* #undef HAVE_INTTYPES_H_LIBZIP */
|
||||
#define HAVE_STDINT_H_LIBZIP
|
||||
#define HAVE_SYS_TYPES_H_LIBZIP
|
||||
#define HAVE___INT8_LIBZIP
|
||||
#define HAVE_INT8_T_LIBZIP
|
||||
#define HAVE_UINT8_T_LIBZIP
|
||||
#define HAVE___INT16_LIBZIP
|
||||
#define HAVE_INT16_T_LIBZIP
|
||||
#define HAVE_UINT16_T_LIBZIP
|
||||
#define HAVE___INT32_LIBZIP
|
||||
#define HAVE_INT32_T_LIBZIP
|
||||
#define HAVE_UINT32_T_LIBZIP
|
||||
#define HAVE___INT64_LIBZIP
|
||||
#define HAVE_INT64_T_LIBZIP
|
||||
#define HAVE_UINT64_T_LIBZIP
|
||||
#define SHORT_LIBZIP 2
|
||||
#define INT_LIBZIP 4
|
||||
#define LONG_LIBZIP 4
|
||||
#define LONG_LONG_LIBZIP 8
|
||||
|
||||
#if defined(HAVE_STDINT_H_LIBZIP)
|
||||
#include <stdint.h>
|
||||
#elif defined(HAVE_INTTYPES_H_LIBZIP)
|
||||
#include <inttypes.h>
|
||||
#elif defined(HAVE_SYS_TYPES_H_LIBZIP)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INT8_T_LIBZIP)
|
||||
typedef int8_t zip_int8_t;
|
||||
#elif defined(HAVE___INT8_LIBZIP)
|
||||
typedef __int8 zip_int8_t;
|
||||
#else
|
||||
typedef signed char zip_int8_t;
|
||||
#endif
|
||||
#if defined(HAVE_UINT8_T_LIBZIP)
|
||||
typedef uint8_t zip_uint8_t;
|
||||
#elif defined(HAVE___INT8_LIBZIP)
|
||||
typedef unsigned __int8 zip_uint8_t;
|
||||
#else
|
||||
typedef unsigned char zip_uint8_t;
|
||||
#endif
|
||||
#if defined(HAVE_INT16_T_LIBZIP)
|
||||
typedef int16_t zip_int16_t;
|
||||
#elif defined(HAVE___INT16_LIBZIP)
|
||||
typedef __int16 zip_int16_t;
|
||||
#elif defined(SHORT_LIBZIP) && SHORT_LIBZIP == 2
|
||||
typedef signed short zip_int16_t;
|
||||
#endif
|
||||
#if defined(HAVE_UINT16_T_LIBZIP)
|
||||
typedef uint16_t zip_uint16_t;
|
||||
#elif defined(HAVE___INT16_LIBZIP)
|
||||
typedef unsigned __int16 zip_uint16_t;
|
||||
#elif defined(SHORT_LIBZIP) && SHORT_LIBZIP == 2
|
||||
typedef unsigned short zip_uint16_t;
|
||||
#endif
|
||||
#if defined(HAVE_INT32_T_LIBZIP)
|
||||
typedef int32_t zip_int32_t;
|
||||
#elif defined(HAVE___INT32_LIBZIP)
|
||||
typedef __int32 zip_int32_t;
|
||||
#elif defined(INT_LIBZIP) && INT_LIBZIP == 4
|
||||
typedef signed int zip_int32_t;
|
||||
#elif defined(LONG_LIBZIP) && LONG_LIBZIP == 4
|
||||
typedef signed long zip_int32_t;
|
||||
#endif
|
||||
#if defined(HAVE_UINT32_T_LIBZIP)
|
||||
typedef uint32_t zip_uint32_t;
|
||||
#elif defined(HAVE___INT32_LIBZIP)
|
||||
typedef unsigned __int32 zip_uint32_t;
|
||||
#elif defined(INT_LIBZIP) && INT_LIBZIP == 4
|
||||
typedef unsigned int zip_uint32_t;
|
||||
#elif defined(LONG_LIBZIP) && LONG_LIBZIP == 4
|
||||
typedef unsigned long zip_uint32_t;
|
||||
#endif
|
||||
#if defined(HAVE_INT64_T_LIBZIP)
|
||||
typedef int64_t zip_int64_t;
|
||||
#elif defined(HAVE___INT64_LIBZIP)
|
||||
typedef __int64 zip_int64_t;
|
||||
#elif defined(LONG_LIBZIP) && LONG_LIBZIP == 8
|
||||
typedef signed long zip_int64_t;
|
||||
#elif defined(LONG_LONG_LIBZIP) && LONG_LONG_LIBZIP == 8
|
||||
typedef signed long long zip_int64_t;
|
||||
#endif
|
||||
#if defined(HAVE_UINT64_T_LIBZIP)
|
||||
typedef uint64_t zip_uint64_t;
|
||||
#elif defined(HAVE___INT64_LIBZIP)
|
||||
typedef unsigned __int64 zip_uint64_t;
|
||||
#elif defined(LONG_LIBZIP) && LONG_LONG_LIBZIP == 8
|
||||
typedef unsigned long zip_uint64_t;
|
||||
#elif defined(LONG_LONG_LIBZIP) && LONG_LONG_LIBZIP == 8
|
||||
typedef unsigned long long zip_uint64_t;
|
||||
#endif
|
||||
|
||||
#define ZIP_INT8_MIN -0x80
|
||||
#define ZIP_INT8_MAX 0x7f
|
||||
#define ZIP_UINT8_MAX 0xff
|
||||
|
||||
#define ZIP_INT16_MIN -0x8000
|
||||
#define ZIP_INT16_MAX 0x7fff
|
||||
#define ZIP_UINT16_MAX 0xffff
|
||||
|
||||
#define ZIP_INT32_MIN -0x80000000L
|
||||
#define ZIP_INT32_MAX 0x7fffffffL
|
||||
#define ZIP_UINT32_MAX 0xffffffffLU
|
||||
|
||||
#define ZIP_INT64_MIN -0x8000000000000000LL
|
||||
#define ZIP_INT64_MAX 0x7fffffffffffffffLL
|
||||
#define ZIP_UINT64_MAX 0xffffffffffffffffULL
|
||||
|
||||
#endif /* zipconf.h */
|
||||
1768
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/include/zlib.h
vendored
Normal file
1768
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/include/zlib.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
151
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/mkstemp.c
vendored
Normal file
151
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/mkstemp.c
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
/* Adapted from NetBSB libc by Dieter Baron */
|
||||
|
||||
/* NetBSD: gettemp.c,v 1.13 2003/12/05 00:57:36 uebayasi Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int
|
||||
_zip_mkstemp(char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int ret;
|
||||
ret = _creat(_mktemp(path), _S_IREAD|_S_IWRITE);
|
||||
if (ret == -1) {
|
||||
return 0;
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int fd;
|
||||
char *start, *trv;
|
||||
struct stat sbuf;
|
||||
pid_t pid;
|
||||
|
||||
/* To guarantee multiple calls generate unique names even if
|
||||
the file is not created. 676 different possibilities with 7
|
||||
or more X's, 26 with 6 or less. */
|
||||
static char xtra[2] = "aa";
|
||||
int xcnt = 0;
|
||||
|
||||
pid = getpid();
|
||||
|
||||
/* Move to end of path and count trailing X's. */
|
||||
for (trv = path; *trv; ++trv)
|
||||
if (*trv == 'X')
|
||||
xcnt++;
|
||||
else
|
||||
xcnt = 0;
|
||||
|
||||
/* Use at least one from xtra. Use 2 if more than 6 X's. */
|
||||
if (*(trv - 1) == 'X')
|
||||
*--trv = xtra[0];
|
||||
if (xcnt > 6 && *(trv - 1) == 'X')
|
||||
*--trv = xtra[1];
|
||||
|
||||
/* Set remaining X's to pid digits with 0's to the left. */
|
||||
while (*--trv == 'X') {
|
||||
*trv = (pid % 10) + '0';
|
||||
pid /= 10;
|
||||
}
|
||||
|
||||
/* update xtra for next call. */
|
||||
if (xtra[0] != 'z')
|
||||
xtra[0]++;
|
||||
else {
|
||||
xtra[0] = 'a';
|
||||
if (xtra[1] != 'z')
|
||||
xtra[1]++;
|
||||
else
|
||||
xtra[1] = 'a';
|
||||
}
|
||||
|
||||
/*
|
||||
* check the target directory; if you have six X's and it
|
||||
* doesn't exist this runs for a *very* long time.
|
||||
*/
|
||||
for (start = trv + 1;; --trv) {
|
||||
if (trv <= path)
|
||||
break;
|
||||
if (*trv == '/') {
|
||||
*trv = '\0';
|
||||
if (stat(path, &sbuf))
|
||||
return (0);
|
||||
if (!S_ISDIR(sbuf.st_mode)) {
|
||||
errno = ENOTDIR;
|
||||
return (0);
|
||||
}
|
||||
*trv = '/';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if ((fd=open(path, O_CREAT|O_EXCL|O_RDWR|O_BINARY, 0600)) >= 0)
|
||||
return (fd);
|
||||
if (errno != EEXIST)
|
||||
return (0);
|
||||
|
||||
/* tricky little algorithm for backward compatibility */
|
||||
for (trv = start;;) {
|
||||
if (!*trv)
|
||||
return (0);
|
||||
if (*trv == 'z')
|
||||
*trv++ = 'a';
|
||||
else {
|
||||
if (isdigit((unsigned char)*trv))
|
||||
*trv = 'a';
|
||||
else
|
||||
++*trv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
#endif
|
||||
}
|
||||
23
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/premake5.lua
vendored
Normal file
23
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/premake5.lua
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
project "zip-lib"
|
||||
language "C"
|
||||
kind "StaticLib"
|
||||
includedirs "include"
|
||||
defines { "N_FSEEKO" }
|
||||
warnings "off"
|
||||
|
||||
files
|
||||
{
|
||||
"**.h",
|
||||
"**.c"
|
||||
}
|
||||
|
||||
filter "system:linux or bsd or solaris or haiku"
|
||||
defines { "HAVE_SSIZE_T_LIBZIP", "HAVE_CONFIG_H" }
|
||||
|
||||
filter "system:windows"
|
||||
defines { "_WINDOWS" }
|
||||
filter { "system:windows", "toolset:mingw" }
|
||||
defines { "HAVE_SSIZE_T_LIBZIP" }
|
||||
|
||||
filter "system:macosx"
|
||||
defines { "HAVE_SSIZE_T_LIBZIP" }
|
||||
513
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zconf.h
vendored
Normal file
513
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zconf.h
vendored
Normal file
@@ -0,0 +1,513 @@
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef ZCONF_H
|
||||
#define ZCONF_H
|
||||
/* #undef Z_PREFIX */
|
||||
/* #undef Z_HAVE_UNISTD_H */
|
||||
|
||||
/*
|
||||
* If you *really* need a unique prefix for all types and library functions,
|
||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||
* this permanently in zconf.h using "./configure --zprefix".
|
||||
*/
|
||||
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||
# define Z_PREFIX_SET
|
||||
|
||||
/* all linked symbols */
|
||||
# define _dist_code z__dist_code
|
||||
# define _length_code z__length_code
|
||||
# define _tr_align z__tr_align
|
||||
# define _tr_flush_bits z__tr_flush_bits
|
||||
# define _tr_flush_block z__tr_flush_block
|
||||
# define _tr_init z__tr_init
|
||||
# define _tr_stored_block z__tr_stored_block
|
||||
# define _tr_tally z__tr_tally
|
||||
# define adler32 z_adler32
|
||||
# define adler32_combine z_adler32_combine
|
||||
# define adler32_combine64 z_adler32_combine64
|
||||
# ifndef Z_SOLO
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# endif
|
||||
# define crc32 z_crc32
|
||||
# define crc32_combine z_crc32_combine
|
||||
# define crc32_combine64 z_crc32_combine64
|
||||
# define deflate z_deflate
|
||||
# define deflateBound z_deflateBound
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflatePending z_deflatePending
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflateResetKeep z_deflateResetKeep
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateSetHeader z_deflateSetHeader
|
||||
# define deflateTune z_deflateTune
|
||||
# define deflate_copyright z_deflate_copyright
|
||||
# define get_crc_table z_get_crc_table
|
||||
# ifndef Z_SOLO
|
||||
# define gz_error z_gz_error
|
||||
# define gz_intmax z_gz_intmax
|
||||
# define gz_strwinerror z_gz_strwinerror
|
||||
# define gzbuffer z_gzbuffer
|
||||
# define gzclearerr z_gzclearerr
|
||||
# define gzclose z_gzclose
|
||||
# define gzclose_r z_gzclose_r
|
||||
# define gzclose_w z_gzclose_w
|
||||
# define gzdirect z_gzdirect
|
||||
# define gzdopen z_gzdopen
|
||||
# define gzeof z_gzeof
|
||||
# define gzerror z_gzerror
|
||||
# define gzflush z_gzflush
|
||||
# define gzgetc z_gzgetc
|
||||
# define gzgetc_ z_gzgetc_
|
||||
# define gzgets z_gzgets
|
||||
# define gzoffset z_gzoffset
|
||||
# define gzoffset64 z_gzoffset64
|
||||
# define gzopen z_gzopen
|
||||
# define gzopen64 z_gzopen64
|
||||
# ifdef _WIN32
|
||||
# define gzopen_w z_gzopen_w
|
||||
# endif
|
||||
# define gzprintf z_gzprintf
|
||||
# define gzvprintf z_gzvprintf
|
||||
# define gzputc z_gzputc
|
||||
# define gzputs z_gzputs
|
||||
# define gzread z_gzread
|
||||
# define gzrewind z_gzrewind
|
||||
# define gzseek z_gzseek
|
||||
# define gzseek64 z_gzseek64
|
||||
# define gzsetparams z_gzsetparams
|
||||
# define gztell z_gztell
|
||||
# define gztell64 z_gztell64
|
||||
# define gzungetc z_gzungetc
|
||||
# define gzwrite z_gzwrite
|
||||
# endif
|
||||
# define inflate z_inflate
|
||||
# define inflateBack z_inflateBack
|
||||
# define inflateBackEnd z_inflateBackEnd
|
||||
# define inflateBackInit_ z_inflateBackInit_
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define inflateGetHeader z_inflateGetHeader
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflateMark z_inflateMark
|
||||
# define inflatePrime z_inflatePrime
|
||||
# define inflateReset z_inflateReset
|
||||
# define inflateReset2 z_inflateReset2
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateGetDictionary z_inflateGetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateUndermine z_inflateUndermine
|
||||
# define inflateResetKeep z_inflateResetKeep
|
||||
# define inflate_copyright z_inflate_copyright
|
||||
# define inflate_fast z_inflate_fast
|
||||
# define inflate_table z_inflate_table
|
||||
# ifndef Z_SOLO
|
||||
# define uncompress z_uncompress
|
||||
# endif
|
||||
# define zError z_zError
|
||||
# ifndef Z_SOLO
|
||||
# define zcalloc z_zcalloc
|
||||
# define zcfree z_zcfree
|
||||
# endif
|
||||
# define zlibCompileFlags z_zlibCompileFlags
|
||||
# define zlibVersion z_zlibVersion
|
||||
|
||||
/* all zlib typedefs in zlib.h and zconf.h */
|
||||
# define Byte z_Byte
|
||||
# define Bytef z_Bytef
|
||||
# define alloc_func z_alloc_func
|
||||
# define charf z_charf
|
||||
# define free_func z_free_func
|
||||
# ifndef Z_SOLO
|
||||
# define gzFile z_gzFile
|
||||
# endif
|
||||
# define gz_header z_gz_header
|
||||
# define gz_headerp z_gz_headerp
|
||||
# define in_func z_in_func
|
||||
# define intf z_intf
|
||||
# define out_func z_out_func
|
||||
# define uInt z_uInt
|
||||
# define uIntf z_uIntf
|
||||
# define uLong z_uLong
|
||||
# define uLongf z_uLongf
|
||||
# define voidp z_voidp
|
||||
# define voidpc z_voidpc
|
||||
# define voidpf z_voidpf
|
||||
|
||||
/* all zlib structs in zlib.h and zconf.h */
|
||||
# define gz_header_s z_gz_header_s
|
||||
# define internal_state z_internal_state
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
#endif
|
||||
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
||||
# define OS2
|
||||
#endif
|
||||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||
# define WINDOWS
|
||||
#endif
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
||||
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
||||
# ifndef SYS16BIT
|
||||
# define SYS16BIT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# define MAXSEG_64K
|
||||
#endif
|
||||
#ifdef MSDOS
|
||||
# define UNALIGNED_OK
|
||||
#endif
|
||||
|
||||
#ifdef __STDC_VERSION__
|
||||
# ifndef STDC
|
||||
# define STDC
|
||||
# endif
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
# ifndef STDC99
|
||||
# define STDC99
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||
# define const /* note: need a more gentle solution here */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||
# define z_const const
|
||||
#else
|
||||
# define z_const
|
||||
#endif
|
||||
|
||||
/* Some Mac compilers merge all .h files incorrectly: */
|
||||
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
|
||||
# define NO_DUMMY_DECL
|
||||
#endif
|
||||
|
||||
/* Maximum value for memLevel in deflateInit2 */
|
||||
#ifndef MAX_MEM_LEVEL
|
||||
# ifdef MAXSEG_64K
|
||||
# define MAX_MEM_LEVEL 8
|
||||
# else
|
||||
# define MAX_MEM_LEVEL 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||
* created by gzip. (Files created by minigzip can still be extracted by
|
||||
* gzip.)
|
||||
*/
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
||||
/* The memory requirements for deflate are (in bytes):
|
||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||
the default memory requirements from 256K to 128K, compile with
|
||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||
Of course this will generally degrade compression (there's no free lunch).
|
||||
|
||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# ifdef STDC
|
||||
# define OF(args) args
|
||||
# else
|
||||
# define OF(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef Z_ARG /* function prototypes for stdarg */
|
||||
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# define Z_ARG(args) args
|
||||
# else
|
||||
# define Z_ARG(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||
* model programming (small or medium model with some far allocations).
|
||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||
* just define FAR to be empty.
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# if defined(M_I86SM) || defined(M_I86MM)
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
/* Turbo C small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef __BORLANDC__
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(WIN32)
|
||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||
* This is not mandatory, but it offers a little performance increase.
|
||||
*/
|
||||
# ifdef ZLIB_DLL
|
||||
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXTERN extern __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXTERN extern __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
# endif /* ZLIB_DLL */
|
||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||
* define ZLIB_WINAPI.
|
||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||
*/
|
||||
# ifdef ZLIB_WINAPI
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
# endif
|
||||
# include <windows.h>
|
||||
/* No need for _export, use ZLIB.DEF instead. */
|
||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||
# define ZEXPORT WINAPI
|
||||
# ifdef WIN32
|
||||
# define ZEXPORTVA WINAPIV
|
||||
# else
|
||||
# define ZEXPORTVA FAR CDECL
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__BEOS__)
|
||||
# ifdef ZLIB_DLL
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXPORT __declspec(dllexport)
|
||||
# define ZEXPORTVA __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXPORT __declspec(dllimport)
|
||||
# define ZEXPORTVA __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ZEXTERN
|
||||
# define ZEXTERN extern
|
||||
#endif
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT
|
||||
#endif
|
||||
#ifndef ZEXPORTVA
|
||||
# define ZEXPORTVA
|
||||
#endif
|
||||
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
#if !defined(__MACTYPES__)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
#ifdef SMALL_MEDIUM
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
typedef uInt FAR uIntf;
|
||||
typedef uLong FAR uLongf;
|
||||
|
||||
#ifdef STDC
|
||||
typedef void const *voidpc;
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
#else
|
||||
typedef Byte const *voidpc;
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||
# include <limits.h>
|
||||
# if (UINT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned
|
||||
# elif (ULONG_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned long
|
||||
# elif (USHRT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned short
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Z_U4
|
||||
typedef Z_U4 z_crc_t;
|
||||
#else
|
||||
typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_STDARG_H
|
||||
#endif
|
||||
|
||||
#ifdef STDC
|
||||
# ifndef Z_SOLO
|
||||
# include <sys/types.h> /* for off_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# ifndef Z_SOLO
|
||||
# include <stdarg.h> /* for va_list */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef Z_SOLO
|
||||
# include <stddef.h> /* for wchar_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||
* though the former does not conform to the LFS document), but considering
|
||||
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||
* equivalently requesting no 64-bit operations
|
||||
*/
|
||||
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||
# undef _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
#ifndef Z_SOLO
|
||||
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
# ifndef z_off_t
|
||||
# define z_off_t off_t
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||
# define Z_LFS64
|
||||
#endif
|
||||
|
||||
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||
# define Z_LARGE64
|
||||
#endif
|
||||
|
||||
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||
# define Z_WANT64
|
||||
#endif
|
||||
|
||||
#if !defined(SEEK_SET) && !defined(Z_SOLO)
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
# define SEEK_CUR 1 /* Seek from current position. */
|
||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
# define z_off64_t off64_t
|
||||
#else
|
||||
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
|
||||
# define z_off64_t __int64
|
||||
# else
|
||||
# define z_off64_t z_off_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
#pragma map(deflateInit_,"DEIN")
|
||||
#pragma map(deflateInit2_,"DEIN2")
|
||||
#pragma map(deflateEnd,"DEEND")
|
||||
#pragma map(deflateBound,"DEBND")
|
||||
#pragma map(inflateInit_,"ININ")
|
||||
#pragma map(inflateInit2_,"ININ2")
|
||||
#pragma map(inflateEnd,"INEND")
|
||||
#pragma map(inflateSync,"INSY")
|
||||
#pragma map(inflateSetDictionary,"INSEDI")
|
||||
#pragma map(compressBound,"CMBND")
|
||||
#pragma map(inflate_table,"INTABL")
|
||||
#pragma map(inflate_fast,"INFA")
|
||||
#pragma map(inflate_copyright,"INCOPY")
|
||||
#endif
|
||||
|
||||
#endif /* ZCONF_H */
|
||||
322
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip.h
vendored
Normal file
322
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip.h
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
#ifndef _HAD_ZIP_H
|
||||
#define _HAD_ZIP_H
|
||||
|
||||
/*
|
||||
zip.h -- exported declarations.
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef ZIP_EXTERN
|
||||
#ifdef _WIN32
|
||||
#define ZIP_EXTERN
|
||||
//__declspec(dllimport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define ZIP_EXTERN __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define ZIP_EXTERN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "zipconf.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
/* flags for zip_open */
|
||||
|
||||
#define ZIP_CREATE 1
|
||||
#define ZIP_EXCL 2
|
||||
#define ZIP_CHECKCONS 4
|
||||
#define ZIP_TRUNCATE 8
|
||||
|
||||
|
||||
/* flags for zip_name_locate, zip_fopen, zip_stat, ... */
|
||||
|
||||
#define ZIP_FL_NOCASE 1u /* ignore case on name lookup */
|
||||
#define ZIP_FL_NODIR 2u /* ignore directory component */
|
||||
#define ZIP_FL_COMPRESSED 4u /* read compressed data */
|
||||
#define ZIP_FL_UNCHANGED 8u /* use original data, ignoring changes */
|
||||
#define ZIP_FL_RECOMPRESS 16u /* force recompression of data */
|
||||
#define ZIP_FL_ENCRYPTED 32u /* read encrypted data (implies ZIP_FL_COMPRESSED) */
|
||||
#define ZIP_FL_ENC_GUESS 0u /* guess string encoding (is default) */
|
||||
#define ZIP_FL_ENC_RAW 64u /* get unmodified string */
|
||||
#define ZIP_FL_ENC_STRICT 128u /* follow specification strictly */
|
||||
#define ZIP_FL_LOCAL 256u /* in local header */
|
||||
#define ZIP_FL_CENTRAL 512u /* in central directory */
|
||||
/* 1024u reserved for internal use */
|
||||
#define ZIP_FL_ENC_UTF_8 2048u /* string is UTF-8 encoded */
|
||||
#define ZIP_FL_ENC_CP437 4096u /* string is CP437 encoded */
|
||||
#define ZIP_FL_OVERWRITE 8192u /* zip_file_add: if file with name exists, overwrite (replace) it */
|
||||
|
||||
/* archive global flags flags */
|
||||
|
||||
#define ZIP_AFL_TORRENT 1u /* torrent zipped */
|
||||
#define ZIP_AFL_RDONLY 2u /* read only -- cannot be cleared */
|
||||
|
||||
|
||||
/* create a new extra field */
|
||||
|
||||
#define ZIP_EXTRA_FIELD_ALL ZIP_UINT16_MAX
|
||||
#define ZIP_EXTRA_FIELD_NEW ZIP_UINT16_MAX
|
||||
|
||||
/* flags for compression and encryption sources */
|
||||
|
||||
#define ZIP_CODEC_DECODE 0 /* decompress/decrypt (encode flag not set) */
|
||||
#define ZIP_CODEC_ENCODE 1 /* compress/encrypt */
|
||||
|
||||
|
||||
/* libzip error codes */
|
||||
|
||||
#define ZIP_ER_OK 0 /* N No error */
|
||||
#define ZIP_ER_MULTIDISK 1 /* N Multi-disk zip archives not supported */
|
||||
#define ZIP_ER_RENAME 2 /* S Renaming temporary file failed */
|
||||
#define ZIP_ER_CLOSE 3 /* S Closing zip archive failed */
|
||||
#define ZIP_ER_SEEK 4 /* S Seek error */
|
||||
#define ZIP_ER_READ 5 /* S Read error */
|
||||
#define ZIP_ER_WRITE 6 /* S Write error */
|
||||
#define ZIP_ER_CRC 7 /* N CRC error */
|
||||
#define ZIP_ER_ZIPCLOSED 8 /* N Containing zip archive was closed */
|
||||
#define ZIP_ER_NOENT 9 /* N No such file */
|
||||
#define ZIP_ER_EXISTS 10 /* N File already exists */
|
||||
#define ZIP_ER_OPEN 11 /* S Can't open file */
|
||||
#define ZIP_ER_TMPOPEN 12 /* S Failure to create temporary file */
|
||||
#define ZIP_ER_ZLIB 13 /* Z Zlib error */
|
||||
#define ZIP_ER_MEMORY 14 /* N Malloc failure */
|
||||
#define ZIP_ER_CHANGED 15 /* N Entry has been changed */
|
||||
#define ZIP_ER_COMPNOTSUPP 16 /* N Compression method not supported */
|
||||
#define ZIP_ER_EOF 17 /* N Premature EOF */
|
||||
#define ZIP_ER_INVAL 18 /* N Invalid argument */
|
||||
#define ZIP_ER_NOZIP 19 /* N Not a zip archive */
|
||||
#define ZIP_ER_INTERNAL 20 /* N Internal error */
|
||||
#define ZIP_ER_INCONS 21 /* N Zip archive inconsistent */
|
||||
#define ZIP_ER_REMOVE 22 /* S Can't remove file */
|
||||
#define ZIP_ER_DELETED 23 /* N Entry has been deleted */
|
||||
#define ZIP_ER_ENCRNOTSUPP 24 /* N Encryption method not supported */
|
||||
#define ZIP_ER_RDONLY 25 /* N Read-only archive */
|
||||
#define ZIP_ER_NOPASSWD 26 /* N No password provided */
|
||||
#define ZIP_ER_WRONGPASSWD 27 /* N Wrong password provided */
|
||||
|
||||
/* type of system error value */
|
||||
|
||||
#define ZIP_ET_NONE 0 /* sys_err unused */
|
||||
#define ZIP_ET_SYS 1 /* sys_err is errno */
|
||||
#define ZIP_ET_ZLIB 2 /* sys_err is zlib error code */
|
||||
|
||||
/* compression methods */
|
||||
|
||||
#define ZIP_CM_DEFAULT -1 /* better of deflate or store */
|
||||
#define ZIP_CM_STORE 0 /* stored (uncompressed) */
|
||||
#define ZIP_CM_SHRINK 1 /* shrunk */
|
||||
#define ZIP_CM_REDUCE_1 2 /* reduced with factor 1 */
|
||||
#define ZIP_CM_REDUCE_2 3 /* reduced with factor 2 */
|
||||
#define ZIP_CM_REDUCE_3 4 /* reduced with factor 3 */
|
||||
#define ZIP_CM_REDUCE_4 5 /* reduced with factor 4 */
|
||||
#define ZIP_CM_IMPLODE 6 /* imploded */
|
||||
/* 7 - Reserved for Tokenizing compression algorithm */
|
||||
#define ZIP_CM_DEFLATE 8 /* deflated */
|
||||
#define ZIP_CM_DEFLATE64 9 /* deflate64 */
|
||||
#define ZIP_CM_PKWARE_IMPLODE 10 /* PKWARE imploding */
|
||||
/* 11 - Reserved by PKWARE */
|
||||
#define ZIP_CM_BZIP2 12 /* compressed using BZIP2 algorithm */
|
||||
/* 13 - Reserved by PKWARE */
|
||||
#define ZIP_CM_LZMA 14 /* LZMA (EFS) */
|
||||
/* 15-17 - Reserved by PKWARE */
|
||||
#define ZIP_CM_TERSE 18 /* compressed using IBM TERSE (new) */
|
||||
#define ZIP_CM_LZ77 19 /* IBM LZ77 z Architecture (PFS) */
|
||||
#define ZIP_CM_WAVPACK 97 /* WavPack compressed data */
|
||||
#define ZIP_CM_PPMD 98 /* PPMd version I, Rev 1 */
|
||||
|
||||
/* encryption methods */
|
||||
|
||||
#define ZIP_EM_NONE 0 /* not encrypted */
|
||||
#define ZIP_EM_TRAD_PKWARE 1 /* traditional PKWARE encryption */
|
||||
#if 0 /* Strong Encryption Header not parsed yet */
|
||||
#define ZIP_EM_DES 0x6601 /* strong encryption: DES */
|
||||
#define ZIP_EM_RC2_OLD 0x6602 /* strong encryption: RC2, version < 5.2 */
|
||||
#define ZIP_EM_3DES_168 0x6603
|
||||
#define ZIP_EM_3DES_112 0x6609
|
||||
#define ZIP_EM_AES_128 0x660e
|
||||
#define ZIP_EM_AES_192 0x660f
|
||||
#define ZIP_EM_AES_256 0x6610
|
||||
#define ZIP_EM_RC2 0x6702 /* strong encryption: RC2, version >= 5.2 */
|
||||
#define ZIP_EM_RC4 0x6801
|
||||
#endif
|
||||
#define ZIP_EM_UNKNOWN 0xffff /* unknown algorithm */
|
||||
|
||||
#define ZIP_OPSYS_DOS 0x00u
|
||||
#define ZIP_OPSYS_AMIGA 0x01u
|
||||
#define ZIP_OPSYS_OPENVMS 0x02u
|
||||
#define ZIP_OPSYS_UNIX 0x03u
|
||||
#define ZIP_OPSYS_VM_CMS 0x04u
|
||||
#define ZIP_OPSYS_ATARI_ST 0x05u
|
||||
#define ZIP_OPSYS_OS_2 0x06u
|
||||
#define ZIP_OPSYS_MACINTOSH 0x07u
|
||||
#define ZIP_OPSYS_Z_SYSTEM 0x08u
|
||||
#define ZIP_OPSYS_CPM 0x09u
|
||||
#define ZIP_OPSYS_WINDOWS_NTFS 0x0au
|
||||
#define ZIP_OPSYS_MVS 0x0bu
|
||||
#define ZIP_OPSYS_VSE 0x0cu
|
||||
#define ZIP_OPSYS_ACORN_RISC 0x0du
|
||||
#define ZIP_OPSYS_VFAT 0x0eu
|
||||
#define ZIP_OPSYS_ALTERNATE_MVS 0x0fu
|
||||
#define ZIP_OPSYS_BEOS 0x10u
|
||||
#define ZIP_OPSYS_TANDEM 0x11u
|
||||
#define ZIP_OPSYS_OS_400 0x12u
|
||||
#define ZIP_OPSYS_OS_X 0x13u
|
||||
|
||||
#define ZIP_OPSYS_DEFAULT ZIP_OPSYS_UNIX
|
||||
|
||||
|
||||
|
||||
enum zip_source_cmd {
|
||||
ZIP_SOURCE_OPEN, /* prepare for reading */
|
||||
ZIP_SOURCE_READ, /* read data */
|
||||
ZIP_SOURCE_CLOSE, /* reading is done */
|
||||
ZIP_SOURCE_STAT, /* get meta information */
|
||||
ZIP_SOURCE_ERROR, /* get error information */
|
||||
ZIP_SOURCE_FREE /* cleanup and free resources */
|
||||
};
|
||||
|
||||
#define ZIP_SOURCE_ERR_LOWER -2
|
||||
|
||||
#define ZIP_STAT_NAME 0x0001u
|
||||
#define ZIP_STAT_INDEX 0x0002u
|
||||
#define ZIP_STAT_SIZE 0x0004u
|
||||
#define ZIP_STAT_COMP_SIZE 0x0008u
|
||||
#define ZIP_STAT_MTIME 0x0010u
|
||||
#define ZIP_STAT_CRC 0x0020u
|
||||
#define ZIP_STAT_COMP_METHOD 0x0040u
|
||||
#define ZIP_STAT_ENCRYPTION_METHOD 0x0080u
|
||||
#define ZIP_STAT_FLAGS 0x0100u
|
||||
|
||||
struct zip_stat {
|
||||
zip_uint64_t valid; /* which fields have valid values */
|
||||
const char *name; /* name of the file */
|
||||
zip_uint64_t index; /* index within archive */
|
||||
zip_uint64_t size; /* size of file (uncompressed) */
|
||||
zip_uint64_t comp_size; /* size of file (compressed) */
|
||||
time_t mtime; /* modification time */
|
||||
zip_uint32_t crc; /* crc of file data */
|
||||
zip_uint16_t comp_method; /* compression method used */
|
||||
zip_uint16_t encryption_method; /* encryption method used */
|
||||
zip_uint32_t flags; /* reserved for future use */
|
||||
};
|
||||
|
||||
struct zip;
|
||||
struct zip_file;
|
||||
struct zip_source;
|
||||
|
||||
typedef zip_uint32_t zip_flags_t;
|
||||
|
||||
typedef zip_int64_t (*zip_source_callback)(void *, void *, zip_uint64_t,
|
||||
enum zip_source_cmd);
|
||||
|
||||
|
||||
|
||||
#ifndef ZIP_DISABLE_DEPRECATED
|
||||
ZIP_EXTERN zip_int64_t zip_add(struct zip *, const char *, struct zip_source *); /* use zip_file_add */
|
||||
ZIP_EXTERN zip_int64_t zip_add_dir(struct zip *, const char *); /* use zip_dir_add */
|
||||
ZIP_EXTERN const char *zip_get_file_comment(struct zip *, zip_uint64_t, int *, int); /* use zip_file_get_comment */
|
||||
ZIP_EXTERN int zip_get_num_files(struct zip *); /* use zip_get_num_entries instead */
|
||||
ZIP_EXTERN int zip_rename(struct zip *, zip_uint64_t, const char *); /* use zip_file_rename */
|
||||
ZIP_EXTERN int zip_replace(struct zip *, zip_uint64_t, struct zip_source *); /* use zip_file_replace */
|
||||
ZIP_EXTERN int zip_set_file_comment(struct zip *, zip_uint64_t, const char *, int); /* use zip_file_set_comment */
|
||||
#endif
|
||||
|
||||
ZIP_EXTERN int zip_archive_set_tempdir(struct zip *, const char *);
|
||||
ZIP_EXTERN int zip_close(struct zip *);
|
||||
ZIP_EXTERN int zip_delete(struct zip *, zip_uint64_t);
|
||||
ZIP_EXTERN zip_int64_t zip_dir_add(struct zip *, const char *, zip_flags_t);
|
||||
ZIP_EXTERN void zip_discard(struct zip *);
|
||||
ZIP_EXTERN void zip_error_clear(struct zip *);
|
||||
ZIP_EXTERN void zip_error_get(struct zip *, int *, int *);
|
||||
ZIP_EXTERN int zip_error_get_sys_type(int);
|
||||
ZIP_EXTERN int zip_error_to_str(char *, zip_uint64_t, int, int);
|
||||
ZIP_EXTERN int zip_fclose(struct zip_file *);
|
||||
ZIP_EXTERN struct zip *zip_fdopen(int, int, int *);
|
||||
ZIP_EXTERN zip_int64_t zip_file_add(struct zip *, const char *, struct zip_source *, zip_flags_t);
|
||||
ZIP_EXTERN void zip_file_error_clear(struct zip_file *);
|
||||
ZIP_EXTERN void zip_file_error_get(struct zip_file *, int *, int *);
|
||||
ZIP_EXTERN int zip_file_extra_field_delete(struct zip *, zip_uint64_t, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_extra_field_delete_by_id(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_extra_field_set(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t, const zip_uint8_t *, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count(struct zip *, zip_uint64_t, zip_flags_t);
|
||||
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count_by_id(struct zip *, zip_uint64_t, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN const zip_uint8_t *zip_file_extra_field_get(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t *, zip_uint16_t *, zip_flags_t);
|
||||
ZIP_EXTERN const zip_uint8_t *zip_file_extra_field_get_by_id(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_uint16_t *, zip_flags_t);
|
||||
ZIP_EXTERN const char *zip_file_get_comment(struct zip *, zip_uint64_t, zip_uint32_t *, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_get_external_attributes(struct zip *, zip_uint64_t, zip_flags_t, zip_uint8_t *, zip_uint32_t *);
|
||||
ZIP_EXTERN int zip_file_rename(struct zip *, zip_uint64_t, const char *, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_replace(struct zip *, zip_uint64_t, struct zip_source *, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_set_comment(struct zip *, zip_uint64_t, const char *, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_set_external_attributes(struct zip *, zip_uint64_t, zip_flags_t, zip_uint8_t, zip_uint32_t);
|
||||
ZIP_EXTERN const char *zip_file_strerror(struct zip_file *);
|
||||
ZIP_EXTERN struct zip_file *zip_fopen(struct zip *, const char *, zip_flags_t);
|
||||
ZIP_EXTERN struct zip_file *zip_fopen_encrypted(struct zip *, const char *, zip_flags_t, const char *);
|
||||
ZIP_EXTERN struct zip_file *zip_fopen_index(struct zip *, zip_uint64_t, zip_flags_t);
|
||||
ZIP_EXTERN struct zip_file *zip_fopen_index_encrypted(struct zip *, zip_uint64_t, zip_flags_t, const char *);
|
||||
ZIP_EXTERN zip_int64_t zip_fread(struct zip_file *, void *, zip_uint64_t);
|
||||
ZIP_EXTERN const char *zip_get_archive_comment(struct zip *, int *, zip_flags_t);
|
||||
ZIP_EXTERN int zip_get_archive_flag(struct zip *, zip_flags_t, zip_flags_t);
|
||||
ZIP_EXTERN const char *zip_get_name(struct zip *, zip_uint64_t, zip_flags_t);
|
||||
ZIP_EXTERN zip_int64_t zip_get_num_entries(struct zip *, zip_flags_t);
|
||||
ZIP_EXTERN zip_int64_t zip_name_locate(struct zip *, const char *, zip_flags_t);
|
||||
ZIP_EXTERN struct zip *zip_open(const char *, int, int *);
|
||||
ZIP_EXTERN int zip_set_archive_comment(struct zip *, const char *, zip_uint16_t);
|
||||
ZIP_EXTERN int zip_set_archive_flag(struct zip *, zip_flags_t, int);
|
||||
ZIP_EXTERN int zip_set_default_password(struct zip *, const char *);
|
||||
ZIP_EXTERN int zip_set_file_compression(struct zip *, zip_uint64_t, zip_int32_t, zip_uint32_t);
|
||||
ZIP_EXTERN struct zip_source *zip_source_buffer(struct zip *, const void *, zip_uint64_t, int);
|
||||
ZIP_EXTERN struct zip_source *zip_source_file(struct zip *, const char *, zip_uint64_t, zip_int64_t);
|
||||
ZIP_EXTERN struct zip_source *zip_source_filep(struct zip *, FILE *, zip_uint64_t, zip_int64_t);
|
||||
ZIP_EXTERN void zip_source_free(struct zip_source *);
|
||||
ZIP_EXTERN struct zip_source *zip_source_function(struct zip *, zip_source_callback, void *);
|
||||
ZIP_EXTERN struct zip_source *zip_source_zip(struct zip *, struct zip *, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t);
|
||||
ZIP_EXTERN int zip_stat(struct zip *, const char *, zip_flags_t, struct zip_stat *);
|
||||
ZIP_EXTERN int zip_stat_index(struct zip *, zip_uint64_t, zip_flags_t, struct zip_stat *);
|
||||
ZIP_EXTERN void zip_stat_init(struct zip_stat *);
|
||||
ZIP_EXTERN const char *zip_strerror(struct zip *);
|
||||
ZIP_EXTERN int zip_unchange(struct zip *, zip_uint64_t);
|
||||
ZIP_EXTERN int zip_unchange_all(struct zip *);
|
||||
ZIP_EXTERN int zip_unchange_archive(struct zip *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _HAD_ZIP_H */
|
||||
52
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_add.c
vendored
Normal file
52
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_add.c
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
zip_add.c -- add file via callback function
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define _ZIP_COMPILING_DEPRECATED
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
NOTE: Return type is signed so we can return -1 on error.
|
||||
The index can not be larger than ZIP_INT64_MAX since the size
|
||||
of the central directory cannot be larger than
|
||||
ZIP_UINT64_MAX, and each entry is larger than 2 bytes.
|
||||
*/
|
||||
|
||||
ZIP_EXTERN zip_int64_t
|
||||
zip_add(struct zip *za, const char *name, struct zip_source *source)
|
||||
{
|
||||
return zip_file_add(za, name, source, 0);
|
||||
}
|
||||
47
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_add_dir.c
vendored
Normal file
47
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_add_dir.c
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
zip_add_dir.c -- add directory
|
||||
Copyright (C) 1999-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define _ZIP_COMPILING_DEPRECATED
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */
|
||||
|
||||
ZIP_EXTERN zip_int64_t
|
||||
zip_add_dir(struct zip *za, const char *name)
|
||||
{
|
||||
return zip_dir_add(za, name, 0);
|
||||
}
|
||||
67
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_add_entry.c
vendored
Normal file
67
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_add_entry.c
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
zip_add_entry.c -- create and init struct zip_entry
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */
|
||||
|
||||
zip_int64_t
|
||||
_zip_add_entry(struct zip *za)
|
||||
{
|
||||
zip_uint64_t idx;
|
||||
|
||||
if (za->nentry+1 >= za->nentry_alloc) {
|
||||
struct zip_entry *rentries;
|
||||
zip_uint64_t nalloc = za->nentry_alloc + 16;
|
||||
/* TODO check for overflow */
|
||||
rentries = (struct zip_entry *)realloc(za->entry, sizeof(struct zip_entry) * (size_t)nalloc);
|
||||
if (!rentries) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return -1;
|
||||
}
|
||||
za->entry = rentries;
|
||||
za->nentry_alloc = nalloc;
|
||||
}
|
||||
|
||||
idx = za->nentry++;
|
||||
|
||||
_zip_entry_init(za->entry+idx);
|
||||
|
||||
return (zip_int64_t)idx;
|
||||
}
|
||||
653
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_close.c
vendored
Normal file
653
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_close.c
vendored
Normal file
@@ -0,0 +1,653 @@
|
||||
/*
|
||||
zip_close.c -- close zip archive and update changes
|
||||
Copyright (C) 1999-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* max deflate size increase: size + ceil(size/16k)*5+6 */
|
||||
#define MAX_DEFLATE_SIZE_32 4293656963u
|
||||
|
||||
static int add_data(struct zip *, struct zip_source *, struct zip_dirent *, FILE *);
|
||||
static int copy_data(FILE *, zip_uint64_t, FILE *, struct zip_error *);
|
||||
static int copy_source(struct zip *, struct zip_source *, FILE *);
|
||||
static int write_cdir(struct zip *, const struct zip_filelist *, zip_uint64_t, FILE *);
|
||||
static char *_zip_create_temp_output(struct zip *, FILE **);
|
||||
static int _zip_torrentzip_cmp(const void *, const void *);
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_close(struct zip *za)
|
||||
{
|
||||
zip_uint64_t i, j, survivors;
|
||||
int error;
|
||||
char *temp;
|
||||
FILE *out;
|
||||
#ifndef _WIN32
|
||||
mode_t mask;
|
||||
#endif
|
||||
struct zip_filelist *filelist;
|
||||
int reopen_on_error;
|
||||
int new_torrentzip;
|
||||
int changed;
|
||||
|
||||
reopen_on_error = 0;
|
||||
|
||||
if (za == NULL)
|
||||
return -1;
|
||||
|
||||
changed = _zip_changed(za, &survivors);
|
||||
|
||||
/* don't create zip files with no entries */
|
||||
if (survivors == 0) {
|
||||
if (za->zn && ((za->open_flags & ZIP_TRUNCATE) || (changed && za->zp))) {
|
||||
if (remove(za->zn) != 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_REMOVE, errno);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
zip_discard(za);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!changed) {
|
||||
zip_discard(za);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (survivors > za->nentry) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INTERNAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((filelist=(struct zip_filelist *)malloc(sizeof(filelist[0])*(size_t)survivors)) == NULL)
|
||||
return -1;
|
||||
|
||||
/* archive comment is special for torrentzip */
|
||||
if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) {
|
||||
/* TODO: use internal function when zip_set_archive_comment clears TORRENT flag */
|
||||
if (zip_set_archive_comment(za, TORRENT_SIG "XXXXXXXX", TORRENT_SIG_LEN + TORRENT_CRC_LEN) < 0) {
|
||||
free(filelist);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* TODO: if no longer torrentzip and archive comment not changed by user, delete it */
|
||||
|
||||
|
||||
/* create list of files with index into original archive */
|
||||
for (i=j=0; i<za->nentry; i++) {
|
||||
if (za->entry[i].deleted)
|
||||
continue;
|
||||
|
||||
if (j >= survivors) {
|
||||
free(filelist);
|
||||
_zip_error_set(&za->error, ZIP_ER_INTERNAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
filelist[j].idx = i;
|
||||
filelist[j].name = zip_get_name(za, i, 0);
|
||||
j++;
|
||||
}
|
||||
if (j < survivors) {
|
||||
free(filelist);
|
||||
_zip_error_set(&za->error, ZIP_ER_INTERNAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if ((temp=_zip_create_temp_output(za, &out)) == NULL) {
|
||||
free(filelist);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
|
||||
qsort(filelist, (size_t)survivors, sizeof(filelist[0]),
|
||||
_zip_torrentzip_cmp);
|
||||
|
||||
new_torrentzip = (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 1
|
||||
&& zip_get_archive_flag(za, ZIP_AFL_TORRENT,
|
||||
ZIP_FL_UNCHANGED) == 0);
|
||||
error = 0;
|
||||
for (j=0; j<survivors; j++) {
|
||||
int new_data;
|
||||
struct zip_entry *entry;
|
||||
struct zip_dirent *de;
|
||||
|
||||
i = filelist[j].idx;
|
||||
entry = za->entry+i;
|
||||
|
||||
new_data = (ZIP_ENTRY_DATA_CHANGED(entry) || new_torrentzip || ZIP_ENTRY_CHANGED(entry, ZIP_DIRENT_COMP_METHOD));
|
||||
|
||||
/* create new local directory entry */
|
||||
if (entry->changes == NULL) {
|
||||
if ((entry->changes=_zip_dirent_clone(entry->orig)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
de = entry->changes;
|
||||
|
||||
if (_zip_read_local_ef(za, i) < 0) {
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
|
||||
_zip_dirent_torrent_normalize(entry->changes);
|
||||
|
||||
|
||||
de->offset = (zip_uint64_t)ftello(out); /* TODO: check for errors */
|
||||
|
||||
if (new_data) {
|
||||
struct zip_source *zs;
|
||||
|
||||
zs = NULL;
|
||||
if (!ZIP_ENTRY_DATA_CHANGED(entry)) {
|
||||
if ((zs=_zip_source_zip_new(za, za, i, ZIP_FL_UNCHANGED, 0, 0, NULL)) == NULL) {
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* add_data writes dirent */
|
||||
if (add_data(za, zs ? zs : entry->source, de, out) < 0) {
|
||||
error = 1;
|
||||
if (zs)
|
||||
zip_source_free(zs);
|
||||
break;
|
||||
}
|
||||
if (zs)
|
||||
zip_source_free(zs);
|
||||
}
|
||||
else {
|
||||
zip_uint64_t offset;
|
||||
|
||||
/* when copying data, all sizes are known -> no data descriptor needed */
|
||||
de->bitflags &= ~ZIP_GPBF_DATA_DESCRIPTOR;
|
||||
if (_zip_dirent_write(de, out, ZIP_FL_LOCAL, &za->error) < 0) {
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
if ((offset=_zip_file_get_offset(za, i, &za->error)) == 0) {
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
if ((fseeko(za->zp, (off_t)offset, SEEK_SET) < 0)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_SEEK, errno);
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
if (copy_data(za->zp, de->comp_size, out, &za->error) < 0) {
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
if (write_cdir(za, filelist, survivors, out) < 0)
|
||||
error = 1;
|
||||
}
|
||||
|
||||
free(filelist);
|
||||
|
||||
if (error) {
|
||||
fclose(out);
|
||||
(void)remove(temp);
|
||||
free(temp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fclose(out) != 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_CLOSE, errno);
|
||||
(void)remove(temp);
|
||||
free(temp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (za->zp) {
|
||||
fclose(za->zp);
|
||||
za->zp = NULL;
|
||||
reopen_on_error = 1;
|
||||
}
|
||||
if (_zip_rename(temp, za->zn) != 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RENAME, errno);
|
||||
(void)remove(temp);
|
||||
free(temp);
|
||||
if (reopen_on_error) {
|
||||
/* ignore errors, since we're already in an error case */
|
||||
za->zp = fopen(za->zn, "rb");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#ifndef _WIN32
|
||||
mask = umask(0);
|
||||
umask(mask);
|
||||
chmod(za->zn, 0666&~mask);
|
||||
#endif
|
||||
|
||||
zip_discard(za);
|
||||
free(temp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
add_data(struct zip *za, struct zip_source *src, struct zip_dirent *de, FILE *ft)
|
||||
{
|
||||
off_t offstart, offdata, offend;
|
||||
struct zip_stat st;
|
||||
struct zip_source *s2;
|
||||
int ret;
|
||||
int is_zip64;
|
||||
zip_flags_t flags;
|
||||
|
||||
if (zip_source_stat(src, &st) < 0) {
|
||||
_zip_error_set_from_source(&za->error, src);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((st.valid & ZIP_STAT_COMP_METHOD) == 0) {
|
||||
st.valid |= ZIP_STAT_COMP_METHOD;
|
||||
st.comp_method = ZIP_CM_STORE;
|
||||
}
|
||||
|
||||
if (ZIP_CM_IS_DEFAULT(de->comp_method) && st.comp_method != ZIP_CM_STORE)
|
||||
de->comp_method = st.comp_method;
|
||||
else if (de->comp_method == ZIP_CM_STORE && (st.valid & ZIP_STAT_SIZE)) {
|
||||
st.valid |= ZIP_STAT_COMP_SIZE;
|
||||
st.comp_size = st.size;
|
||||
}
|
||||
else {
|
||||
/* we'll recompress */
|
||||
st.valid &= ~ZIP_STAT_COMP_SIZE;
|
||||
}
|
||||
|
||||
|
||||
flags = ZIP_EF_LOCAL;
|
||||
|
||||
if ((st.valid & ZIP_STAT_SIZE) == 0)
|
||||
flags |= ZIP_FL_FORCE_ZIP64;
|
||||
else {
|
||||
de->uncomp_size = st.size;
|
||||
|
||||
if ((st.valid & ZIP_STAT_COMP_SIZE) == 0) {
|
||||
if (( ((de->comp_method == ZIP_CM_DEFLATE || ZIP_CM_IS_DEFAULT(de->comp_method)) && st.size > MAX_DEFLATE_SIZE_32)
|
||||
|| (de->comp_method != ZIP_CM_STORE && de->comp_method != ZIP_CM_DEFLATE && !ZIP_CM_IS_DEFAULT(de->comp_method))))
|
||||
flags |= ZIP_FL_FORCE_ZIP64;
|
||||
}
|
||||
else
|
||||
de->comp_size = st.comp_size;
|
||||
}
|
||||
|
||||
|
||||
offstart = ftello(ft);
|
||||
|
||||
/* as long as we don't support non-seekable output, clear data descriptor bit */
|
||||
de->bitflags &= ~ZIP_GPBF_DATA_DESCRIPTOR;
|
||||
if ((is_zip64=_zip_dirent_write(de, ft, flags, &za->error)) < 0)
|
||||
return -1;
|
||||
|
||||
|
||||
if (st.comp_method == ZIP_CM_STORE || (ZIP_CM_IS_DEFAULT(de->comp_method) && st.comp_method != de->comp_method)) {
|
||||
struct zip_source *s_store, *s_crc;
|
||||
zip_compression_implementation comp_impl;
|
||||
|
||||
if (st.comp_method != ZIP_CM_STORE) {
|
||||
if ((comp_impl=_zip_get_compression_implementation(st.comp_method)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0);
|
||||
return -1;
|
||||
}
|
||||
if ((s_store=comp_impl(za, src, st.comp_method, ZIP_CODEC_DECODE)) == NULL) {
|
||||
/* error set by comp_impl */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
s_store = src;
|
||||
|
||||
if ((s_crc=zip_source_crc(za, s_store, 0)) == NULL) {
|
||||
if (s_store != src)
|
||||
zip_source_pop(s_store);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* TODO: deflate 0-byte files for torrentzip? */
|
||||
if (de->comp_method != ZIP_CM_STORE && ((st.valid & ZIP_STAT_SIZE) == 0 || st.size != 0)) {
|
||||
if ((comp_impl=_zip_get_compression_implementation(de->comp_method)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0);
|
||||
zip_source_pop(s_crc);
|
||||
if (s_store != src)
|
||||
zip_source_pop(s_store);
|
||||
return -1;
|
||||
}
|
||||
if ((s2=comp_impl(za, s_crc, de->comp_method, ZIP_CODEC_ENCODE)) == NULL) {
|
||||
zip_source_pop(s_crc);
|
||||
if (s_store != src)
|
||||
zip_source_pop(s_store);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
s2 = s_crc;
|
||||
}
|
||||
else
|
||||
s2 = src;
|
||||
|
||||
offdata = ftello(ft);
|
||||
|
||||
ret = copy_source(za, s2, ft);
|
||||
|
||||
if (zip_source_stat(s2, &st) < 0)
|
||||
ret = -1;
|
||||
|
||||
while (s2 != src) {
|
||||
if ((s2=zip_source_pop(s2)) == NULL) {
|
||||
/* TODO: set erorr */
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
offend = ftello(ft);
|
||||
|
||||
if (fseeko(ft, offstart, SEEK_SET) < 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_SEEK, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((st.valid & (ZIP_STAT_COMP_METHOD|ZIP_STAT_CRC|ZIP_STAT_SIZE)) != (ZIP_STAT_COMP_METHOD|ZIP_STAT_CRC|ZIP_STAT_SIZE)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INTERNAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (st.valid & ZIP_STAT_MTIME)
|
||||
de->last_mod = st.mtime;
|
||||
else
|
||||
time(&de->last_mod);
|
||||
de->comp_method = st.comp_method;
|
||||
de->crc = st.crc;
|
||||
de->uncomp_size = st.size;
|
||||
de->comp_size = (zip_uint64_t)(offend - offdata);
|
||||
|
||||
if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
|
||||
_zip_dirent_torrent_normalize(de);
|
||||
|
||||
if ((ret=_zip_dirent_write(de, ft, flags, &za->error)) < 0)
|
||||
return -1;
|
||||
|
||||
if (is_zip64 != ret) {
|
||||
/* Zip64 mismatch between preliminary file header written before data and final file header written afterwards */
|
||||
_zip_error_set(&za->error, ZIP_ER_INTERNAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (fseeko(ft, offend, SEEK_SET) < 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_SEEK, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
copy_data(FILE *fs, zip_uint64_t len, FILE *ft, struct zip_error *error)
|
||||
{
|
||||
char buf[BUFSIZE];
|
||||
size_t n, nn;
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
while (len > 0) {
|
||||
nn = len > sizeof(buf) ? sizeof(buf) : len > SIZE_MAX ? SIZE_MAX : (size_t)len;
|
||||
if ((n=fread(buf, 1, nn, fs)) == 0) {
|
||||
if (ferror(fs)) {
|
||||
_zip_error_set(error, ZIP_ER_READ, errno);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
_zip_error_set(error, ZIP_ER_EOF, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (fwrite(buf, 1, n, ft) != (size_t)n) {
|
||||
_zip_error_set(error, ZIP_ER_WRITE, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
len -= n;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
copy_source(struct zip *za, struct zip_source *src, FILE *ft)
|
||||
{
|
||||
char buf[BUFSIZE];
|
||||
zip_int64_t n;
|
||||
int ret;
|
||||
|
||||
if (zip_source_open(src) < 0) {
|
||||
_zip_error_set_from_source(&za->error, src);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
while ((n=zip_source_read(src, buf, sizeof(buf))) > 0) {
|
||||
if (fwrite(buf, 1, (size_t)n, ft) != (size_t)n) {
|
||||
_zip_error_set(&za->error, ZIP_ER_WRITE, errno);
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (n < 0) {
|
||||
if (ret == 0)
|
||||
_zip_error_set_from_source(&za->error, src);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
zip_source_close(src);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
write_cdir(struct zip *za, const struct zip_filelist *filelist, zip_uint64_t survivors, FILE *out)
|
||||
{
|
||||
off_t cd_start, end;
|
||||
zip_int64_t size;
|
||||
uLong crc;
|
||||
char buf[TORRENT_CRC_LEN+1];
|
||||
|
||||
cd_start = ftello(out);
|
||||
|
||||
if ((size=_zip_cdir_write(za, filelist, survivors, out)) < 0)
|
||||
return -1;
|
||||
|
||||
end = ftello(out);
|
||||
|
||||
if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
/* fix up torrentzip comment */
|
||||
|
||||
if (_zip_filerange_crc(out, cd_start, (off_t)size, &crc, &za->error) < 0)
|
||||
return -1;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%08lX", (long)crc);
|
||||
|
||||
if (fseeko(out, end-TORRENT_CRC_LEN, SEEK_SET) < 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_SEEK, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fwrite(buf, TORRENT_CRC_LEN, 1, out) != 1) {
|
||||
_zip_error_set(&za->error, ZIP_ER_WRITE, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
_zip_changed(const struct zip *za, zip_uint64_t *survivorsp)
|
||||
{
|
||||
int changed;
|
||||
zip_uint64_t i, survivors;
|
||||
|
||||
changed = 0;
|
||||
survivors = 0;
|
||||
|
||||
if (za->comment_changed || za->ch_flags != za->flags)
|
||||
changed = 1;
|
||||
|
||||
for (i=0; i<za->nentry; i++) {
|
||||
if (za->entry[i].deleted || za->entry[i].source || (za->entry[i].changes && za->entry[i].changes->changed != 0))
|
||||
changed = 1;
|
||||
if (!za->entry[i].deleted)
|
||||
survivors++;
|
||||
}
|
||||
|
||||
if (survivorsp)
|
||||
*survivorsp = survivors;
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static char *
|
||||
_zip_create_temp_output(struct zip *za, FILE **outp)
|
||||
{
|
||||
char *temp;
|
||||
int tfd;
|
||||
FILE *tfp;
|
||||
|
||||
if (za->tempdir) {
|
||||
if ((temp=(char *)malloc(strlen(za->tempdir)+13)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(temp, "%s/.zip.XXXXXX", za->tempdir);
|
||||
}
|
||||
else {
|
||||
if ((temp=(char *)malloc(strlen(za->zn)+8)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(temp, "%s.XXXXXX", za->zn);
|
||||
}
|
||||
|
||||
if ((tfd=mkstemp(temp)) == -1) {
|
||||
_zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
|
||||
free(temp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((tfp=fdopen(tfd, "r+b")) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
|
||||
close(tfd);
|
||||
(void)remove(temp);
|
||||
free(temp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
According to Pierre Joye, Windows in some environments per
|
||||
default creates text files, so force binary mode.
|
||||
*/
|
||||
_setmode(_fileno(tfp), _O_BINARY );
|
||||
#endif
|
||||
|
||||
*outp = tfp;
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
_zip_torrentzip_cmp(const void *a, const void *b)
|
||||
{
|
||||
const char *aname = ((const struct zip_filelist *)a)->name;
|
||||
const char *bname = ((const struct zip_filelist *)b)->name;
|
||||
|
||||
if (aname == NULL)
|
||||
return (bname != NULL) * -1;
|
||||
else if (bname == NULL)
|
||||
return 1;
|
||||
|
||||
return strcasecmp(aname, bname);
|
||||
}
|
||||
63
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_delete.c
vendored
Normal file
63
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_delete.c
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
zip_delete.c -- delete file from zip archive
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_delete(struct zip *za, zip_uint64_t idx)
|
||||
{
|
||||
if (idx >= za->nentry) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* allow duplicate file names, because the file will
|
||||
* be removed directly afterwards */
|
||||
if (_zip_unchange(za, idx, 1) != 0)
|
||||
return -1;
|
||||
|
||||
za->entry[idx].deleted = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
95
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_dir_add.c
vendored
Normal file
95
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_dir_add.c
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
zip_dir_add.c -- add directory
|
||||
Copyright (C) 1999-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */
|
||||
|
||||
ZIP_EXTERN zip_int64_t
|
||||
zip_dir_add(struct zip *za, const char *name, zip_flags_t flags)
|
||||
{
|
||||
size_t len;
|
||||
zip_int64_t idx;
|
||||
char *s;
|
||||
struct zip_source *source;
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (name == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = NULL;
|
||||
len = strlen(name);
|
||||
|
||||
if (name[len-1] != '/') {
|
||||
if ((s=(char *)malloc(len+2)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return -1;
|
||||
}
|
||||
strcpy(s, name);
|
||||
s[len] = '/';
|
||||
s[len+1] = '\0';
|
||||
}
|
||||
|
||||
if ((source=zip_source_buffer(za, NULL, 0, 0)) == NULL) {
|
||||
free(s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
idx = _zip_file_replace(za, ZIP_UINT64_MAX, s ? s : name, source, flags);
|
||||
|
||||
free(s);
|
||||
|
||||
if (idx < 0)
|
||||
zip_source_free(source);
|
||||
else {
|
||||
if (zip_file_set_external_attributes(za, (zip_uint64_t)idx, 0, ZIP_OPSYS_DEFAULT, ZIP_EXT_ATTRIB_DEFAULT_DIR) < 0) {
|
||||
zip_delete(za, (zip_uint64_t)idx);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
1025
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_dirent.c
vendored
Normal file
1025
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_dirent.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
83
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_discard.c
vendored
Normal file
83
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_discard.c
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
zip_discard.c -- discard and free struct zip
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
/* zip_discard:
|
||||
frees the space allocated to a zipfile struct, and closes the
|
||||
corresponding file. */
|
||||
|
||||
void
|
||||
zip_discard(struct zip *za)
|
||||
{
|
||||
zip_uint64_t i;
|
||||
|
||||
if (za == NULL)
|
||||
return;
|
||||
|
||||
if (za->zn)
|
||||
free(za->zn);
|
||||
|
||||
if (za->zp)
|
||||
fclose(za->zp);
|
||||
|
||||
free(za->default_password);
|
||||
_zip_string_free(za->comment_orig);
|
||||
_zip_string_free(za->comment_changes);
|
||||
|
||||
if (za->entry) {
|
||||
for (i=0; i<za->nentry; i++)
|
||||
_zip_entry_finalize(za->entry+i);
|
||||
free(za->entry);
|
||||
}
|
||||
|
||||
for (i=0; i<za->nfile; i++) {
|
||||
if (za->file[i]->error.zip_err == ZIP_ER_OK) {
|
||||
_zip_error_set(&za->file[i]->error, ZIP_ER_ZIPCLOSED, 0);
|
||||
za->file[i]->za = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
_zip_error_fini(&za->error);
|
||||
free(za->file);
|
||||
|
||||
free(za);
|
||||
|
||||
return;
|
||||
}
|
||||
55
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_entry.c
vendored
Normal file
55
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_entry.c
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
zip_entry.c -- struct zip_entry helper functions
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
void
|
||||
_zip_entry_finalize(struct zip_entry *e)
|
||||
{
|
||||
_zip_unchange_data(e);
|
||||
_zip_dirent_free(e->orig);
|
||||
_zip_dirent_free(e->changes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_entry_init(struct zip_entry *e)
|
||||
{
|
||||
e->orig = NULL;
|
||||
e->changes = NULL;
|
||||
e->source = NULL;
|
||||
e->deleted = 0;
|
||||
}
|
||||
76
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_err_str.c
vendored
Normal file
76
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_err_str.c
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
This file was generated automatically by ./make_zip_err_str.sh
|
||||
from ./zip.h; make changes there.
|
||||
*/
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
const char * const _zip_err_str[] = {
|
||||
"No error",
|
||||
"Multi-disk zip archives not supported",
|
||||
"Renaming temporary file failed",
|
||||
"Closing zip archive failed",
|
||||
"Seek error",
|
||||
"Read error",
|
||||
"Write error",
|
||||
"CRC error",
|
||||
"Containing zip archive was closed",
|
||||
"No such file",
|
||||
"File already exists",
|
||||
"Can't open file",
|
||||
"Failure to create temporary file",
|
||||
"Zlib error",
|
||||
"Malloc failure",
|
||||
"Entry has been changed",
|
||||
"Compression method not supported",
|
||||
"Premature EOF",
|
||||
"Invalid argument",
|
||||
"Not a zip archive",
|
||||
"Internal error",
|
||||
"Zip archive inconsistent",
|
||||
"Can't remove file",
|
||||
"Entry has been deleted",
|
||||
"Encryption method not supported",
|
||||
"Read-only archive",
|
||||
"No password provided",
|
||||
"Wrong password provided",
|
||||
};
|
||||
|
||||
const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]);
|
||||
|
||||
#define N ZIP_ET_NONE
|
||||
#define S ZIP_ET_SYS
|
||||
#define Z ZIP_ET_ZLIB
|
||||
|
||||
const int _zip_err_type[] = {
|
||||
N,
|
||||
N,
|
||||
S,
|
||||
S,
|
||||
S,
|
||||
S,
|
||||
S,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
S,
|
||||
S,
|
||||
Z,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
S,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
N,
|
||||
};
|
||||
115
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error.c
vendored
Normal file
115
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error.c
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
zip_error.c -- struct zip_error helper functions
|
||||
Copyright (C) 1999-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_error_clear(struct zip_error *err)
|
||||
{
|
||||
if (err == NULL)
|
||||
return;
|
||||
|
||||
err->zip_err = ZIP_ER_OK;
|
||||
err->sys_err = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_error_copy(struct zip_error *dst, const struct zip_error *src)
|
||||
{
|
||||
dst->zip_err = src->zip_err;
|
||||
dst->sys_err = src->sys_err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_error_fini(struct zip_error *err)
|
||||
{
|
||||
free(err->str);
|
||||
err->str = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_error_get(const struct zip_error *err, int *zep, int *sep)
|
||||
{
|
||||
if (zep)
|
||||
*zep = err->zip_err;
|
||||
if (sep) {
|
||||
if (zip_error_get_sys_type(err->zip_err) != ZIP_ET_NONE)
|
||||
*sep = err->sys_err;
|
||||
else
|
||||
*sep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_error_init(struct zip_error *err)
|
||||
{
|
||||
err->zip_err = ZIP_ER_OK;
|
||||
err->sys_err = 0;
|
||||
err->str = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_error_set(struct zip_error *err, int ze, int se)
|
||||
{
|
||||
if (err) {
|
||||
err->zip_err = ze;
|
||||
err->sys_err = se;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_error_set_from_source(struct zip_error *err, struct zip_source *src)
|
||||
{
|
||||
int ze, se;
|
||||
|
||||
zip_source_error(src, &ze, &se);
|
||||
_zip_error_set(err, ze, se);
|
||||
}
|
||||
47
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error_clear.c
vendored
Normal file
47
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error_clear.c
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
zip_error_clear.c -- clear zip error
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN void
|
||||
zip_error_clear(struct zip *za)
|
||||
{
|
||||
if (za == NULL)
|
||||
return;
|
||||
|
||||
_zip_error_clear(&za->error);
|
||||
}
|
||||
44
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error_get.c
vendored
Normal file
44
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error_get.c
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
zip_error_get.c -- get zip error
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN void
|
||||
zip_error_get(struct zip *za, int *zep, int *sep)
|
||||
{
|
||||
_zip_error_get(&za->error, zep, sep);
|
||||
}
|
||||
47
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error_get_sys_type.c
vendored
Normal file
47
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error_get_sys_type.c
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
zip_error_get_sys_type.c -- return type of system error code
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_error_get_sys_type(int ze)
|
||||
{
|
||||
if (ze < 0 || ze >= _zip_nerr_str)
|
||||
return 0;
|
||||
|
||||
return _zip_err_type[ze];
|
||||
}
|
||||
90
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error_strerror.c
vendored
Normal file
90
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error_strerror.c
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
zip_error_sterror.c -- get string representation of struct zip_error
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
_zip_error_strerror(struct zip_error *err)
|
||||
{
|
||||
const char *zs, *ss;
|
||||
char buf[128], *s;
|
||||
|
||||
_zip_error_fini(err);
|
||||
|
||||
if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) {
|
||||
sprintf(buf, "Unknown error %d", err->zip_err);
|
||||
zs = NULL;
|
||||
ss = buf;
|
||||
}
|
||||
else {
|
||||
zs = _zip_err_str[err->zip_err];
|
||||
|
||||
switch (_zip_err_type[err->zip_err]) {
|
||||
case ZIP_ET_SYS:
|
||||
ss = strerror(err->sys_err);
|
||||
break;
|
||||
|
||||
case ZIP_ET_ZLIB:
|
||||
ss = zError(err->sys_err);
|
||||
break;
|
||||
|
||||
default:
|
||||
ss = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ss == NULL)
|
||||
return zs;
|
||||
else {
|
||||
if ((s=(char *)malloc(strlen(ss)
|
||||
+ (zs ? strlen(zs)+2 : 0) + 1)) == NULL)
|
||||
return _zip_err_str[ZIP_ER_MEMORY];
|
||||
|
||||
sprintf(s, "%s%s%s",
|
||||
(zs ? zs : ""),
|
||||
(zs ? ": " : ""),
|
||||
ss);
|
||||
err->str = s;
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
70
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error_to_str.c
vendored
Normal file
70
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_error_to_str.c
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
zip_error_to_str.c -- get string representation of zip error code
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_error_to_str(char *buf, zip_uint64_t len, int ze, int se)
|
||||
{
|
||||
const char *zs, *ss;
|
||||
|
||||
if (ze < 0 || ze >= _zip_nerr_str)
|
||||
return snprintf(buf, (size_t)len, "Unknown error %d", ze);
|
||||
|
||||
zs = _zip_err_str[ze];
|
||||
|
||||
switch (_zip_err_type[ze]) {
|
||||
case ZIP_ET_SYS:
|
||||
ss = strerror(se);
|
||||
break;
|
||||
|
||||
case ZIP_ET_ZLIB:
|
||||
ss = zError(se);
|
||||
break;
|
||||
|
||||
default:
|
||||
ss = NULL;
|
||||
}
|
||||
|
||||
return snprintf(buf, (size_t)len, "%s%s%s",
|
||||
zs, (ss ? ": " : ""), (ss ? ss : ""));
|
||||
}
|
||||
386
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_extra_field.c
vendored
Normal file
386
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_extra_field.c
vendored
Normal file
@@ -0,0 +1,386 @@
|
||||
/*
|
||||
zip_extra_field.c -- manipulate extra fields
|
||||
Copyright (C) 2012-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
struct zip_extra_field *
|
||||
_zip_ef_clone(const struct zip_extra_field *ef, struct zip_error *error)
|
||||
{
|
||||
struct zip_extra_field *head, *prev, *def;
|
||||
|
||||
head = prev = NULL;
|
||||
|
||||
while (ef) {
|
||||
if ((def=_zip_ef_new(ef->id, ef->size, ef->data, ef->flags)) == NULL) {
|
||||
_zip_error_set(error, ZIP_ER_MEMORY, 0);
|
||||
_zip_ef_free(head);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (head == NULL)
|
||||
head = def;
|
||||
if (prev)
|
||||
prev->next = def;
|
||||
prev = def;
|
||||
|
||||
ef = ef->next;
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
|
||||
struct zip_extra_field *
|
||||
_zip_ef_delete_by_id(struct zip_extra_field *ef, zip_uint16_t id, zip_uint16_t id_idx, zip_flags_t flags)
|
||||
{
|
||||
struct zip_extra_field *head, *prev;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
head = ef;
|
||||
prev = NULL;
|
||||
for (; ef; ef=(prev ? prev->next : head)) {
|
||||
if ((ef->flags & flags & ZIP_EF_BOTH) && ((ef->id == id) || (id == ZIP_EXTRA_FIELD_ALL))) {
|
||||
if (id_idx == ZIP_EXTRA_FIELD_ALL || i == id_idx) {
|
||||
ef->flags &= ~(flags & ZIP_EF_BOTH);
|
||||
if ((ef->flags & ZIP_EF_BOTH) == 0) {
|
||||
if (prev)
|
||||
prev->next = ef->next;
|
||||
else
|
||||
head = ef->next;
|
||||
ef->next = NULL;
|
||||
_zip_ef_free(ef);
|
||||
|
||||
if (id_idx == ZIP_EXTRA_FIELD_ALL)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
if (i > id_idx)
|
||||
break;
|
||||
}
|
||||
prev = ef;
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_ef_free(struct zip_extra_field *ef)
|
||||
{
|
||||
struct zip_extra_field *ef2;
|
||||
|
||||
while (ef) {
|
||||
ef2 = ef->next;
|
||||
free(ef->data);
|
||||
free(ef);
|
||||
ef = ef2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const zip_uint8_t *
|
||||
_zip_ef_get_by_id(const struct zip_extra_field *ef, zip_uint16_t *lenp, zip_uint16_t id, zip_uint16_t id_idx, zip_flags_t flags, struct zip_error *error)
|
||||
{
|
||||
static const zip_uint8_t empty[1] = { '\0' };
|
||||
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
for (; ef; ef=ef->next) {
|
||||
if (ef->id == id && (ef->flags & flags & ZIP_EF_BOTH)) {
|
||||
if (i < id_idx) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lenp)
|
||||
*lenp = ef->size;
|
||||
if (ef->size > 0)
|
||||
return ef->data;
|
||||
else
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
|
||||
_zip_error_set(error, ZIP_ER_NOENT, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct zip_extra_field *
|
||||
_zip_ef_merge(struct zip_extra_field *to, struct zip_extra_field *from)
|
||||
{
|
||||
struct zip_extra_field *ef2, *tt, *tail;
|
||||
int duplicate;
|
||||
|
||||
if (to == NULL)
|
||||
return from;
|
||||
|
||||
for (tail=to; tail->next; tail=tail->next)
|
||||
;
|
||||
|
||||
for (; from; from=ef2) {
|
||||
ef2 = from->next;
|
||||
|
||||
duplicate = 0;
|
||||
for (tt=to; tt; tt=tt->next) {
|
||||
if (tt->id == from->id && tt->size == from->size && memcmp(tt->data, from->data, tt->size) == 0) {
|
||||
tt->flags |= (from->flags & ZIP_EF_BOTH);
|
||||
duplicate = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
from->next = NULL;
|
||||
if (duplicate)
|
||||
_zip_ef_free(from);
|
||||
else
|
||||
tail = tail->next = from;
|
||||
}
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct zip_extra_field *
|
||||
_zip_ef_new(zip_uint16_t id, zip_uint16_t size, const zip_uint8_t *data, zip_flags_t flags)
|
||||
{
|
||||
struct zip_extra_field *ef;
|
||||
|
||||
if ((ef=(struct zip_extra_field *)malloc(sizeof(*ef))) == NULL)
|
||||
return NULL;
|
||||
|
||||
ef->next = NULL;
|
||||
ef->flags = flags;
|
||||
ef->id = id;
|
||||
ef->size = size;
|
||||
if (size > 0) {
|
||||
if ((ef->data=(zip_uint8_t *)_zip_memdup(data, size, NULL)) == NULL) {
|
||||
free(ef);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
ef->data = NULL;
|
||||
|
||||
return ef;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct zip_extra_field *
|
||||
_zip_ef_parse(const zip_uint8_t *data, zip_uint16_t len, zip_flags_t flags, struct zip_error *error)
|
||||
{
|
||||
struct zip_extra_field *ef, *ef2, *ef_head;
|
||||
const zip_uint8_t *p;
|
||||
zip_uint16_t fid, flen;
|
||||
|
||||
ef_head = NULL;
|
||||
for (p=data; p<data+len; p+=flen) {
|
||||
if (p+4 > data+len) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
_zip_ef_free(ef_head);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fid = _zip_read2(&p);
|
||||
flen = _zip_read2(&p);
|
||||
|
||||
if (p+flen > data+len) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
_zip_ef_free(ef_head);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ef2=_zip_ef_new(fid, flen, p, flags)) == NULL) {
|
||||
_zip_error_set(error, ZIP_ER_MEMORY, 0);
|
||||
_zip_ef_free(ef_head);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ef_head) {
|
||||
ef->next = ef2;
|
||||
ef = ef2;
|
||||
}
|
||||
else
|
||||
ef_head = ef = ef2;
|
||||
}
|
||||
|
||||
return ef_head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct zip_extra_field *
|
||||
_zip_ef_remove_internal(struct zip_extra_field *ef)
|
||||
{
|
||||
struct zip_extra_field *ef_head;
|
||||
struct zip_extra_field *prev, *next;
|
||||
|
||||
ef_head = ef;
|
||||
prev = NULL;
|
||||
|
||||
while (ef) {
|
||||
if (ZIP_EF_IS_INTERNAL(ef->id)) {
|
||||
next = ef->next;
|
||||
if (ef_head == ef)
|
||||
ef_head = next;
|
||||
ef->next = NULL;
|
||||
_zip_ef_free(ef);
|
||||
if (prev)
|
||||
prev->next = next;
|
||||
ef = next;
|
||||
}
|
||||
else {
|
||||
prev = ef;
|
||||
ef = ef->next;
|
||||
}
|
||||
}
|
||||
|
||||
return ef_head;
|
||||
}
|
||||
|
||||
|
||||
zip_uint16_t
|
||||
_zip_ef_size(const struct zip_extra_field *ef, zip_flags_t flags)
|
||||
{
|
||||
zip_uint16_t size;
|
||||
|
||||
size = 0;
|
||||
for (; ef; ef=ef->next) {
|
||||
if (ef->flags & flags & ZIP_EF_BOTH)
|
||||
size += 4+ef->size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_ef_write(const struct zip_extra_field *ef, zip_flags_t flags, FILE *f)
|
||||
{
|
||||
for (; ef; ef=ef->next) {
|
||||
if (ef->flags & flags & ZIP_EF_BOTH) {
|
||||
_zip_write2(ef->id, f);
|
||||
_zip_write2(ef->size, f);
|
||||
if (ef->size > 0)
|
||||
fwrite(ef->data, ef->size, 1, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
_zip_read_local_ef(struct zip *za, zip_uint64_t idx)
|
||||
{
|
||||
struct zip_entry *e;
|
||||
unsigned char b[4];
|
||||
const unsigned char *p;
|
||||
zip_uint16_t fname_len, ef_len;
|
||||
|
||||
if (idx >= za->nentry) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
e = za->entry+idx;
|
||||
|
||||
if (e->orig == NULL || e->orig->local_extra_fields_read)
|
||||
return 0;
|
||||
|
||||
|
||||
if (fseeko(za->zp, (off_t)(e->orig->offset + 26), SEEK_SET) < 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_SEEK, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fread(b, sizeof(b), 1, za->zp) != 1) {
|
||||
_zip_error_set(&za->error, ZIP_ER_READ, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
p = b;
|
||||
fname_len = _zip_read2(&p);
|
||||
ef_len = _zip_read2(&p);
|
||||
|
||||
if (ef_len > 0) {
|
||||
struct zip_extra_field *ef;
|
||||
zip_uint8_t *ef_raw;
|
||||
|
||||
if (fseek(za->zp, fname_len, SEEK_CUR) < 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_SEEK, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ef_raw = _zip_read_data(NULL, za->zp, ef_len, 0, &za->error);
|
||||
|
||||
if (ef_raw == NULL)
|
||||
return -1;
|
||||
|
||||
if ((ef=_zip_ef_parse(ef_raw, ef_len, ZIP_EF_LOCAL, &za->error)) == NULL) {
|
||||
free(ef_raw);
|
||||
return -1;
|
||||
}
|
||||
free(ef_raw);
|
||||
|
||||
ef = _zip_ef_remove_internal(ef);
|
||||
e->orig->extra_fields = _zip_ef_merge(e->orig->extra_fields, ef);
|
||||
}
|
||||
|
||||
e->orig->local_extra_fields_read = 1;
|
||||
|
||||
if (e->changes && e->changes->local_extra_fields_read == 0) {
|
||||
e->changes->extra_fields = e->orig->extra_fields;
|
||||
e->changes->local_extra_fields_read = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
374
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_extra_field_api.c
vendored
Normal file
374
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_extra_field_api.c
vendored
Normal file
@@ -0,0 +1,374 @@
|
||||
/*
|
||||
zip_extra_field_api.c -- public extra fields API functions
|
||||
Copyright (C) 2012-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_file_extra_field_delete(struct zip *za, zip_uint64_t idx, zip_uint16_t ef_idx, zip_flags_t flags)
|
||||
{
|
||||
struct zip_dirent *de;
|
||||
|
||||
if ((flags & ZIP_EF_BOTH) == 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (((flags & ZIP_EF_BOTH) == ZIP_EF_BOTH) && (ef_idx != ZIP_EXTRA_FIELD_ALL)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
|
||||
return -1;
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_zip_file_extra_field_prepare_for_change(za, idx) < 0)
|
||||
return -1;
|
||||
|
||||
de = za->entry[idx].changes;
|
||||
|
||||
de->extra_fields = _zip_ef_delete_by_id(de->extra_fields, ZIP_EXTRA_FIELD_ALL, ef_idx, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_file_extra_field_delete_by_id(struct zip *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_uint16_t ef_idx, zip_flags_t flags)
|
||||
{
|
||||
struct zip_dirent *de;
|
||||
|
||||
if ((flags & ZIP_EF_BOTH) == 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (((flags & ZIP_EF_BOTH) == ZIP_EF_BOTH) && (ef_idx != ZIP_EXTRA_FIELD_ALL)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
|
||||
return -1;
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_zip_file_extra_field_prepare_for_change(za, idx) < 0)
|
||||
return -1;
|
||||
|
||||
de = za->entry[idx].changes;
|
||||
|
||||
de->extra_fields = _zip_ef_delete_by_id(de->extra_fields, ef_id, ef_idx, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN const zip_uint8_t *
|
||||
zip_file_extra_field_get(struct zip *za, zip_uint64_t idx, zip_uint16_t ef_idx, zip_uint16_t *idp, zip_uint16_t *lenp, zip_flags_t flags)
|
||||
{
|
||||
static const zip_uint8_t empty[1] = { '\0' };
|
||||
|
||||
struct zip_dirent *de;
|
||||
struct zip_extra_field *ef;
|
||||
int i;
|
||||
|
||||
if ((flags & ZIP_EF_BOTH) == 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((de=_zip_get_dirent(za, idx, flags, &za->error)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (flags & ZIP_FL_LOCAL)
|
||||
if (_zip_read_local_ef(za, idx) < 0)
|
||||
return NULL;
|
||||
|
||||
i = 0;
|
||||
for (ef=de->extra_fields; ef; ef=ef->next) {
|
||||
if (ef->flags & flags & ZIP_EF_BOTH) {
|
||||
if (i < ef_idx) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (idp)
|
||||
*idp = ef->id;
|
||||
if (lenp)
|
||||
*lenp = ef->size;
|
||||
if (ef->size > 0)
|
||||
return ef->data;
|
||||
else
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
|
||||
_zip_error_set(&za->error, ZIP_ER_NOENT, 0);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN const zip_uint8_t *
|
||||
zip_file_extra_field_get_by_id(struct zip *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_uint16_t ef_idx, zip_uint16_t *lenp, zip_flags_t flags)
|
||||
{
|
||||
struct zip_dirent *de;
|
||||
|
||||
if ((flags & ZIP_EF_BOTH) == 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((de=_zip_get_dirent(za, idx, flags, &za->error)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (flags & ZIP_FL_LOCAL)
|
||||
if (_zip_read_local_ef(za, idx) < 0)
|
||||
return NULL;
|
||||
|
||||
return _zip_ef_get_by_id(de->extra_fields, lenp, ef_id, ef_idx, flags, &za->error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN zip_int16_t
|
||||
zip_file_extra_fields_count(struct zip *za, zip_uint64_t idx, zip_flags_t flags)
|
||||
{
|
||||
struct zip_dirent *de;
|
||||
struct zip_extra_field *ef;
|
||||
zip_uint16_t n;
|
||||
|
||||
if ((flags & ZIP_EF_BOTH) == 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((de=_zip_get_dirent(za, idx, flags, &za->error)) == NULL)
|
||||
return -1;
|
||||
|
||||
if (flags & ZIP_FL_LOCAL)
|
||||
if (_zip_read_local_ef(za, idx) < 0)
|
||||
return -1;
|
||||
|
||||
n = 0;
|
||||
for (ef=de->extra_fields; ef; ef=ef->next)
|
||||
if (ef->flags & flags & ZIP_EF_BOTH)
|
||||
n++;
|
||||
|
||||
return (zip_int16_t)n;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN zip_int16_t
|
||||
zip_file_extra_fields_count_by_id(struct zip *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_flags_t flags)
|
||||
{
|
||||
struct zip_dirent *de;
|
||||
struct zip_extra_field *ef;
|
||||
zip_uint16_t n;
|
||||
|
||||
if ((flags & ZIP_EF_BOTH) == 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((de=_zip_get_dirent(za, idx, flags, &za->error)) == NULL)
|
||||
return -1;
|
||||
|
||||
if (flags & ZIP_FL_LOCAL)
|
||||
if (_zip_read_local_ef(za, idx) < 0)
|
||||
return -1;
|
||||
|
||||
n = 0;
|
||||
for (ef=de->extra_fields; ef; ef=ef->next)
|
||||
if (ef->id == ef_id && (ef->flags & flags & ZIP_EF_BOTH))
|
||||
n++;
|
||||
|
||||
return (zip_int16_t)n;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_file_extra_field_set(struct zip *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_uint16_t ef_idx, const zip_uint8_t *data, zip_uint16_t len, zip_flags_t flags)
|
||||
{
|
||||
struct zip_dirent *de;
|
||||
zip_uint16_t ls, cs;
|
||||
struct zip_extra_field *ef, *ef_prev, *ef_new;
|
||||
int i, found, new_len;
|
||||
|
||||
if ((flags & ZIP_EF_BOTH) == 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
|
||||
return -1;
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ZIP_EF_IS_INTERNAL(ef_id)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_zip_file_extra_field_prepare_for_change(za, idx) < 0)
|
||||
return -1;
|
||||
|
||||
de = za->entry[idx].changes;
|
||||
|
||||
ef = de->extra_fields;
|
||||
ef_prev = NULL;
|
||||
i = 0;
|
||||
found = 0;
|
||||
|
||||
for (; ef; ef=ef->next) {
|
||||
if (ef->id == ef_id && (ef->flags & flags & ZIP_EF_BOTH)) {
|
||||
if (i == ef_idx) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
ef_prev = ef;
|
||||
}
|
||||
|
||||
if (i < ef_idx && ef_idx != ZIP_EXTRA_FIELD_NEW) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (flags & ZIP_EF_LOCAL)
|
||||
ls = _zip_ef_size(de->extra_fields, ZIP_EF_LOCAL);
|
||||
else
|
||||
ls = 0;
|
||||
if (flags & ZIP_EF_CENTRAL)
|
||||
cs = _zip_ef_size(de->extra_fields, ZIP_EF_CENTRAL);
|
||||
else
|
||||
cs = 0;
|
||||
|
||||
new_len = ls > cs ? ls : cs;
|
||||
if (found)
|
||||
new_len -= ef->size + 4;
|
||||
new_len += len + 4;
|
||||
|
||||
if (new_len > ZIP_UINT16_MAX) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ef_new=_zip_ef_new(ef_id, len, data, flags)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
if ((ef->flags & ZIP_EF_BOTH) == (flags & ZIP_EF_BOTH)) {
|
||||
ef_new->next = ef->next;
|
||||
ef->next = NULL;
|
||||
_zip_ef_free(ef);
|
||||
if (ef_prev)
|
||||
ef_prev->next = ef_new;
|
||||
else
|
||||
de->extra_fields = ef_new;
|
||||
}
|
||||
else {
|
||||
ef->flags &= ~(flags & ZIP_EF_BOTH);
|
||||
ef_new->next = ef->next;
|
||||
ef->next = ef_new;
|
||||
}
|
||||
}
|
||||
else if (ef_prev) {
|
||||
ef_new->next = ef_prev->next;
|
||||
ef_prev->next = ef_new;
|
||||
}
|
||||
else
|
||||
de->extra_fields = ef_new;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
_zip_file_extra_field_prepare_for_change(struct zip *za, zip_uint64_t idx)
|
||||
{
|
||||
struct zip_entry *e;
|
||||
|
||||
if (idx >= za->nentry) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
e = za->entry+idx;
|
||||
|
||||
if (e->changes && (e->changes->changed & ZIP_DIRENT_EXTRA_FIELD))
|
||||
return 0;
|
||||
|
||||
if (e->orig) {
|
||||
if (_zip_read_local_ef(za, idx) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (e->changes == NULL) {
|
||||
if ((e->changes=_zip_dirent_clone(e->orig)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (e->orig && e->orig->extra_fields) {
|
||||
if ((e->changes->extra_fields=_zip_ef_clone(e->orig->extra_fields, &za->error)) == NULL)
|
||||
return -1;
|
||||
}
|
||||
e->changes->changed |= ZIP_DIRENT_EXTRA_FIELD;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
68
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fclose.c
vendored
Normal file
68
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fclose.c
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
zip_fclose.c -- close file in zip archive
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_fclose(struct zip_file *zf)
|
||||
{
|
||||
int ret;
|
||||
unsigned int i;
|
||||
|
||||
if (zf->src)
|
||||
zip_source_free(zf->src);
|
||||
|
||||
if (zf->za) {
|
||||
for (i=0; i<zf->za->nfile; i++) {
|
||||
if (zf->za->file[i] == zf) {
|
||||
zf->za->file[i] = zf->za->file[zf->za->nfile-1];
|
||||
zf->za->nfile--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
if (zf->error.zip_err)
|
||||
ret = zf->error.zip_err;
|
||||
|
||||
_zip_error_fini(&zf->error);
|
||||
free(zf);
|
||||
return ret;
|
||||
}
|
||||
75
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fdopen.c
vendored
Normal file
75
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fdopen.c
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
zip_fdopen.c -- open read-only archive from file descriptor
|
||||
Copyright (C) 2009-2010 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip *
|
||||
zip_fdopen(int fd_orig, int _flags, int *zep)
|
||||
{
|
||||
int fd;
|
||||
FILE *fp;
|
||||
unsigned int flags;
|
||||
|
||||
if (_flags < 0) {
|
||||
if (zep)
|
||||
*zep = ZIP_ER_INVAL;
|
||||
return NULL;
|
||||
}
|
||||
flags = (unsigned int)_flags;
|
||||
|
||||
if (flags & ZIP_TRUNCATE) {
|
||||
*zep = ZIP_ER_INVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We dup() here to avoid messing with the passed in fd.
|
||||
We could not restore it to the original state in case of error. */
|
||||
|
||||
if ((fd=dup(fd_orig)) < 0) {
|
||||
*zep = ZIP_ER_OPEN;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((fp=fdopen(fd, "rb")) == NULL) {
|
||||
close(fd);
|
||||
*zep = ZIP_ER_OPEN;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
close(fd_orig);
|
||||
return _zip_open(NULL, fp, flags, zep);
|
||||
}
|
||||
55
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_add.c
vendored
Normal file
55
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_add.c
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
zip_file_add.c -- add file via callback function
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
/*
|
||||
NOTE: Return type is signed so we can return -1 on error.
|
||||
The index can not be larger than ZIP_INT64_MAX since the size
|
||||
of the central directory cannot be larger than
|
||||
ZIP_UINT64_MAX, and each entry is larger than 2 bytes.
|
||||
*/
|
||||
|
||||
ZIP_EXTERN zip_int64_t
|
||||
zip_file_add(struct zip *za, const char *name, struct zip_source *source, zip_flags_t flags)
|
||||
{
|
||||
if (name == NULL || source == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _zip_file_replace(za, ZIP_UINT64_MAX, name, source, flags);
|
||||
}
|
||||
47
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_error_clear.c
vendored
Normal file
47
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_error_clear.c
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
zip_file_error_clear.c -- clear zip file error
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN void
|
||||
zip_file_error_clear(struct zip_file *zf)
|
||||
{
|
||||
if (zf == NULL)
|
||||
return;
|
||||
|
||||
_zip_error_clear(&zf->error);
|
||||
}
|
||||
44
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_error_get.c
vendored
Normal file
44
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_error_get.c
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
zip_file_error_get.c -- get zip file error
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN void
|
||||
zip_file_error_get(struct zip_file *zf, int *zep, int *sep)
|
||||
{
|
||||
_zip_error_get(&zf->error, zep, sep);
|
||||
}
|
||||
58
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_get_comment.c
vendored
Normal file
58
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_get_comment.c
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
zip_file_get_comment.c -- get file comment
|
||||
Copyright (C) 2006-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
/* lenp is 32 bit because converted comment can be longer than ZIP_UINT16_MAX */
|
||||
|
||||
ZIP_EXTERN const char *
|
||||
zip_file_get_comment(struct zip *za, zip_uint64_t idx, zip_uint32_t *lenp, zip_flags_t flags)
|
||||
{
|
||||
struct zip_dirent *de;
|
||||
zip_uint32_t len;
|
||||
const zip_uint8_t *str;
|
||||
|
||||
if ((de=_zip_get_dirent(za, idx, flags, NULL)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((str=_zip_string_get(de->comment, &len, flags, &za->error)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (lenp)
|
||||
*lenp = len;
|
||||
|
||||
return (const char *)str;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
zip_file_get_external_attributes.c -- get opsys/external attributes
|
||||
Copyright (C) 2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
int
|
||||
zip_file_get_external_attributes(struct zip *za, zip_uint64_t idx, zip_flags_t flags, zip_uint8_t *opsys, zip_uint32_t *attributes)
|
||||
{
|
||||
struct zip_dirent *de;
|
||||
|
||||
if ((de=_zip_get_dirent(za, idx, flags, NULL)) == NULL)
|
||||
return -1;
|
||||
|
||||
if (opsys)
|
||||
*opsys = (de->version_madeby >> 8) & 0xff;
|
||||
|
||||
if (attributes)
|
||||
*attributes = de->ext_attrib;
|
||||
|
||||
return 0;
|
||||
}
|
||||
76
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_get_offset.c
vendored
Normal file
76
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_get_offset.c
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
zip_file_get_offset.c -- get offset of file data in archive.
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
/* _zip_file_get_offset(za, ze):
|
||||
Returns the offset of the file data for entry ze.
|
||||
|
||||
On error, fills in za->error and returns 0.
|
||||
*/
|
||||
|
||||
zip_uint64_t
|
||||
_zip_file_get_offset(const struct zip *za, zip_uint64_t idx, struct zip_error *error)
|
||||
{
|
||||
zip_uint64_t offset;
|
||||
zip_int32_t size;
|
||||
|
||||
offset = za->entry[idx].orig->offset;
|
||||
|
||||
if (fseeko(za->zp, (off_t)offset, SEEK_SET) != 0) {
|
||||
_zip_error_set(error, ZIP_ER_SEEK, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* TODO: cache? */
|
||||
if ((size=_zip_dirent_size(za->zp, ZIP_EF_LOCAL, error)) < 0)
|
||||
return 0;
|
||||
|
||||
if (offset+(zip_uint32_t)size > ZIP_OFF_MAX) {
|
||||
_zip_error_set(error, ZIP_ER_SEEK, EFBIG);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return offset + (zip_uint32_t)size;
|
||||
}
|
||||
70
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_rename.c
vendored
Normal file
70
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_rename.c
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
zip_file_rename.c -- rename file in zip archive
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_file_rename(struct zip *za, zip_uint64_t idx, const char *name, zip_flags_t flags)
|
||||
{
|
||||
const char *old_name;
|
||||
int old_is_dir, new_is_dir;
|
||||
|
||||
if (idx >= za->nentry || (name != NULL && strlen(name) > ZIP_UINT16_MAX)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((old_name=zip_get_name(za, idx, 0)) == NULL)
|
||||
return -1;
|
||||
|
||||
new_is_dir = (name != NULL && name[strlen(name)-1] == '/');
|
||||
old_is_dir = (old_name[strlen(old_name)-1] == '/');
|
||||
|
||||
if (new_is_dir != old_is_dir) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _zip_set_name(za, idx, name, flags);
|
||||
}
|
||||
111
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_replace.c
vendored
Normal file
111
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_replace.c
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
zip_file_replace.c -- replace file via callback function
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_file_replace(struct zip *za, zip_uint64_t idx, struct zip_source *source, zip_flags_t flags)
|
||||
{
|
||||
if (idx >= za->nentry || source == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_zip_file_replace(za, idx, NULL, source, flags) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */
|
||||
|
||||
zip_int64_t
|
||||
_zip_file_replace(struct zip *za, zip_uint64_t idx, const char *name, struct zip_source *source, zip_flags_t flags)
|
||||
{
|
||||
zip_uint64_t za_nentry_prev;
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
za_nentry_prev = za->nentry;
|
||||
if (idx == ZIP_UINT64_MAX) {
|
||||
zip_int64_t i = -1;
|
||||
|
||||
if (flags & ZIP_FL_OVERWRITE)
|
||||
i = _zip_name_locate(za, name, flags, NULL);
|
||||
|
||||
if (i == -1) {
|
||||
/* create and use new entry, used by zip_add */
|
||||
if ((i=_zip_add_entry(za)) < 0)
|
||||
return -1;
|
||||
}
|
||||
idx = (zip_uint64_t)i;
|
||||
}
|
||||
|
||||
if (name && _zip_set_name(za, idx, name, flags) != 0) {
|
||||
if (za->nentry != za_nentry_prev) {
|
||||
_zip_entry_finalize(za->entry+idx);
|
||||
za->nentry = za_nentry_prev;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* does not change any name related data, so we can do it here;
|
||||
* needed for a double add of the same file name */
|
||||
_zip_unchange_data(za->entry+idx);
|
||||
|
||||
if (za->entry[idx].orig != NULL && (za->entry[idx].changes == NULL || (za->entry[idx].changes->changed & ZIP_DIRENT_COMP_METHOD) == 0)) {
|
||||
if (za->entry[idx].changes == NULL) {
|
||||
if ((za->entry[idx].changes=_zip_dirent_clone(za->entry[idx].orig)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
za->entry[idx].changes->comp_method = ZIP_CM_REPLACED_DEFAULT;
|
||||
za->entry[idx].changes->changed |= ZIP_DIRENT_COMP_METHOD;
|
||||
}
|
||||
|
||||
za->entry[idx].source = source;
|
||||
|
||||
return (zip_int64_t)idx;
|
||||
}
|
||||
105
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_set_comment.c
vendored
Normal file
105
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_set_comment.c
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
zip_file_set_comment.c -- set comment for file in archive
|
||||
Copyright (C) 2006-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_file_set_comment(struct zip *za, zip_uint64_t idx,
|
||||
const char *comment, zip_uint16_t len, zip_flags_t flags)
|
||||
{
|
||||
struct zip_entry *e;
|
||||
struct zip_string *cstr;
|
||||
int changed;
|
||||
|
||||
if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
|
||||
return -1;
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (len > 0 && comment == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
if ((cstr=_zip_string_new((const zip_uint8_t *)comment, len, flags, &za->error)) == NULL)
|
||||
return -1;
|
||||
if ((flags & ZIP_FL_ENCODING_ALL) == ZIP_FL_ENC_GUESS && _zip_guess_encoding(cstr, ZIP_ENCODING_UNKNOWN) == ZIP_ENCODING_UTF8_GUESSED)
|
||||
cstr->encoding = ZIP_ENCODING_UTF8_KNOWN;
|
||||
}
|
||||
else
|
||||
cstr = NULL;
|
||||
|
||||
e = za->entry+idx;
|
||||
|
||||
if (e->changes) {
|
||||
_zip_string_free(e->changes->comment);
|
||||
e->changes->comment = NULL;
|
||||
e->changes->changed &= ~ZIP_DIRENT_COMMENT;
|
||||
}
|
||||
|
||||
if (e->orig && e->orig->comment)
|
||||
changed = !_zip_string_equal(e->orig->comment, cstr);
|
||||
else
|
||||
changed = (cstr != NULL);
|
||||
|
||||
if (changed) {
|
||||
if (e->changes == NULL) {
|
||||
if ((e->changes=_zip_dirent_clone(e->orig)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
_zip_string_free(cstr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
e->changes->comment = cstr;
|
||||
e->changes->changed |= ZIP_DIRENT_COMMENT;
|
||||
}
|
||||
else {
|
||||
_zip_string_free(cstr);
|
||||
if (e->changes && e->changes->changed == 0) {
|
||||
_zip_dirent_free(e->changes);
|
||||
e->changes = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
zip_file_set_external_attributes.c -- set external attributes for entry
|
||||
Copyright (C) 2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
int
|
||||
zip_file_set_external_attributes(struct zip *za, zip_uint64_t idx, zip_flags_t flags, zip_uint8_t opsys, zip_uint32_t attributes)
|
||||
{
|
||||
struct zip_entry *e;
|
||||
int changed;
|
||||
zip_uint8_t unchanged_opsys;
|
||||
zip_uint32_t unchanged_attributes;
|
||||
|
||||
if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
|
||||
return -1;
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
e = za->entry+idx;
|
||||
|
||||
unchanged_opsys = e->orig ? e->orig->version_madeby>>8 : ZIP_OPSYS_DEFAULT;
|
||||
unchanged_attributes = e->orig ? e->orig->ext_attrib : ZIP_EXT_ATTRIB_DEFAULT;
|
||||
|
||||
changed = (opsys != unchanged_opsys || attributes != unchanged_attributes);
|
||||
|
||||
if (changed) {
|
||||
if (e->changes == NULL) {
|
||||
if ((e->changes=_zip_dirent_clone(e->orig)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
e->changes->version_madeby = (opsys << 8) | (e->changes->version_madeby & 0xff);
|
||||
e->changes->ext_attrib = attributes;
|
||||
e->changes->changed |= ZIP_DIRENT_ATTRIBUTES;
|
||||
}
|
||||
else if (e->changes) {
|
||||
e->changes->changed &= ~ZIP_DIRENT_ATTRIBUTES;
|
||||
if (e->changes->changed == 0) {
|
||||
_zip_dirent_free(e->changes);
|
||||
e->changes = NULL;
|
||||
}
|
||||
else {
|
||||
e->changes->version_madeby = (unchanged_opsys << 8) | (e->changes->version_madeby & 0xff);
|
||||
e->changes->ext_attrib = unchanged_attributes;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_strerror.c
vendored
Normal file
44
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_file_strerror.c
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
zip_file_sterror.c -- get string representation of zip file error
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN const char *
|
||||
zip_file_strerror(struct zip_file *zf)
|
||||
{
|
||||
return _zip_error_strerror(&zf->error);
|
||||
}
|
||||
71
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_filerange_crc.c
vendored
Normal file
71
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_filerange_crc.c
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
zip_filerange_crc.c -- compute CRC32 for a range of a file
|
||||
Copyright (C) 2008-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
_zip_filerange_crc(FILE *fp, off_t start, off_t len, uLong *crcp,
|
||||
struct zip_error *errp)
|
||||
{
|
||||
Bytef buf[BUFSIZE];
|
||||
size_t n;
|
||||
|
||||
*crcp = crc32(0L, Z_NULL, 0);
|
||||
|
||||
if (fseeko(fp, start, SEEK_SET) != 0) {
|
||||
_zip_error_set(errp, ZIP_ER_SEEK, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (len > 0) {
|
||||
n = len > BUFSIZE ? BUFSIZE : (size_t)len;
|
||||
if ((n=fread(buf, 1, n, fp)) == 0) {
|
||||
_zip_error_set(errp, ZIP_ER_READ, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*crcp = crc32(*crcp, buf, (uInt)n);
|
||||
|
||||
len-= n;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
49
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fopen.c
vendored
Normal file
49
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fopen.c
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
zip_fopen.c -- open file in zip archive for reading
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip_file *
|
||||
zip_fopen(struct zip *za, const char *fname, zip_flags_t flags)
|
||||
{
|
||||
zip_int64_t idx;
|
||||
|
||||
if ((idx=zip_name_locate(za, fname, flags)) < 0)
|
||||
return NULL;
|
||||
|
||||
return zip_fopen_index_encrypted(za, (zip_uint64_t)idx, flags, za->default_password);
|
||||
}
|
||||
49
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fopen_encrypted.c
vendored
Normal file
49
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fopen_encrypted.c
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
zip_fopen_encrypted.c -- open file for reading with password
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip_file *
|
||||
zip_fopen_encrypted(struct zip *za, const char *fname, zip_flags_t flags, const char *password)
|
||||
{
|
||||
zip_int64_t idx;
|
||||
|
||||
if ((idx=zip_name_locate(za, fname, flags)) < 0)
|
||||
return NULL;
|
||||
|
||||
return zip_fopen_index_encrypted(za, (zip_uint64_t)idx, flags, password);
|
||||
}
|
||||
48
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fopen_index.c
vendored
Normal file
48
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fopen_index.c
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
zip_fopen_index.c -- open file in zip archive for reading by index
|
||||
Copyright (C) 1999-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip_file *
|
||||
zip_fopen_index(struct zip *za, zip_uint64_t index, zip_flags_t flags)
|
||||
{
|
||||
return zip_fopen_index_encrypted(za, index, flags, za->default_password);
|
||||
}
|
||||
106
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fopen_index_encrypted.c
vendored
Normal file
106
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fopen_index_encrypted.c
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
zip_fopen_index_encrypted.c -- open file for reading by index w/ password
|
||||
Copyright (C) 1999-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
static struct zip_file *_zip_file_new(struct zip *za);
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip_file *
|
||||
zip_fopen_index_encrypted(struct zip *za, zip_uint64_t index, zip_flags_t flags,
|
||||
const char *password)
|
||||
{
|
||||
struct zip_file *zf;
|
||||
struct zip_source *src;
|
||||
|
||||
if ((src=_zip_source_zip_new(za, za, index, flags, 0, 0, password)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (zip_source_open(src) < 0) {
|
||||
_zip_error_set_from_source(&za->error, src);
|
||||
zip_source_free(src);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((zf=_zip_file_new(za)) == NULL) {
|
||||
zip_source_free(src);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
zf->src = src;
|
||||
|
||||
return zf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct zip_file *
|
||||
_zip_file_new(struct zip *za)
|
||||
{
|
||||
struct zip_file *zf, **file;
|
||||
|
||||
if ((zf=(struct zip_file *)malloc(sizeof(struct zip_file))) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (za->nfile+1 >= za->nfile_alloc) {
|
||||
unsigned int n;
|
||||
n = za->nfile_alloc + 10;
|
||||
file = (struct zip_file **)realloc(za->file,
|
||||
n*sizeof(struct zip_file *));
|
||||
if (file == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
free(zf);
|
||||
return NULL;
|
||||
}
|
||||
za->nfile_alloc = n;
|
||||
za->file = file;
|
||||
}
|
||||
|
||||
za->file[za->nfile++] = zf;
|
||||
|
||||
zf->za = za;
|
||||
_zip_error_init(&zf->error);
|
||||
zf->eof = 0;
|
||||
zf->src = NULL;
|
||||
|
||||
return zf;
|
||||
}
|
||||
65
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fread.c
vendored
Normal file
65
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_fread.c
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
zip_fread.c -- read from file
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN zip_int64_t
|
||||
zip_fread(struct zip_file *zf, void *outbuf, zip_uint64_t toread)
|
||||
{
|
||||
zip_int64_t n;
|
||||
|
||||
if (!zf)
|
||||
return -1;
|
||||
|
||||
if (zf->error.zip_err != 0)
|
||||
return -1;
|
||||
|
||||
if (toread > ZIP_INT64_MAX) {
|
||||
_zip_error_set(&zf->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((zf->eof) || (toread == 0))
|
||||
return 0;
|
||||
|
||||
if ((n=zip_source_read(zf->src, outbuf, toread)) < 0) {
|
||||
_zip_error_set_from_source(&zf->error, zf->src);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
61
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_archive_comment.c
vendored
Normal file
61
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_archive_comment.c
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
zip_get_archive_comment.c -- get archive comment
|
||||
Copyright (C) 2006-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN const char *
|
||||
zip_get_archive_comment(struct zip *za, int *lenp, zip_flags_t flags)
|
||||
{
|
||||
struct zip_string *comment;
|
||||
zip_uint32_t len;
|
||||
const zip_uint8_t *str;
|
||||
|
||||
if ((flags & ZIP_FL_UNCHANGED) || (za->comment_changes == NULL))
|
||||
comment = za->comment_orig;
|
||||
else
|
||||
comment = za->comment_changes;
|
||||
|
||||
if ((str=_zip_string_get(comment, &len, flags, &za->error)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (lenp)
|
||||
*lenp = (int)len;
|
||||
|
||||
return (const char *)str;
|
||||
}
|
||||
48
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_archive_flag.c
vendored
Normal file
48
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_archive_flag.c
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
zip_get_archive_flag.c -- get archive global flag
|
||||
Copyright (C) 2008 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_get_archive_flag(struct zip *za, zip_flags_t flag, zip_flags_t flags)
|
||||
{
|
||||
unsigned int fl;
|
||||
|
||||
fl = (flags & ZIP_FL_UNCHANGED) ? za->flags : za->ch_flags;
|
||||
|
||||
return (fl & flag) ? 1 : 0;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
zip_get_compression_implementation.c -- get compression implementation
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
zip_compression_implementation
|
||||
_zip_get_compression_implementation(zip_int32_t cm)
|
||||
{
|
||||
if (cm == ZIP_CM_DEFLATE || ZIP_CM_IS_DEFAULT(cm))
|
||||
return zip_source_deflate;
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
zip_get_encryption_implementation.c -- get encryption implementation
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
zip_encryption_implementation
|
||||
_zip_get_encryption_implementation(zip_uint16_t em)
|
||||
{
|
||||
if (em == ZIP_EM_TRAD_PKWARE)
|
||||
return zip_source_pkware;
|
||||
return NULL;
|
||||
}
|
||||
53
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_file_comment.c
vendored
Normal file
53
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_file_comment.c
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
zip_get_file_comment.c -- get file comment
|
||||
Copyright (C) 2006-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define _ZIP_COMPILING_DEPRECATED
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN const char *
|
||||
zip_get_file_comment(struct zip *za, zip_uint64_t idx, int *lenp, int flags)
|
||||
{
|
||||
zip_uint32_t len;
|
||||
const char *s;
|
||||
|
||||
if ((s=zip_file_get_comment(za, idx, &len, (zip_flags_t)flags)) != NULL) {
|
||||
if (lenp)
|
||||
*lenp = (int)len;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
63
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_name.c
vendored
Normal file
63
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_name.c
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
zip_get_name.c -- get filename for a file in zip file
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN const char *
|
||||
zip_get_name(struct zip *za, zip_uint64_t idx, zip_flags_t flags)
|
||||
{
|
||||
return _zip_get_name(za, idx, flags, &za->error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
_zip_get_name(struct zip *za, zip_uint64_t idx, zip_flags_t flags, struct zip_error *error)
|
||||
{
|
||||
struct zip_dirent *de;
|
||||
const zip_uint8_t *str;
|
||||
|
||||
if ((de=_zip_get_dirent(za, idx, flags, error)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((str=_zip_string_get(de->filename, NULL, flags, error)) == NULL)
|
||||
return NULL;
|
||||
|
||||
return (const char *)str;
|
||||
}
|
||||
55
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_num_entries.c
vendored
Normal file
55
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_num_entries.c
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
zip_get_num_entries.c -- get number of entries in archive
|
||||
Copyright (C) 1999-2011 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN zip_int64_t
|
||||
zip_get_num_entries(struct zip *za, zip_flags_t flags)
|
||||
{
|
||||
zip_uint64_t n;
|
||||
|
||||
if (za == NULL)
|
||||
return -1;
|
||||
|
||||
if (flags & ZIP_FL_UNCHANGED) {
|
||||
n = za->nentry;
|
||||
while (n>0 && za->entry[n-1].orig == NULL)
|
||||
--n;
|
||||
return (zip_int64_t)n;
|
||||
}
|
||||
return (zip_int64_t)za->nentry;
|
||||
}
|
||||
49
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_num_files.c
vendored
Normal file
49
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_get_num_files.c
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
zip_get_num_files.c -- get number of files in archive
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define _ZIP_COMPILING_DEPRECATED
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_get_num_files(struct zip *za)
|
||||
{
|
||||
if (za == NULL)
|
||||
return -1;
|
||||
|
||||
/* TODO: check for overflow */
|
||||
return (int)za->nentry;
|
||||
}
|
||||
58
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_memdup.c
vendored
Normal file
58
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_memdup.c
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
zip_memdup.c -- internal zip function, "strdup" with len
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
void *
|
||||
_zip_memdup(const void *mem, size_t len, struct zip_error *error)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
if (len == 0)
|
||||
return NULL;
|
||||
|
||||
ret = malloc(len);
|
||||
if (!ret) {
|
||||
_zip_error_set(error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(ret, mem, len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
91
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_name_locate.c
vendored
Normal file
91
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_name_locate.c
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
zip_name_locate.c -- get index by name
|
||||
Copyright (C) 1999-2011 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN zip_int64_t
|
||||
zip_name_locate(struct zip *za, const char *fname, zip_flags_t flags)
|
||||
{
|
||||
return _zip_name_locate(za, fname, flags, &za->error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
zip_int64_t
|
||||
_zip_name_locate(struct zip *za, const char *fname, zip_flags_t flags, struct zip_error *error)
|
||||
{
|
||||
int (*cmp)(const char *, const char *);
|
||||
const char *fn, *p;
|
||||
zip_uint64_t i;
|
||||
|
||||
if (za == NULL)
|
||||
return -1;
|
||||
|
||||
if (fname == NULL) {
|
||||
_zip_error_set(error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp;
|
||||
|
||||
for (i=0; i<za->nentry; i++) {
|
||||
fn = _zip_get_name(za, i, flags, error);
|
||||
|
||||
/* newly added (partially filled) entry or error */
|
||||
if (fn == NULL)
|
||||
continue;
|
||||
|
||||
if (flags & ZIP_FL_NODIR) {
|
||||
p = strrchr(fn, '/');
|
||||
if (p)
|
||||
fn = p+1;
|
||||
}
|
||||
|
||||
if (cmp(fname, fn) == 0) {
|
||||
_zip_error_clear(error);
|
||||
return (zip_int64_t)i;
|
||||
}
|
||||
}
|
||||
|
||||
_zip_error_set(error, ZIP_ER_NOENT, 0);
|
||||
return -1;
|
||||
}
|
||||
72
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_new.c
vendored
Normal file
72
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_new.c
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
zip_new.c -- create and init struct zip
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
/* _zip_new:
|
||||
creates a new zipfile struct, and sets the contents to zero; returns
|
||||
the new struct. */
|
||||
|
||||
struct zip *
|
||||
_zip_new(struct zip_error *error)
|
||||
{
|
||||
struct zip *za;
|
||||
|
||||
za = (struct zip *)malloc(sizeof(struct zip));
|
||||
if (!za) {
|
||||
_zip_error_set(error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
za->zn = NULL;
|
||||
za->zp = NULL;
|
||||
za->open_flags = 0;
|
||||
_zip_error_init(&za->error);
|
||||
za->flags = za->ch_flags = 0;
|
||||
za->default_password = NULL;
|
||||
za->comment_orig = za->comment_changes = NULL;
|
||||
za->comment_changed = 0;
|
||||
za->nentry = za->nentry_alloc = 0;
|
||||
za->entry = NULL;
|
||||
za->nfile = za->nfile_alloc = 0;
|
||||
za->file = NULL;
|
||||
za->tempdir = NULL;
|
||||
|
||||
return za;
|
||||
}
|
||||
742
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_open.c
vendored
Normal file
742
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_open.c
vendored
Normal file
@@ -0,0 +1,742 @@
|
||||
/*
|
||||
zip_open.c -- open zip archive by name
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
static void set_error(int *, const struct zip_error *, int);
|
||||
static struct zip *_zip_allocate_new(const char *, unsigned int, int *);
|
||||
static zip_int64_t _zip_checkcons(FILE *, struct zip_cdir *, struct zip_error *);
|
||||
static void _zip_check_torrentzip(struct zip *, const struct zip_cdir *);
|
||||
static struct zip_cdir *_zip_find_central_dir(FILE *, unsigned int, int *, off_t);
|
||||
static int _zip_file_exists(const char *, unsigned int, int *);
|
||||
static int _zip_headercomp(const struct zip_dirent *, const struct zip_dirent *);
|
||||
static unsigned char *_zip_memmem(const unsigned char *, size_t,
|
||||
const unsigned char *, size_t);
|
||||
static struct zip_cdir *_zip_readcdir(FILE *, off_t, unsigned char *, const unsigned char *,
|
||||
size_t, unsigned int, struct zip_error *);
|
||||
static struct zip_cdir *_zip_read_eocd(const unsigned char *, const unsigned char *, off_t,
|
||||
size_t, unsigned int, struct zip_error *);
|
||||
static struct zip_cdir *_zip_read_eocd64(FILE *, const unsigned char *, const unsigned char *,
|
||||
off_t, size_t, unsigned int, struct zip_error *);
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip *
|
||||
zip_open(const char *fn, int _flags, int *zep)
|
||||
{
|
||||
FILE *fp;
|
||||
unsigned int flags;
|
||||
|
||||
if (_flags < 0) {
|
||||
if (zep)
|
||||
*zep = ZIP_ER_INVAL;
|
||||
return NULL;
|
||||
}
|
||||
flags = (unsigned int)_flags;
|
||||
|
||||
switch (_zip_file_exists(fn, flags, zep)) {
|
||||
case -1:
|
||||
return NULL;
|
||||
case 0:
|
||||
return _zip_allocate_new(fn, flags, zep);
|
||||
default:
|
||||
if (flags & ZIP_TRUNCATE) {
|
||||
FILE *f;
|
||||
|
||||
if ((f = fopen(fn, "rb")) == NULL) {
|
||||
set_error(zep, NULL, ZIP_ER_OPEN);
|
||||
return NULL;
|
||||
}
|
||||
fclose(f);
|
||||
return _zip_allocate_new(fn, flags, zep);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ((fp=fopen(fn, "rb")) == NULL) {
|
||||
set_error(zep, NULL, ZIP_ER_OPEN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _zip_open(fn, fp, flags, zep);
|
||||
}
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_archive_set_tempdir(struct zip *za, const char *tempdir)
|
||||
{
|
||||
char *new_tempdir;
|
||||
|
||||
if (tempdir) {
|
||||
if ((new_tempdir = strdup(tempdir)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, errno);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
new_tempdir = NULL;
|
||||
|
||||
free(za->tempdir);
|
||||
za->tempdir = new_tempdir;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct zip *
|
||||
_zip_open(const char *fn, FILE *fp, unsigned int flags, int *zep)
|
||||
{
|
||||
struct zip *za;
|
||||
struct zip_cdir *cdir;
|
||||
off_t len;
|
||||
|
||||
if (fseeko(fp, 0, SEEK_END) < 0) {
|
||||
*zep = ZIP_ER_SEEK;
|
||||
return NULL;
|
||||
}
|
||||
len = ftello(fp);
|
||||
|
||||
/* treat empty files as empty archives */
|
||||
if (len == 0) {
|
||||
if ((za=_zip_allocate_new(fn, flags, zep)) == NULL)
|
||||
fclose(fp);
|
||||
else
|
||||
za->zp = fp;
|
||||
return za;
|
||||
}
|
||||
|
||||
cdir = _zip_find_central_dir(fp, flags, zep, len);
|
||||
if (cdir == NULL) {
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((za=_zip_allocate_new(fn, flags, zep)) == NULL) {
|
||||
_zip_cdir_free(cdir);
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
za->entry = cdir->entry;
|
||||
za->nentry = cdir->nentry;
|
||||
za->nentry_alloc = cdir->nentry_alloc;
|
||||
za->comment_orig = cdir->comment;
|
||||
|
||||
za->zp = fp;
|
||||
|
||||
_zip_check_torrentzip(za, cdir);
|
||||
|
||||
za->ch_flags = za->flags;
|
||||
|
||||
free(cdir);
|
||||
|
||||
return za;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
set_error(int *zep, const struct zip_error *err, int ze)
|
||||
{
|
||||
int se;
|
||||
|
||||
if (err) {
|
||||
_zip_error_get(err, &ze, &se);
|
||||
if (zip_error_get_sys_type(ze) == ZIP_ET_SYS)
|
||||
errno = se;
|
||||
}
|
||||
|
||||
if (zep)
|
||||
*zep = ze;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* _zip_readcdir:
|
||||
tries to find a valid end-of-central-directory at the beginning of
|
||||
buf, and then the corresponding central directory entries.
|
||||
Returns a struct zip_cdir which contains the central directory
|
||||
entries, or NULL if unsuccessful. */
|
||||
|
||||
static struct zip_cdir *
|
||||
_zip_readcdir(FILE *fp, off_t buf_offset, unsigned char *buf, const unsigned char *eocd, size_t buflen,
|
||||
unsigned int flags, struct zip_error *error)
|
||||
{
|
||||
struct zip_cdir *cd;
|
||||
const unsigned char *cdp;
|
||||
const unsigned char **bufp;
|
||||
zip_int64_t tail_len, comment_len;
|
||||
zip_uint64_t i, left;
|
||||
|
||||
tail_len = buf + buflen - eocd - EOCDLEN;
|
||||
if (tail_len < 0) {
|
||||
/* not enough bytes left for comment */
|
||||
_zip_error_set(error, ZIP_ER_NOZIP, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* check for end-of-central-dir magic */
|
||||
if (memcmp(eocd, EOCD_MAGIC, 4) != 0) {
|
||||
_zip_error_set(error, ZIP_ER_NOZIP, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (memcmp(eocd+4, "\0\0\0\0", 4) != 0) {
|
||||
_zip_error_set(error, ZIP_ER_MULTIDISK, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (eocd-EOCD64LOCLEN >= buf && memcmp(eocd-EOCD64LOCLEN, EOCD64LOC_MAGIC, 4) == 0)
|
||||
cd = _zip_read_eocd64(fp, eocd-EOCD64LOCLEN, buf, buf_offset, buflen, flags, error);
|
||||
else
|
||||
cd = _zip_read_eocd(eocd, buf, buf_offset, buflen, flags, error);
|
||||
|
||||
if (cd == NULL)
|
||||
return NULL;
|
||||
|
||||
cdp = eocd + 20;
|
||||
comment_len = _zip_read2(&cdp);
|
||||
|
||||
if ((zip_uint64_t)cd->offset+(zip_uint64_t)cd->size > (zip_uint64_t)buf_offset + (zip_uint64_t)(eocd-buf)) {
|
||||
/* cdir spans past EOCD record */
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
_zip_cdir_free(cd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (tail_len < comment_len || ((flags & ZIP_CHECKCONS) && tail_len != comment_len)) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
_zip_cdir_free(cd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (comment_len) {
|
||||
if ((cd->comment=_zip_string_new(eocd+EOCDLEN, (zip_uint16_t)comment_len, ZIP_FL_ENC_GUESS, error)) == NULL) {
|
||||
_zip_cdir_free(cd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (cd->offset >= buf_offset) {
|
||||
/* if buffer already read in, use it */
|
||||
cdp = buf + (cd->offset - buf_offset);
|
||||
bufp = &cdp;
|
||||
}
|
||||
else {
|
||||
/* go to start of cdir and read it entry by entry */
|
||||
bufp = NULL;
|
||||
clearerr(fp);
|
||||
fseeko(fp, cd->offset, SEEK_SET);
|
||||
/* possible consistency check: cd->offset =
|
||||
len-(cd->size+cd->comment_len+EOCDLEN) ? */
|
||||
if (ferror(fp) || (ftello(fp) != cd->offset)) {
|
||||
/* seek error or offset of cdir wrong */
|
||||
if (ferror(fp))
|
||||
_zip_error_set(error, ZIP_ER_SEEK, errno);
|
||||
else
|
||||
_zip_error_set(error, ZIP_ER_NOZIP, 0);
|
||||
_zip_cdir_free(cd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
left = (zip_uint64_t)cd->size;
|
||||
i=0;
|
||||
while (i<cd->nentry && left > 0) {
|
||||
if ((cd->entry[i].orig=_zip_dirent_new()) == NULL
|
||||
|| (_zip_dirent_read(cd->entry[i].orig, fp, bufp, &left, 0, error)) < 0) {
|
||||
_zip_cdir_free(cd);
|
||||
return NULL;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (i != cd->nentry || ((flags & ZIP_CHECKCONS) && left != 0)) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
_zip_cdir_free(cd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return cd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* _zip_checkcons:
|
||||
Checks the consistency of the central directory by comparing central
|
||||
directory entries with local headers and checking for plausible
|
||||
file and header offsets. Returns -1 if not plausible, else the
|
||||
difference between the lowest and the highest fileposition reached */
|
||||
|
||||
static zip_int64_t
|
||||
_zip_checkcons(FILE *fp, struct zip_cdir *cd, struct zip_error *error)
|
||||
{
|
||||
zip_uint64_t i;
|
||||
zip_uint64_t min, max, j;
|
||||
struct zip_dirent temp;
|
||||
|
||||
if (cd->nentry) {
|
||||
max = cd->entry[0].orig->offset;
|
||||
min = cd->entry[0].orig->offset;
|
||||
}
|
||||
else
|
||||
min = max = 0;
|
||||
|
||||
for (i=0; i<cd->nentry; i++) {
|
||||
if (cd->entry[i].orig->offset < min)
|
||||
min = cd->entry[i].orig->offset;
|
||||
if (min > (zip_uint64_t)cd->offset) {
|
||||
_zip_error_set(error, ZIP_ER_NOZIP, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
j = cd->entry[i].orig->offset + cd->entry[i].orig->comp_size
|
||||
+ _zip_string_length(cd->entry[i].orig->filename) + LENTRYSIZE;
|
||||
if (j > max)
|
||||
max = j;
|
||||
if (max > (zip_uint64_t)cd->offset) {
|
||||
_zip_error_set(error, ZIP_ER_NOZIP, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fseeko(fp, (off_t)cd->entry[i].orig->offset, SEEK_SET) != 0) {
|
||||
_zip_error_set(error, ZIP_ER_SEEK, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_zip_dirent_read(&temp, fp, NULL, NULL, 1, error) == -1)
|
||||
return -1;
|
||||
|
||||
if (_zip_headercomp(cd->entry[i].orig, &temp) != 0) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
_zip_dirent_finalize(&temp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cd->entry[i].orig->extra_fields = _zip_ef_merge(cd->entry[i].orig->extra_fields, temp.extra_fields);
|
||||
cd->entry[i].orig->local_extra_fields_read = 1;
|
||||
temp.extra_fields = NULL;
|
||||
|
||||
_zip_dirent_finalize(&temp);
|
||||
}
|
||||
|
||||
return (max-min) < ZIP_INT64_MAX ? (zip_int64_t)(max-min) : ZIP_INT64_MAX;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* _zip_check_torrentzip:
|
||||
check whether ZA has a valid TORRENTZIP comment, i.e. is torrentzipped */
|
||||
|
||||
static void
|
||||
_zip_check_torrentzip(struct zip *za, const struct zip_cdir *cdir)
|
||||
{
|
||||
uLong crc_got, crc_should;
|
||||
char buf[8+1];
|
||||
char *end;
|
||||
|
||||
if (za->zp == NULL || cdir == NULL)
|
||||
return;
|
||||
|
||||
if (_zip_string_length(cdir->comment) != TORRENT_SIG_LEN+8
|
||||
|| strncmp((const char *)cdir->comment->raw, TORRENT_SIG, TORRENT_SIG_LEN) != 0)
|
||||
return;
|
||||
|
||||
memcpy(buf, cdir->comment->raw+TORRENT_SIG_LEN, 8);
|
||||
buf[8] = '\0';
|
||||
errno = 0;
|
||||
crc_should = strtoul(buf, &end, 16);
|
||||
if ((crc_should == UINT_MAX && errno != 0) || (end && *end))
|
||||
return;
|
||||
|
||||
if (_zip_filerange_crc(za->zp, cdir->offset, cdir->size, &crc_got, NULL) < 0)
|
||||
return;
|
||||
|
||||
if (crc_got == crc_should)
|
||||
za->flags |= ZIP_AFL_TORRENT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* _zip_headercomp:
|
||||
compares a central directory entry and a local file header
|
||||
Return 0 if they are consistent, -1 if not. */
|
||||
|
||||
static int
|
||||
_zip_headercomp(const struct zip_dirent *central, const struct zip_dirent *local)
|
||||
{
|
||||
if ((central->version_needed != local->version_needed)
|
||||
#if 0
|
||||
/* some zip-files have different values in local
|
||||
and global headers for the bitflags */
|
||||
|| (central->bitflags != local->bitflags)
|
||||
#endif
|
||||
|| (central->comp_method != local->comp_method)
|
||||
|| (central->last_mod != local->last_mod)
|
||||
|| !_zip_string_equal(central->filename, local->filename))
|
||||
return -1;
|
||||
|
||||
|
||||
if ((central->crc != local->crc) || (central->comp_size != local->comp_size)
|
||||
|| (central->uncomp_size != local->uncomp_size)) {
|
||||
/* InfoZip stores valid values in local header even when data descriptor is used.
|
||||
This is in violation of the appnote. */
|
||||
if (((local->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0
|
||||
|| local->crc != 0 || local->comp_size != 0 || local->uncomp_size != 0))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct zip *
|
||||
_zip_allocate_new(const char *fn, unsigned int flags, int *zep)
|
||||
{
|
||||
struct zip *za;
|
||||
struct zip_error error;
|
||||
|
||||
if ((za=_zip_new(&error)) == NULL) {
|
||||
set_error(zep, &error, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fn == NULL)
|
||||
za->zn = NULL;
|
||||
else {
|
||||
za->zn = strdup(fn);
|
||||
if (!za->zn) {
|
||||
zip_discard(za);
|
||||
set_error(zep, NULL, ZIP_ER_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
za->open_flags = flags;
|
||||
return za;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
_zip_file_exists(const char *fn, unsigned int flags, int *zep)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (fn == NULL) {
|
||||
set_error(zep, NULL, ZIP_ER_INVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (stat(fn, &st) != 0) {
|
||||
if (flags & ZIP_CREATE)
|
||||
return 0;
|
||||
else {
|
||||
set_error(zep, NULL, ZIP_ER_OPEN);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if ((flags & ZIP_EXCL)) {
|
||||
set_error(zep, NULL, ZIP_ER_EXISTS);
|
||||
return -1;
|
||||
}
|
||||
/* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL,
|
||||
just like open() */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct zip_cdir *
|
||||
_zip_find_central_dir(FILE *fp, unsigned int flags, int *zep, off_t len)
|
||||
{
|
||||
struct zip_cdir *cdir, *cdirnew;
|
||||
unsigned char *buf, *match;
|
||||
off_t buf_offset;
|
||||
size_t buflen;
|
||||
zip_int64_t a, i;
|
||||
zip_int64_t best;
|
||||
struct zip_error zerr;
|
||||
|
||||
if (len < (off_t)EOCDLEN) {
|
||||
set_error(zep, NULL, ZIP_ER_NOZIP);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
i = fseeko(fp, -(len < CDBUFSIZE ? len : CDBUFSIZE), SEEK_END);
|
||||
if (i == -1 && errno != EFBIG) {
|
||||
/* seek before start of file on my machine */
|
||||
set_error(zep, NULL, ZIP_ER_SEEK);
|
||||
return NULL;
|
||||
}
|
||||
buf_offset = ftello(fp);
|
||||
|
||||
/* 64k is too much for stack */
|
||||
if ((buf=(unsigned char *)malloc(CDBUFSIZE)) == NULL) {
|
||||
set_error(zep, NULL, ZIP_ER_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
clearerr(fp);
|
||||
buflen = fread(buf, 1, CDBUFSIZE, fp);
|
||||
|
||||
if (ferror(fp)) {
|
||||
set_error(zep, NULL, ZIP_ER_READ);
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
best = -1;
|
||||
cdir = NULL;
|
||||
match = buf+ (buflen < CDBUFSIZE ? 0 : EOCD64LOCLEN);
|
||||
_zip_error_set(&zerr, ZIP_ER_NOZIP, 0);
|
||||
|
||||
while ((match=_zip_memmem(match, buflen-(size_t)(match-buf)-(EOCDLEN-4),
|
||||
(const unsigned char *)EOCD_MAGIC, 4))!=NULL) {
|
||||
/* found match -- check, if good */
|
||||
/* to avoid finding the same match all over again */
|
||||
match++;
|
||||
if ((cdirnew=_zip_readcdir(fp, buf_offset, buf, match-1, buflen, flags,
|
||||
&zerr)) == NULL)
|
||||
continue;
|
||||
|
||||
if (cdir) {
|
||||
if (best <= 0)
|
||||
best = _zip_checkcons(fp, cdir, &zerr);
|
||||
a = _zip_checkcons(fp, cdirnew, &zerr);
|
||||
if (best < a) {
|
||||
_zip_cdir_free(cdir);
|
||||
cdir = cdirnew;
|
||||
best = a;
|
||||
}
|
||||
else
|
||||
_zip_cdir_free(cdirnew);
|
||||
}
|
||||
else {
|
||||
cdir = cdirnew;
|
||||
if (flags & ZIP_CHECKCONS)
|
||||
best = _zip_checkcons(fp, cdir, &zerr);
|
||||
else
|
||||
best = 0;
|
||||
}
|
||||
cdirnew = NULL;
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
if (best < 0) {
|
||||
set_error(zep, &zerr, 0);
|
||||
_zip_cdir_free(cdir);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return cdir;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static unsigned char *
|
||||
_zip_memmem(const unsigned char *big, size_t biglen, const unsigned char *little, size_t littlelen)
|
||||
{
|
||||
const unsigned char *p;
|
||||
|
||||
if ((biglen < littlelen) || (littlelen == 0))
|
||||
return NULL;
|
||||
p = big-1;
|
||||
while ((p=(const unsigned char *)
|
||||
memchr(p+1, little[0], (size_t)(big-(p+1))+(size_t)(biglen-littlelen)+1)) != NULL) {
|
||||
if (memcmp(p+1, little+1, littlelen-1)==0)
|
||||
return (unsigned char *)p;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct zip_cdir *
|
||||
_zip_read_eocd(const unsigned char *eocd, const unsigned char *buf, off_t buf_offset, size_t buflen,
|
||||
unsigned int flags, struct zip_error *error)
|
||||
{
|
||||
struct zip_cdir *cd;
|
||||
const unsigned char *cdp;
|
||||
zip_uint64_t i, nentry, size, offset;
|
||||
|
||||
if (eocd+EOCDLEN > buf+buflen) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cdp = eocd + 8;
|
||||
|
||||
/* number of cdir-entries on this disk */
|
||||
i = _zip_read2(&cdp);
|
||||
/* number of cdir-entries */
|
||||
nentry = _zip_read2(&cdp);
|
||||
|
||||
if (nentry != i) {
|
||||
_zip_error_set(error, ZIP_ER_NOZIP, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size = _zip_read4(&cdp);
|
||||
offset = _zip_read4(&cdp);
|
||||
|
||||
if (size > ZIP_OFF_MAX || offset > ZIP_OFF_MAX || offset+size > ZIP_OFF_MAX) {
|
||||
_zip_error_set(error, ZIP_ER_SEEK, EFBIG);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (offset+size > (zip_uint64_t)(buf_offset + (eocd-buf))) {
|
||||
/* cdir spans past EOCD record */
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((flags & ZIP_CHECKCONS) && offset+size != (zip_uint64_t)(buf_offset + (eocd-buf))) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((cd=_zip_cdir_new(nentry, error)) == NULL)
|
||||
return NULL;
|
||||
|
||||
cd->size = (off_t)size;
|
||||
cd->offset = (off_t)offset;
|
||||
|
||||
return cd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct zip_cdir *
|
||||
_zip_read_eocd64(FILE *f, const zip_uint8_t *eocd64loc, const zip_uint8_t *buf,
|
||||
off_t buf_offset, size_t buflen, unsigned int flags, struct zip_error *error)
|
||||
{
|
||||
struct zip_cdir *cd;
|
||||
zip_uint64_t offset;
|
||||
const zip_uint8_t *cdp;
|
||||
zip_uint8_t eocd[EOCD64LEN];
|
||||
zip_uint64_t eocd_offset;
|
||||
zip_uint64_t size, nentry, i;
|
||||
|
||||
cdp = eocd64loc+8;
|
||||
eocd_offset = _zip_read8(&cdp);
|
||||
|
||||
if (eocd_offset > ZIP_OFF_MAX || eocd_offset + EOCD64LEN > ZIP_OFF_MAX) {
|
||||
_zip_error_set(error, ZIP_ER_SEEK, EFBIG);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (eocd64loc < buf || (off_t)eocd_offset+EOCD64LEN > (buf_offset+(eocd64loc-buf))) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((off_t)eocd_offset >= buf_offset && (off_t)eocd_offset+EOCD64LEN <= buf_offset+(ssize_t)buflen)
|
||||
cdp = buf+((off_t)eocd_offset-buf_offset);
|
||||
else {
|
||||
if (fseeko(f, (off_t)eocd_offset, SEEK_SET) != 0) {
|
||||
_zip_error_set(error, ZIP_ER_SEEK, errno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
clearerr(f);
|
||||
if (fread(eocd, 1, EOCD64LEN, f) < EOCD64LEN) {
|
||||
_zip_error_set(error, ZIP_ER_READ, errno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ferror(f)) {
|
||||
_zip_error_set(error, ZIP_ER_READ, errno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cdp = eocd;
|
||||
}
|
||||
|
||||
if (memcmp(cdp, EOCD64_MAGIC, 4) != 0) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
return NULL;
|
||||
}
|
||||
cdp += 4;
|
||||
|
||||
size = _zip_read8(&cdp);
|
||||
|
||||
if ((flags & ZIP_CHECKCONS) && size+eocd_offset+12 != (zip_uint64_t)(buf_offset+(eocd64loc-buf))) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cdp += 4; /* skip version made by/needed */
|
||||
cdp += 8; /* skip num disks */
|
||||
|
||||
nentry = _zip_read8(&cdp);
|
||||
i = _zip_read8(&cdp);
|
||||
|
||||
if (nentry != i) {
|
||||
_zip_error_set(error, ZIP_ER_MULTIDISK, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size = _zip_read8(&cdp);
|
||||
offset = _zip_read8(&cdp);
|
||||
|
||||
if (size > ZIP_OFF_MAX || offset > ZIP_OFF_MAX || offset+size > ZIP_OFF_MAX) {
|
||||
_zip_error_set(error, ZIP_ER_SEEK, EFBIG);
|
||||
return NULL;
|
||||
}
|
||||
if ((flags & ZIP_CHECKCONS) && offset+size != eocd_offset) {
|
||||
_zip_error_set(error, ZIP_ER_INCONS, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((cd=_zip_cdir_new(nentry, error)) == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
cd->size = (off_t)size;
|
||||
cd->offset = (off_t)offset;
|
||||
|
||||
return cd;
|
||||
}
|
||||
47
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_rename.c
vendored
Normal file
47
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_rename.c
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
zip_rename.c -- rename file in zip archive
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define _ZIP_COMPILING_DEPRECATED
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_rename(struct zip *za, zip_uint64_t idx, const char *name)
|
||||
{
|
||||
return zip_file_rename(za, idx, name, 0);
|
||||
}
|
||||
45
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_replace.c
vendored
Normal file
45
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_replace.c
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
zip_replace.c -- replace file via callback function
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define _ZIP_COMPILING_DEPRECATED
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_replace(struct zip *za, zip_uint64_t idx, struct zip_source *source)
|
||||
{
|
||||
return zip_file_replace(za, idx, source, 0);
|
||||
}
|
||||
84
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_set_archive_comment.c
vendored
Normal file
84
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_set_archive_comment.c
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
zip_set_archive_comment.c -- set archive comment
|
||||
Copyright (C) 2006-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_set_archive_comment(struct zip *za, const char *comment, zip_uint16_t len)
|
||||
{
|
||||
struct zip_string *cstr;
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (len > 0 && comment == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
if ((cstr=_zip_string_new((const zip_uint8_t *)comment, len, ZIP_FL_ENC_GUESS, &za->error)) == NULL)
|
||||
return -1;
|
||||
|
||||
if (_zip_guess_encoding(cstr, ZIP_ENCODING_UNKNOWN) == ZIP_ENCODING_CP437) {
|
||||
_zip_string_free(cstr);
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
cstr = NULL;
|
||||
|
||||
_zip_string_free(za->comment_changes);
|
||||
za->comment_changes = NULL;
|
||||
|
||||
if (((za->comment_orig && _zip_string_equal(za->comment_orig, cstr))
|
||||
|| (za->comment_orig == NULL && cstr == NULL))) {
|
||||
_zip_string_free(cstr);
|
||||
za->comment_changed = 0;
|
||||
}
|
||||
else {
|
||||
za->comment_changes = cstr;
|
||||
za->comment_changed = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
69
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_set_archive_flag.c
vendored
Normal file
69
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_set_archive_flag.c
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
zip_get_archive_flag.c -- set archive global flag
|
||||
Copyright (C) 2008-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_set_archive_flag(struct zip *za, zip_flags_t flag, int value)
|
||||
{
|
||||
unsigned int new_flags;
|
||||
|
||||
if (value)
|
||||
new_flags = za->ch_flags | flag;
|
||||
else
|
||||
new_flags = za->ch_flags & ~flag;
|
||||
|
||||
if (new_flags == za->ch_flags)
|
||||
return 0;
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((flag & ZIP_AFL_RDONLY) && value
|
||||
&& (za->ch_flags & ZIP_AFL_RDONLY) == 0) {
|
||||
if (_zip_changed(za, NULL)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
za->ch_flags = new_flags;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
zip_set_default_password.c -- set default password for decryption
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_set_default_password(struct zip *za, const char *passwd)
|
||||
{
|
||||
if (za == NULL)
|
||||
return -1;
|
||||
|
||||
if (za->default_password)
|
||||
free(za->default_password);
|
||||
|
||||
if (passwd) {
|
||||
if ((za->default_password=strdup(passwd)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
za->default_password = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
51
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_set_file_comment.c
vendored
Normal file
51
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_set_file_comment.c
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
zip_set_file_comment.c -- set comment for file in archive
|
||||
Copyright (C) 2006-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define _ZIP_COMPILING_DEPRECATED
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_set_file_comment(struct zip *za, zip_uint64_t idx, const char *comment, int len)
|
||||
{
|
||||
if (len < 0 || len > ZIP_UINT16_MAX) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
return zip_file_set_comment(za, idx, comment, (zip_uint16_t)len, 0);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
zip_set_file_compression.c -- set compression for file in archive
|
||||
Copyright (C) 2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_set_file_compression(struct zip *za, zip_uint64_t idx,
|
||||
zip_int32_t method, zip_uint32_t flags)
|
||||
{
|
||||
struct zip_entry *e;
|
||||
zip_int32_t old_method;
|
||||
|
||||
if (idx >= za->nentry) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (method != ZIP_CM_DEFAULT && method != ZIP_CM_STORE && method != ZIP_CM_DEFLATE) {
|
||||
_zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
e = za->entry+idx;
|
||||
|
||||
old_method = (e->orig == NULL ? ZIP_CM_DEFAULT : e->orig->comp_method);
|
||||
|
||||
/* TODO: revisit this when flags are supported, since they may require a recompression */
|
||||
|
||||
if (method == old_method) {
|
||||
if (e->changes) {
|
||||
e->changes->changed &= ~ZIP_DIRENT_COMP_METHOD;
|
||||
if (e->changes->changed == 0) {
|
||||
_zip_dirent_free(e->changes);
|
||||
e->changes = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (e->changes == NULL) {
|
||||
if ((e->changes=_zip_dirent_clone(e->orig)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
e->changes->comp_method = method;
|
||||
e->changes->changed |= ZIP_DIRENT_COMP_METHOD;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
117
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_set_name.c
vendored
Normal file
117
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_set_name.c
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
zip_set_name.c -- rename helper function
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
int
|
||||
_zip_set_name(struct zip *za, zip_uint64_t idx, const char *name, zip_flags_t flags)
|
||||
{
|
||||
struct zip_entry *e;
|
||||
struct zip_string *str;
|
||||
int changed;
|
||||
zip_int64_t i;
|
||||
|
||||
if (idx >= za->nentry) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ZIP_IS_RDONLY(za)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (name && strlen(name) > 0) {
|
||||
/* TODO: check for string too long */
|
||||
if ((str=_zip_string_new((const zip_uint8_t *)name, (zip_uint16_t)strlen(name), flags, &za->error)) == NULL)
|
||||
return -1;
|
||||
if ((flags & ZIP_FL_ENCODING_ALL) == ZIP_FL_ENC_GUESS && _zip_guess_encoding(str, ZIP_ENCODING_UNKNOWN) == ZIP_ENCODING_UTF8_GUESSED)
|
||||
str->encoding = ZIP_ENCODING_UTF8_KNOWN;
|
||||
}
|
||||
else
|
||||
str = NULL;
|
||||
|
||||
/* TODO: encoding flags needed for CP437? */
|
||||
if ((i=_zip_name_locate(za, name, 0, NULL)) >= 0 && (zip_uint64_t)i != idx) {
|
||||
_zip_string_free(str);
|
||||
_zip_error_set(&za->error, ZIP_ER_EXISTS, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* no effective name change */
|
||||
if (i>=0 && (zip_uint64_t)i == idx) {
|
||||
_zip_string_free(str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
e = za->entry+idx;
|
||||
|
||||
if (e->changes) {
|
||||
_zip_string_free(e->changes->filename);
|
||||
e->changes->filename = NULL;
|
||||
e->changes->changed &= ~ZIP_DIRENT_FILENAME;
|
||||
}
|
||||
|
||||
if (e->orig)
|
||||
changed = !_zip_string_equal(e->orig->filename, str);
|
||||
else
|
||||
changed = 1;
|
||||
|
||||
if (changed) {
|
||||
if (e->changes == NULL) {
|
||||
if ((e->changes=_zip_dirent_clone(e->orig)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
_zip_string_free(str);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
e->changes->filename = str;
|
||||
e->changes->changed |= ZIP_DIRENT_FILENAME;
|
||||
}
|
||||
else {
|
||||
_zip_string_free(str);
|
||||
if (e->changes && e->changes->changed == 0) {
|
||||
_zip_dirent_free(e->changes);
|
||||
e->changes = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
161
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_buffer.c
vendored
Normal file
161
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_buffer.c
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
zip_source_buffer.c -- create zip data source from buffer
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
struct read_data {
|
||||
const char *buf, *data, *end;
|
||||
time_t mtime;
|
||||
int freep;
|
||||
};
|
||||
|
||||
static zip_int64_t read_data(void *, void *, zip_uint64_t, enum zip_source_cmd);
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip_source *
|
||||
zip_source_buffer(struct zip *za, const void *data, zip_uint64_t len, int freep)
|
||||
{
|
||||
struct read_data *f;
|
||||
struct zip_source *zs;
|
||||
|
||||
if (za == NULL)
|
||||
return NULL;
|
||||
|
||||
if (data == NULL && len > 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((f=(struct read_data *)malloc(sizeof(*f))) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f->data = (const char *)data;
|
||||
f->end = ((const char *)data)+len;
|
||||
f->freep = freep;
|
||||
f->mtime = time(NULL);
|
||||
|
||||
if ((zs=zip_source_function(za, read_data, f)) == NULL) {
|
||||
free(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return zs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_int64_t
|
||||
read_data(void *state, void *data, zip_uint64_t len, enum zip_source_cmd cmd)
|
||||
{
|
||||
struct read_data *z;
|
||||
char *buf;
|
||||
zip_uint64_t n;
|
||||
|
||||
z = (struct read_data *)state;
|
||||
buf = (char *)data;
|
||||
|
||||
switch (cmd) {
|
||||
case ZIP_SOURCE_OPEN:
|
||||
z->buf = z->data;
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_READ:
|
||||
n = (zip_uint64_t)(z->end - z->buf);
|
||||
if (n > len)
|
||||
n = len;
|
||||
|
||||
if (n) {
|
||||
memcpy(buf, z->buf, (size_t)n);
|
||||
z->buf += n;
|
||||
}
|
||||
|
||||
return (zip_int64_t)n;
|
||||
|
||||
case ZIP_SOURCE_CLOSE:
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_STAT:
|
||||
{
|
||||
struct zip_stat *st;
|
||||
|
||||
if (len < sizeof(*st))
|
||||
return -1;
|
||||
|
||||
st = (struct zip_stat *)data;
|
||||
|
||||
zip_stat_init(st);
|
||||
st->mtime = z->mtime;
|
||||
st->size = (zip_uint64_t)(z->end - z->data);
|
||||
st->comp_size = st->size;
|
||||
st->comp_method = ZIP_CM_STORE;
|
||||
st->encryption_method = ZIP_EM_NONE;
|
||||
st->valid = ZIP_STAT_MTIME|ZIP_STAT_SIZE|ZIP_STAT_COMP_SIZE
|
||||
|ZIP_STAT_COMP_METHOD|ZIP_STAT_ENCRYPTION_METHOD;
|
||||
|
||||
return sizeof(*st);
|
||||
}
|
||||
|
||||
case ZIP_SOURCE_ERROR:
|
||||
{
|
||||
int *e;
|
||||
|
||||
if (len < sizeof(int)*2)
|
||||
return -1;
|
||||
|
||||
e = (int *)data;
|
||||
e[0] = e[1] = 0;
|
||||
}
|
||||
return sizeof(int)*2;
|
||||
|
||||
case ZIP_SOURCE_FREE:
|
||||
if (z->freep) {
|
||||
free((void *)z->data);
|
||||
z->data = NULL;
|
||||
}
|
||||
free(z);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
54
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_close.c
vendored
Normal file
54
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_close.c
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
zip_source_close.c -- close zip_source (stop reading)
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
void
|
||||
zip_source_close(struct zip_source *src)
|
||||
{
|
||||
if (!src->is_open)
|
||||
return;
|
||||
|
||||
if (src->src == NULL)
|
||||
(void)src->cb.f(src->ud, NULL, 0, ZIP_SOURCE_CLOSE);
|
||||
else {
|
||||
(void)src->cb.l(src->src, src->ud, NULL, 0, ZIP_SOURCE_CLOSE);
|
||||
zip_source_close(src->src);
|
||||
}
|
||||
|
||||
src->is_open = 0;
|
||||
}
|
||||
166
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_crc.c
vendored
Normal file
166
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_crc.c
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
zip_source_crc.c -- pass-through source that calculates CRC32 and size
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
struct crc_context {
|
||||
int eof;
|
||||
int validate;
|
||||
int e[2];
|
||||
zip_uint64_t size;
|
||||
zip_uint32_t crc;
|
||||
};
|
||||
|
||||
static zip_int64_t crc_read(struct zip_source *, void *, void *
|
||||
, zip_uint64_t, enum zip_source_cmd);
|
||||
|
||||
|
||||
|
||||
struct zip_source *
|
||||
zip_source_crc(struct zip *za, struct zip_source *src, int validate)
|
||||
{
|
||||
struct crc_context *ctx;
|
||||
|
||||
if (src == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ctx=(struct crc_context *)malloc(sizeof(*ctx))) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->eof = 0;
|
||||
ctx->validate = validate;
|
||||
ctx->e[0] = ctx->e[1] = 0;
|
||||
ctx->size = 0;
|
||||
ctx->crc = 0;
|
||||
|
||||
return zip_source_layered(za, src, crc_read, ctx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_int64_t
|
||||
crc_read(struct zip_source *src, void *_ctx, void *data,
|
||||
zip_uint64_t len, enum zip_source_cmd cmd)
|
||||
{
|
||||
struct crc_context *ctx;
|
||||
zip_int64_t n;
|
||||
|
||||
ctx = (struct crc_context *)_ctx;
|
||||
|
||||
switch (cmd) {
|
||||
case ZIP_SOURCE_OPEN:
|
||||
ctx->eof = 0;
|
||||
ctx->crc = (zip_uint32_t)crc32(0, NULL, 0);
|
||||
ctx->size = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_READ:
|
||||
if (ctx->eof || len == 0)
|
||||
return 0;
|
||||
|
||||
if ((n=zip_source_read(src, data, len)) < 0)
|
||||
return ZIP_SOURCE_ERR_LOWER;
|
||||
|
||||
if (n == 0) {
|
||||
ctx->eof = 1;
|
||||
if (ctx->validate) {
|
||||
struct zip_stat st;
|
||||
|
||||
if (zip_source_stat(src, &st) < 0)
|
||||
return ZIP_SOURCE_ERR_LOWER;
|
||||
|
||||
if ((st.valid & ZIP_STAT_CRC) && st.crc != ctx->crc) {
|
||||
ctx->e[0] = ZIP_ER_CRC;
|
||||
ctx->e[1] = 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
if ((st.valid & ZIP_STAT_SIZE) && st.size != ctx->size) {
|
||||
ctx->e[0] = ZIP_ER_INCONS;
|
||||
ctx->e[1] = 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ctx->size += (zip_uint64_t)n;
|
||||
ctx->crc = (zip_uint32_t)crc32(ctx->crc, (const Bytef *)data, (uInt)n); /* TODO: check for overflow, use multiple crc calls if needed */
|
||||
}
|
||||
return n;
|
||||
|
||||
case ZIP_SOURCE_CLOSE:
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_STAT:
|
||||
{
|
||||
struct zip_stat *st;
|
||||
|
||||
st = (struct zip_stat *)data;
|
||||
|
||||
if (ctx->eof) {
|
||||
/* TODO: Set comp_size, comp_method, encryption_method?
|
||||
After all, this only works for uncompressed data. */
|
||||
st->size = ctx->size;
|
||||
st->crc = ctx->crc;
|
||||
st->comp_size = ctx->size;
|
||||
st->comp_method = ZIP_CM_STORE;
|
||||
st->encryption_method = ZIP_EM_NONE;
|
||||
st->valid |= ZIP_STAT_SIZE|ZIP_STAT_CRC|ZIP_STAT_COMP_SIZE|ZIP_STAT_COMP_METHOD|ZIP_STAT_ENCRYPTION_METHOD;;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_ERROR:
|
||||
memcpy(data, ctx->e, sizeof(ctx->e));
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_FREE:
|
||||
free(ctx);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
392
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_deflate.c
vendored
Normal file
392
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_deflate.c
vendored
Normal file
@@ -0,0 +1,392 @@
|
||||
/*
|
||||
zip_source_deflate.c -- deflate (de)compressoin routines
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
struct deflate {
|
||||
int e[2];
|
||||
|
||||
int eof;
|
||||
int mem_level;
|
||||
zip_uint64_t size;
|
||||
char buffer[BUFSIZE];
|
||||
z_stream zstr;
|
||||
};
|
||||
|
||||
static zip_int64_t compress_read(struct zip_source *, struct deflate *,
|
||||
void *, zip_uint64_t);
|
||||
static zip_int64_t decompress_read(struct zip_source *, struct deflate *,
|
||||
void *, zip_uint64_t);
|
||||
static zip_int64_t deflate_compress(struct zip_source *, void *, void *,
|
||||
zip_uint64_t, enum zip_source_cmd);
|
||||
static zip_int64_t deflate_decompress(struct zip_source *, void *, void *,
|
||||
zip_uint64_t, enum zip_source_cmd);
|
||||
static void deflate_free(struct deflate *);
|
||||
|
||||
|
||||
|
||||
struct zip_source *
|
||||
zip_source_deflate(struct zip *za, struct zip_source *src,
|
||||
zip_int32_t cm, int flags)
|
||||
{
|
||||
struct deflate *ctx;
|
||||
struct zip_source *s2;
|
||||
|
||||
if (src == NULL || (cm != ZIP_CM_DEFLATE && !ZIP_CM_IS_DEFAULT(cm))) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ctx=(struct deflate *)malloc(sizeof(*ctx))) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->e[0] = ctx->e[1] = 0;
|
||||
ctx->eof = 0;
|
||||
if (flags & ZIP_CODEC_ENCODE) {
|
||||
if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
|
||||
ctx->mem_level = TORRENT_MEM_LEVEL;
|
||||
else
|
||||
ctx->mem_level = MAX_MEM_LEVEL;
|
||||
}
|
||||
|
||||
if ((s2=zip_source_layered(za, src,
|
||||
((flags & ZIP_CODEC_ENCODE)
|
||||
? deflate_compress : deflate_decompress),
|
||||
ctx)) == NULL) {
|
||||
deflate_free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return s2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_int64_t
|
||||
compress_read(struct zip_source *src, struct deflate *ctx,
|
||||
void *data, zip_uint64_t len)
|
||||
{
|
||||
int end, ret;
|
||||
zip_int64_t n;
|
||||
|
||||
if (ctx->e[0] != 0)
|
||||
return -1;
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
ctx->zstr.next_out = (Bytef *)data;
|
||||
ctx->zstr.avail_out = (uInt)len; /* TODO: check for overflow */
|
||||
|
||||
end = 0;
|
||||
while (!end) {
|
||||
ret = deflate(&ctx->zstr, ctx->eof ? Z_FINISH : 0);
|
||||
|
||||
switch (ret) {
|
||||
case Z_OK:
|
||||
case Z_STREAM_END:
|
||||
/* all ok */
|
||||
|
||||
if (ctx->zstr.avail_out == 0
|
||||
|| (ctx->eof && ctx->zstr.avail_in == 0))
|
||||
end = 1;
|
||||
break;
|
||||
|
||||
case Z_BUF_ERROR:
|
||||
if (ctx->zstr.avail_in == 0) {
|
||||
if (ctx->eof) {
|
||||
end = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((n=zip_source_read(src, ctx->buffer, sizeof(ctx->buffer))) < 0) {
|
||||
zip_source_error(src, ctx->e, ctx->e+1);
|
||||
end = 1;
|
||||
break;
|
||||
}
|
||||
else if (n == 0) {
|
||||
ctx->eof = 1;
|
||||
ctx->size = ctx->zstr.total_in;
|
||||
/* TODO: check against stat of src? */
|
||||
}
|
||||
else {
|
||||
ctx->zstr.next_in = (Bytef *)ctx->buffer;
|
||||
ctx->zstr.avail_in = (uInt)n;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/* fallthrough */
|
||||
case Z_NEED_DICT:
|
||||
case Z_DATA_ERROR:
|
||||
case Z_STREAM_ERROR:
|
||||
case Z_MEM_ERROR:
|
||||
ctx->e[0] = ZIP_ER_ZLIB;
|
||||
ctx->e[1] = ret;
|
||||
|
||||
end = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->zstr.avail_out < len)
|
||||
return (zip_int64_t)(len - ctx->zstr.avail_out);
|
||||
|
||||
return (ctx->e[0] == 0) ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_int64_t
|
||||
decompress_read(struct zip_source *src, struct deflate *ctx,
|
||||
void *data, zip_uint64_t len)
|
||||
{
|
||||
int end, ret;
|
||||
zip_int64_t n;
|
||||
|
||||
if (ctx->e[0] != 0)
|
||||
return -1;
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
ctx->zstr.next_out = (Bytef *)data;
|
||||
ctx->zstr.avail_out = (uInt)len; /* TODO: check for overflow */
|
||||
|
||||
end = 0;
|
||||
while (!end && ctx->zstr.avail_out) {
|
||||
ret = inflate(&ctx->zstr, Z_SYNC_FLUSH);
|
||||
|
||||
switch (ret) {
|
||||
case Z_OK:
|
||||
break;
|
||||
|
||||
case Z_STREAM_END:
|
||||
ctx->eof = 1;
|
||||
end = 1;
|
||||
break;
|
||||
|
||||
case Z_BUF_ERROR:
|
||||
if (ctx->zstr.avail_in == 0) {
|
||||
if (ctx->eof) {
|
||||
end = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((n=zip_source_read(src, ctx->buffer, sizeof(ctx->buffer))) < 0) {
|
||||
zip_source_error(src, ctx->e, ctx->e+1);
|
||||
end = 1;
|
||||
break;
|
||||
}
|
||||
else if (n == 0)
|
||||
ctx->eof = 1;
|
||||
else {
|
||||
ctx->zstr.next_in = (Bytef *)ctx->buffer;
|
||||
ctx->zstr.avail_in = (uInt)n;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/* fallthrough */
|
||||
case Z_NEED_DICT:
|
||||
case Z_DATA_ERROR:
|
||||
case Z_STREAM_ERROR:
|
||||
case Z_MEM_ERROR:
|
||||
ctx->e[0] = ZIP_ER_ZLIB;
|
||||
ctx->e[1] = ret;
|
||||
end = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->zstr.avail_out < len)
|
||||
return (zip_int64_t)(len - ctx->zstr.avail_out);
|
||||
|
||||
return (ctx->e[0] == 0) ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_int64_t
|
||||
deflate_compress(struct zip_source *src, void *ud, void *data,
|
||||
zip_uint64_t len, enum zip_source_cmd cmd)
|
||||
{
|
||||
struct deflate *ctx;
|
||||
int ret;
|
||||
|
||||
ctx = (struct deflate *)ud;
|
||||
|
||||
switch (cmd) {
|
||||
case ZIP_SOURCE_OPEN:
|
||||
ctx->zstr.zalloc = Z_NULL;
|
||||
ctx->zstr.zfree = Z_NULL;
|
||||
ctx->zstr.opaque = NULL;
|
||||
ctx->zstr.avail_in = 0;
|
||||
ctx->zstr.next_in = NULL;
|
||||
ctx->zstr.avail_out = 0;
|
||||
ctx->zstr.next_out = NULL;
|
||||
|
||||
/* negative value to tell zlib not to write a header */
|
||||
if ((ret=deflateInit2(&ctx->zstr, Z_BEST_COMPRESSION, Z_DEFLATED,
|
||||
-MAX_WBITS, ctx->mem_level,
|
||||
Z_DEFAULT_STRATEGY)) != Z_OK) {
|
||||
ctx->e[0] = ZIP_ER_ZLIB;
|
||||
ctx->e[1] = ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_READ:
|
||||
return compress_read(src, ctx, data, len);
|
||||
|
||||
case ZIP_SOURCE_CLOSE:
|
||||
deflateEnd(&ctx->zstr);
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_STAT:
|
||||
{
|
||||
struct zip_stat *st;
|
||||
|
||||
st = (struct zip_stat *)data;
|
||||
|
||||
st->comp_method = ZIP_CM_DEFLATE;
|
||||
st->valid |= ZIP_STAT_COMP_METHOD;
|
||||
if (ctx->eof) {
|
||||
st->comp_size = ctx->size;
|
||||
st->valid |= ZIP_STAT_COMP_SIZE;
|
||||
}
|
||||
else
|
||||
st->valid &= ~ZIP_STAT_COMP_SIZE;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_ERROR:
|
||||
memcpy(data, ctx->e, sizeof(int)*2);
|
||||
return sizeof(int)*2;
|
||||
|
||||
case ZIP_SOURCE_FREE:
|
||||
deflate_free(ctx);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
ctx->e[0] = ZIP_ER_INVAL;
|
||||
ctx->e[1] = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_int64_t
|
||||
deflate_decompress(struct zip_source *src, void *ud, void *data,
|
||||
zip_uint64_t len, enum zip_source_cmd cmd)
|
||||
{
|
||||
struct deflate *ctx;
|
||||
zip_int64_t n;
|
||||
int ret;
|
||||
|
||||
ctx = (struct deflate *)ud;
|
||||
|
||||
switch (cmd) {
|
||||
case ZIP_SOURCE_OPEN:
|
||||
if ((n=zip_source_read(src, ctx->buffer, sizeof(ctx->buffer))) < 0)
|
||||
return ZIP_SOURCE_ERR_LOWER;
|
||||
|
||||
ctx->zstr.zalloc = Z_NULL;
|
||||
ctx->zstr.zfree = Z_NULL;
|
||||
ctx->zstr.opaque = NULL;
|
||||
ctx->zstr.next_in = (Bytef *)ctx->buffer;
|
||||
ctx->zstr.avail_in = (uInt)n /* TODO: check for overflow */;
|
||||
|
||||
/* negative value to tell zlib that there is no header */
|
||||
if ((ret=inflateInit2(&ctx->zstr, -MAX_WBITS)) != Z_OK) {
|
||||
ctx->e[0] = ZIP_ER_ZLIB;
|
||||
ctx->e[1] = ret;
|
||||
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_READ:
|
||||
return decompress_read(src, ctx, data, len);
|
||||
|
||||
case ZIP_SOURCE_CLOSE:
|
||||
inflateEnd(&ctx->zstr);
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_STAT:
|
||||
{
|
||||
struct zip_stat *st;
|
||||
|
||||
st = (struct zip_stat *)data;
|
||||
|
||||
st->comp_method = ZIP_CM_STORE;
|
||||
if (st->comp_size > 0 && st->size > 0)
|
||||
st->comp_size = st->size;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_ERROR:
|
||||
if (len < sizeof(int)*2)
|
||||
return -1;
|
||||
|
||||
memcpy(data, ctx->e, sizeof(int)*2);
|
||||
return sizeof(int)*2;
|
||||
|
||||
case ZIP_SOURCE_FREE:
|
||||
/* TODO: inflateEnd if close was not called */
|
||||
free(ctx);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
ctx->e[0] = ZIP_ER_INVAL;
|
||||
ctx->e[1] = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
deflate_free(struct deflate *ctx)
|
||||
{
|
||||
/* TODO: deflateEnd if close was not called */
|
||||
free(ctx);
|
||||
}
|
||||
84
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_error.c
vendored
Normal file
84
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_error.c
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
zip_source_error.c -- get last error from zip_source
|
||||
Copyright (C) 2009-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
void
|
||||
zip_source_error(struct zip_source *src, int *ze, int *se)
|
||||
{
|
||||
int e[2];
|
||||
|
||||
if (src->src == NULL) {
|
||||
if (src->cb.f(src->ud, e, sizeof(e), ZIP_SOURCE_ERROR) < 0) {
|
||||
e[0] = ZIP_ER_INTERNAL;
|
||||
e[1] = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (src->error_source) {
|
||||
case ZIP_LES_NONE:
|
||||
e[0] = e[1] = 0;
|
||||
break;
|
||||
|
||||
case ZIP_LES_INVAL:
|
||||
e[0] = ZIP_ER_INVAL;
|
||||
e[1] = 0;
|
||||
break;
|
||||
|
||||
case ZIP_LES_LOWER:
|
||||
zip_source_error(src->src, ze, se);
|
||||
return;
|
||||
|
||||
case ZIP_LES_UPPER:
|
||||
if (src->cb.l(src->src, src->ud, e, sizeof(e), ZIP_SOURCE_ERROR) < 0) {
|
||||
e[0] = ZIP_ER_INTERNAL;
|
||||
e[1] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
e[0] = ZIP_ER_INTERNAL;
|
||||
e[1] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ze)
|
||||
*ze = e[0];
|
||||
if (se)
|
||||
*se = e[1];
|
||||
}
|
||||
56
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_file.c
vendored
Normal file
56
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_file.c
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
zip_source_file.c -- create data source from file
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip_source *
|
||||
zip_source_file(struct zip *za, const char *fname, zip_uint64_t start,
|
||||
zip_int64_t len)
|
||||
{
|
||||
if (za == NULL)
|
||||
return NULL;
|
||||
|
||||
if (fname == NULL || len < -1) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _zip_source_file_or_p(za, fname, NULL, start, len, 1, NULL);
|
||||
}
|
||||
251
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_filep.c
vendored
Normal file
251
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_filep.c
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
zip_source_filep.c -- create data source from FILE *
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
struct read_file {
|
||||
char *fname; /* name of file to copy from */
|
||||
FILE *f; /* file to copy from */
|
||||
int closep; /* close f */
|
||||
struct zip_stat st; /* stat information passed in */
|
||||
|
||||
zip_uint64_t off; /* start offset of */
|
||||
zip_int64_t len; /* length of data to copy */
|
||||
zip_int64_t remain; /* bytes remaining to be copied */
|
||||
int e[2]; /* error codes */
|
||||
};
|
||||
|
||||
static zip_int64_t read_file(void *state, void *data, zip_uint64_t len,
|
||||
enum zip_source_cmd cmd);
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip_source *
|
||||
zip_source_filep(struct zip *za, FILE *file, zip_uint64_t start,
|
||||
zip_int64_t len)
|
||||
{
|
||||
if (za == NULL)
|
||||
return NULL;
|
||||
|
||||
if (file == NULL || len < -1) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _zip_source_file_or_p(za, NULL, file, start, len, 1, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct zip_source *
|
||||
_zip_source_file_or_p(struct zip *za, const char *fname, FILE *file,
|
||||
zip_uint64_t start, zip_int64_t len, int closep,
|
||||
const struct zip_stat *st)
|
||||
{
|
||||
struct read_file *f;
|
||||
struct zip_source *zs;
|
||||
|
||||
if (file == NULL && fname == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((f=(struct read_file *)malloc(sizeof(struct read_file))) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f->fname = NULL;
|
||||
if (fname) {
|
||||
if ((f->fname=strdup(fname)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
free(f);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
f->f = file;
|
||||
f->off = start;
|
||||
f->len = (len ? len : -1);
|
||||
f->closep = f->fname ? 1 : closep;
|
||||
if (st)
|
||||
memcpy(&f->st, st, sizeof(f->st));
|
||||
else
|
||||
zip_stat_init(&f->st);
|
||||
|
||||
if ((zs=zip_source_function(za, read_file, f)) == NULL) {
|
||||
free(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return zs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_int64_t
|
||||
read_file(void *state, void *data, zip_uint64_t len, enum zip_source_cmd cmd)
|
||||
{
|
||||
struct read_file *z;
|
||||
char *buf;
|
||||
zip_uint64_t n;
|
||||
size_t i;
|
||||
|
||||
z = (struct read_file *)state;
|
||||
buf = (char *)data;
|
||||
|
||||
switch (cmd) {
|
||||
case ZIP_SOURCE_OPEN:
|
||||
if (z->fname) {
|
||||
if ((z->f=fopen(z->fname, "rb")) == NULL) {
|
||||
z->e[0] = ZIP_ER_OPEN;
|
||||
z->e[1] = errno;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (z->closep && z->off > 0) {
|
||||
if (fseeko(z->f, (off_t)z->off, SEEK_SET) < 0) {
|
||||
z->e[0] = ZIP_ER_SEEK;
|
||||
z->e[1] = errno;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
z->remain = z->len;
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_READ:
|
||||
if (z->remain != -1)
|
||||
n = len > (zip_uint64_t)z->remain ? (zip_uint64_t)z->remain : len;
|
||||
else
|
||||
n = len;
|
||||
|
||||
if (n > SIZE_MAX)
|
||||
n = SIZE_MAX;
|
||||
|
||||
if (!z->closep) {
|
||||
/* we might share this file with others, so let's be safe */
|
||||
if (fseeko(z->f, (off_t)(z->off + (zip_uint64_t)(z->len-z->remain)), SEEK_SET) < 0) {
|
||||
z->e[0] = ZIP_ER_SEEK;
|
||||
z->e[1] = errno;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((i=fread(buf, 1, (size_t)n, z->f)) == 0) {
|
||||
if (ferror(z->f)) {
|
||||
z->e[0] = ZIP_ER_READ;
|
||||
z->e[1] = errno;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (z->remain != -1)
|
||||
z->remain -= i;
|
||||
|
||||
return (zip_int64_t)i;
|
||||
|
||||
case ZIP_SOURCE_CLOSE:
|
||||
if (z->fname) {
|
||||
fclose(z->f);
|
||||
z->f = NULL;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_STAT:
|
||||
{
|
||||
if (len < sizeof(z->st))
|
||||
return -1;
|
||||
|
||||
if (z->st.valid != 0)
|
||||
memcpy(data, &z->st, sizeof(z->st));
|
||||
else {
|
||||
struct zip_stat *st;
|
||||
struct stat fst;
|
||||
int err;
|
||||
|
||||
if (z->f)
|
||||
err = fstat(fileno(z->f), &fst);
|
||||
else
|
||||
err = stat(z->fname, &fst);
|
||||
|
||||
if (err != 0) {
|
||||
z->e[0] = ZIP_ER_READ; /* best match */
|
||||
z->e[1] = errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
st = (struct zip_stat *)data;
|
||||
|
||||
zip_stat_init(st);
|
||||
st->mtime = fst.st_mtime;
|
||||
st->valid |= ZIP_STAT_MTIME;
|
||||
if (z->len != -1) {
|
||||
st->size = (zip_uint64_t)z->len;
|
||||
st->valid |= ZIP_STAT_SIZE;
|
||||
}
|
||||
else if ((fst.st_mode&S_IFMT) == S_IFREG) {
|
||||
st->size = (zip_uint64_t)fst.st_size;
|
||||
st->valid |= ZIP_STAT_SIZE;
|
||||
}
|
||||
}
|
||||
return sizeof(z->st);
|
||||
}
|
||||
|
||||
case ZIP_SOURCE_ERROR:
|
||||
if (len < sizeof(int)*2)
|
||||
return -1;
|
||||
|
||||
memcpy(data, z->e, sizeof(int)*2);
|
||||
return sizeof(int)*2;
|
||||
|
||||
case ZIP_SOURCE_FREE:
|
||||
free(z->fname);
|
||||
if (z->closep && z->f)
|
||||
fclose(z->f);
|
||||
free(z);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
59
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_free.c
vendored
Normal file
59
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_free.c
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
zip_source_free.c -- free zip data source
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN void
|
||||
zip_source_free(struct zip_source *src)
|
||||
{
|
||||
if (src == NULL)
|
||||
return;
|
||||
|
||||
if (src->is_open)
|
||||
zip_source_close(src);
|
||||
|
||||
if (src->src == NULL)
|
||||
(void)src->cb.f(src->ud, NULL, 0, ZIP_SOURCE_FREE);
|
||||
else {
|
||||
(void)src->cb.l(src->src, src->ud, NULL, 0, ZIP_SOURCE_FREE);
|
||||
zip_source_free(src->src);
|
||||
}
|
||||
|
||||
free(src);
|
||||
}
|
||||
78
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_function.c
vendored
Normal file
78
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_function.c
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
zip_source_function.c -- create zip data source from callback function
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip_source *
|
||||
zip_source_function(struct zip *za, zip_source_callback zcb, void *ud)
|
||||
{
|
||||
struct zip_source *zs;
|
||||
|
||||
if (za == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((zs=_zip_source_new(za)) == NULL)
|
||||
return NULL;
|
||||
|
||||
zs->cb.f = zcb;
|
||||
zs->ud = ud;
|
||||
|
||||
return zs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct zip_source *
|
||||
_zip_source_new(struct zip *za)
|
||||
{
|
||||
struct zip_source *src;
|
||||
|
||||
if ((src=(struct zip_source *)malloc(sizeof(*src))) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
src->src = NULL;
|
||||
src->cb.f = NULL;
|
||||
src->ud = NULL;
|
||||
src->error_source = ZIP_LES_NONE;
|
||||
src->is_open = 0;
|
||||
|
||||
return src;
|
||||
}
|
||||
59
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_layered.c
vendored
Normal file
59
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_layered.c
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
zip_source_layered.c -- create layered source
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
struct zip_source *
|
||||
zip_source_layered(struct zip *za, struct zip_source *src,
|
||||
zip_source_layered_callback cb, void *ud)
|
||||
{
|
||||
struct zip_source *zs;
|
||||
|
||||
if (za == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((zs=_zip_source_new(za)) == NULL)
|
||||
return NULL;
|
||||
|
||||
zs->src = src;
|
||||
zs->cb.l = cb;
|
||||
zs->ud = ud;
|
||||
|
||||
return zs;
|
||||
}
|
||||
76
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_open.c
vendored
Normal file
76
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_open.c
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
zip_source_open.c -- open zip_source (prepare for reading)
|
||||
Copyright (C) 2009-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
int
|
||||
zip_source_open(struct zip_source *src)
|
||||
{
|
||||
zip_int64_t ret;
|
||||
|
||||
if (src->is_open) {
|
||||
src->error_source = ZIP_LES_INVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (src->src == NULL) {
|
||||
if (src->cb.f(src->ud, NULL, 0, ZIP_SOURCE_OPEN) < 0)
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
if (zip_source_open(src->src) < 0) {
|
||||
src->error_source = ZIP_LES_LOWER;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = src->cb.l(src->src, src->ud, NULL, 0, ZIP_SOURCE_OPEN);
|
||||
|
||||
if (ret < 0) {
|
||||
zip_source_close(src->src);
|
||||
|
||||
if (ret == ZIP_SOURCE_ERR_LOWER)
|
||||
src->error_source = ZIP_LES_LOWER;
|
||||
else
|
||||
src->error_source = ZIP_LES_UPPER;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
src->is_open = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
234
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_pkware.c
vendored
Normal file
234
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_pkware.c
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
zip_source_pkware.c -- Traditional PKWARE de/encryption routines
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
struct trad_pkware {
|
||||
int e[2];
|
||||
|
||||
zip_uint32_t key[3];
|
||||
};
|
||||
|
||||
#define HEADERLEN 12
|
||||
#define KEY0 305419896
|
||||
#define KEY1 591751049
|
||||
#define KEY2 878082192
|
||||
|
||||
|
||||
|
||||
static void decrypt(struct trad_pkware *, zip_uint8_t *,
|
||||
const zip_uint8_t *, zip_uint64_t, int);
|
||||
static int decrypt_header(struct zip_source *, struct trad_pkware *);
|
||||
static zip_int64_t pkware_decrypt(struct zip_source *, void *, void *,
|
||||
zip_uint64_t, enum zip_source_cmd);
|
||||
static void pkware_free(struct trad_pkware *);
|
||||
|
||||
|
||||
|
||||
struct zip_source *
|
||||
zip_source_pkware(struct zip *za, struct zip_source *src,
|
||||
zip_uint16_t em, int flags, const char *password)
|
||||
{
|
||||
struct trad_pkware *ctx;
|
||||
struct zip_source *s2;
|
||||
|
||||
if (password == NULL || src == NULL || em != ZIP_EM_TRAD_PKWARE) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
if (flags & ZIP_CODEC_ENCODE) {
|
||||
_zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ctx=(struct trad_pkware *)malloc(sizeof(*ctx))) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->e[0] = ctx->e[1] = 0;
|
||||
|
||||
ctx->key[0] = KEY0;
|
||||
ctx->key[1] = KEY1;
|
||||
ctx->key[2] = KEY2;
|
||||
decrypt(ctx, NULL, (const zip_uint8_t *)password, strlen(password), 1);
|
||||
|
||||
if ((s2=zip_source_layered(za, src, pkware_decrypt, ctx)) == NULL) {
|
||||
pkware_free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return s2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
decrypt(struct trad_pkware *ctx, zip_uint8_t *out, const zip_uint8_t *in,
|
||||
zip_uint64_t len, int update_only)
|
||||
{
|
||||
zip_uint16_t tmp;
|
||||
zip_uint64_t i;
|
||||
Bytef b;
|
||||
|
||||
for (i=0; i<len; i++) {
|
||||
b = in[i];
|
||||
|
||||
if (!update_only) {
|
||||
/* decrypt next byte */
|
||||
tmp = (zip_uint16_t)(ctx->key[2] | 2);
|
||||
tmp = (tmp * (tmp ^ 1)) >> 8;
|
||||
b ^= tmp;
|
||||
}
|
||||
|
||||
/* store cleartext */
|
||||
if (out)
|
||||
out[i] = b;
|
||||
|
||||
/* update keys */
|
||||
ctx->key[0] = (zip_uint32_t)crc32(ctx->key[0] ^ 0xffffffffUL, &b, 1) ^ 0xffffffffUL;
|
||||
ctx->key[1] = (ctx->key[1] + (ctx->key[0] & 0xff)) * 134775813 + 1;
|
||||
b = ctx->key[1] >> 24;
|
||||
ctx->key[2] = (zip_uint32_t)crc32(ctx->key[2] ^ 0xffffffffUL, &b, 1) ^ 0xffffffffUL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
decrypt_header(struct zip_source *src, struct trad_pkware *ctx)
|
||||
{
|
||||
zip_uint8_t header[HEADERLEN];
|
||||
struct zip_stat st;
|
||||
zip_int64_t n;
|
||||
unsigned short dostime, dosdate;
|
||||
|
||||
if ((n=zip_source_read(src, header, HEADERLEN)) < 0) {
|
||||
zip_source_error(src, ctx->e, ctx->e+1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n != HEADERLEN) {
|
||||
ctx->e[0] = ZIP_ER_EOF;
|
||||
ctx->e[1] = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
decrypt(ctx, header, header, HEADERLEN, 0);
|
||||
|
||||
if (zip_source_stat(src, &st) < 0) {
|
||||
/* stat failed, skip password validation */
|
||||
return 0;
|
||||
}
|
||||
|
||||
_zip_u2d_time(st.mtime, &dostime, &dosdate);
|
||||
|
||||
if (header[HEADERLEN-1] != st.crc>>24
|
||||
&& header[HEADERLEN-1] != dostime>>8) {
|
||||
ctx->e[0] = ZIP_ER_WRONGPASSWD;
|
||||
ctx->e[1] = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_int64_t
|
||||
pkware_decrypt(struct zip_source *src, void *ud, void *data,
|
||||
zip_uint64_t len, enum zip_source_cmd cmd)
|
||||
{
|
||||
struct trad_pkware *ctx;
|
||||
zip_int64_t n;
|
||||
|
||||
ctx = (struct trad_pkware *)ud;
|
||||
|
||||
switch (cmd) {
|
||||
case ZIP_SOURCE_OPEN:
|
||||
if (decrypt_header(src, ctx) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_READ:
|
||||
if ((n=zip_source_read(src, data, len)) < 0)
|
||||
return ZIP_SOURCE_ERR_LOWER;
|
||||
|
||||
decrypt((struct trad_pkware *)ud, (zip_uint8_t *)data, (zip_uint8_t *)data, (zip_uint64_t)n,
|
||||
0);
|
||||
return n;
|
||||
|
||||
case ZIP_SOURCE_CLOSE:
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_STAT:
|
||||
{
|
||||
struct zip_stat *st;
|
||||
|
||||
st = (struct zip_stat *)data;
|
||||
|
||||
st->encryption_method = ZIP_EM_NONE;
|
||||
st->valid |= ZIP_STAT_ENCRYPTION_METHOD;
|
||||
/* TODO: deduce HEADERLEN from size for uncompressed */
|
||||
if (st->valid & ZIP_STAT_COMP_SIZE)
|
||||
st->comp_size -= HEADERLEN;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_ERROR:
|
||||
memcpy(data, ctx->e, sizeof(int)*2);
|
||||
return sizeof(int)*2;
|
||||
|
||||
case ZIP_SOURCE_FREE:
|
||||
pkware_free(ctx);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
ctx->e[0] = ZIP_ER_INVAL;
|
||||
ctx->e[1] = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
pkware_free(struct trad_pkware *ctx)
|
||||
{
|
||||
free(ctx);
|
||||
}
|
||||
63
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_pop.c
vendored
Normal file
63
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_pop.c
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
zip_source_pop.c -- pop top layer from zip data source
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
struct zip_source *
|
||||
zip_source_pop(struct zip_source *src)
|
||||
{
|
||||
struct zip_source *lower;
|
||||
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
lower = src->src;
|
||||
|
||||
if (lower == NULL)
|
||||
zip_source_free(src);
|
||||
else {
|
||||
if (src->is_open)
|
||||
(void)src->cb.l(src, src->ud, NULL, 0, ZIP_SOURCE_CLOSE);
|
||||
(void)src->cb.l(src, src->ud, NULL, 0, ZIP_SOURCE_FREE);
|
||||
|
||||
free(src);
|
||||
}
|
||||
|
||||
return lower;
|
||||
}
|
||||
64
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_read.c
vendored
Normal file
64
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_read.c
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
zip_source_read.c -- read data from zip_source
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
zip_int64_t
|
||||
zip_source_read(struct zip_source *src, void *data, zip_uint64_t len)
|
||||
{
|
||||
zip_int64_t ret;
|
||||
|
||||
if (!src->is_open || len > ZIP_INT64_MAX || (len > 0 && data == NULL)) {
|
||||
src->error_source = ZIP_LES_INVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (src->src == NULL)
|
||||
return src->cb.f(src->ud, data, len, ZIP_SOURCE_READ);
|
||||
|
||||
ret = src->cb.l(src->src, src->ud, data, len, ZIP_SOURCE_READ);
|
||||
|
||||
if (ret < 0) {
|
||||
if (ret == ZIP_SOURCE_ERR_LOWER)
|
||||
src->error_source = ZIP_LES_LOWER;
|
||||
else
|
||||
src->error_source = ZIP_LES_UPPER;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
72
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_stat.c
vendored
Normal file
72
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_stat.c
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
zip_source_stat.c -- get meta information from zip_source
|
||||
Copyright (C) 2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
int
|
||||
zip_source_stat(struct zip_source *src, struct zip_stat *st)
|
||||
{
|
||||
zip_int64_t ret;
|
||||
|
||||
if (st == NULL) {
|
||||
src->error_source = ZIP_LES_INVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (src->src == NULL) {
|
||||
if (src->cb.f(src->ud, st, sizeof(*st), ZIP_SOURCE_STAT) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (zip_source_stat(src->src, st) < 0) {
|
||||
src->error_source = ZIP_LES_LOWER;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = src->cb.l(src->src, src->ud, st, sizeof(*st), ZIP_SOURCE_STAT);
|
||||
|
||||
if (ret < 0) {
|
||||
if (ret == ZIP_SOURCE_ERR_LOWER)
|
||||
src->error_source = ZIP_LES_LOWER;
|
||||
else
|
||||
src->error_source = ZIP_LES_UPPER;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
150
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_window.c
vendored
Normal file
150
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_window.c
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
zip_source_window.c -- return part of lower source
|
||||
Copyright (C) 2012-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
struct window {
|
||||
zip_uint64_t skip;
|
||||
zip_uint64_t len;
|
||||
zip_uint64_t left;
|
||||
int e[2];
|
||||
};
|
||||
|
||||
static zip_int64_t window_read(struct zip_source *, void *, void *,
|
||||
zip_uint64_t, enum zip_source_cmd);
|
||||
|
||||
|
||||
|
||||
struct zip_source *
|
||||
zip_source_window(struct zip *za, struct zip_source *src, zip_uint64_t start, zip_uint64_t len)
|
||||
{
|
||||
struct window *ctx;
|
||||
|
||||
if (src == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ctx=(struct window *)malloc(sizeof(*ctx))) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->skip = start;
|
||||
ctx->len = len;
|
||||
ctx->left = len;
|
||||
|
||||
return zip_source_layered(za, src, window_read, ctx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_int64_t
|
||||
window_read(struct zip_source *src, void *_ctx, void *data,
|
||||
zip_uint64_t len, enum zip_source_cmd cmd)
|
||||
{
|
||||
struct window *ctx;
|
||||
zip_int64_t ret;
|
||||
zip_uint64_t n, i;
|
||||
char b[8192];
|
||||
|
||||
ctx = (struct window *)_ctx;
|
||||
|
||||
switch (cmd) {
|
||||
case ZIP_SOURCE_OPEN:
|
||||
for (n=0; n<ctx->skip; n+=(zip_uint64_t)ret) {
|
||||
i = (ctx->skip-n > sizeof(b) ? sizeof(b) : ctx->skip-n);
|
||||
if ((ret=zip_source_read(src, b, i)) < 0)
|
||||
return ZIP_SOURCE_ERR_LOWER;
|
||||
if (ret==0) {
|
||||
ctx->e[0] = ZIP_ER_EOF;
|
||||
ctx->e[1] = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_READ:
|
||||
if (len > ctx->left)
|
||||
len = ctx->left;
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
if ((ret=zip_source_read(src, data, len)) < 0)
|
||||
return ZIP_SOURCE_ERR_LOWER;
|
||||
|
||||
ctx->left -= (zip_uint64_t)ret;
|
||||
|
||||
if (ret == 0) {
|
||||
if (ctx->left > 0) {
|
||||
ctx->e[0] = ZIP_ER_EOF;
|
||||
ctx->e[1] = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
case ZIP_SOURCE_CLOSE:
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_STAT:
|
||||
{
|
||||
struct zip_stat *st;
|
||||
|
||||
st = (struct zip_stat *)data;
|
||||
|
||||
st->size = ctx->len;
|
||||
st->valid |= ZIP_STAT_SIZE;
|
||||
st->valid &= ~(ZIP_STAT_CRC|ZIP_STAT_COMP_SIZE);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_ERROR:
|
||||
memcpy(data, ctx->e, sizeof(ctx->e));
|
||||
return 0;
|
||||
|
||||
case ZIP_SOURCE_FREE:
|
||||
free(ctx);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
61
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_zip.c
vendored
Normal file
61
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_zip.c
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
zip_source_zip.c -- create data source from zip file
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN struct zip_source *
|
||||
zip_source_zip(struct zip *za, struct zip *srcza, zip_uint64_t srcidx,
|
||||
zip_flags_t flags, zip_uint64_t start, zip_int64_t len)
|
||||
{
|
||||
if (len < -1) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (len == -1)
|
||||
len = 0;
|
||||
|
||||
if (start == 0 && len == 0)
|
||||
flags |= ZIP_FL_COMPRESSED;
|
||||
else
|
||||
flags &= ~ZIP_FL_COMPRESSED;
|
||||
|
||||
return _zip_source_zip_new(za, srcza, srcidx, flags, start, (zip_uint64_t)len, NULL);
|
||||
}
|
||||
172
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_zip_new.c
vendored
Normal file
172
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_source_zip_new.c
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
zip_source_zip_new.c -- prepare data structures for zip_fopen/zip_source_zip
|
||||
Copyright (C) 2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
struct zip_source *
|
||||
_zip_source_zip_new(struct zip *za, struct zip *srcza, zip_uint64_t srcidx, zip_flags_t flags,
|
||||
zip_uint64_t start, zip_uint64_t len, const char *password)
|
||||
{
|
||||
zip_compression_implementation comp_impl;
|
||||
zip_encryption_implementation enc_impl;
|
||||
struct zip_source *src, *s2;
|
||||
zip_uint64_t offset;
|
||||
struct zip_stat st;
|
||||
|
||||
if (za == NULL)
|
||||
return NULL;
|
||||
|
||||
if (srcza == NULL || srcidx >= srcza->nentry) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((flags & ZIP_FL_UNCHANGED) == 0
|
||||
&& (ZIP_ENTRY_DATA_CHANGED(srcza->entry+srcidx) || srcza->entry[srcidx].deleted)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (zip_stat_index(srcza, srcidx, flags|ZIP_FL_UNCHANGED, &st) < 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INTERNAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (flags & ZIP_FL_ENCRYPTED)
|
||||
flags |= ZIP_FL_COMPRESSED;
|
||||
|
||||
if ((start > 0 || len > 0) && (flags & ZIP_FL_COMPRESSED)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* overflow or past end of file */
|
||||
if ((start > 0 || len > 0) && (start+len < start || start+len > st.size)) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
enc_impl = NULL;
|
||||
if (((flags & ZIP_FL_ENCRYPTED) == 0) && (st.encryption_method != ZIP_EM_NONE)) {
|
||||
if (password == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_NOPASSWD, 0);
|
||||
return NULL;
|
||||
}
|
||||
if ((enc_impl=_zip_get_encryption_implementation(st.encryption_method)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
comp_impl = NULL;
|
||||
if ((flags & ZIP_FL_COMPRESSED) == 0) {
|
||||
if (st.comp_method != ZIP_CM_STORE) {
|
||||
if ((comp_impl=_zip_get_compression_implementation(st.comp_method)) == NULL) {
|
||||
_zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((offset=_zip_file_get_offset(srcza, srcidx, &za->error)) == 0)
|
||||
return NULL;
|
||||
|
||||
if (st.comp_size == 0) {
|
||||
if ((src=zip_source_buffer(za, NULL, 0, 0)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
if (start+len > 0 && enc_impl == NULL && comp_impl == NULL) {
|
||||
struct zip_stat st2;
|
||||
|
||||
st2.size = len ? len : st.size-start;
|
||||
st2.comp_size = st2.size;
|
||||
st2.comp_method = ZIP_CM_STORE;
|
||||
st2.mtime = st.mtime;
|
||||
st2.valid = ZIP_STAT_SIZE|ZIP_STAT_COMP_SIZE|ZIP_STAT_COMP_METHOD|ZIP_STAT_MTIME;
|
||||
|
||||
/* TODO: check for overflow of st2.size */
|
||||
if ((src=_zip_source_file_or_p(za, NULL, srcza->zp, offset+start, (zip_int64_t)st2.size, 0, &st2)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
/* TODO: check for overflow of st.comp_size */
|
||||
if ((src=_zip_source_file_or_p(za, NULL, srcza->zp, offset, (zip_int64_t)st.comp_size, 0, &st)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (enc_impl) {
|
||||
if ((s2=enc_impl(za, src, st.encryption_method, 0, password)) == NULL) {
|
||||
zip_source_free(src);
|
||||
/* TODO: set error (how?) */
|
||||
return NULL;
|
||||
}
|
||||
src = s2;
|
||||
}
|
||||
if (comp_impl) {
|
||||
if ((s2=comp_impl(za, src, st.comp_method, 0)) == NULL) {
|
||||
zip_source_free(src);
|
||||
/* TODO: set error (how?) */
|
||||
return NULL;
|
||||
}
|
||||
src = s2;
|
||||
}
|
||||
if (((flags & ZIP_FL_COMPRESSED) == 0 || st.comp_method == ZIP_CM_STORE)
|
||||
&& (len == 0 || len == st.comp_size)) {
|
||||
/* when reading the whole file, check for crc errors */
|
||||
if ((s2=zip_source_crc(za, src, 1)) == NULL) {
|
||||
zip_source_free(src);
|
||||
/* TODO: set error (how?) */
|
||||
return NULL;
|
||||
}
|
||||
src = s2;
|
||||
}
|
||||
|
||||
if (start+len > 0 && (comp_impl || enc_impl)) {
|
||||
if ((s2=zip_source_window(za, src, start, len ? len : st.size-start)) == NULL) {
|
||||
zip_source_free(src);
|
||||
/* TODO: set error (how?) (why?) */
|
||||
return NULL;
|
||||
}
|
||||
src = s2;
|
||||
}
|
||||
}
|
||||
|
||||
return src;
|
||||
}
|
||||
49
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_stat.c
vendored
Normal file
49
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_stat.c
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
zip_stat.c -- get information about file by name
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_stat(struct zip *za, const char *fname, zip_flags_t flags, struct zip_stat *st)
|
||||
{
|
||||
zip_int64_t idx;
|
||||
|
||||
if ((idx=zip_name_locate(za, fname, flags)) < 0)
|
||||
return -1;
|
||||
|
||||
return zip_stat_index(za, (zip_uint64_t)idx, flags, st);
|
||||
}
|
||||
88
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_stat_index.c
vendored
Normal file
88
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_stat_index.c
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
zip_stat_index.c -- get information about file by index
|
||||
Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_stat_index(struct zip *za, zip_uint64_t index, zip_flags_t flags,
|
||||
struct zip_stat *st)
|
||||
{
|
||||
const char *name;
|
||||
struct zip_dirent *de;
|
||||
|
||||
if ((de=_zip_get_dirent(za, index, flags, NULL)) == NULL)
|
||||
return -1;
|
||||
|
||||
if ((name=zip_get_name(za, index, flags)) == NULL)
|
||||
return -1;
|
||||
|
||||
|
||||
if ((flags & ZIP_FL_UNCHANGED) == 0
|
||||
&& ZIP_ENTRY_DATA_CHANGED(za->entry+index)) {
|
||||
if (zip_source_stat(za->entry[index].source, st) < 0) {
|
||||
_zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
zip_stat_init(st);
|
||||
|
||||
st->crc = de->crc;
|
||||
st->size = de->uncomp_size;
|
||||
st->mtime = de->last_mod;
|
||||
st->comp_size = de->comp_size;
|
||||
st->comp_method = (zip_uint16_t)de->comp_method;
|
||||
if (de->bitflags & ZIP_GPBF_ENCRYPTED) {
|
||||
if (de->bitflags & ZIP_GPBF_STRONG_ENCRYPTION) {
|
||||
/* TODO */
|
||||
st->encryption_method = ZIP_EM_UNKNOWN;
|
||||
}
|
||||
else
|
||||
st->encryption_method = ZIP_EM_TRAD_PKWARE;
|
||||
}
|
||||
else
|
||||
st->encryption_method = ZIP_EM_NONE;
|
||||
st->valid = ZIP_STAT_CRC|ZIP_STAT_SIZE|ZIP_STAT_MTIME
|
||||
|ZIP_STAT_COMP_SIZE|ZIP_STAT_COMP_METHOD|ZIP_STAT_ENCRYPTION_METHOD;
|
||||
}
|
||||
|
||||
st->index = index;
|
||||
st->name = name;
|
||||
st->valid |= ZIP_STAT_INDEX|ZIP_STAT_NAME;
|
||||
|
||||
return 0;
|
||||
}
|
||||
52
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_stat_init.c
vendored
Normal file
52
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_stat_init.c
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
zip_stat_init.c -- initialize struct zip_stat.
|
||||
Copyright (C) 2006-2009 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN void
|
||||
zip_stat_init(struct zip_stat *st)
|
||||
{
|
||||
st->valid = 0;
|
||||
st->name = NULL;
|
||||
st->index = ZIP_UINT64_MAX;
|
||||
st->crc = 0;
|
||||
st->mtime = (time_t)-1;
|
||||
st->size = 0;
|
||||
st->comp_size = 0;
|
||||
st->comp_method = ZIP_CM_STORE;
|
||||
st->encryption_method = ZIP_EM_NONE;
|
||||
}
|
||||
44
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_strerror.c
vendored
Normal file
44
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_strerror.c
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
zip_sterror.c -- get string representation of zip error
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN const char *
|
||||
zip_strerror(struct zip *za)
|
||||
{
|
||||
return _zip_error_strerror(&za->error);
|
||||
}
|
||||
196
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_string.c
vendored
Normal file
196
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_string.c
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
zip_string.c -- string handling (with encoding)
|
||||
Copyright (C) 2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
zip_uint32_t
|
||||
_zip_string_crc32(const struct zip_string *s)
|
||||
{
|
||||
zip_uint32_t crc;
|
||||
|
||||
crc = (zip_uint32_t)crc32(0L, Z_NULL, 0);
|
||||
|
||||
if (s != NULL)
|
||||
crc = (zip_uint32_t)crc32(crc, s->raw, s->length);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
_zip_string_equal(const struct zip_string *a, const struct zip_string *b)
|
||||
{
|
||||
if (a == NULL || b == NULL)
|
||||
return a == b;
|
||||
|
||||
if (a->length != b->length)
|
||||
return 0;
|
||||
|
||||
/* TODO: encoding */
|
||||
|
||||
return (memcmp(a->raw, b->raw, a->length) == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_string_free(struct zip_string *s)
|
||||
{
|
||||
if (s == NULL)
|
||||
return;
|
||||
|
||||
free(s->raw);
|
||||
free(s->converted);
|
||||
free(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const zip_uint8_t *
|
||||
_zip_string_get(struct zip_string *string, zip_uint32_t *lenp, zip_flags_t flags, struct zip_error *error)
|
||||
{
|
||||
static const zip_uint8_t empty[1] = "";
|
||||
|
||||
if (string == NULL) {
|
||||
if (lenp)
|
||||
*lenp = 0;
|
||||
return empty;
|
||||
}
|
||||
|
||||
if ((flags & ZIP_FL_ENC_RAW) == 0) {
|
||||
/* start guessing */
|
||||
if (string->encoding == ZIP_ENCODING_UNKNOWN)
|
||||
_zip_guess_encoding(string, ZIP_ENCODING_UNKNOWN);
|
||||
|
||||
if (((flags & ZIP_FL_ENC_STRICT)
|
||||
&& string->encoding != ZIP_ENCODING_ASCII && string->encoding != ZIP_ENCODING_UTF8_KNOWN)
|
||||
|| (string->encoding == ZIP_ENCODING_CP437)) {
|
||||
if (string->converted == NULL) {
|
||||
if ((string->converted=_zip_cp437_to_utf8(string->raw, string->length,
|
||||
&string->converted_length, error)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
if (lenp)
|
||||
*lenp = string->converted_length;
|
||||
return string->converted;
|
||||
}
|
||||
}
|
||||
|
||||
if (lenp)
|
||||
*lenp = string->length;
|
||||
return string->raw;
|
||||
}
|
||||
|
||||
|
||||
|
||||
zip_uint16_t
|
||||
_zip_string_length(const struct zip_string *s)
|
||||
{
|
||||
if (s == NULL)
|
||||
return 0;
|
||||
|
||||
return s->length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct zip_string *
|
||||
_zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags, struct zip_error *error)
|
||||
{
|
||||
struct zip_string *s;
|
||||
enum zip_encoding_type expected_encoding;
|
||||
|
||||
if (length == 0)
|
||||
return NULL;
|
||||
|
||||
switch (flags & ZIP_FL_ENCODING_ALL) {
|
||||
case ZIP_FL_ENC_GUESS:
|
||||
expected_encoding = ZIP_ENCODING_UNKNOWN;
|
||||
break;
|
||||
case ZIP_FL_ENC_UTF_8:
|
||||
expected_encoding = ZIP_ENCODING_UTF8_KNOWN;
|
||||
break;
|
||||
case ZIP_FL_ENC_CP437:
|
||||
expected_encoding = ZIP_ENCODING_CP437;
|
||||
break;
|
||||
default:
|
||||
_zip_error_set(error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((s=(struct zip_string *)malloc(sizeof(*s))) == NULL) {
|
||||
_zip_error_set(error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((s->raw=(zip_uint8_t *)malloc(length+1)) == NULL) {
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(s->raw, raw, length);
|
||||
s->raw[length] = '\0';
|
||||
s->length = length;
|
||||
s->encoding = ZIP_ENCODING_UNKNOWN;
|
||||
s->converted = NULL;
|
||||
s->converted_length = 0;
|
||||
|
||||
if (expected_encoding != ZIP_ENCODING_UNKNOWN) {
|
||||
if (_zip_guess_encoding(s, expected_encoding) == ZIP_ENCODING_ERROR) {
|
||||
_zip_string_free(s);
|
||||
_zip_error_set(error, ZIP_ER_INVAL, 0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_zip_string_write(const struct zip_string *s, FILE *f)
|
||||
{
|
||||
if (s == NULL)
|
||||
return;
|
||||
|
||||
fwrite(s->raw, s->length, 1, f);
|
||||
}
|
||||
74
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_unchange.c
vendored
Normal file
74
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_unchange.c
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
zip_unchange.c -- undo changes to file in zip archive
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_unchange(struct zip *za, zip_uint64_t idx)
|
||||
{
|
||||
return _zip_unchange(za, idx, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
_zip_unchange(struct zip *za, zip_uint64_t idx, int allow_duplicates)
|
||||
{
|
||||
zip_int64_t i;
|
||||
|
||||
if (idx >= za->nentry) {
|
||||
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!allow_duplicates && za->entry[idx].changes && (za->entry[idx].changes->changed & ZIP_DIRENT_FILENAME)) {
|
||||
i = _zip_name_locate(za, _zip_get_name(za, idx, ZIP_FL_UNCHANGED, NULL), 0, NULL);
|
||||
if (i >= 0 && (zip_uint64_t)i != idx) {
|
||||
_zip_error_set(&za->error, ZIP_ER_EXISTS, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
_zip_dirent_free(za->entry[idx].changes);
|
||||
za->entry[idx].changes = NULL;
|
||||
|
||||
_zip_unchange_data(za->entry+idx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
55
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_unchange_all.c
vendored
Normal file
55
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_unchange_all.c
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
zip_unchange.c -- undo changes to all files in zip archive
|
||||
Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_unchange_all(struct zip *za)
|
||||
{
|
||||
int ret;
|
||||
zip_uint64_t i;
|
||||
|
||||
ret = 0;
|
||||
for (i=0; i<za->nentry; i++)
|
||||
ret |= _zip_unchange(za, i, 1);
|
||||
|
||||
ret |= zip_unchange_archive(za);
|
||||
|
||||
return ret;
|
||||
}
|
||||
54
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_unchange_archive.c
vendored
Normal file
54
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_unchange_archive.c
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
zip_unchange_archive.c -- undo global changes to ZIP archive
|
||||
Copyright (C) 2006-2008 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_unchange_archive(struct zip *za)
|
||||
{
|
||||
if (za->comment_changed) {
|
||||
_zip_string_free(za->comment_changes);
|
||||
za->comment_changes = NULL;
|
||||
za->comment_changed = 0;
|
||||
}
|
||||
|
||||
za->ch_flags = za->flags;
|
||||
|
||||
return 0;
|
||||
}
|
||||
56
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_unchange_data.c
vendored
Normal file
56
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_unchange_data.c
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
zip_unchange_data.c -- undo helper function
|
||||
Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
void
|
||||
_zip_unchange_data(struct zip_entry *ze)
|
||||
{
|
||||
if (ze->source) {
|
||||
zip_source_free(ze->source);
|
||||
ze->source = NULL;
|
||||
}
|
||||
|
||||
if (ze->changes != NULL && (ze->changes->changed & ZIP_DIRENT_COMP_METHOD) && ze->changes->comp_method == ZIP_CM_REPLACED_DEFAULT) {
|
||||
ze->changes->changed &= ~ZIP_DIRENT_COMP_METHOD;
|
||||
if (ze->changes->changed == 0) {
|
||||
_zip_dirent_free(ze->changes);
|
||||
ze->changes = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ze->deleted = 0;
|
||||
}
|
||||
|
||||
255
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_utf-8.c
vendored
Normal file
255
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zip_utf-8.c
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
zip_utf-8.c -- UTF-8 support functions for libzip
|
||||
Copyright (C) 2011-2012 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
static const zip_uint16_t _cp437_to_unicode[256] = {
|
||||
/* 0x00 - 0x0F */
|
||||
0x2007, 0x263A, 0x263B, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022,
|
||||
0x25D8, 0x25CB, 0x25D9, 0x2642, 0x2640, 0x266A, 0x266B, 0x263C,
|
||||
|
||||
/* 0x10 - 0x1F */
|
||||
0x25BA, 0x25C4, 0x2195, 0x203C, 0x00B6, 0x00A7, 0x25AC, 0x21A8,
|
||||
0x2191, 0x2193, 0x2192, 0x2190, 0x221F, 0x2194, 0x25B2, 0x25BC,
|
||||
|
||||
/* 0x20 - 0x2F */
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
|
||||
|
||||
/* 0x30 - 0x3F */
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
|
||||
|
||||
/* 0x40 - 0x4F */
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
|
||||
|
||||
/* 0x50 - 0x5F */
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
|
||||
|
||||
/* 0x60 - 0x6F */
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
|
||||
|
||||
/* 0x70 - 0x7F */
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x2302,
|
||||
|
||||
/* 0x80 - 0x8F */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
|
||||
/* 0x90 - 0x9F */
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
|
||||
|
||||
/* 0xA0 - 0xAF */
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
||||
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
|
||||
/* 0xB0 - 0xBF */
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
|
||||
/* 0xC0 - 0xCF */
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
|
||||
/* 0xD0 - 0xDF */
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
|
||||
/* 0xE0 - 0xEF */
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
|
||||
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
|
||||
/* 0xF0 - 0xFF */
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#define UTF_8_LEN_2_MASK 0xe0
|
||||
#define UTF_8_LEN_2_MATCH 0xc0
|
||||
#define UTF_8_LEN_3_MASK 0xf0
|
||||
#define UTF_8_LEN_3_MATCH 0xe0
|
||||
#define UTF_8_LEN_4_MASK 0xf8
|
||||
#define UTF_8_LEN_4_MATCH 0xf0
|
||||
#define UTF_8_CONTINUE_MASK 0xc0
|
||||
#define UTF_8_CONTINUE_MATCH 0x80
|
||||
|
||||
|
||||
|
||||
enum zip_encoding_type
|
||||
_zip_guess_encoding(struct zip_string *str, enum zip_encoding_type expected_encoding)
|
||||
{
|
||||
enum zip_encoding_type enc;
|
||||
const zip_uint8_t *name;
|
||||
zip_uint32_t i, j, ulen;
|
||||
|
||||
if (str == NULL)
|
||||
return ZIP_ENCODING_ASCII;
|
||||
|
||||
name = str->raw;
|
||||
|
||||
if (str->encoding != ZIP_ENCODING_UNKNOWN)
|
||||
enc = str->encoding;
|
||||
else {
|
||||
enc = ZIP_ENCODING_ASCII;
|
||||
for (i=0; i<str->length; i++) {
|
||||
if ((name[i] > 31 && name[i] < 128) || name[i] == '\r' || name[i] == '\n' || name[i] == '\t')
|
||||
continue;
|
||||
|
||||
enc = ZIP_ENCODING_UTF8_GUESSED;
|
||||
if ((name[i] & UTF_8_LEN_2_MASK) == UTF_8_LEN_2_MATCH)
|
||||
ulen = 1;
|
||||
else if ((name[i] & UTF_8_LEN_3_MASK) == UTF_8_LEN_3_MATCH)
|
||||
ulen = 2;
|
||||
else if ((name[i] & UTF_8_LEN_4_MASK) == UTF_8_LEN_4_MATCH)
|
||||
ulen = 3;
|
||||
else {
|
||||
enc = ZIP_ENCODING_CP437;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i + ulen >= str->length) {
|
||||
enc = ZIP_ENCODING_CP437;
|
||||
break;
|
||||
}
|
||||
|
||||
for (j=1; j<=ulen; j++) {
|
||||
if ((name[i+j] & UTF_8_CONTINUE_MASK) != UTF_8_CONTINUE_MATCH) {
|
||||
enc = ZIP_ENCODING_CP437;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
i += ulen;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
str->encoding = enc;
|
||||
|
||||
if (expected_encoding != ZIP_ENCODING_UNKNOWN) {
|
||||
if (expected_encoding == ZIP_ENCODING_UTF8_KNOWN && enc == ZIP_ENCODING_UTF8_GUESSED)
|
||||
str->encoding = enc = ZIP_ENCODING_UTF8_KNOWN;
|
||||
|
||||
if (expected_encoding != enc && enc != ZIP_ENCODING_ASCII)
|
||||
return ZIP_ENCODING_ERROR;
|
||||
}
|
||||
|
||||
return enc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_uint32_t
|
||||
_zip_unicode_to_utf8_len(zip_uint32_t codepoint)
|
||||
{
|
||||
if (codepoint < 0x0080)
|
||||
return 1;
|
||||
if (codepoint < 0x0800)
|
||||
return 2;
|
||||
if (codepoint < 0x10000)
|
||||
return 3;
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static zip_uint32_t
|
||||
_zip_unicode_to_utf8(zip_uint32_t codepoint, zip_uint8_t *buf)
|
||||
{
|
||||
if (codepoint < 0x0080) {
|
||||
buf[0] = codepoint & 0xff;
|
||||
return 1;
|
||||
}
|
||||
if (codepoint < 0x0800) {
|
||||
buf[0] = UTF_8_LEN_2_MATCH | ((codepoint >> 6) & 0x1f);
|
||||
buf[1] = UTF_8_CONTINUE_MATCH | (codepoint & 0x3f);
|
||||
return 2;
|
||||
}
|
||||
if (codepoint < 0x10000) {
|
||||
buf[0] = UTF_8_LEN_3_MATCH | ((codepoint >> 12) & 0x0f);
|
||||
buf[1] = UTF_8_CONTINUE_MATCH | ((codepoint >> 6) & 0x3f);
|
||||
buf[2] = UTF_8_CONTINUE_MATCH | (codepoint & 0x3f);
|
||||
return 3;
|
||||
}
|
||||
buf[0] = UTF_8_LEN_4_MATCH | ((codepoint >> 18) & 0x07);
|
||||
buf[1] = UTF_8_CONTINUE_MATCH | ((codepoint >> 12) & 0x3f);
|
||||
buf[2] = UTF_8_CONTINUE_MATCH | ((codepoint >> 6) & 0x3f);
|
||||
buf[3] = UTF_8_CONTINUE_MATCH | (codepoint & 0x3f);
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
zip_uint8_t *
|
||||
_zip_cp437_to_utf8(const zip_uint8_t * const _cp437buf, zip_uint32_t len,
|
||||
zip_uint32_t *utf8_lenp, struct zip_error *error)
|
||||
{
|
||||
zip_uint8_t *cp437buf = (zip_uint8_t *)_cp437buf;
|
||||
zip_uint8_t *utf8buf;
|
||||
zip_uint32_t buflen, i, offset;
|
||||
|
||||
if (len == 0) {
|
||||
if (utf8_lenp)
|
||||
*utf8_lenp = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buflen = 1;
|
||||
for (i=0; i<len; i++)
|
||||
buflen += _zip_unicode_to_utf8_len(_cp437_to_unicode[cp437buf[i]]);
|
||||
|
||||
if ((utf8buf=(zip_uint8_t*)malloc(buflen)) == NULL) {
|
||||
_zip_error_set(error, ZIP_ER_MEMORY, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
for (i=0; i<len; i++)
|
||||
offset += _zip_unicode_to_utf8(_cp437_to_unicode[cp437buf[i]],
|
||||
utf8buf+offset);
|
||||
|
||||
utf8buf[buflen-1] = 0;
|
||||
if (utf8_lenp)
|
||||
*utf8_lenp = buflen-1;
|
||||
return utf8buf;
|
||||
}
|
||||
120
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zipconf.h
vendored
Normal file
120
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zipconf.h
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
#ifndef _HAD_ZIPCONF_H
|
||||
#define _HAD_ZIPCONF_H
|
||||
|
||||
/*
|
||||
zipconf.h -- platform specific include file
|
||||
|
||||
This file was generated automatically by CMake
|
||||
based on ../cmake-zipconf.h.in.
|
||||
*/
|
||||
|
||||
/* #undef HAVE_INTTYPES_H_LIBZIP */
|
||||
#define HAVE_STDINT_H_LIBZIP
|
||||
#define HAVE_SYS_TYPES_H_LIBZIP
|
||||
#define HAVE___INT8_LIBZIP
|
||||
#define HAVE_INT8_T_LIBZIP
|
||||
#define HAVE_UINT8_T_LIBZIP
|
||||
#define HAVE___INT16_LIBZIP
|
||||
#define HAVE_INT16_T_LIBZIP
|
||||
#define HAVE_UINT16_T_LIBZIP
|
||||
#define HAVE___INT32_LIBZIP
|
||||
#define HAVE_INT32_T_LIBZIP
|
||||
#define HAVE_UINT32_T_LIBZIP
|
||||
#define HAVE___INT64_LIBZIP
|
||||
#define HAVE_INT64_T_LIBZIP
|
||||
#define HAVE_UINT64_T_LIBZIP
|
||||
#define SHORT_LIBZIP 2
|
||||
#define INT_LIBZIP 4
|
||||
#define LONG_LIBZIP 4
|
||||
#define LONG_LONG_LIBZIP 8
|
||||
|
||||
#if defined(HAVE_STDINT_H_LIBZIP)
|
||||
#include <stdint.h>
|
||||
#elif defined(HAVE_INTTYPES_H_LIBZIP)
|
||||
#include <inttypes.h>
|
||||
#elif defined(HAVE_SYS_TYPES_H_LIBZIP)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INT8_T_LIBZIP)
|
||||
typedef int8_t zip_int8_t;
|
||||
#elif defined(HAVE___INT8_LIBZIP)
|
||||
typedef __int8 zip_int8_t;
|
||||
#else
|
||||
typedef signed char zip_int8_t;
|
||||
#endif
|
||||
#if defined(HAVE_UINT8_T_LIBZIP)
|
||||
typedef uint8_t zip_uint8_t;
|
||||
#elif defined(HAVE___INT8_LIBZIP)
|
||||
typedef unsigned __int8 zip_uint8_t;
|
||||
#else
|
||||
typedef unsigned char zip_uint8_t;
|
||||
#endif
|
||||
#if defined(HAVE_INT16_T_LIBZIP)
|
||||
typedef int16_t zip_int16_t;
|
||||
#elif defined(HAVE___INT16_LIBZIP)
|
||||
typedef __int16 zip_int16_t;
|
||||
#elif defined(SHORT_LIBZIP) && SHORT_LIBZIP == 2
|
||||
typedef signed short zip_int16_t;
|
||||
#endif
|
||||
#if defined(HAVE_UINT16_T_LIBZIP)
|
||||
typedef uint16_t zip_uint16_t;
|
||||
#elif defined(HAVE___INT16_LIBZIP)
|
||||
typedef unsigned __int16 zip_uint16_t;
|
||||
#elif defined(SHORT_LIBZIP) && SHORT_LIBZIP == 2
|
||||
typedef unsigned short zip_uint16_t;
|
||||
#endif
|
||||
#if defined(HAVE_INT32_T_LIBZIP)
|
||||
typedef int32_t zip_int32_t;
|
||||
#elif defined(HAVE___INT32_LIBZIP)
|
||||
typedef __int32 zip_int32_t;
|
||||
#elif defined(INT_LIBZIP) && INT_LIBZIP == 4
|
||||
typedef signed int zip_int32_t;
|
||||
#elif defined(LONG_LIBZIP) && LONG_LIBZIP == 4
|
||||
typedef signed long zip_int32_t;
|
||||
#endif
|
||||
#if defined(HAVE_UINT32_T_LIBZIP)
|
||||
typedef uint32_t zip_uint32_t;
|
||||
#elif defined(HAVE___INT32_LIBZIP)
|
||||
typedef unsigned __int32 zip_uint32_t;
|
||||
#elif defined(INT_LIBZIP) && INT_LIBZIP == 4
|
||||
typedef unsigned int zip_uint32_t;
|
||||
#elif defined(LONG_LIBZIP) && LONG_LIBZIP == 4
|
||||
typedef unsigned long zip_uint32_t;
|
||||
#endif
|
||||
#if defined(HAVE_INT64_T_LIBZIP)
|
||||
typedef int64_t zip_int64_t;
|
||||
#elif defined(HAVE___INT64_LIBZIP)
|
||||
typedef __int64 zip_int64_t;
|
||||
#elif defined(LONG_LIBZIP) && LONG_LIBZIP == 8
|
||||
typedef signed long zip_int64_t;
|
||||
#elif defined(LONG_LONG_LIBZIP) && LONG_LONG_LIBZIP == 8
|
||||
typedef signed long long zip_int64_t;
|
||||
#endif
|
||||
#if defined(HAVE_UINT64_T_LIBZIP)
|
||||
typedef uint64_t zip_uint64_t;
|
||||
#elif defined(HAVE___INT64_LIBZIP)
|
||||
typedef unsigned __int64 zip_uint64_t;
|
||||
#elif defined(LONG_LIBZIP) && LONG_LONG_LIBZIP == 8
|
||||
typedef unsigned long zip_uint64_t;
|
||||
#elif defined(LONG_LONG_LIBZIP) && LONG_LONG_LIBZIP == 8
|
||||
typedef unsigned long long zip_uint64_t;
|
||||
#endif
|
||||
|
||||
#define ZIP_INT8_MIN -0x80
|
||||
#define ZIP_INT8_MAX 0x7f
|
||||
#define ZIP_UINT8_MAX 0xff
|
||||
|
||||
#define ZIP_INT16_MIN -0x8000
|
||||
#define ZIP_INT16_MAX 0x7fff
|
||||
#define ZIP_UINT16_MAX 0xffff
|
||||
|
||||
#define ZIP_INT32_MIN -0x80000000L
|
||||
#define ZIP_INT32_MAX 0x7fffffffL
|
||||
#define ZIP_UINT32_MAX 0xffffffffLU
|
||||
|
||||
#define ZIP_INT64_MIN -0x8000000000000000LL
|
||||
#define ZIP_INT64_MAX 0x7fffffffffffffffLL
|
||||
#define ZIP_UINT64_MAX 0xffffffffffffffffULL
|
||||
|
||||
#endif /* zipconf.h */
|
||||
514
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zipint.h
vendored
Normal file
514
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zipint.h
vendored
Normal file
@@ -0,0 +1,514 @@
|
||||
#ifndef _HAD_ZIPINT_H
|
||||
#define _HAD_ZIPINT_H
|
||||
|
||||
/*
|
||||
zipint.h -- internal declarations.
|
||||
Copyright (C) 1999-2013 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* to have *_MAX definitions for all types when compiling with g++ */
|
||||
#define __STDC_LIMIT_MACROS
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ZIP_EXTERN
|
||||
//__declspec(dllexport)
|
||||
/* for dup(), close(), etc. */
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifndef _ZIP_COMPILING_DEPRECATED
|
||||
#define ZIP_DISABLE_DEPRECATED
|
||||
#endif
|
||||
|
||||
#include "zip.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_MOVEFILEEXA
|
||||
#include <windows.h>
|
||||
#define _zip_rename(s, t) (!MoveFileExA((s), (t), MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING))
|
||||
#else
|
||||
#define _zip_rename rename
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(HAVE__CLOSE)
|
||||
#define close _close
|
||||
#endif
|
||||
#if defined(HAVE__DUP)
|
||||
#define dup _dup
|
||||
#endif
|
||||
/* crashes reported when using fdopen instead of _fdopen on Windows/Visual Studio 10/Win64 */
|
||||
#if defined(HAVE__FDOPEN)
|
||||
#define fdopen _fdopen
|
||||
#endif
|
||||
#if defined(HAVE__FILENO)
|
||||
#define fileno _fileno
|
||||
#endif
|
||||
/* Windows' open() doesn't understand Unix permissions */
|
||||
#if defined(HAVE__OPEN)
|
||||
#define open(a, b, c) _open((a), (b))
|
||||
#endif
|
||||
#if defined(HAVE__SNPRINTF)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#if defined(HAVE__STRDUP) && !defined(HAVE_STRDUP)
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FSEEKO
|
||||
#define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FTELLO
|
||||
#define ftello(s) ((long)ftell((s)))
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKSTEMP
|
||||
int _zip_mkstemp(char *);
|
||||
#define mkstemp _zip_mkstemp
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#if !defined(HAVE_STRCASECMP)
|
||||
#if defined(HAVE__STRICMP)
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SIZEOF_OFF_T == 8
|
||||
#define ZIP_OFF_MAX ZIP_INT64_MAX
|
||||
#elif SIZEOF_OFF_T == 4
|
||||
#define ZIP_OFF_MAX ZIP_INT32_MAX
|
||||
#elif SIZEOF_OFF_T == 2
|
||||
#define ZIP_OFF_MAX ZIP_INT16_MAX
|
||||
#else
|
||||
#error unsupported size of off_t
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#if SIZEOF_SIZE_T == 8
|
||||
#define SIZE_MAX ZIP_INT64_MAX
|
||||
#elif SIZEOF_SIZE_T == 4
|
||||
#define SIZE_MAX ZIP_INT32_MAX
|
||||
#elif SIZEOF_SIZE_T == 2
|
||||
#define SIZE_MAX ZIP_INT16_MAX
|
||||
#else
|
||||
#error unsupported size of size_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define CENTRAL_MAGIC "PK\1\2"
|
||||
#define LOCAL_MAGIC "PK\3\4"
|
||||
#define EOCD_MAGIC "PK\5\6"
|
||||
#define DATADES_MAGIC "PK\7\8"
|
||||
#define EOCD64LOC_MAGIC "PK\6\7"
|
||||
#define EOCD64_MAGIC "PK\6\6"
|
||||
#define TORRENT_SIG "TORRENTZIPPED-"
|
||||
#define TORRENT_SIG_LEN 14
|
||||
#define TORRENT_CRC_LEN 8
|
||||
#define TORRENT_MEM_LEVEL 8
|
||||
#define CDENTRYSIZE 46u
|
||||
#define LENTRYSIZE 30
|
||||
#define MAXCOMLEN 65536
|
||||
#define MAXEXTLEN 65536
|
||||
#define EOCDLEN 22
|
||||
#define EOCD64LOCLEN 20
|
||||
#define EOCD64LEN 56
|
||||
#define CDBUFSIZE (MAXCOMLEN+EOCDLEN+EOCD64LOCLEN)
|
||||
#define BUFSIZE 8192
|
||||
|
||||
#define ZIP_CM_REPLACED_DEFAULT (-2)
|
||||
|
||||
#define ZIP_CM_IS_DEFAULT(x) ((x) == ZIP_CM_DEFAULT || (x) == ZIP_CM_REPLACED_DEFAULT)
|
||||
|
||||
#define ZIP_EF_UTF_8_COMMENT 0x6375
|
||||
#define ZIP_EF_UTF_8_NAME 0x7075
|
||||
#define ZIP_EF_ZIP64 0x0001
|
||||
|
||||
#define ZIP_EF_IS_INTERNAL(id) ((id) == ZIP_EF_UTF_8_COMMENT || (id) == ZIP_EF_UTF_8_NAME || (id) == ZIP_EF_ZIP64)
|
||||
|
||||
/* according to unzip-6.0's zipinfo.c, this corresponds to a regular file with rw permissions for everyone */
|
||||
#define ZIP_EXT_ATTRIB_DEFAULT (0100666<<16)
|
||||
/* according to unzip-6.0's zipinfo.c, this corresponds to a directory with rwx permissions for everyone */
|
||||
#define ZIP_EXT_ATTRIB_DEFAULT_DIR (0040777<<16)
|
||||
|
||||
|
||||
/* This section contains API that won't materialize like this. It's
|
||||
placed in the internal section, pending cleanup. */
|
||||
|
||||
typedef struct zip_source *(*zip_compression_implementation)(struct zip *,
|
||||
struct zip_source *,
|
||||
zip_int32_t, int);
|
||||
typedef struct zip_source *(*zip_encryption_implementation)(struct zip *,
|
||||
struct zip_source *,
|
||||
zip_uint16_t, int,
|
||||
const char *);
|
||||
|
||||
zip_compression_implementation _zip_get_compression_implementation(zip_int32_t);
|
||||
zip_encryption_implementation _zip_get_encryption_implementation(zip_uint16_t);
|
||||
|
||||
|
||||
|
||||
|
||||
/* This API is not final yet, but we need it internally, so it's private for now. */
|
||||
|
||||
const zip_uint8_t *zip_get_extra_field_by_id(struct zip *, int, int, zip_uint16_t, int, zip_uint16_t *);
|
||||
|
||||
/* This section contains API that is of limited use until support for
|
||||
user-supplied compression/encryption implementation is finished.
|
||||
Thus we will keep it private for now. */
|
||||
|
||||
typedef zip_int64_t (*zip_source_layered_callback)(struct zip_source *, void *,
|
||||
void *, zip_uint64_t,
|
||||
enum zip_source_cmd);
|
||||
|
||||
void zip_source_close(struct zip_source *);
|
||||
struct zip_source *zip_source_crc(struct zip *, struct zip_source *,
|
||||
int);
|
||||
struct zip_source *zip_source_deflate(struct zip *,
|
||||
struct zip_source *,
|
||||
zip_int32_t, int);
|
||||
void zip_source_error(struct zip_source *, int *, int *);
|
||||
struct zip_source *zip_source_layered(struct zip *,
|
||||
struct zip_source *,
|
||||
zip_source_layered_callback,
|
||||
void *);
|
||||
int zip_source_open(struct zip_source *);
|
||||
struct zip_source *zip_source_pkware(struct zip *,
|
||||
struct zip_source *,
|
||||
zip_uint16_t, int,
|
||||
const char *);
|
||||
zip_int64_t zip_source_read(struct zip_source *, void *,
|
||||
zip_uint64_t);
|
||||
int zip_source_stat(struct zip_source *, struct zip_stat *);
|
||||
struct zip_source *zip_source_window(struct zip *, struct zip_source *,
|
||||
zip_uint64_t, zip_uint64_t);
|
||||
|
||||
|
||||
/* This function will probably remain private. It is not needed to
|
||||
implement compression/encryption routines. (We should probably
|
||||
rename it to _zip_source_pop.) */
|
||||
|
||||
struct zip_source *zip_source_pop(struct zip_source *);
|
||||
|
||||
|
||||
|
||||
/* error source for layered sources */
|
||||
|
||||
enum zip_les { ZIP_LES_NONE, ZIP_LES_UPPER, ZIP_LES_LOWER, ZIP_LES_INVAL };
|
||||
|
||||
/* directory entry: general purpose bit flags */
|
||||
|
||||
#define ZIP_GPBF_ENCRYPTED 0x0001 /* is encrypted */
|
||||
#define ZIP_GPBF_DATA_DESCRIPTOR 0x0008 /* crc/size after file data */
|
||||
#define ZIP_GPBF_STRONG_ENCRYPTION 0x0040 /* uses strong encryption */
|
||||
#define ZIP_GPBF_ENCODING_UTF_8 0x0800 /* file name encoding is UTF-8 */
|
||||
|
||||
|
||||
/* extra fields */
|
||||
#define ZIP_EF_LOCAL ZIP_FL_LOCAL /* include in local header */
|
||||
#define ZIP_EF_CENTRAL ZIP_FL_CENTRAL /* include in central directory */
|
||||
#define ZIP_EF_BOTH (ZIP_EF_LOCAL|ZIP_EF_CENTRAL) /* include in both */
|
||||
|
||||
#define ZIP_FL_FORCE_ZIP64 1024 /* force zip64 extra field (_zip_dirent_write) */
|
||||
|
||||
#define ZIP_FL_ENCODING_ALL (ZIP_FL_ENC_GUESS|ZIP_FL_ENC_CP437|ZIP_FL_ENC_UTF_8)
|
||||
|
||||
|
||||
/* encoding type */
|
||||
enum zip_encoding_type {
|
||||
ZIP_ENCODING_UNKNOWN, /* not yet analyzed */
|
||||
ZIP_ENCODING_ASCII, /* plain ASCII */
|
||||
ZIP_ENCODING_UTF8_KNOWN, /* is UTF-8 */
|
||||
ZIP_ENCODING_UTF8_GUESSED, /* possibly UTF-8 */
|
||||
ZIP_ENCODING_CP437, /* Code Page 437 */
|
||||
ZIP_ENCODING_ERROR /* should be UTF-8 but isn't */
|
||||
};
|
||||
|
||||
/* error information */
|
||||
|
||||
struct zip_error {
|
||||
int zip_err; /* libzip error code (ZIP_ER_*) */
|
||||
int sys_err; /* copy of errno (E*) or zlib error code */
|
||||
char *str; /* string representation or NULL */
|
||||
};
|
||||
|
||||
/* zip archive, part of API */
|
||||
|
||||
struct zip {
|
||||
char *zn; /* file name */
|
||||
FILE *zp; /* file */
|
||||
unsigned int open_flags; /* flags passed to zip_open */
|
||||
struct zip_error error; /* error information */
|
||||
|
||||
unsigned int flags; /* archive global flags */
|
||||
unsigned int ch_flags; /* changed archive global flags */
|
||||
|
||||
char *default_password; /* password used when no other supplied */
|
||||
|
||||
struct zip_string *comment_orig; /* archive comment */
|
||||
struct zip_string *comment_changes; /* changed archive comment */
|
||||
int comment_changed; /* whether archive comment was changed */
|
||||
|
||||
zip_uint64_t nentry; /* number of entries */
|
||||
zip_uint64_t nentry_alloc; /* number of entries allocated */
|
||||
struct zip_entry *entry; /* entries */
|
||||
|
||||
unsigned int nfile; /* number of opened files within archive */
|
||||
unsigned int nfile_alloc; /* number of files allocated */
|
||||
struct zip_file **file; /* opened files within archive */
|
||||
|
||||
char *tempdir; /* custom temp dir (needed e.g. for OS X sandboxing) */
|
||||
};
|
||||
|
||||
/* file in zip archive, part of API */
|
||||
|
||||
struct zip_file {
|
||||
struct zip *za; /* zip archive containing this file */
|
||||
struct zip_error error; /* error information */
|
||||
int eof;
|
||||
struct zip_source *src; /* data source */
|
||||
};
|
||||
|
||||
/* zip archive directory entry (central or local) */
|
||||
|
||||
#define ZIP_DIRENT_COMP_METHOD 0x0001u
|
||||
#define ZIP_DIRENT_FILENAME 0x0002u
|
||||
#define ZIP_DIRENT_COMMENT 0x0004u
|
||||
#define ZIP_DIRENT_EXTRA_FIELD 0x0008u
|
||||
#define ZIP_DIRENT_ATTRIBUTES 0x0010u
|
||||
#define ZIP_DIRENT_ALL 0xffffu
|
||||
|
||||
struct zip_dirent {
|
||||
zip_uint32_t changed;
|
||||
int local_extra_fields_read; /* whether we already read in local header extra fields */
|
||||
int cloned; /* whether this instance is cloned, and thus shares non-changed strings */
|
||||
|
||||
zip_uint16_t version_madeby; /* (c) version of creator */
|
||||
zip_uint16_t version_needed; /* (cl) version needed to extract */
|
||||
zip_uint16_t bitflags; /* (cl) general purpose bit flag */
|
||||
zip_int32_t comp_method; /* (cl) compression method used (uint16 and ZIP_CM_DEFAULT (-1)) */
|
||||
time_t last_mod; /* (cl) time of last modification */
|
||||
zip_uint32_t crc; /* (cl) CRC-32 of uncompressed data */
|
||||
zip_uint64_t comp_size; /* (cl) size of compressed data */
|
||||
zip_uint64_t uncomp_size; /* (cl) size of uncompressed data */
|
||||
struct zip_string *filename; /* (cl) file name (NUL-terminated) */
|
||||
struct zip_extra_field *extra_fields; /* (cl) extra fields, parsed */
|
||||
struct zip_string *comment; /* (c) file comment */
|
||||
zip_uint32_t disk_number; /* (c) disk number start */
|
||||
zip_uint16_t int_attrib; /* (c) internal file attributes */
|
||||
zip_uint32_t ext_attrib; /* (c) external file attributes */
|
||||
zip_uint64_t offset; /* (c) offset of local header */
|
||||
};
|
||||
|
||||
/* zip archive central directory */
|
||||
|
||||
struct zip_cdir {
|
||||
struct zip_entry *entry; /* directory entries */
|
||||
zip_uint64_t nentry; /* number of entries */
|
||||
zip_uint64_t nentry_alloc; /* number of entries allocated */
|
||||
|
||||
off_t size; /* size of central directory */
|
||||
off_t offset; /* offset of central directory in file */
|
||||
struct zip_string *comment; /* zip archive comment */
|
||||
};
|
||||
|
||||
struct zip_extra_field {
|
||||
struct zip_extra_field *next;
|
||||
zip_flags_t flags; /* in local/central header */
|
||||
zip_uint16_t id; /* header id */
|
||||
zip_uint16_t size; /* data size */
|
||||
zip_uint8_t *data;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct zip_source {
|
||||
struct zip_source *src;
|
||||
union {
|
||||
zip_source_callback f;
|
||||
zip_source_layered_callback l;
|
||||
} cb;
|
||||
void *ud;
|
||||
enum zip_les error_source;
|
||||
int is_open;
|
||||
};
|
||||
|
||||
/* entry in zip archive directory */
|
||||
|
||||
struct zip_entry {
|
||||
struct zip_dirent *orig;
|
||||
struct zip_dirent *changes;
|
||||
struct zip_source *source;
|
||||
int deleted;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* file or archive comment, or filename */
|
||||
|
||||
struct zip_string {
|
||||
zip_uint8_t *raw; /* raw string */
|
||||
zip_uint16_t length; /* length of raw string */
|
||||
enum zip_encoding_type encoding; /* autorecognized encoding */
|
||||
zip_uint8_t *converted; /* autoconverted string */
|
||||
zip_uint32_t converted_length; /* length of converted */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* which files to write, and in which order (name is for torrentzip sorting) */
|
||||
|
||||
struct zip_filelist {
|
||||
zip_uint64_t idx;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern const char * const _zip_err_str[];
|
||||
extern const int _zip_nerr_str;
|
||||
extern const int _zip_err_type[];
|
||||
|
||||
|
||||
|
||||
#define ZIP_ENTRY_CHANGED(e, f) ((e)->changes && ((e)->changes->changed & (f)))
|
||||
|
||||
#define ZIP_ENTRY_DATA_CHANGED(x) ((x)->source != NULL)
|
||||
|
||||
#define ZIP_IS_RDONLY(za) ((za)->ch_flags & ZIP_AFL_RDONLY)
|
||||
|
||||
|
||||
|
||||
zip_int64_t _zip_add_entry(struct zip *);
|
||||
|
||||
int _zip_cdir_compute_crc(struct zip *, uLong *);
|
||||
void _zip_cdir_free(struct zip_cdir *);
|
||||
int _zip_cdir_grow(struct zip_cdir *, zip_uint64_t, struct zip_error *);
|
||||
struct zip_cdir *_zip_cdir_new(zip_uint64_t, struct zip_error *);
|
||||
zip_int64_t _zip_cdir_write(struct zip *, const struct zip_filelist *, zip_uint64_t, FILE *);
|
||||
|
||||
struct zip_dirent *_zip_dirent_clone(const struct zip_dirent *);
|
||||
void _zip_dirent_free(struct zip_dirent *);
|
||||
void _zip_dirent_finalize(struct zip_dirent *);
|
||||
void _zip_dirent_init(struct zip_dirent *);
|
||||
int _zip_dirent_needs_zip64(const struct zip_dirent *, zip_flags_t);
|
||||
struct zip_dirent *_zip_dirent_new(void);
|
||||
int _zip_dirent_read(struct zip_dirent *, FILE *, const unsigned char **,
|
||||
zip_uint64_t *, int, struct zip_error *);
|
||||
zip_int32_t _zip_dirent_size(FILE *, zip_uint16_t, struct zip_error *);
|
||||
void _zip_dirent_torrent_normalize(struct zip_dirent *);
|
||||
int _zip_dirent_write(struct zip_dirent *, FILE *, zip_flags_t, struct zip_error *);
|
||||
|
||||
struct zip_extra_field *_zip_ef_clone(const struct zip_extra_field *, struct zip_error *);
|
||||
struct zip_extra_field *_zip_ef_delete_by_id(struct zip_extra_field *, zip_uint16_t, zip_uint16_t, zip_flags_t);
|
||||
void _zip_ef_free(struct zip_extra_field *);
|
||||
const zip_uint8_t *_zip_ef_get_by_id(const struct zip_extra_field *, zip_uint16_t *, zip_uint16_t, zip_uint16_t, zip_flags_t, struct zip_error *);
|
||||
struct zip_extra_field *_zip_ef_merge(struct zip_extra_field *, struct zip_extra_field *);
|
||||
struct zip_extra_field *_zip_ef_new(zip_uint16_t, zip_uint16_t, const zip_uint8_t *, zip_flags_t);
|
||||
struct zip_extra_field *_zip_ef_parse(const zip_uint8_t *, zip_uint16_t, zip_flags_t, struct zip_error *);
|
||||
struct zip_extra_field *_zip_ef_remove_internal(struct zip_extra_field *);
|
||||
zip_uint16_t _zip_ef_size(const struct zip_extra_field *, zip_flags_t);
|
||||
void _zip_ef_write(const struct zip_extra_field *, zip_flags_t, FILE *);
|
||||
|
||||
void _zip_entry_finalize(struct zip_entry *);
|
||||
void _zip_entry_init(struct zip_entry *);
|
||||
|
||||
void _zip_error_clear(struct zip_error *);
|
||||
void _zip_error_copy(struct zip_error *, const struct zip_error *);
|
||||
void _zip_error_fini(struct zip_error *);
|
||||
void _zip_error_get(const struct zip_error *, int *, int *);
|
||||
void _zip_error_init(struct zip_error *);
|
||||
void _zip_error_set(struct zip_error *, int, int);
|
||||
void _zip_error_set_from_source(struct zip_error *, struct zip_source *);
|
||||
const char *_zip_error_strerror(struct zip_error *);
|
||||
|
||||
const zip_uint8_t *_zip_extract_extra_field_by_id(struct zip_error *, zip_uint16_t, int, const zip_uint8_t *, zip_uint16_t, zip_uint16_t *);
|
||||
|
||||
int _zip_file_extra_field_prepare_for_change(struct zip *, zip_uint64_t);
|
||||
int _zip_file_fillbuf(void *, size_t, struct zip_file *);
|
||||
zip_uint64_t _zip_file_get_offset(const struct zip *, zip_uint64_t, struct zip_error *);
|
||||
|
||||
int _zip_filerange_crc(FILE *, off_t, off_t, uLong *, struct zip_error *);
|
||||
|
||||
struct zip_dirent *_zip_get_dirent(struct zip *, zip_uint64_t, zip_flags_t, struct zip_error *);
|
||||
|
||||
enum zip_encoding_type _zip_guess_encoding(struct zip_string *, enum zip_encoding_type);
|
||||
zip_uint8_t *_zip_cp437_to_utf8(const zip_uint8_t * const, zip_uint32_t,
|
||||
zip_uint32_t *, struct zip_error *error);
|
||||
|
||||
struct zip *_zip_open(const char *, FILE *, unsigned int, int *);
|
||||
|
||||
int _zip_read_local_ef(struct zip *, zip_uint64_t);
|
||||
|
||||
struct zip_source *_zip_source_file_or_p(struct zip *, const char *, FILE *,
|
||||
zip_uint64_t, zip_int64_t, int,
|
||||
const struct zip_stat *);
|
||||
struct zip_source *_zip_source_new(struct zip *);
|
||||
struct zip_source *_zip_source_zip_new(struct zip *, struct zip *, zip_uint64_t, zip_flags_t,
|
||||
zip_uint64_t, zip_uint64_t, const char *);
|
||||
|
||||
int _zip_string_equal(const struct zip_string *, const struct zip_string *);
|
||||
void _zip_string_free(struct zip_string *);
|
||||
zip_uint32_t _zip_string_crc32(const struct zip_string *);
|
||||
const zip_uint8_t *_zip_string_get(struct zip_string *, zip_uint32_t *, zip_flags_t, struct zip_error *);
|
||||
zip_uint16_t _zip_string_length(const struct zip_string *);
|
||||
struct zip_string *_zip_string_new(const zip_uint8_t *, zip_uint16_t, zip_flags_t, struct zip_error *);
|
||||
void _zip_string_write(const struct zip_string *, FILE *);
|
||||
|
||||
int _zip_changed(const struct zip *, zip_uint64_t *);
|
||||
const char *_zip_get_name(struct zip *, zip_uint64_t, zip_flags_t, struct zip_error *);
|
||||
int _zip_local_header_read(struct zip *, int);
|
||||
void *_zip_memdup(const void *, size_t, struct zip_error *);
|
||||
zip_int64_t _zip_name_locate(struct zip *, const char *, zip_flags_t, struct zip_error *);
|
||||
struct zip *_zip_new(struct zip_error *);
|
||||
zip_uint16_t _zip_read2(const zip_uint8_t **);
|
||||
zip_uint32_t _zip_read4(const zip_uint8_t **);
|
||||
zip_uint64_t _zip_read8(const zip_uint8_t **);
|
||||
zip_uint8_t *_zip_read_data(const zip_uint8_t **, FILE *, size_t, int, struct zip_error *);
|
||||
zip_int64_t _zip_file_replace(struct zip *, zip_uint64_t, const char *, struct zip_source *, zip_flags_t);
|
||||
int _zip_set_name(struct zip *, zip_uint64_t, const char *, zip_flags_t);
|
||||
void _zip_u2d_time(time_t, zip_uint16_t *, zip_uint16_t *);
|
||||
int _zip_unchange(struct zip *, zip_uint64_t, int);
|
||||
void _zip_unchange_data(struct zip_entry *);
|
||||
|
||||
void _zip_poke4(zip_uint32_t, zip_uint8_t **);
|
||||
void _zip_poke8(zip_uint64_t, zip_uint8_t **);
|
||||
void _zip_write2(zip_uint16_t, FILE *);
|
||||
void _zip_write4(zip_uint32_t, FILE *);
|
||||
void _zip_write8(zip_uint64_t, FILE *);
|
||||
|
||||
|
||||
#endif /* zipint.h */
|
||||
1768
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zlib.h
vendored
Normal file
1768
Src/external_dependencies/openmpt-trunk/include/premake/contrib/libzip/zlib.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user