mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
license issue: substitution of miniLZO with miniz
This commit is contained in:
parent
62a7742421
commit
0c4883daf0
123
README.LZO
123
README.LZO
|
@ -1,123 +0,0 @@
|
|||
|
||||
============================================================================
|
||||
miniLZO -- mini subset of the LZO real-time data compression library
|
||||
============================================================================
|
||||
|
||||
Author : Markus Franz Xaver Johannes Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
http://www.oberhumer.com/opensource/lzo/
|
||||
Version : 2.08
|
||||
Date : 29 Jun 2014
|
||||
|
||||
I've created miniLZO for projects where it is inconvenient to
|
||||
include (or require) the full LZO source code just because you
|
||||
want to add a little bit of data compression to your application.
|
||||
|
||||
miniLZO implements the LZO1X-1 compressor and both the standard and
|
||||
safe LZO1X decompressor. Apart from fast compression it also useful
|
||||
for situations where you want to use pre-compressed data files (which
|
||||
must have been compressed with LZO1X-999).
|
||||
|
||||
miniLZO consists of one C source file and three header files:
|
||||
minilzo.c
|
||||
minilzo.h, lzoconf.h, lzodefs.h
|
||||
|
||||
To use miniLZO just copy these files into your source directory, add
|
||||
minilzo.c to your Makefile and #include minilzo.h from your program.
|
||||
Note: you also must distribute this file ('README.LZO') with your project.
|
||||
|
||||
minilzo.o compiles to about 6 KiB (using gcc or Visual C on an i386), and
|
||||
the sources are about 30 KiB when packed with zip - so there's no more
|
||||
excuse that your application doesn't support data compression :-)
|
||||
|
||||
For more information, documentation, example programs and other support
|
||||
files (like Makefiles and build scripts) please download the full LZO
|
||||
package from
|
||||
http://www.oberhumer.com/opensource/lzo/
|
||||
|
||||
Have fun,
|
||||
Markus
|
||||
|
||||
|
||||
P.S. minilzo.c is generated automatically from the LZO sources and
|
||||
therefore functionality is completely identical
|
||||
|
||||
|
||||
Appendix A: building miniLZO
|
||||
----------------------------
|
||||
miniLZO is written such a way that it should compile and run
|
||||
out-of-the-box on most machines.
|
||||
|
||||
If you are running on a very unusual architecture and lzo_init() fails then
|
||||
you should first recompile with '-DLZO_DEBUG' to see what causes the failure.
|
||||
The most probable case is something like 'sizeof(void *) != sizeof(size_t)'.
|
||||
After identifying the problem you can compile by adding some defines
|
||||
like '-DSIZEOF_VOID_P=8' to your Makefile.
|
||||
|
||||
The best solution is (of course) using Autoconf - if your project uses
|
||||
Autoconf anyway just add '-DMINILZO_HAVE_CONFIG_H' to your compiler
|
||||
flags when compiling minilzo.c. See the LZO distribution for an example
|
||||
how to set up configure.ac.
|
||||
|
||||
|
||||
Appendix B: list of public functions available in miniLZO
|
||||
---------------------------------------------------------
|
||||
Library initialization
|
||||
lzo_init()
|
||||
|
||||
Compression
|
||||
lzo1x_1_compress()
|
||||
|
||||
Decompression
|
||||
lzo1x_decompress()
|
||||
lzo1x_decompress_safe()
|
||||
|
||||
Checksum functions
|
||||
lzo_adler32()
|
||||
|
||||
Version functions
|
||||
lzo_version()
|
||||
lzo_version_string()
|
||||
lzo_version_date()
|
||||
|
||||
Portable (but slow) string functions
|
||||
lzo_memcmp()
|
||||
lzo_memcpy()
|
||||
lzo_memmove()
|
||||
lzo_memset()
|
||||
|
||||
|
||||
Appendix C: suggested macros for 'configure.ac' when using Autoconf
|
||||
-------------------------------------------------------------------
|
||||
Checks for typedefs and structures
|
||||
AC_CHECK_TYPE(ptrdiff_t,long)
|
||||
AC_TYPE_SIZE_T
|
||||
AC_CHECK_SIZEOF(short)
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(long)
|
||||
AC_CHECK_SIZEOF(long long)
|
||||
AC_CHECK_SIZEOF(__int64)
|
||||
AC_CHECK_SIZEOF(void *)
|
||||
AC_CHECK_SIZEOF(size_t)
|
||||
AC_CHECK_SIZEOF(ptrdiff_t)
|
||||
|
||||
Checks for compiler characteristics
|
||||
AC_C_CONST
|
||||
|
||||
Checks for library functions
|
||||
AC_CHECK_FUNCS(memcmp memcpy memmove memset)
|
||||
|
||||
|
||||
Appendix D: Copyright
|
||||
---------------------
|
||||
LZO and miniLZO are Copyright (C) 1996-2014 Markus Franz Xaver Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
LZO and miniLZO are distributed under the terms of the GNU General
|
||||
Public License (GPL). See the file COPYING.
|
||||
|
||||
Special licenses for commercial and other applications which
|
||||
are not willing to accept the GNU General Public License
|
||||
are available by contacting the author.
|
||||
|
||||
|
|
@ -7,9 +7,9 @@ SUBDIRS = ulib
|
|||
TO_INC = ulib/README \
|
||||
ulib/*.h \
|
||||
ulib/base/*.h \
|
||||
ulib/base/lzo/*.h \
|
||||
ulib/base/zip/*.h \
|
||||
ulib/base/ssl/*.h \
|
||||
ulib/base/miniz/*.h \
|
||||
ulib/base/zopfli/*.h \
|
||||
ulib/base/zopfli/COPYING \
|
||||
ulib/base/coder/*.h \
|
||||
|
|
|
@ -391,9 +391,9 @@ SUBDIRS = ulib
|
|||
TO_INC = ulib/README \
|
||||
ulib/*.h \
|
||||
ulib/base/*.h \
|
||||
ulib/base/lzo/*.h \
|
||||
ulib/base/zip/*.h \
|
||||
ulib/base/ssl/*.h \
|
||||
ulib/base/miniz/*.h \
|
||||
ulib/base/zopfli/*.h \
|
||||
ulib/base/zopfli/COPYING \
|
||||
ulib/base/coder/*.h \
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <ulib/utility/base64.h>
|
||||
#include <ulib/utility/hexdump.h>
|
||||
#include <ulib/utility/dir_walk.h>
|
||||
#include <ulib/utility/compress.h>
|
||||
#include <ulib/utility/interrupt.h>
|
||||
#include <ulib/utility/websocket.h>
|
||||
#include <ulib/utility/xml_escape.h>
|
||||
|
|
|
@ -1,444 +0,0 @@
|
|||
/* lzoconf.h -- configuration of the LZO data compression library
|
||||
|
||||
This file is part of the LZO real-time data compression library.
|
||||
|
||||
Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
The LZO library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
The LZO library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the LZO library; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
http://www.oberhumer.com/opensource/lzo/
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __LZOCONF_H_INCLUDED
|
||||
#define __LZOCONF_H_INCLUDED 1
|
||||
|
||||
#define LZO_VERSION 0x2080
|
||||
#define LZO_VERSION_STRING "2.08"
|
||||
#define LZO_VERSION_DATE "Jun 29 2014"
|
||||
|
||||
/* internal Autoconf configuration file - only used when building LZO */
|
||||
#if defined(LZO_HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
// LZO requires a conforming <limits.h>
|
||||
************************************************************************/
|
||||
|
||||
#if !defined(CHAR_BIT) || (CHAR_BIT != 8)
|
||||
# error "invalid CHAR_BIT"
|
||||
#endif
|
||||
#if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
|
||||
# error "check your compiler installation"
|
||||
#endif
|
||||
#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
|
||||
# error "your limits.h macros are broken"
|
||||
#endif
|
||||
|
||||
/* get OS and architecture defines */
|
||||
#ifndef __LZODEFS_H_INCLUDED
|
||||
#include "lzodefs.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
// some core defines
|
||||
************************************************************************/
|
||||
|
||||
/* memory checkers */
|
||||
#if !defined(__LZO_CHECKER)
|
||||
# if defined(__BOUNDS_CHECKING_ON)
|
||||
# define __LZO_CHECKER 1
|
||||
# elif defined(__CHECKER__)
|
||||
# define __LZO_CHECKER 1
|
||||
# elif defined(__INSURE__)
|
||||
# define __LZO_CHECKER 1
|
||||
# elif defined(__PURIFY__)
|
||||
# define __LZO_CHECKER 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
// integral and pointer types
|
||||
************************************************************************/
|
||||
|
||||
/* lzo_uint must match size_t */
|
||||
#if !defined(LZO_UINT_MAX)
|
||||
# if (LZO_ABI_LLP64)
|
||||
# if (LZO_OS_WIN64)
|
||||
typedef unsigned __int64 lzo_uint;
|
||||
typedef __int64 lzo_int;
|
||||
# else
|
||||
typedef lzo_ullong_t lzo_uint;
|
||||
typedef lzo_llong_t lzo_int;
|
||||
# endif
|
||||
# define LZO_SIZEOF_LZO_UINT 8
|
||||
# define LZO_UINT_MAX 0xffffffffffffffffull
|
||||
# define LZO_INT_MAX 9223372036854775807LL
|
||||
# define LZO_INT_MIN (-1LL - LZO_INT_MAX)
|
||||
# elif (LZO_ABI_IP32L64) /* MIPS R5900 */
|
||||
typedef unsigned int lzo_uint;
|
||||
typedef int lzo_int;
|
||||
# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_INT
|
||||
# define LZO_UINT_MAX UINT_MAX
|
||||
# define LZO_INT_MAX INT_MAX
|
||||
# define LZO_INT_MIN INT_MIN
|
||||
# elif (ULONG_MAX >= LZO_0xffffffffL)
|
||||
typedef unsigned long lzo_uint;
|
||||
typedef long lzo_int;
|
||||
# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LONG
|
||||
# define LZO_UINT_MAX ULONG_MAX
|
||||
# define LZO_INT_MAX LONG_MAX
|
||||
# define LZO_INT_MIN LONG_MIN
|
||||
# else
|
||||
# error "lzo_uint"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The larger type of lzo_uint and lzo_uint32_t. */
|
||||
#if (LZO_SIZEOF_LZO_UINT >= 4)
|
||||
# define lzo_xint lzo_uint
|
||||
#else
|
||||
# define lzo_xint lzo_uint32_t
|
||||
#endif
|
||||
|
||||
typedef int lzo_bool;
|
||||
|
||||
/* sanity checks */
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT)
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint))
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t))
|
||||
|
||||
#ifndef __LZO_MMODEL
|
||||
#define __LZO_MMODEL /*empty*/
|
||||
#endif
|
||||
|
||||
/* no typedef here because of const-pointer issues */
|
||||
#define lzo_bytep unsigned char __LZO_MMODEL *
|
||||
#define lzo_charp char __LZO_MMODEL *
|
||||
#define lzo_voidp void __LZO_MMODEL *
|
||||
#define lzo_shortp short __LZO_MMODEL *
|
||||
#define lzo_ushortp unsigned short __LZO_MMODEL *
|
||||
#define lzo_intp lzo_int __LZO_MMODEL *
|
||||
#define lzo_uintp lzo_uint __LZO_MMODEL *
|
||||
#define lzo_xintp lzo_xint __LZO_MMODEL *
|
||||
#define lzo_voidpp lzo_voidp __LZO_MMODEL *
|
||||
#define lzo_bytepp lzo_bytep __LZO_MMODEL *
|
||||
|
||||
#define lzo_int8_tp lzo_int8_t __LZO_MMODEL *
|
||||
#define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL *
|
||||
#define lzo_int16_tp lzo_int16_t __LZO_MMODEL *
|
||||
#define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL *
|
||||
#define lzo_int32_tp lzo_int32_t __LZO_MMODEL *
|
||||
#define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL *
|
||||
#if defined(lzo_int64_t)
|
||||
#define lzo_int64_tp lzo_int64_t __LZO_MMODEL *
|
||||
#define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL *
|
||||
#endif
|
||||
|
||||
/* Older LZO versions used to support ancient systems and memory models
|
||||
* like 16-bit MSDOS with __huge pointers and Cray PVP, but these
|
||||
* obsolete configurations are not supported any longer.
|
||||
*/
|
||||
#if defined(__LZO_MMODEL_HUGE)
|
||||
#error "__LZO_MMODEL_HUGE is unsupported"
|
||||
#endif
|
||||
#if (LZO_MM_PVP)
|
||||
#error "LZO_MM_PVP is unsupported"
|
||||
#endif
|
||||
#if (LZO_SIZEOF_INT < 4)
|
||||
#error "LZO_SIZEOF_INT < 4 is unsupported"
|
||||
#endif
|
||||
#if (__LZO_UINTPTR_T_IS_POINTER)
|
||||
#error "__LZO_UINTPTR_T_IS_POINTER is unsupported"
|
||||
#endif
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4)
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4)
|
||||
/* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should
|
||||
* work but have not received much testing lately, so be strict here.
|
||||
*/
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t))
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t))
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t))
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t))
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t))
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t))
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp))
|
||||
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep))
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
// function types
|
||||
************************************************************************/
|
||||
|
||||
/* name mangling */
|
||||
#if !defined(__LZO_EXTERN_C)
|
||||
# ifdef __cplusplus
|
||||
# define __LZO_EXTERN_C extern "C"
|
||||
# else
|
||||
# define __LZO_EXTERN_C extern
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* calling convention */
|
||||
#if !defined(__LZO_CDECL)
|
||||
# define __LZO_CDECL __lzo_cdecl
|
||||
#endif
|
||||
|
||||
/* DLL export information */
|
||||
#if !defined(__LZO_EXPORT1)
|
||||
# define __LZO_EXPORT1 /*empty*/
|
||||
#endif
|
||||
#if !defined(__LZO_EXPORT2)
|
||||
# define __LZO_EXPORT2 /*empty*/
|
||||
#endif
|
||||
|
||||
/* __cdecl calling convention for public C and assembly functions */
|
||||
#if !defined(LZO_PUBLIC)
|
||||
# define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
|
||||
#endif
|
||||
#if !defined(LZO_EXTERN)
|
||||
# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype)
|
||||
#endif
|
||||
#if !defined(LZO_PRIVATE)
|
||||
# define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL
|
||||
#endif
|
||||
|
||||
/* function types */
|
||||
typedef int
|
||||
(__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len,
|
||||
lzo_bytep dst, lzo_uintp dst_len,
|
||||
lzo_voidp wrkmem );
|
||||
|
||||
typedef int
|
||||
(__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len,
|
||||
lzo_bytep dst, lzo_uintp dst_len,
|
||||
lzo_voidp wrkmem );
|
||||
|
||||
typedef int
|
||||
(__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len,
|
||||
lzo_bytep dst, lzo_uintp dst_len,
|
||||
lzo_voidp wrkmem );
|
||||
|
||||
typedef int
|
||||
(__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len,
|
||||
lzo_bytep dst, lzo_uintp dst_len,
|
||||
lzo_voidp wrkmem,
|
||||
const lzo_bytep dict, lzo_uint dict_len );
|
||||
|
||||
typedef int
|
||||
(__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len,
|
||||
lzo_bytep dst, lzo_uintp dst_len,
|
||||
lzo_voidp wrkmem,
|
||||
const lzo_bytep dict, lzo_uint dict_len );
|
||||
|
||||
|
||||
/* Callback interface. Currently only the progress indicator ("nprogress")
|
||||
* is used, but this may change in a future release. */
|
||||
|
||||
struct lzo_callback_t;
|
||||
typedef struct lzo_callback_t lzo_callback_t;
|
||||
#define lzo_callback_p lzo_callback_t __LZO_MMODEL *
|
||||
|
||||
/* malloc & free function types */
|
||||
typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t)
|
||||
(lzo_callback_p self, lzo_uint items, lzo_uint size);
|
||||
typedef void (__LZO_CDECL *lzo_free_func_t)
|
||||
(lzo_callback_p self, lzo_voidp ptr);
|
||||
|
||||
/* a progress indicator callback function */
|
||||
typedef void (__LZO_CDECL *lzo_progress_func_t)
|
||||
(lzo_callback_p, lzo_uint, lzo_uint, int);
|
||||
|
||||
struct lzo_callback_t
|
||||
{
|
||||
/* custom allocators (set to 0 to disable) */
|
||||
lzo_alloc_func_t nalloc; /* [not used right now] */
|
||||
lzo_free_func_t nfree; /* [not used right now] */
|
||||
|
||||
/* a progress indicator callback function (set to 0 to disable) */
|
||||
lzo_progress_func_t nprogress;
|
||||
|
||||
/* INFO: the first parameter "self" of the nalloc/nfree/nprogress
|
||||
* callbacks points back to this struct, so you are free to store
|
||||
* some extra info in the following variables. */
|
||||
lzo_voidp user1;
|
||||
lzo_xint user2;
|
||||
lzo_xint user3;
|
||||
};
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
// error codes and prototypes
|
||||
************************************************************************/
|
||||
|
||||
/* Error codes for the compression/decompression functions. Negative
|
||||
* values are errors, positive values will be used for special but
|
||||
* normal events.
|
||||
*/
|
||||
#define LZO_E_OK 0
|
||||
#define LZO_E_ERROR (-1)
|
||||
#define LZO_E_OUT_OF_MEMORY (-2) /* [lzo_alloc_func_t failure] */
|
||||
#define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */
|
||||
#define LZO_E_INPUT_OVERRUN (-4)
|
||||
#define LZO_E_OUTPUT_OVERRUN (-5)
|
||||
#define LZO_E_LOOKBEHIND_OVERRUN (-6)
|
||||
#define LZO_E_EOF_NOT_FOUND (-7)
|
||||
#define LZO_E_INPUT_NOT_CONSUMED (-8)
|
||||
#define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */
|
||||
#define LZO_E_INVALID_ARGUMENT (-10)
|
||||
#define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */
|
||||
#define LZO_E_OUTPUT_NOT_CONSUMED (-12)
|
||||
#define LZO_E_INTERNAL_ERROR (-99)
|
||||
|
||||
|
||||
#ifndef lzo_sizeof_dict_t
|
||||
# define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep))
|
||||
#endif
|
||||
|
||||
/* lzo_init() should be the first function you call.
|
||||
* Check the return code !
|
||||
*
|
||||
* lzo_init() is a macro to allow checking that the library and the
|
||||
* compiler's view of various types are consistent.
|
||||
*/
|
||||
#define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
|
||||
(int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\
|
||||
(int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
|
||||
(int)sizeof(lzo_callback_t))
|
||||
LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int);
|
||||
|
||||
/* version functions (useful for shared libraries) */
|
||||
LZO_EXTERN(unsigned) lzo_version(void);
|
||||
LZO_EXTERN(const char *) lzo_version_string(void);
|
||||
LZO_EXTERN(const char *) lzo_version_date(void);
|
||||
LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
|
||||
LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
|
||||
|
||||
/* string functions */
|
||||
LZO_EXTERN(int)
|
||||
lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len);
|
||||
LZO_EXTERN(lzo_voidp)
|
||||
lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
|
||||
LZO_EXTERN(lzo_voidp)
|
||||
lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
|
||||
LZO_EXTERN(lzo_voidp)
|
||||
lzo_memset(lzo_voidp buf, int c, lzo_uint len);
|
||||
|
||||
/* checksum functions */
|
||||
LZO_EXTERN(lzo_uint32_t)
|
||||
lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
|
||||
LZO_EXTERN(lzo_uint32_t)
|
||||
lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
|
||||
LZO_EXTERN(const lzo_uint32_tp)
|
||||
lzo_get_crc32_table(void);
|
||||
|
||||
/* misc. */
|
||||
LZO_EXTERN(int) _lzo_config_check(void);
|
||||
typedef union {
|
||||
lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04;
|
||||
void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09;
|
||||
#if defined(lzo_int64_t)
|
||||
lzo_uint64_t a10;
|
||||
#endif
|
||||
} lzo_align_t;
|
||||
|
||||
/* align a char pointer on a boundary that is a multiple of 'size' */
|
||||
LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size);
|
||||
#define LZO_PTR_ALIGN_UP(p,size) \
|
||||
((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size)))
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
// deprecated macros - only for backward compatibility
|
||||
************************************************************************/
|
||||
|
||||
/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */
|
||||
#define lzo_byte unsigned char
|
||||
/* deprecated type names */
|
||||
#define lzo_int32 lzo_int32_t
|
||||
#define lzo_uint32 lzo_uint32_t
|
||||
#define lzo_int32p lzo_int32_t __LZO_MMODEL *
|
||||
#define lzo_uint32p lzo_uint32_t __LZO_MMODEL *
|
||||
#define LZO_INT32_MAX LZO_INT32_C(2147483647)
|
||||
#define LZO_UINT32_MAX LZO_UINT32_C(4294967295)
|
||||
#if defined(lzo_int64_t)
|
||||
#define lzo_int64 lzo_int64_t
|
||||
#define lzo_uint64 lzo_uint64_t
|
||||
#define lzo_int64p lzo_int64_t __LZO_MMODEL *
|
||||
#define lzo_uint64p lzo_uint64_t __LZO_MMODEL *
|
||||
#define LZO_INT64_MAX LZO_INT64_C(9223372036854775807)
|
||||
#define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615)
|
||||
#endif
|
||||
/* deprecated types */
|
||||
typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u;
|
||||
typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u;
|
||||
|
||||
#if defined(LZO_CFG_COMPAT)
|
||||
|
||||
#define __LZOCONF_H 1
|
||||
|
||||
#if defined(LZO_ARCH_I086)
|
||||
# define __LZO_i386 1
|
||||
#elif defined(LZO_ARCH_I386)
|
||||
# define __LZO_i386 1
|
||||
#endif
|
||||
|
||||
#if defined(LZO_OS_DOS16)
|
||||
# define __LZO_DOS 1
|
||||
# define __LZO_DOS16 1
|
||||
#elif defined(LZO_OS_DOS32)
|
||||
# define __LZO_DOS 1
|
||||
#elif defined(LZO_OS_WIN16)
|
||||
# define __LZO_WIN 1
|
||||
# define __LZO_WIN16 1
|
||||
#elif defined(LZO_OS_WIN32)
|
||||
# define __LZO_WIN 1
|
||||
#endif
|
||||
|
||||
#define __LZO_CMODEL /*empty*/
|
||||
#define __LZO_DMODEL /*empty*/
|
||||
#define __LZO_ENTRY __LZO_CDECL
|
||||
#define LZO_EXTERN_CDECL LZO_EXTERN
|
||||
#define LZO_ALIGN LZO_PTR_ALIGN_UP
|
||||
|
||||
#define lzo_compress_asm_t lzo_compress_t
|
||||
#define lzo_decompress_asm_t lzo_decompress_t
|
||||
|
||||
#endif /* LZO_CFG_COMPAT */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* already included */
|
||||
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,94 +0,0 @@
|
|||
/* minilzo.h -- mini subset of the LZO real-time data compression library
|
||||
|
||||
This file is part of the LZO real-time data compression library.
|
||||
|
||||
Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
The LZO library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
The LZO library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the LZO library; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
http://www.oberhumer.com/opensource/lzo/
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE:
|
||||
* the full LZO package can be found at
|
||||
* http://www.oberhumer.com/opensource/lzo/
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __MINILZO_H
|
||||
#define __MINILZO_H 1
|
||||
|
||||
#define MINILZO_VERSION 0x2080
|
||||
|
||||
#ifdef __LZOCONF_H
|
||||
# error "you cannot use both LZO and miniLZO"
|
||||
#endif
|
||||
|
||||
#undef LZO_HAVE_CONFIG_H
|
||||
#include "lzoconf.h"
|
||||
|
||||
#if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION)
|
||||
# error "version mismatch in header files"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
//
|
||||
************************************************************************/
|
||||
|
||||
/* Memory required for the wrkmem parameter.
|
||||
* When the required size is 0, you can also pass a NULL pointer.
|
||||
*/
|
||||
|
||||
#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS
|
||||
#define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t))
|
||||
#define LZO1X_MEM_DECOMPRESS (0)
|
||||
|
||||
|
||||
/* compression */
|
||||
LZO_EXTERN(int)
|
||||
lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len,
|
||||
lzo_bytep dst, lzo_uintp dst_len,
|
||||
lzo_voidp wrkmem );
|
||||
|
||||
/* decompression */
|
||||
LZO_EXTERN(int)
|
||||
lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len,
|
||||
lzo_bytep dst, lzo_uintp dst_len,
|
||||
lzo_voidp wrkmem /* NOT USED */ );
|
||||
|
||||
/* safe decompression with overrun testing */
|
||||
LZO_EXTERN(int)
|
||||
lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len,
|
||||
lzo_bytep dst, lzo_uintp dst_len,
|
||||
lzo_voidp wrkmem /* NOT USED */ );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* already included */
|
||||
|
887
include/ulib/base/miniz/miniz.h
Normal file
887
include/ulib/base/miniz/miniz.h
Normal file
|
@ -0,0 +1,887 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013-2014 RAD Game Tools and Valve Software
|
||||
* Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/* miniz.c v1.15 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
|
||||
See "unlicense" statement at the end of this file.
|
||||
Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013
|
||||
Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt
|
||||
|
||||
Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define
|
||||
MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros).
|
||||
|
||||
* Change History
|
||||
10/13/13 v1.15 - Interim bugfix release while I work on the next major release with Zip64 support (almost there!):
|
||||
- Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug
|
||||
would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place()
|
||||
(which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag).
|
||||
- Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size
|
||||
- Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries.
|
||||
Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice).
|
||||
- Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes
|
||||
- mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed
|
||||
- Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6.
|
||||
- Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti
|
||||
- Merged MZ_FORCEINLINE fix from hdeanclark
|
||||
- Fix <time.h> include before config #ifdef, thanks emil.brink
|
||||
- Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can
|
||||
set it to 1 for real-time compression).
|
||||
- Merged in some compiler fixes from paulharris's github repro.
|
||||
- Retested this build under Windows (VS 2010, including static analysis), tcc 0.9.26, gcc v4.6 and clang v3.3.
|
||||
- Added example6.c, which dumps an image of the mandelbrot set to a PNG file.
|
||||
- Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more.
|
||||
5/20/12 v1.14 - MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include <time.h> (thanks fermtect).
|
||||
5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit.
|
||||
- Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files.
|
||||
- Eliminated a bunch of warnings when compiling with GCC 32-bit/64.
|
||||
- Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly
|
||||
"Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning).
|
||||
- Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64.
|
||||
- Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test.
|
||||
- Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives.
|
||||
- Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.)
|
||||
- Fix ftell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself).
|
||||
4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's.
|
||||
level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson <bruced@valvesoftware.com> for the feedback/bug report.
|
||||
5/28/11 v1.11 - Added statement from unlicense.org
|
||||
5/27/11 v1.10 - Substantial compressor optimizations:
|
||||
- Level 1 is now ~4x faster than before. The L1 compressor's throughput now varies between 70-110MB/sec. on a
|
||||
- Core i7 (actual throughput varies depending on the type of data, and x64 vs. x86).
|
||||
- Improved baseline L2-L9 compression perf. Also, greatly improved compression perf. issues on some file types.
|
||||
- Refactored the compression code for better readability and maintainability.
|
||||
- Added level 10 compression level (L10 has slightly better ratio than level 9, but could have a potentially large
|
||||
drop in throughput on some files).
|
||||
5/15/11 v1.09 - Initial stable release.
|
||||
|
||||
* Low-level Deflate/Inflate implementation notes:
|
||||
|
||||
Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or
|
||||
greedy parsing, match length filtering, RLE-only, and Huffman-only streams. It performs and compresses
|
||||
approximately as well as zlib.
|
||||
|
||||
Decompression: Use the "tinfl" API's. The entire decompressor is implemented as a single function
|
||||
coroutine: see tinfl_decompress(). It supports decompression into a 32KB (or larger power of 2) wrapping buffer, or into a memory
|
||||
block large enough to hold the entire file.
|
||||
|
||||
The low-level tdefl/tinfl API's do not make any use of dynamic memory allocation.
|
||||
|
||||
* zlib-style API notes:
|
||||
|
||||
miniz.c implements a fairly large subset of zlib. There's enough functionality present for it to be a drop-in
|
||||
zlib replacement in many apps:
|
||||
The z_stream struct, optional memory allocation callbacks
|
||||
deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound
|
||||
inflateInit/inflateInit2/inflate/inflateEnd
|
||||
compress, compress2, compressBound, uncompress
|
||||
CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines.
|
||||
Supports raw deflate streams or standard zlib streams with adler-32 checking.
|
||||
|
||||
Limitations:
|
||||
The callback API's are not implemented yet. No support for gzip headers or zlib static dictionaries.
|
||||
I've tried to closely emulate zlib's various flavors of stream flushing and return status codes, but
|
||||
there are no guarantees that miniz.c pulls this off perfectly.
|
||||
|
||||
* PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, originally written by
|
||||
Alex Evans. Supports 1-4 bytes/pixel images.
|
||||
|
||||
* ZIP archive API notes:
|
||||
|
||||
The ZIP archive API's where designed with simplicity and efficiency in mind, with just enough abstraction to
|
||||
get the job done with minimal fuss. There are simple API's to retrieve file information, read files from
|
||||
existing archives, create new archives, append new files to existing archives, or clone archive data from
|
||||
one archive to another. It supports archives located in memory or the heap, on disk (using stdio.h),
|
||||
or you can specify custom file read/write callbacks.
|
||||
|
||||
- Archive reading: Just call this function to read a single file from a disk archive:
|
||||
|
||||
void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name,
|
||||
size_t *pSize, mz_uint zip_flags);
|
||||
|
||||
For more complex cases, use the "mz_zip_reader" functions. Upon opening an archive, the entire central
|
||||
directory is located and read as-is into memory, and subsequent file access only occurs when reading individual files.
|
||||
|
||||
- Archives file scanning: The simple way is to use this function to scan a loaded archive for a specific file:
|
||||
|
||||
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
|
||||
|
||||
The locate operation can optionally check file comments too, which (as one example) can be used to identify
|
||||
multiple versions of the same file in an archive. This function uses a simple linear search through the central
|
||||
directory, so it's not very fast.
|
||||
|
||||
Alternately, you can iterate through all the files in an archive (using mz_zip_reader_get_num_files()) and
|
||||
retrieve detailed info on each file by calling mz_zip_reader_file_stat().
|
||||
|
||||
- Archive creation: Use the "mz_zip_writer" functions. The ZIP writer immediately writes compressed file data
|
||||
to disk and builds an exact image of the central directory in memory. The central directory image is written
|
||||
all at once at the end of the archive file when the archive is finalized.
|
||||
|
||||
The archive writer can optionally align each file's local header and file data to any power of 2 alignment,
|
||||
which can be useful when the archive will be read from optical media. Also, the writer supports placing
|
||||
arbitrary data blobs at the very beginning of ZIP archives. Archives written using either feature are still
|
||||
readable by any ZIP tool.
|
||||
|
||||
- Archive appending: The simple way to add a single file to an archive is to call this function:
|
||||
|
||||
mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name,
|
||||
const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
|
||||
|
||||
The archive will be created if it doesn't already exist, otherwise it'll be appended to.
|
||||
Note the appending is done in-place and is not an atomic operation, so if something goes wrong
|
||||
during the operation it's possible the archive could be left without a central directory (although the local
|
||||
file headers and file data will be fine, so the archive will be recoverable).
|
||||
|
||||
For more complex archive modification scenarios:
|
||||
1. The safest way is to use a mz_zip_reader to read the existing archive, cloning only those bits you want to
|
||||
preserve into a new archive using using the mz_zip_writer_add_from_zip_reader() function (which compiles the
|
||||
compressed file data as-is). When you're done, delete the old archive and rename the newly written archive, and
|
||||
you're done. This is safe but requires a bunch of temporary disk space or heap memory.
|
||||
|
||||
2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using mz_zip_writer_init_from_reader(),
|
||||
append new files as needed, then finalize the archive which will write an updated central directory to the
|
||||
original archive. (This is basically what mz_zip_add_mem_to_archive_file_in_place() does.) There's a
|
||||
possibility that the archive's central directory could be lost with this method if anything goes wrong, though.
|
||||
|
||||
- ZIP archive support limitations:
|
||||
No zip64 or spanning support. Extraction functions can only handle unencrypted, stored or deflated files.
|
||||
Requires streams capable of seeking.
|
||||
|
||||
* This is a header file library, like stb_image.c. To get only a header file, either cut and paste the
|
||||
below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then include miniz.c from it.
|
||||
|
||||
* Important: For best perf. be sure to customize the below macros for your target platform:
|
||||
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
|
||||
#define MINIZ_LITTLE_ENDIAN 1
|
||||
#define MINIZ_HAS_64BIT_REGISTERS 1
|
||||
|
||||
* On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before including miniz.c to ensure miniz
|
||||
uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be able to process large files
|
||||
(i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes).
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define MZ_ASSERT(x) assert(x)
|
||||
|
||||
#ifdef MINIZ_NO_MALLOC
|
||||
#define MZ_MALLOC(x) NULL
|
||||
#define MZ_FREE(x) (void) x, ((void)0)
|
||||
#define MZ_REALLOC(p, x) NULL
|
||||
#else
|
||||
#define MZ_MALLOC(x) malloc(x)
|
||||
#define MZ_FREE(x) free(x)
|
||||
#define MZ_REALLOC(p, x) realloc(p, x)
|
||||
#endif
|
||||
|
||||
#define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MZ_MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj))
|
||||
|
||||
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
|
||||
#define MZ_READ_LE16(p) *((const mz_uint16 *)(p))
|
||||
#define MZ_READ_LE32(p) *((const mz_uint32 *)(p))
|
||||
#else
|
||||
#define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))
|
||||
#define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U))
|
||||
#endif
|
||||
|
||||
#define MZ_READ_LE64(p) (((mz_uint64)MZ_READ_LE32(p)) | (((mz_uint64)MZ_READ_LE32((const mz_uint8 *)(p) + sizeof(mz_uint32))) << 32U))
|
||||
|
||||
#ifdef COMPILER_MSVC
|
||||
#define MZ_FORCEINLINE __forceinline
|
||||
#elif defined(COMPILER_GCCLIKE)
|
||||
#define MZ_FORCEINLINE inline __attribute__((__always_inline__))
|
||||
#else
|
||||
#define MZ_FORCEINLINE inline
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void *miniz_def_alloc_func(void *opaque, size_t items, size_t size);
|
||||
extern void miniz_def_free_func(void *opaque, void *address);
|
||||
extern void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size);
|
||||
|
||||
#define MZ_UINT16_MAX (0xFFFFU)
|
||||
#define MZ_UINT32_MAX (0xFFFFFFFFU)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// Defines to completely disable specific portions of miniz.c:
|
||||
// If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl.
|
||||
|
||||
// Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O.
|
||||
#define MINIZ_NO_STDIO
|
||||
|
||||
// If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able to get the current time, or
|
||||
// get/set file times, and the C run-time funcs that get/set times won't be called.
|
||||
// The current downside is the times written to your archives will be from 1979.
|
||||
#define MINIZ_NO_TIME
|
||||
|
||||
// Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's.
|
||||
#define MINIZ_NO_ARCHIVE_APIS
|
||||
|
||||
// Define MINIZ_NO_ARCHIVE_APIS to disable all writing related ZIP archive API's.
|
||||
#define MINIZ_NO_ARCHIVE_WRITING_APIS
|
||||
|
||||
// Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression API's.
|
||||
//#define MINIZ_NO_ZLIB_APIS
|
||||
|
||||
// Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib.
|
||||
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
|
||||
|
||||
// Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc.
|
||||
// Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc
|
||||
// callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user
|
||||
// functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work.
|
||||
//#define MINIZ_NO_MALLOC
|
||||
|
||||
#if defined(__TINYC__) && (defined(__linux) || defined(__linux__))
|
||||
// TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux
|
||||
#define MINIZ_NO_TIME
|
||||
#endif
|
||||
|
||||
#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__)
|
||||
// MINIZ_X86_OR_X64_CPU is only used to help set the below macros.
|
||||
#define MINIZ_X86_OR_X64_CPU 1
|
||||
#endif
|
||||
|
||||
#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU
|
||||
// Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian.
|
||||
#define MINIZ_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#if MINIZ_X86_OR_X64_CPU
|
||||
// Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses.
|
||||
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
|
||||
#endif
|
||||
|
||||
#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__)
|
||||
// Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions).
|
||||
#define MINIZ_HAS_64BIT_REGISTERS 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ------------------- zlib-style API Definitions.
|
||||
|
||||
// For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits!
|
||||
typedef unsigned long mz_ulong;
|
||||
|
||||
// mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap.
|
||||
void mz_free(void *p);
|
||||
|
||||
#define MZ_ADLER32_INIT (1)
|
||||
// mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL.
|
||||
mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
|
||||
|
||||
#define MZ_CRC32_INIT (0)
|
||||
// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL.
|
||||
mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
|
||||
|
||||
// Compression strategies.
|
||||
enum
|
||||
{
|
||||
MZ_DEFAULT_STRATEGY = 0,
|
||||
MZ_FILTERED = 1,
|
||||
MZ_HUFFMAN_ONLY = 2,
|
||||
MZ_RLE = 3,
|
||||
MZ_FIXED = 4
|
||||
};
|
||||
|
||||
// Method
|
||||
#define MZ_DEFLATED 8
|
||||
|
||||
#ifndef MINIZ_NO_ZLIB_APIS
|
||||
|
||||
// Heap allocation callbacks.
|
||||
// Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long.
|
||||
typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size);
|
||||
typedef void (*mz_free_func)(void *opaque, void *address);
|
||||
typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size);
|
||||
|
||||
#define MZ_VERSION "9.1.15"
|
||||
#define MZ_VERNUM 0x91F0
|
||||
#define MZ_VER_MAJOR 9
|
||||
#define MZ_VER_MINOR 1
|
||||
#define MZ_VER_REVISION 15
|
||||
#define MZ_VER_SUBREVISION 0
|
||||
|
||||
// Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs).
|
||||
enum
|
||||
{
|
||||
MZ_NO_FLUSH = 0,
|
||||
MZ_PARTIAL_FLUSH = 1,
|
||||
MZ_SYNC_FLUSH = 2,
|
||||
MZ_FULL_FLUSH = 3,
|
||||
MZ_FINISH = 4,
|
||||
MZ_BLOCK = 5
|
||||
};
|
||||
|
||||
// Return status codes. MZ_PARAM_ERROR is non-standard.
|
||||
enum
|
||||
{
|
||||
MZ_OK = 0,
|
||||
MZ_STREAM_END = 1,
|
||||
MZ_NEED_DICT = 2,
|
||||
MZ_ERRNO = -1,
|
||||
MZ_STREAM_ERROR = -2,
|
||||
MZ_DATA_ERROR = -3,
|
||||
MZ_MEM_ERROR = -4,
|
||||
MZ_BUF_ERROR = -5,
|
||||
MZ_VERSION_ERROR = -6,
|
||||
MZ_PARAM_ERROR = -10000
|
||||
};
|
||||
|
||||
// Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL.
|
||||
enum
|
||||
{
|
||||
MZ_NO_COMPRESSION = 0,
|
||||
MZ_BEST_SPEED = 1,
|
||||
MZ_BEST_COMPRESSION = 9,
|
||||
MZ_UBER_COMPRESSION = 10,
|
||||
MZ_DEFAULT_LEVEL = 6,
|
||||
MZ_DEFAULT_COMPRESSION = -1
|
||||
};
|
||||
|
||||
// Window bits
|
||||
#define MZ_DEFAULT_WINDOW_BITS 15
|
||||
|
||||
struct mz_internal_state;
|
||||
|
||||
// Compression/decompression stream struct.
|
||||
typedef struct mz_stream_s
|
||||
{
|
||||
const unsigned char *next_in; // pointer to next byte to read
|
||||
unsigned int avail_in; // number of bytes available at next_in
|
||||
mz_ulong total_in; // total number of bytes consumed so far
|
||||
|
||||
unsigned char *next_out; // pointer to next byte to write
|
||||
unsigned int avail_out; // number of bytes that can be written to next_out
|
||||
mz_ulong total_out; // total number of bytes produced so far
|
||||
|
||||
char *msg; // error msg (unused)
|
||||
struct mz_internal_state *state; // internal state, allocated by zalloc/zfree
|
||||
|
||||
mz_alloc_func zalloc; // optional heap allocation function (defaults to malloc)
|
||||
mz_free_func zfree; // optional heap free function (defaults to free)
|
||||
void *opaque; // heap alloc function user pointer
|
||||
|
||||
int data_type; // data_type (unused)
|
||||
mz_ulong adler; // adler32 of the source or uncompressed data
|
||||
mz_ulong reserved; // not used
|
||||
} mz_stream;
|
||||
|
||||
typedef mz_stream *mz_streamp;
|
||||
|
||||
// Returns the version string of miniz.c.
|
||||
const char *mz_version(void);
|
||||
|
||||
// mz_deflateInit() initializes a compressor with default options:
|
||||
// Parameters:
|
||||
// pStream must point to an initialized mz_stream struct.
|
||||
// level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION].
|
||||
// level 1 enables a specially optimized compression function that's been optimized purely for performance, not ratio.
|
||||
// (This special func. is currently only enabled when MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.)
|
||||
// Return values:
|
||||
// MZ_OK on success.
|
||||
// MZ_STREAM_ERROR if the stream is bogus.
|
||||
// MZ_PARAM_ERROR if the input parameters are bogus.
|
||||
// MZ_MEM_ERROR on out of memory.
|
||||
int mz_deflateInit(mz_streamp pStream, int level);
|
||||
|
||||
// mz_deflateInit2() is like mz_deflate(), except with more control:
|
||||
// Additional parameters:
|
||||
// method must be MZ_DEFLATED
|
||||
// window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer)
|
||||
// mem_level must be between [1, 9] (it's checked but ignored by miniz.c)
|
||||
int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy);
|
||||
|
||||
// Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2().
|
||||
int mz_deflateReset(mz_streamp pStream);
|
||||
|
||||
// mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible.
|
||||
// Parameters:
|
||||
// pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members.
|
||||
// flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or MZ_FINISH.
|
||||
// Return values:
|
||||
// MZ_OK on success (when flushing, or if more input is needed but not available, and/or there's more output to be written but the output buffer is full).
|
||||
// MZ_STREAM_END if all input has been consumed and all output bytes have been written. Don't call mz_deflate() on the stream anymore.
|
||||
// MZ_STREAM_ERROR if the stream is bogus.
|
||||
// MZ_PARAM_ERROR if one of the parameters is invalid.
|
||||
// MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.)
|
||||
int mz_deflate(mz_streamp pStream, int flush);
|
||||
|
||||
// mz_deflateEnd() deinitializes a compressor:
|
||||
// Return values:
|
||||
// MZ_OK on success.
|
||||
// MZ_STREAM_ERROR if the stream is bogus.
|
||||
int mz_deflateEnd(mz_streamp pStream);
|
||||
|
||||
// mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH.
|
||||
mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len);
|
||||
|
||||
// Single-call compression functions mz_compress() and mz_compress2():
|
||||
// Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure.
|
||||
int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
|
||||
int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level);
|
||||
|
||||
// mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress().
|
||||
mz_ulong mz_compressBound(mz_ulong source_len);
|
||||
|
||||
// Initializes a decompressor.
|
||||
int mz_inflateInit(mz_streamp pStream);
|
||||
|
||||
// mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer:
|
||||
// window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate).
|
||||
int mz_inflateInit2(mz_streamp pStream, int window_bits);
|
||||
|
||||
// Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible.
|
||||
// Parameters:
|
||||
// pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members.
|
||||
// flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH.
|
||||
// On the first call, if flush is MZ_FINISH it's assumed the input and output buffers are both sized large enough to decompress the entire stream in a single call (this is slightly faster).
|
||||
// MZ_FINISH implies that there are no more source bytes available beside what's already in the input buffer, and that the output buffer is large enough to hold the rest of the decompressed data.
|
||||
// Return values:
|
||||
// MZ_OK on success. Either more input is needed but not available, and/or there's more output to be written but the output buffer is full.
|
||||
// MZ_STREAM_END if all needed input has been consumed and all output bytes have been written. For zlib streams, the adler-32 of the decompressed data has also been verified.
|
||||
// MZ_STREAM_ERROR if the stream is bogus.
|
||||
// MZ_DATA_ERROR if the deflate stream is invalid.
|
||||
// MZ_PARAM_ERROR if one of the parameters is invalid.
|
||||
// MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again
|
||||
// with more input data, or with more room in the output buffer (except when using single call decompression, described above).
|
||||
int mz_inflate(mz_streamp pStream, int flush);
|
||||
|
||||
// Deinitializes a decompressor.
|
||||
int mz_inflateEnd(mz_streamp pStream);
|
||||
|
||||
// Single-call decompression.
|
||||
// Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure.
|
||||
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
|
||||
|
||||
// Returns a string description of the specified error code, or NULL if the error code is invalid.
|
||||
const char *mz_error(int err);
|
||||
|
||||
// Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports.
|
||||
// Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project.
|
||||
#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
|
||||
typedef unsigned char Byte;
|
||||
typedef unsigned int uInt;
|
||||
typedef mz_ulong uLong;
|
||||
typedef Byte Bytef;
|
||||
typedef uInt uIntf;
|
||||
typedef char charf;
|
||||
typedef int intf;
|
||||
typedef void *voidpf;
|
||||
typedef uLong uLongf;
|
||||
typedef void *voidp;
|
||||
typedef void *const voidpc;
|
||||
#define Z_NULL 0
|
||||
#define Z_NO_FLUSH MZ_NO_FLUSH
|
||||
#define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH
|
||||
#define Z_SYNC_FLUSH MZ_SYNC_FLUSH
|
||||
#define Z_FULL_FLUSH MZ_FULL_FLUSH
|
||||
#define Z_FINISH MZ_FINISH
|
||||
#define Z_BLOCK MZ_BLOCK
|
||||
#define Z_OK MZ_OK
|
||||
#define Z_STREAM_END MZ_STREAM_END
|
||||
#define Z_NEED_DICT MZ_NEED_DICT
|
||||
#define Z_ERRNO MZ_ERRNO
|
||||
#define Z_STREAM_ERROR MZ_STREAM_ERROR
|
||||
#define Z_DATA_ERROR MZ_DATA_ERROR
|
||||
#define Z_MEM_ERROR MZ_MEM_ERROR
|
||||
#define Z_BUF_ERROR MZ_BUF_ERROR
|
||||
#define Z_VERSION_ERROR MZ_VERSION_ERROR
|
||||
#define Z_PARAM_ERROR MZ_PARAM_ERROR
|
||||
#define Z_NO_COMPRESSION MZ_NO_COMPRESSION
|
||||
#define Z_BEST_SPEED MZ_BEST_SPEED
|
||||
#define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION
|
||||
#define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION
|
||||
#define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY
|
||||
#define Z_FILTERED MZ_FILTERED
|
||||
#define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY
|
||||
#define Z_RLE MZ_RLE
|
||||
#define Z_FIXED MZ_FIXED
|
||||
#define Z_DEFLATED MZ_DEFLATED
|
||||
#define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS
|
||||
#define alloc_func mz_alloc_func
|
||||
#define free_func mz_free_func
|
||||
#define internal_state mz_internal_state
|
||||
#define z_stream mz_stream
|
||||
#define deflateInit mz_deflateInit
|
||||
#define deflateInit2 mz_deflateInit2
|
||||
#define deflateReset mz_deflateReset
|
||||
#define deflate mz_deflate
|
||||
#define deflateEnd mz_deflateEnd
|
||||
#define deflateBound mz_deflateBound
|
||||
#define compress mz_compress
|
||||
#define compress2 mz_compress2
|
||||
#define compressBound mz_compressBound
|
||||
#define inflateInit mz_inflateInit
|
||||
#define inflateInit2 mz_inflateInit2
|
||||
#define inflate mz_inflate
|
||||
#define inflateEnd mz_inflateEnd
|
||||
#define uncompress mz_uncompress
|
||||
#define crc32 mz_crc32
|
||||
#define adler32 mz_adler32
|
||||
#define MAX_WBITS 15
|
||||
#define MAX_MEM_LEVEL 9
|
||||
#define zError mz_error
|
||||
#define ZLIB_VERSION MZ_VERSION
|
||||
#define ZLIB_VERNUM MZ_VERNUM
|
||||
#define ZLIB_VER_MAJOR MZ_VER_MAJOR
|
||||
#define ZLIB_VER_MINOR MZ_VER_MINOR
|
||||
#define ZLIB_VER_REVISION MZ_VER_REVISION
|
||||
#define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION
|
||||
#define zlibVersion mz_version
|
||||
#define zlib_version mz_version()
|
||||
#endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
|
||||
|
||||
#endif // MINIZ_NO_ZLIB_APIS
|
||||
|
||||
// ------------------- Types and macros
|
||||
|
||||
typedef unsigned char mz_uint8;
|
||||
typedef signed short mz_int16;
|
||||
typedef unsigned short mz_uint16;
|
||||
typedef unsigned int mz_uint32;
|
||||
typedef unsigned int mz_uint;
|
||||
typedef int64_t mz_int64;
|
||||
typedef uint64_t mz_uint64;
|
||||
typedef int mz_bool;
|
||||
|
||||
#define MZ_FALSE (0)
|
||||
#define MZ_TRUE (1)
|
||||
|
||||
// Works around MSVC's spammy "warning C4127: conditional expression is constant" message.
|
||||
#ifdef COMPILER_MSVC
|
||||
#define MZ_MACRO_END while (0, 0)
|
||||
#else
|
||||
#define MZ_MACRO_END while (0)
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------- Low-level Decompression API Definitions
|
||||
|
||||
// Decompression flags used by tinfl_decompress().
|
||||
// TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream.
|
||||
// TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input.
|
||||
// TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB).
|
||||
// TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes.
|
||||
enum
|
||||
{
|
||||
TINFL_FLAG_PARSE_ZLIB_HEADER = 1,
|
||||
TINFL_FLAG_HAS_MORE_INPUT = 2,
|
||||
TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4,
|
||||
TINFL_FLAG_COMPUTE_ADLER32 = 8
|
||||
};
|
||||
|
||||
// High level decompression functions:
|
||||
// tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc().
|
||||
// On entry:
|
||||
// pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress.
|
||||
// On return:
|
||||
// Function returns a pointer to the decompressed data, or NULL on failure.
|
||||
// *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data.
|
||||
// The caller must call mz_free() on the returned block when it's no longer needed.
|
||||
void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
|
||||
|
||||
// tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory.
|
||||
// Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success.
|
||||
#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1))
|
||||
size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
|
||||
|
||||
// tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer.
|
||||
// Returns 1 on success or 0 on failure.
|
||||
typedef int (*tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
|
||||
int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
|
||||
|
||||
struct tinfl_decompressor_tag;
|
||||
typedef struct tinfl_decompressor_tag tinfl_decompressor;
|
||||
|
||||
// Max size of LZ dictionary.
|
||||
#define TINFL_LZ_DICT_SIZE 32768
|
||||
|
||||
// Return status.
|
||||
typedef enum
|
||||
{
|
||||
// This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data
|
||||
// is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly).
|
||||
// If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again.
|
||||
TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS = -4,
|
||||
|
||||
// This flag indicates that one or more of the input parameters was obviously bogus. (You can try calling it again, but if you get this error the calling code is wrong.)
|
||||
TINFL_STATUS_BAD_PARAM = -3,
|
||||
TINFL_STATUS_ADLER32_MISMATCH = -2,
|
||||
TINFL_STATUS_FAILED = -1,
|
||||
TINFL_STATUS_DONE = 0,
|
||||
TINFL_STATUS_NEEDS_MORE_INPUT = 1,
|
||||
TINFL_STATUS_HAS_MORE_OUTPUT = 2
|
||||
} tinfl_status;
|
||||
|
||||
// Initializes the decompressor to its initial state.
|
||||
#define tinfl_init(r) \
|
||||
do \
|
||||
{ \
|
||||
(r)->m_state = 0; \
|
||||
} \
|
||||
MZ_MACRO_END
|
||||
#define tinfl_get_adler32(r) (r)->m_check_adler32
|
||||
|
||||
// Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability.
|
||||
// This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output.
|
||||
tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags);
|
||||
|
||||
// Internal/private bits follow.
|
||||
enum
|
||||
{
|
||||
TINFL_MAX_HUFF_TABLES = 3,
|
||||
TINFL_MAX_HUFF_SYMBOLS_0 = 288,
|
||||
TINFL_MAX_HUFF_SYMBOLS_1 = 32,
|
||||
TINFL_MAX_HUFF_SYMBOLS_2 = 19,
|
||||
TINFL_FAST_LOOKUP_BITS = 10,
|
||||
TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0];
|
||||
mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2];
|
||||
} tinfl_huff_table;
|
||||
|
||||
#if MINIZ_HAS_64BIT_REGISTERS
|
||||
#define TINFL_USE_64BIT_BITBUF 1
|
||||
#endif
|
||||
|
||||
#if TINFL_USE_64BIT_BITBUF
|
||||
typedef mz_uint64 tinfl_bit_buf_t;
|
||||
#define TINFL_BITBUF_SIZE (64)
|
||||
#else
|
||||
typedef mz_uint32 tinfl_bit_buf_t;
|
||||
#define TINFL_BITBUF_SIZE (32)
|
||||
#endif
|
||||
|
||||
struct tinfl_decompressor_tag
|
||||
{
|
||||
mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES];
|
||||
tinfl_bit_buf_t m_bit_buf;
|
||||
size_t m_dist_from_out_buf_start;
|
||||
tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES];
|
||||
mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137];
|
||||
};
|
||||
|
||||
// ------------------- Low-level Compression API Definitions
|
||||
|
||||
// Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly slower, and raw/dynamic blocks will be output more frequently).
|
||||
#define TDEFL_LESS_MEMORY 0
|
||||
|
||||
// tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search):
|
||||
// TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression).
|
||||
enum
|
||||
{
|
||||
TDEFL_HUFFMAN_ONLY = 0,
|
||||
TDEFL_DEFAULT_MAX_PROBES = 128,
|
||||
TDEFL_MAX_PROBES_MASK = 0xFFF
|
||||
};
|
||||
|
||||
// TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data.
|
||||
// TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even when not writing zlib headers).
|
||||
// TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more efficient lazy parsing.
|
||||
// TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's initialization time to the minimum, but the output may vary from run to run given the same input (depending on the contents of memory).
|
||||
// TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1)
|
||||
// TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled.
|
||||
// TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables.
|
||||
// TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks.
|
||||
// The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK).
|
||||
enum
|
||||
{
|
||||
TDEFL_WRITE_ZLIB_HEADER = 0x01000,
|
||||
TDEFL_COMPUTE_ADLER32 = 0x02000,
|
||||
TDEFL_GREEDY_PARSING_FLAG = 0x04000,
|
||||
TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000,
|
||||
TDEFL_RLE_MATCHES = 0x10000,
|
||||
TDEFL_FILTER_MATCHES = 0x20000,
|
||||
TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000,
|
||||
TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000
|
||||
};
|
||||
|
||||
// High level compression functions:
|
||||
// tdefl_compress_mem_to_heap() compresses a block in memory to a heap block allocated via malloc().
|
||||
// On entry:
|
||||
// pSrc_buf, src_buf_len: Pointer and size of source block to compress.
|
||||
// flags: The max match finder probes (default is 128) logically OR'd against the above flags. Higher probes are slower but improve compression.
|
||||
// On return:
|
||||
// Function returns a pointer to the compressed data, or NULL on failure.
|
||||
// *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data.
|
||||
// The caller must free() the returned block when it's no longer needed.
|
||||
void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
|
||||
|
||||
// tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory.
|
||||
// Returns 0 on failure.
|
||||
size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
|
||||
|
||||
// Compresses an image to a compressed PNG file in memory.
|
||||
// On entry:
|
||||
// pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4.
|
||||
// The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory.
|
||||
// level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL
|
||||
// If flip is true, the image will be flipped on the Y axis (useful for OpenGL apps).
|
||||
// On return:
|
||||
// Function returns a pointer to the compressed data, or NULL on failure.
|
||||
// *pLen_out will be set to the size of the PNG image file.
|
||||
// The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed.
|
||||
void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip);
|
||||
void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out);
|
||||
|
||||
// Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time.
|
||||
typedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
|
||||
|
||||
// tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally.
|
||||
mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
|
||||
|
||||
enum
|
||||
{
|
||||
TDEFL_MAX_HUFF_TABLES = 3,
|
||||
TDEFL_MAX_HUFF_SYMBOLS_0 = 288,
|
||||
TDEFL_MAX_HUFF_SYMBOLS_1 = 32,
|
||||
TDEFL_MAX_HUFF_SYMBOLS_2 = 19,
|
||||
TDEFL_LZ_DICT_SIZE = 32768,
|
||||
TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1,
|
||||
TDEFL_MIN_MATCH_LEN = 3,
|
||||
TDEFL_MAX_MATCH_LEN = 258
|
||||
};
|
||||
|
||||
// TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes).
|
||||
#if TDEFL_LESS_MEMORY
|
||||
enum
|
||||
{
|
||||
TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024,
|
||||
TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10,
|
||||
TDEFL_MAX_HUFF_SYMBOLS = 288,
|
||||
TDEFL_LZ_HASH_BITS = 12,
|
||||
TDEFL_LEVEL1_HASH_SIZE_MASK = 4095,
|
||||
TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3,
|
||||
TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS
|
||||
};
|
||||
#else
|
||||
enum
|
||||
{
|
||||
TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024,
|
||||
TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10,
|
||||
TDEFL_MAX_HUFF_SYMBOLS = 288,
|
||||
TDEFL_LZ_HASH_BITS = 15,
|
||||
TDEFL_LEVEL1_HASH_SIZE_MASK = 4095,
|
||||
TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3,
|
||||
TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS
|
||||
};
|
||||
#endif
|
||||
|
||||
// The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions.
|
||||
typedef enum
|
||||
{
|
||||
TDEFL_STATUS_BAD_PARAM = -2,
|
||||
TDEFL_STATUS_PUT_BUF_FAILED = -1,
|
||||
TDEFL_STATUS_OKAY = 0,
|
||||
TDEFL_STATUS_DONE = 1,
|
||||
} tdefl_status;
|
||||
|
||||
// Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums
|
||||
typedef enum
|
||||
{
|
||||
TDEFL_NO_FLUSH = 0,
|
||||
TDEFL_SYNC_FLUSH = 2,
|
||||
TDEFL_FULL_FLUSH = 3,
|
||||
TDEFL_FINISH = 4
|
||||
} tdefl_flush;
|
||||
|
||||
// tdefl's compression state structure.
|
||||
typedef struct
|
||||
{
|
||||
tdefl_put_buf_func_ptr m_pPut_buf_func;
|
||||
void *m_pPut_buf_user;
|
||||
mz_uint m_flags, m_max_probes[2];
|
||||
int m_greedy_parsing;
|
||||
mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size;
|
||||
mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end;
|
||||
mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer;
|
||||
mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish;
|
||||
tdefl_status m_prev_return_status;
|
||||
const void *m_pIn_buf;
|
||||
void *m_pOut_buf;
|
||||
size_t *m_pIn_buf_size, *m_pOut_buf_size;
|
||||
tdefl_flush m_flush;
|
||||
const mz_uint8 *m_pSrc;
|
||||
size_t m_src_buf_left, m_out_buf_ofs;
|
||||
mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1];
|
||||
mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
|
||||
mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
|
||||
mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
|
||||
mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE];
|
||||
mz_uint16 m_next[TDEFL_LZ_DICT_SIZE];
|
||||
mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE];
|
||||
mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE];
|
||||
} tdefl_compressor;
|
||||
|
||||
// Initializes the compressor.
|
||||
// There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory.
|
||||
// pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
|
||||
// If pBut_buf_func is NULL the user should always call the tdefl_compress() API.
|
||||
// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.)
|
||||
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
|
||||
|
||||
// Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible.
|
||||
tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush);
|
||||
|
||||
// tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr.
|
||||
// tdefl_compress_buffer() always consumes the entire input buffer.
|
||||
tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush);
|
||||
|
||||
tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d);
|
||||
mz_uint32 tdefl_get_adler32(tdefl_compressor *d);
|
||||
|
||||
// Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't defined, because it uses some of its macros.
|
||||
#ifndef MINIZ_NO_ZLIB_APIS
|
||||
// Create tdefl_compress() flags given zlib-style compression parameters.
|
||||
// level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files)
|
||||
// window_bits may be -15 (raw deflate) or 15 (zlib)
|
||||
// strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED
|
||||
mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy);
|
||||
#endif // #ifndef MINIZ_NO_ZLIB_APIS
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -137,6 +137,7 @@ static URDBObjectHandler<UDataStorage*>* db_user;
|
|||
static URDBObjectHandler<UDataStorage*>* db_nodog;
|
||||
|
||||
#define IP_UNIFI "151.11.47.5"
|
||||
#define IP_UNIFI_TMP "159.213.248.230"
|
||||
#define IP_CASCINE "159.213.248.232"
|
||||
#define NAMED_PIPE "/tmp/wi_auth_db.op"
|
||||
#define FIRENZECARD_REDIR "http://wxfi.comune.fi.it/?ap=%v"
|
||||
|
@ -1700,7 +1701,7 @@ static void usp_init_wi_auth()
|
|||
vallow_IP_user = U_NEW(UVector<UIPAllow*>);
|
||||
vallow_IP_request = U_NEW(UVector<UIPAllow*>);
|
||||
|
||||
(void) x.assign(U_CONSTANT_TO_PARAM("172.0.0.0/8, " IP_UNIFI ", " IP_CASCINE)); // NB: unifi and cascine has MasqueradeDevice...
|
||||
(void) x.assign(U_CONSTANT_TO_PARAM("172.0.0.0/8, " IP_UNIFI ", " IP_UNIFI_TMP ", " IP_CASCINE)); // NB: unifi and cascine has MasqueradeDevice...
|
||||
|
||||
(void) UIPAllow::parseMask(x, *vallow_IP_request);
|
||||
|
||||
|
@ -2831,7 +2832,8 @@ static void setAccessPointLocalization()
|
|||
U_INTERNAL_ASSERT_POINTER(url_banner_ap_path)
|
||||
U_INTERNAL_ASSERT_POINTER(url_banner_comune_path)
|
||||
|
||||
if (ap_address->equal(U_CONSTANT_TO_PARAM(IP_UNIFI)))
|
||||
if (ap_address->equal(U_CONSTANT_TO_PARAM(IP_UNIFI)) ||
|
||||
ap_address->equal(U_CONSTANT_TO_PARAM(IP_UNIFI)))
|
||||
{
|
||||
if (ap_label->equal(U_CONSTANT_TO_PARAM("05"))) // careggi
|
||||
{
|
||||
|
@ -5686,7 +5688,7 @@ static void POST_LoginRequest(bool idp)
|
|||
if (idp == false &&
|
||||
*ip &&
|
||||
ip->equal(U_CLIENT_ADDRESS_TO_PARAM) == false &&
|
||||
UClientImage_Base::isAllowed(*vallow_IP_request) == false) // "172.0.0.0/8, 159.213.248.230"
|
||||
UClientImage_Base::isAllowed(*vallow_IP_request) == false) // 172.0.0.0/8, ...
|
||||
{
|
||||
U_LOGGER("*** PARAM IP(%v) FROM AP(%v) IS DIFFERENT FROM CLIENT ADDRESS(%.*s) - REALM(%v) UID(%v) ***", ip->rep, ap->rep, U_CLIENT_ADDRESS_TO_TRACE, realm.rep, uid->rep);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define U_SSL_TIMEOUT_MS (10L * 1000L) // 10 second handshake timeout
|
||||
|
||||
// NB: to avoid mis-aligned we use 4 bytes...
|
||||
#define U_LZOP_COMPRESS "\x89LZO" // "\211LZO" "\x89\x4c\x5a\x4f"
|
||||
#define U_MINIZ_COMPRESS "\x89MNZ" // "\211MNZ" "\x89\x4d\x4e\x5a"
|
||||
|
||||
#define U_PATH_MAX (1024U - (1 + sizeof(ustringrep)))
|
||||
// -------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// = LIBRARY
|
||||
// ULib - c++ library
|
||||
//
|
||||
// = FILENAME
|
||||
// compress.h
|
||||
//
|
||||
// = AUTHOR
|
||||
// Stefano Casazza
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
#ifndef ULIB_COMPRESS_H
|
||||
#define ULIB_COMPRESS_H 1
|
||||
|
||||
#include <ulib/internal/common.h>
|
||||
|
||||
struct U_EXPORT UCompress {
|
||||
|
||||
static void init();
|
||||
static bool flag_init;
|
||||
|
||||
static uint32_t compress(const char* src, uint32_t src_len, char* dst);
|
||||
static uint32_t decompress(const char* src, uint32_t src_len, char* dst);
|
||||
|
||||
// We want to compress the data block at `src' with length `src_len' to
|
||||
// the block at `dst'. Because the input block may be incompressible,
|
||||
// we must provide a little more output space in case that compression
|
||||
// is not possible.
|
||||
|
||||
static uint32_t space(uint32_t src_len)
|
||||
{
|
||||
U_TRACE(0, "UCompress::space(%u)", src_len)
|
||||
|
||||
U_RETURN(src_len + src_len / 64 + 16 + 3);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
// LZO method
|
||||
|
||||
static bool isCompress(const char* s) { return (*(int32_t*)s == U_MULTICHAR_CONSTANT32('\x89','L','Z','O')); }
|
||||
static bool isCompress(const char* s) { return (*(int32_t*)s == U_MULTICHAR_CONSTANT32('\x89','M','N','Z')); } // U_MINIZ_COMPRESS
|
||||
static bool isCompress(const UString& s) { return isCompress(s.data()); }
|
||||
|
||||
static UString compress(const char* s, uint32_t n);
|
||||
|
|
|
@ -14,10 +14,10 @@ pkgconfigdir = $(libdir)/pkgconfig
|
|||
pkgconfig_DATA = ULib.pc
|
||||
|
||||
## DEFS = -DDEBUG_DEBUG @DEFS@
|
||||
## base/lzo/minilzo.c
|
||||
## base/mkqsort.c base/rsort.c
|
||||
|
||||
SRC_C = base/base.c base/base_error.c base/hash.c base/utility.c \
|
||||
base/lzo/minilzo.c \
|
||||
SRC_C = base/base.c base/base_error.c base/hash.c base/utility.c base/miniz/miniz.c \
|
||||
base/coder/cbase64.c base/coder/cquoted_printable.c base/coder/curl_coder.c base/coder/cxml_coder.c base/coder/cescape.c base/coder/chexdump.c
|
||||
|
||||
SRC_CPP = internal/common.cpp \
|
||||
|
@ -26,7 +26,7 @@ SRC_CPP = internal/common.cpp \
|
|||
dynamic/dynamic.cpp dynamic/plugin.cpp \
|
||||
mime/header.cpp mime/entity.cpp mime/multipart.cpp \
|
||||
container/vector.cpp container/hash_map.cpp container/tree.cpp \
|
||||
utility/interrupt.cpp utility/compress.cpp utility/services.cpp utility/semaphore.cpp utility/base64.cpp \
|
||||
utility/interrupt.cpp utility/services.cpp utility/semaphore.cpp utility/base64.cpp \
|
||||
utility/lock.cpp utility/string_ext.cpp utility/socket_ext.cpp utility/uhttp.cpp \
|
||||
utility/data_session.cpp utility/ring_buffer.cpp utility/websocket.cpp utility/dir_walk.cpp \
|
||||
lemon/expression.cpp \
|
||||
|
|
|
@ -204,7 +204,7 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)"
|
|||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
lib@ULIB@_la_LIBADD =
|
||||
am__lib@ULIB@_la_SOURCES_DIST = base/base.c base/base_error.c \
|
||||
base/hash.c base/utility.c base/lzo/minilzo.c \
|
||||
base/hash.c base/utility.c base/miniz/miniz.c \
|
||||
base/coder/cbase64.c base/coder/cquoted_printable.c \
|
||||
base/coder/curl_coder.c base/coder/cxml_coder.c \
|
||||
base/coder/cescape.c base/coder/chexdump.c base/base_trace.c \
|
||||
|
@ -221,9 +221,9 @@ am__lib@ULIB@_la_SOURCES_DIST = base/base.c base/base_error.c \
|
|||
dynamic/dynamic.cpp dynamic/plugin.cpp mime/header.cpp \
|
||||
mime/entity.cpp mime/multipart.cpp container/vector.cpp \
|
||||
container/hash_map.cpp container/tree.cpp \
|
||||
utility/interrupt.cpp utility/compress.cpp \
|
||||
utility/services.cpp utility/semaphore.cpp utility/base64.cpp \
|
||||
utility/lock.cpp utility/string_ext.cpp utility/socket_ext.cpp \
|
||||
utility/interrupt.cpp utility/services.cpp \
|
||||
utility/semaphore.cpp utility/base64.cpp utility/lock.cpp \
|
||||
utility/string_ext.cpp utility/socket_ext.cpp \
|
||||
utility/uhttp.cpp utility/data_session.cpp \
|
||||
utility/ring_buffer.cpp utility/websocket.cpp \
|
||||
utility/dir_walk.cpp lemon/expression.cpp orm/orm.cpp \
|
||||
|
@ -296,7 +296,7 @@ am__dirstamp = $(am__leading_dot)dirstamp
|
|||
@SSL_TRUE@am__objects_20 = base/ssl/cdes3.lo base/ssl/dgst.lo
|
||||
@MINGW_TRUE@am__objects_21 = base/win32/mingw32.lo
|
||||
am__objects_22 = base/base.lo base/base_error.lo base/hash.lo \
|
||||
base/utility.lo base/lzo/minilzo.lo base/coder/cbase64.lo \
|
||||
base/utility.lo base/miniz/miniz.lo base/coder/cbase64.lo \
|
||||
base/coder/cquoted_printable.lo base/coder/curl_coder.lo \
|
||||
base/coder/cxml_coder.lo base/coder/cescape.lo \
|
||||
base/coder/chexdump.lo $(am__objects_1) $(am__objects_2) \
|
||||
|
@ -371,14 +371,13 @@ am__objects_61 = internal/common.lo ui/dialog.lo db/cdb.lo db/rdb.lo \
|
|||
debug/debug_common.lo debug/error.lo dynamic/dynamic.lo \
|
||||
dynamic/plugin.lo mime/header.lo mime/entity.lo \
|
||||
mime/multipart.lo container/vector.lo container/hash_map.lo \
|
||||
container/tree.lo utility/interrupt.lo utility/compress.lo \
|
||||
utility/services.lo utility/semaphore.lo utility/base64.lo \
|
||||
utility/lock.lo utility/string_ext.lo utility/socket_ext.lo \
|
||||
utility/uhttp.lo utility/data_session.lo \
|
||||
utility/ring_buffer.lo utility/websocket.lo \
|
||||
utility/dir_walk.lo lemon/expression.lo orm/orm.lo \
|
||||
orm/orm_driver.lo net/ipaddress.lo net/socket.lo net/ping.lo \
|
||||
net/server/server.lo net/server/client_image.lo \
|
||||
container/tree.lo utility/interrupt.lo utility/services.lo \
|
||||
utility/semaphore.lo utility/base64.lo utility/lock.lo \
|
||||
utility/string_ext.lo utility/socket_ext.lo utility/uhttp.lo \
|
||||
utility/data_session.lo utility/ring_buffer.lo \
|
||||
utility/websocket.lo utility/dir_walk.lo lemon/expression.lo \
|
||||
orm/orm.lo orm/orm_driver.lo net/ipaddress.lo net/socket.lo \
|
||||
net/ping.lo net/server/server.lo net/server/client_image.lo \
|
||||
net/client/client_rdb.lo net/server/client_image_rdb.lo \
|
||||
net/server/server_rdb.lo \
|
||||
net/server/plugin/mod_proxy_service.lo net/rpc/rpc.lo \
|
||||
|
@ -660,7 +659,7 @@ DEFAULT_INCLUDES = -I. -I$(top_builddir)/include
|
|||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = ULib.pc
|
||||
SRC_C = base/base.c base/base_error.c base/hash.c base/utility.c \
|
||||
base/lzo/minilzo.c base/coder/cbase64.c \
|
||||
base/miniz/miniz.c base/coder/cbase64.c \
|
||||
base/coder/cquoted_printable.c base/coder/curl_coder.c \
|
||||
base/coder/cxml_coder.c base/coder/cescape.c \
|
||||
base/coder/chexdump.c $(am__append_4) $(am__append_7) \
|
||||
|
@ -675,9 +674,9 @@ SRC_CPP = internal/common.cpp ui/dialog.cpp db/cdb.cpp db/rdb.cpp \
|
|||
debug/debug_common.cpp debug/error.cpp dynamic/dynamic.cpp \
|
||||
dynamic/plugin.cpp mime/header.cpp mime/entity.cpp \
|
||||
mime/multipart.cpp container/vector.cpp container/hash_map.cpp \
|
||||
container/tree.cpp utility/interrupt.cpp utility/compress.cpp \
|
||||
utility/services.cpp utility/semaphore.cpp utility/base64.cpp \
|
||||
utility/lock.cpp utility/string_ext.cpp utility/socket_ext.cpp \
|
||||
container/tree.cpp utility/interrupt.cpp utility/services.cpp \
|
||||
utility/semaphore.cpp utility/base64.cpp utility/lock.cpp \
|
||||
utility/string_ext.cpp utility/socket_ext.cpp \
|
||||
utility/uhttp.cpp utility/data_session.cpp \
|
||||
utility/ring_buffer.cpp utility/websocket.cpp \
|
||||
utility/dir_walk.cpp lemon/expression.cpp orm/orm.cpp \
|
||||
|
@ -805,14 +804,14 @@ base/base_error.lo: base/$(am__dirstamp) \
|
|||
base/$(DEPDIR)/$(am__dirstamp)
|
||||
base/hash.lo: base/$(am__dirstamp) base/$(DEPDIR)/$(am__dirstamp)
|
||||
base/utility.lo: base/$(am__dirstamp) base/$(DEPDIR)/$(am__dirstamp)
|
||||
base/lzo/$(am__dirstamp):
|
||||
@$(MKDIR_P) base/lzo
|
||||
@: > base/lzo/$(am__dirstamp)
|
||||
base/lzo/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) base/lzo/$(DEPDIR)
|
||||
@: > base/lzo/$(DEPDIR)/$(am__dirstamp)
|
||||
base/lzo/minilzo.lo: base/lzo/$(am__dirstamp) \
|
||||
base/lzo/$(DEPDIR)/$(am__dirstamp)
|
||||
base/miniz/$(am__dirstamp):
|
||||
@$(MKDIR_P) base/miniz
|
||||
@: > base/miniz/$(am__dirstamp)
|
||||
base/miniz/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) base/miniz/$(DEPDIR)
|
||||
@: > base/miniz/$(DEPDIR)/$(am__dirstamp)
|
||||
base/miniz/miniz.lo: base/miniz/$(am__dirstamp) \
|
||||
base/miniz/$(DEPDIR)/$(am__dirstamp)
|
||||
base/coder/$(am__dirstamp):
|
||||
@$(MKDIR_P) base/coder
|
||||
@: > base/coder/$(am__dirstamp)
|
||||
|
@ -978,8 +977,6 @@ utility/$(DEPDIR)/$(am__dirstamp):
|
|||
@: > utility/$(DEPDIR)/$(am__dirstamp)
|
||||
utility/interrupt.lo: utility/$(am__dirstamp) \
|
||||
utility/$(DEPDIR)/$(am__dirstamp)
|
||||
utility/compress.lo: utility/$(am__dirstamp) \
|
||||
utility/$(DEPDIR)/$(am__dirstamp)
|
||||
utility/services.lo: utility/$(am__dirstamp) \
|
||||
utility/$(DEPDIR)/$(am__dirstamp)
|
||||
utility/semaphore.lo: utility/$(am__dirstamp) \
|
||||
|
@ -1335,8 +1332,8 @@ mostlyclean-compile:
|
|||
-rm -f base/*.lo
|
||||
-rm -f base/coder/*.$(OBJEXT)
|
||||
-rm -f base/coder/*.lo
|
||||
-rm -f base/lzo/*.$(OBJEXT)
|
||||
-rm -f base/lzo/*.lo
|
||||
-rm -f base/miniz/*.$(OBJEXT)
|
||||
-rm -f base/miniz/*.lo
|
||||
-rm -f base/ssl/*.$(OBJEXT)
|
||||
-rm -f base/ssl/*.lo
|
||||
-rm -f base/win32/*.$(OBJEXT)
|
||||
|
@ -1452,7 +1449,7 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@base/coder/$(DEPDIR)/curl_coder.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@base/coder/$(DEPDIR)/cxml_coder.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@base/coder/$(DEPDIR)/zopfli.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@base/lzo/$(DEPDIR)/minilzo.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@base/miniz/$(DEPDIR)/miniz.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@base/ssl/$(DEPDIR)/cdes3.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@base/ssl/$(DEPDIR)/dgst.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@base/win32/$(DEPDIR)/mingw32.Plo@am__quote@
|
||||
|
@ -1563,7 +1560,6 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@ssl/net/$(DEPDIR)/sslsocket.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/dialog.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@utility/$(DEPDIR)/base64.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@utility/$(DEPDIR)/compress.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@utility/$(DEPDIR)/data_session.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@utility/$(DEPDIR)/des3.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@utility/$(DEPDIR)/dir_walk.Plo@am__quote@
|
||||
|
@ -1646,7 +1642,7 @@ clean-libtool:
|
|||
-rm -rf .libs _libs
|
||||
-rm -rf base/.libs base/_libs
|
||||
-rm -rf base/coder/.libs base/coder/_libs
|
||||
-rm -rf base/lzo/.libs base/lzo/_libs
|
||||
-rm -rf base/miniz/.libs base/miniz/_libs
|
||||
-rm -rf base/ssl/.libs base/ssl/_libs
|
||||
-rm -rf base/win32/.libs base/win32/_libs
|
||||
-rm -rf base/zip/.libs base/zip/_libs
|
||||
|
@ -1785,8 +1781,8 @@ distclean-generic:
|
|||
-rm -f base/$(am__dirstamp)
|
||||
-rm -f base/coder/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f base/coder/$(am__dirstamp)
|
||||
-rm -f base/lzo/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f base/lzo/$(am__dirstamp)
|
||||
-rm -f base/miniz/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f base/miniz/$(am__dirstamp)
|
||||
-rm -f base/ssl/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f base/ssl/$(am__dirstamp)
|
||||
-rm -f base/win32/$(DEPDIR)/$(am__dirstamp)
|
||||
|
@ -1878,7 +1874,7 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool clean-local \
|
|||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR) base/$(DEPDIR) base/coder/$(DEPDIR) base/lzo/$(DEPDIR) base/ssl/$(DEPDIR) base/win32/$(DEPDIR) base/zip/$(DEPDIR) container/$(DEPDIR) curl/$(DEPDIR) db/$(DEPDIR) dbi/$(DEPDIR) debug/$(DEPDIR) dynamic/$(DEPDIR) event/$(DEPDIR) flex/$(DEPDIR) internal/$(DEPDIR) json/$(DEPDIR) ldap/$(DEPDIR) lemon/$(DEPDIR) libevent/$(DEPDIR) magic/$(DEPDIR) mime/$(DEPDIR) net/$(DEPDIR) net/client/$(DEPDIR) net/rpc/$(DEPDIR) net/server/$(DEPDIR) net/server/plugin/$(DEPDIR) net/server/plugin/mod_geoip/$(DEPDIR) net/server/plugin/mod_shib/$(DEPDIR) orm/$(DEPDIR) orm/driver/$(DEPDIR) pcre/$(DEPDIR) query/$(DEPDIR) replace/$(DEPDIR) ssh/net/$(DEPDIR) ssl/$(DEPDIR) ssl/mime/$(DEPDIR) ssl/net/$(DEPDIR) ui/$(DEPDIR) utility/$(DEPDIR) xml/expat/$(DEPDIR) xml/libxml2/$(DEPDIR) xml/soap/$(DEPDIR) zip/$(DEPDIR)
|
||||
-rm -rf ./$(DEPDIR) base/$(DEPDIR) base/coder/$(DEPDIR) base/miniz/$(DEPDIR) base/ssl/$(DEPDIR) base/win32/$(DEPDIR) base/zip/$(DEPDIR) container/$(DEPDIR) curl/$(DEPDIR) db/$(DEPDIR) dbi/$(DEPDIR) debug/$(DEPDIR) dynamic/$(DEPDIR) event/$(DEPDIR) flex/$(DEPDIR) internal/$(DEPDIR) json/$(DEPDIR) ldap/$(DEPDIR) lemon/$(DEPDIR) libevent/$(DEPDIR) magic/$(DEPDIR) mime/$(DEPDIR) net/$(DEPDIR) net/client/$(DEPDIR) net/rpc/$(DEPDIR) net/server/$(DEPDIR) net/server/plugin/$(DEPDIR) net/server/plugin/mod_geoip/$(DEPDIR) net/server/plugin/mod_shib/$(DEPDIR) orm/$(DEPDIR) orm/driver/$(DEPDIR) pcre/$(DEPDIR) query/$(DEPDIR) replace/$(DEPDIR) ssh/net/$(DEPDIR) ssl/$(DEPDIR) ssl/mime/$(DEPDIR) ssl/net/$(DEPDIR) ui/$(DEPDIR) utility/$(DEPDIR) xml/expat/$(DEPDIR) xml/libxml2/$(DEPDIR) xml/soap/$(DEPDIR) zip/$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic
|
||||
|
||||
|
@ -1923,7 +1919,7 @@ install-ps-am:
|
|||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR) base/$(DEPDIR) base/coder/$(DEPDIR) base/lzo/$(DEPDIR) base/ssl/$(DEPDIR) base/win32/$(DEPDIR) base/zip/$(DEPDIR) container/$(DEPDIR) curl/$(DEPDIR) db/$(DEPDIR) dbi/$(DEPDIR) debug/$(DEPDIR) dynamic/$(DEPDIR) event/$(DEPDIR) flex/$(DEPDIR) internal/$(DEPDIR) json/$(DEPDIR) ldap/$(DEPDIR) lemon/$(DEPDIR) libevent/$(DEPDIR) magic/$(DEPDIR) mime/$(DEPDIR) net/$(DEPDIR) net/client/$(DEPDIR) net/rpc/$(DEPDIR) net/server/$(DEPDIR) net/server/plugin/$(DEPDIR) net/server/plugin/mod_geoip/$(DEPDIR) net/server/plugin/mod_shib/$(DEPDIR) orm/$(DEPDIR) orm/driver/$(DEPDIR) pcre/$(DEPDIR) query/$(DEPDIR) replace/$(DEPDIR) ssh/net/$(DEPDIR) ssl/$(DEPDIR) ssl/mime/$(DEPDIR) ssl/net/$(DEPDIR) ui/$(DEPDIR) utility/$(DEPDIR) xml/expat/$(DEPDIR) xml/libxml2/$(DEPDIR) xml/soap/$(DEPDIR) zip/$(DEPDIR)
|
||||
-rm -rf ./$(DEPDIR) base/$(DEPDIR) base/coder/$(DEPDIR) base/miniz/$(DEPDIR) base/ssl/$(DEPDIR) base/win32/$(DEPDIR) base/zip/$(DEPDIR) container/$(DEPDIR) curl/$(DEPDIR) db/$(DEPDIR) dbi/$(DEPDIR) debug/$(DEPDIR) dynamic/$(DEPDIR) event/$(DEPDIR) flex/$(DEPDIR) internal/$(DEPDIR) json/$(DEPDIR) ldap/$(DEPDIR) lemon/$(DEPDIR) libevent/$(DEPDIR) magic/$(DEPDIR) mime/$(DEPDIR) net/$(DEPDIR) net/client/$(DEPDIR) net/rpc/$(DEPDIR) net/server/$(DEPDIR) net/server/plugin/$(DEPDIR) net/server/plugin/mod_geoip/$(DEPDIR) net/server/plugin/mod_shib/$(DEPDIR) orm/$(DEPDIR) orm/driver/$(DEPDIR) pcre/$(DEPDIR) query/$(DEPDIR) replace/$(DEPDIR) ssh/net/$(DEPDIR) ssl/$(DEPDIR) ssl/mime/$(DEPDIR) ssl/net/$(DEPDIR) ui/$(DEPDIR) utility/$(DEPDIR) xml/expat/$(DEPDIR) xml/libxml2/$(DEPDIR) xml/soap/$(DEPDIR) zip/$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "base/hash.c"
|
||||
#include "base/utility.c"
|
||||
#include "base/base_error.c"
|
||||
#include "base/lzo/minilzo.c"
|
||||
#include "base/miniz/miniz.c"
|
||||
#include "base/coder/cbase64.c"
|
||||
#include "base/coder/cescape.c"
|
||||
#include "base/coder/chexdump.c"
|
||||
|
|
|
@ -79,7 +79,6 @@
|
|||
#include "utility/base64.cpp"
|
||||
#include "utility/dir_walk.cpp"
|
||||
#include "utility/interrupt.cpp"
|
||||
#include "utility/compress.cpp"
|
||||
#include "utility/services.cpp"
|
||||
#include "utility/semaphore.cpp"
|
||||
#include "utility/websocket.cpp"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
2780
src/ulib/base/miniz/miniz.c
Normal file
2780
src/ulib/base/miniz/miniz.c
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -465,11 +465,13 @@ bool UClient_Base::sendRequest(bool bread_response)
|
|||
bool bssl_save = USocketExt::bssl;
|
||||
USocketExt::bssl = socket->isSSL(true);
|
||||
bool blocking_save = USocketExt::blocking;
|
||||
USocketExt::blocking = socket->isBlocking();
|
||||
// USocketExt::blocking = socket->isBlocking();
|
||||
|
||||
resend:
|
||||
if (connect())
|
||||
{
|
||||
USocketExt::blocking = socket->isBlocking();
|
||||
|
||||
ok = (USocketExt::writev(socket, iov, iovcnt, ncount, timeoutMS, 1) == ncount);
|
||||
|
||||
if (ok == false)
|
||||
|
@ -518,10 +520,9 @@ end:
|
|||
USocketExt::bssl = bssl_save;
|
||||
USocketExt::blocking = blocking_save;
|
||||
|
||||
if (ok)
|
||||
if (ok &&
|
||||
socket->isOpen())
|
||||
{
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
|
||||
if (socket->isConnected() == false) socket->iState = USocket::CONNECT;
|
||||
|
||||
U_RETURN(true);
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// = LIBRARY
|
||||
// ULib - c++ library
|
||||
//
|
||||
// = FILENAME
|
||||
// compress.cpp
|
||||
//
|
||||
// = AUTHOR
|
||||
// Stefano Casazza
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
#include <ulib/internal/common.h>
|
||||
#include <ulib/base/lzo/minilzo.h>
|
||||
#include <ulib/utility/compress.h>
|
||||
|
||||
bool UCompress::flag_init;
|
||||
|
||||
/* Work-memory needed for compression. Allocate memory in units
|
||||
* of `lzo_align_t' (instead of `char') to make sure it is properly aligned
|
||||
*/
|
||||
|
||||
#define HEAP_ALLOC(var,size) \
|
||||
lzo_align_t __LZO_MMODEL var [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ]
|
||||
|
||||
static HEAP_ALLOC(wrkmem,LZO1X_1_MEM_COMPRESS);
|
||||
|
||||
void UCompress::init()
|
||||
{
|
||||
U_TRACE(0, "UCompress::init()")
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(flag_init, false)
|
||||
|
||||
#ifdef DEBUG
|
||||
int r = lzo_init();
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(r,LZO_E_OK)
|
||||
#else
|
||||
(void) lzo_init();
|
||||
#endif
|
||||
|
||||
// if (r != LZO_E_OK) U_ERROR("lzo_init() failed");
|
||||
|
||||
flag_init = true;
|
||||
}
|
||||
|
||||
uint32_t UCompress::compress(const char* src, uint32_t src_len, char* dst)
|
||||
{
|
||||
U_TRACE(0, "UCompress::compress(%.*S,%u,%p)", src_len, src, src_len, dst)
|
||||
|
||||
// Step 1: initialize the LZO library
|
||||
|
||||
if (flag_init == false) init();
|
||||
|
||||
U_INTERNAL_ASSERT(flag_init)
|
||||
|
||||
// Step 2: compress from `src' to `dst' with LZO1X-1
|
||||
|
||||
lzo_uint out_len;
|
||||
|
||||
#ifdef DEBUG
|
||||
int r = lzo1x_1_compress((lzo_byte*)src, (lzo_uint)src_len, (lzo_byte*)dst, &out_len, wrkmem);
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(r,LZO_E_OK)
|
||||
#else
|
||||
(void) lzo1x_1_compress((lzo_byte*)src, (lzo_uint)src_len, (lzo_byte*)dst, &out_len, wrkmem);
|
||||
#endif
|
||||
|
||||
U_INTERNAL_DUMP("compressed %u bytes into %u bytes (%u%%)", src_len, out_len,
|
||||
100 - (out_len * 100 / src_len))
|
||||
|
||||
U_RETURN(out_len);
|
||||
}
|
||||
|
||||
uint32_t UCompress::decompress(const char* src, uint32_t src_len, char* dst)
|
||||
{
|
||||
U_TRACE(0, "UCompress::decompress(%.*S,%u,%p)", src_len, src, src_len, dst)
|
||||
|
||||
// Step 1: initialize the LZO library
|
||||
|
||||
if (flag_init == false) init();
|
||||
|
||||
U_INTERNAL_ASSERT(flag_init)
|
||||
|
||||
// Step 2: decompress from `src' to `dst' with LZO1X-1
|
||||
|
||||
lzo_uint out_len;
|
||||
|
||||
#ifdef DEBUG
|
||||
int r = lzo1x_decompress((lzo_byte*)src, (lzo_uint)src_len, (lzo_byte*)dst, &out_len, NULL);
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(r,LZO_E_OK)
|
||||
#else
|
||||
(void) lzo1x_decompress((lzo_byte*)src, (lzo_uint)src_len, (lzo_byte*)dst, &out_len, NULL);
|
||||
#endif
|
||||
|
||||
U_INTERNAL_DUMP("decompressed %u bytes back into %u bytes", src_len, out_len)
|
||||
|
||||
U_RETURN(out_len);
|
||||
}
|
|
@ -19,8 +19,8 @@ UString UDES3::signData(const char* fmt, ...)
|
|||
{
|
||||
U_TRACE(0, "UDES3::signData(%S)", fmt)
|
||||
|
||||
uint32_t sz1;
|
||||
UString buffer1(U_CAPACITY), buffer2(U_CAPACITY), signed_data(U_CAPACITY);
|
||||
const char* ptr = buffer1.data();
|
||||
|
||||
va_list argp;
|
||||
va_start(argp, fmt);
|
||||
|
@ -29,17 +29,19 @@ UString UDES3::signData(const char* fmt, ...)
|
|||
|
||||
va_end(argp);
|
||||
|
||||
sz1 = buffer1.size();
|
||||
// uint32_t sz1 = buffer1.size();
|
||||
//
|
||||
// if (sz1 <= 2048) encode((const unsigned char*)ptr, sz1, buffer2);
|
||||
// else
|
||||
// {
|
||||
// UString data = UStringExt::compress(ptr, sz1);
|
||||
// uint32_t sz2 = data.size();
|
||||
//
|
||||
// if (sz2 < (sz1 - (sz1 / 4))) encode((const unsigned char*)data.data(), sz2, buffer2);
|
||||
// else encode((const unsigned char*)ptr, sz1, buffer2);
|
||||
// }
|
||||
|
||||
if (sz1 <= 512) encode((const unsigned char*)buffer1.data(), sz1, buffer2);
|
||||
else
|
||||
{
|
||||
UString data = UStringExt::compress(buffer1.data(), sz1);
|
||||
uint32_t sz2 = data.size();
|
||||
|
||||
if (sz2 < (sz1 - (sz1 / 4))) encode((const unsigned char*) data.data(), sz2, buffer2);
|
||||
else encode((const unsigned char*)buffer1.data(), sz1, buffer2);
|
||||
}
|
||||
encode((const unsigned char*)ptr, buffer1.size(), buffer2);
|
||||
|
||||
UBase64::encodeUrl(buffer2, signed_data);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <ulib/url.h>
|
||||
#include <ulib/file.h>
|
||||
#include <ulib/tokenizer.h>
|
||||
#include <ulib/utility/compress.h>
|
||||
#include <ulib/base/miniz/miniz.h>
|
||||
#include <ulib/utility/string_ext.h>
|
||||
|
||||
#ifdef USE_LIBPCRE
|
||||
|
@ -1293,13 +1293,14 @@ UString UStringExt::compress(const char* s, uint32_t sz)
|
|||
{
|
||||
U_TRACE(0, "UStringExt::compress(%.*S,%u)", sz, s, sz)
|
||||
|
||||
UString r(U_CONSTANT_SIZE(U_LZOP_COMPRESS) + sizeof(uint32_t) + UCompress::space(sz));
|
||||
UString out(U_CONSTANT_SIZE(U_MINIZ_COMPRESS) + sizeof(uint32_t) + sz + 32);
|
||||
|
||||
mz_ulong out_len = out.capacity() - U_CONSTANT_SIZE(U_MINIZ_COMPRESS) + sizeof(uint32_t);
|
||||
unsigned char* ptr = (unsigned char*)out.data();
|
||||
|
||||
// copy magic byte
|
||||
|
||||
char* ptr = r.data();
|
||||
|
||||
*(int32_t*)ptr = U_MULTICHAR_CONSTANT32('\x89','L','Z','O');
|
||||
*(int32_t*)ptr = U_MULTICHAR_CONSTANT32('\x89','M','N','Z'); // U_MINIZ_COMPRESS
|
||||
ptr += 4;
|
||||
|
||||
// copy original size
|
||||
|
@ -1310,15 +1311,22 @@ UString UStringExt::compress(const char* s, uint32_t sz)
|
|||
uint32_t size_original = u_invert32(*(uint32_t*)&sz);
|
||||
#endif
|
||||
|
||||
U_MEMCPY(ptr, &size_original, sizeof(uint32_t));
|
||||
*(int32_t*)ptr = *(int32_t*)&size_original;
|
||||
|
||||
// compress with lzo
|
||||
#ifdef DEBUG
|
||||
int r =
|
||||
#endif
|
||||
U_SYSCALL(mz_compress, "%p,%p,%p,%u", ptr + sizeof(uint32_t), &out_len, (const unsigned char*)s, sz);
|
||||
|
||||
r.rep->_length = U_CONSTANT_SIZE(U_LZOP_COMPRESS) + sizeof(uint32_t) + UCompress::compress(s, sz, ptr + sizeof(uint32_t));
|
||||
U_INTERNAL_ASSERT_EQUALS(r, Z_OK)
|
||||
|
||||
U_INTERNAL_ASSERT(UStringExt::isCompress(r))
|
||||
out.rep->_length = U_CONSTANT_SIZE(U_MINIZ_COMPRESS) + sizeof(uint32_t) + out_len;
|
||||
|
||||
U_RETURN_STRING(r);
|
||||
U_INTERNAL_DUMP("compressed %u bytes into %lu bytes (%u%%)", sz, out_len, 100 - (out_len * 100 / sz))
|
||||
|
||||
U_INTERNAL_ASSERT(UStringExt::isCompress(out))
|
||||
|
||||
U_RETURN_STRING(out);
|
||||
}
|
||||
|
||||
UString UStringExt::decompress(const char* s, uint32_t n)
|
||||
|
@ -1331,7 +1339,7 @@ UString UStringExt::decompress(const char* s, uint32_t n)
|
|||
|
||||
// read original size
|
||||
|
||||
const char* ptr = (char*)s + U_CONSTANT_SIZE(U_LZOP_COMPRESS);
|
||||
const char* ptr = (char*)s + U_CONSTANT_SIZE(U_MINIZ_COMPRESS);
|
||||
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
uint32_t sz = *(uint32_t*)ptr;
|
||||
|
@ -1339,15 +1347,23 @@ UString UStringExt::decompress(const char* s, uint32_t n)
|
|||
uint32_t sz = u_invert32(*(uint32_t*)ptr);
|
||||
#endif
|
||||
|
||||
// decompress with lzo
|
||||
|
||||
U_INTERNAL_DUMP("sz = %u", sz)
|
||||
|
||||
UString r(sz + 32);
|
||||
UString out(sz + 32);
|
||||
mz_ulong out_len = out.capacity();
|
||||
|
||||
r.rep->_length = UCompress::decompress(ptr + sizeof(uint32_t), n - U_CONSTANT_SIZE(U_LZOP_COMPRESS) - sizeof(uint32_t), r.rep->data());
|
||||
#ifdef DEBUG
|
||||
int r =
|
||||
#endif
|
||||
U_SYSCALL(mz_uncompress, "%p,%p,%p,%u", (unsigned char*)out.rep->data(), &out_len, (const unsigned char*)ptr + sizeof(uint32_t), n - U_CONSTANT_SIZE(U_MINIZ_COMPRESS) - sizeof(uint32_t));
|
||||
|
||||
U_RETURN_STRING(r);
|
||||
U_INTERNAL_ASSERT_EQUALS(r, Z_OK)
|
||||
|
||||
U_INTERNAL_DUMP("decompressed %u bytes back into %lu bytes", n - U_CONSTANT_SIZE(U_MINIZ_COMPRESS) - sizeof(uint32_t), out_len)
|
||||
|
||||
out.rep->_length = out_len;
|
||||
|
||||
U_RETURN_STRING(out);
|
||||
}
|
||||
|
||||
UString UStringExt::deflate(const char* s, uint32_t len, int type) // .gz compress
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
./Makefile - compression ratio (69%)
|
||||
./Makefile.am - compression ratio (55%)
|
||||
./Makefile.in - compression ratio (72%)
|
||||
./application.test - compression ratio (18%)
|
||||
./cdb.test - compression ratio (10%)
|
||||
./compress.test - compression ratio (16%)
|
||||
./file.test - compression ratio (17%)
|
||||
./file_config.cf - compression ratio (56%)
|
||||
./file_config.gperf - compression ratio (66%)
|
||||
./file_config.test - compression ratio (18%)
|
||||
./inp/cdb.input - compression ratio (23%)
|
||||
./inp/compress.input - compression ratio (50%)
|
||||
./inp/file_config.input - compression ratio (27%)
|
||||
./inp/tree.input - compression ratio (55%)
|
||||
./inp/vector.input - compression ratio (27%)
|
||||
./inp/words.lst - compression ratio (20%)
|
||||
./log.test - compression ratio (7%)
|
||||
./memory_pool.test - compression ratio (15%)
|
||||
./notifier.test - compression ratio (13%)
|
||||
./options.test - compression ratio (53%)
|
||||
./random.cdb - compression ratio (48%)
|
||||
./rdb.test - compression ratio (30%)
|
||||
./string.test - compression ratio (13%)
|
||||
./test_application.cpp - compression ratio (54%)
|
||||
./test_cdb.cpp - compression ratio (52%)
|
||||
./test_compress.cpp - compression ratio (37%)
|
||||
./test_file.cpp - compression ratio (58%)
|
||||
./test_file_config.cpp - compression ratio (64%)
|
||||
./test_interrupt.cpp - compression ratio (40%)
|
||||
./test_log.cpp - compression ratio (7%)
|
||||
./test_memory_pool.cpp - compression ratio (65%)
|
||||
./test_notifier.cpp - compression ratio (64%)
|
||||
./test_options.cpp - compression ratio (47%)
|
||||
./test_process.cpp - compression ratio (25%)
|
||||
./test_rdb.cpp - compression ratio (57%)
|
||||
./test_string.cpp - compression ratio (69%)
|
||||
./test_timer.cpp - compression ratio (60%)
|
||||
./test_timeval.cpp - compression ratio (46%)
|
||||
./test_tree.cpp - compression ratio (65%)
|
||||
./test_vector.cpp - compression ratio (71%)
|
||||
./timer.test - compression ratio (9%)
|
||||
./timeval.test - compression ratio (13%)
|
||||
./tree.test - compression ratio (11%)
|
||||
./vector.test - compression ratio (18%)
|
||||
./Makefile - compression ratio (77%)
|
||||
./Makefile.am - compression ratio (69%)
|
||||
./Makefile.in - compression ratio (79%)
|
||||
./application.test - compression ratio (37%)
|
||||
./cdb.test - compression ratio (27%)
|
||||
./compress.test - compression ratio (32%)
|
||||
./file.test - compression ratio (37%)
|
||||
./file_config.cf - compression ratio (68%)
|
||||
./file_config.gperf - compression ratio (74%)
|
||||
./file_config.test - compression ratio (34%)
|
||||
./inp/cdb.input - compression ratio (49%)
|
||||
./inp/compress.input - compression ratio (69%)
|
||||
./inp/file_config.input - compression ratio (43%)
|
||||
./inp/tree.input - compression ratio (63%)
|
||||
./inp/vector.input - compression ratio (48%)
|
||||
./inp/words.lst - compression ratio (47%)
|
||||
./log.test - compression ratio (28%)
|
||||
./memory_pool.test - compression ratio (32%)
|
||||
./notifier.test - compression ratio (29%)
|
||||
./options.test - compression ratio (67%)
|
||||
./random.cdb - compression ratio (49%)
|
||||
./rdb.test - compression ratio (45%)
|
||||
./string.test - compression ratio (30%)
|
||||
./test_application.cpp - compression ratio (67%)
|
||||
./test_cdb.cpp - compression ratio (65%)
|
||||
./test_compress.cpp - compression ratio (51%)
|
||||
./test_file.cpp - compression ratio (70%)
|
||||
./test_file_config.cpp - compression ratio (75%)
|
||||
./test_interrupt.cpp - compression ratio (56%)
|
||||
./test_log.cpp - compression ratio (25%)
|
||||
./test_memory_pool.cpp - compression ratio (76%)
|
||||
./test_notifier.cpp - compression ratio (75%)
|
||||
./test_options.cpp - compression ratio (60%)
|
||||
./test_process.cpp - compression ratio (42%)
|
||||
./test_rdb.cpp - compression ratio (70%)
|
||||
./test_string.cpp - compression ratio (80%)
|
||||
./test_timer.cpp - compression ratio (71%)
|
||||
./test_timeval.cpp - compression ratio (60%)
|
||||
./test_tree.cpp - compression ratio (75%)
|
||||
./test_vector.cpp - compression ratio (80%)
|
||||
./timer.test - compression ratio (26%)
|
||||
./timeval.test - compression ratio (30%)
|
||||
./tree.test - compression ratio (28%)
|
||||
./vector.test - compression ratio (35%)
|
||||
|
|
|
@ -1,29 +1,20 @@
|
|||
// test_compress.cpp
|
||||
|
||||
#include <ulib/file.h>
|
||||
#include <ulib/utility/compress.h>
|
||||
#include <ulib/utility/string_ext.h>
|
||||
|
||||
static void check(const UString& dati, const UString& file)
|
||||
static void check(const UString& file)
|
||||
{
|
||||
U_INTERNAL_ASSERT( dati == UStringExt::decompress(UStringExt::compress(dati)) )
|
||||
UString dati = UFile::contentOf(file),
|
||||
compressed = UStringExt::compress(dati),
|
||||
uncompressed = UStringExt::decompress(compressed);
|
||||
|
||||
char src[dati.size()];
|
||||
char dst[UCompress::space(dati.size())];
|
||||
U_INTERNAL_ASSERT_EQUALS(dati, uncompressed)
|
||||
|
||||
size_t dst_len = UCompress::compress(U_STRING_TO_PARAM(dati), dst);
|
||||
size_t src_len = UCompress::decompress(dst, dst_len, src);
|
||||
|
||||
U_INTERNAL_ASSERT( dati.size() == src_len );
|
||||
U_INTERNAL_ASSERT( memcmp(src, U_STRING_TO_PARAM(dati)) == 0 );
|
||||
|
||||
int ratio = (dst_len * 100 / src_len);
|
||||
|
||||
printf("%.*s - compression ratio (%d%%)\n", U_STRING_TO_TRACE(file), 100 - ratio);
|
||||
printf("%.*s - compression ratio (%d%%)\n", U_STRING_TO_TRACE(file), 100 - (dati.size() * 100 / compressed.size()));
|
||||
}
|
||||
|
||||
int
|
||||
U_EXPORT main (int argc, char* argv[])
|
||||
int U_EXPORT main (int argc, char* argv[])
|
||||
{
|
||||
U_ULIB_INIT(argv);
|
||||
|
||||
|
@ -31,10 +22,5 @@ U_EXPORT main (int argc, char* argv[])
|
|||
|
||||
UString filename;
|
||||
|
||||
while (cin >> filename)
|
||||
{
|
||||
UString dati = UFile::contentOf(filename);
|
||||
|
||||
check(dati, filename);
|
||||
}
|
||||
while (cin >> filename) check(filename);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user