Update from MiniLZO 2.00 to 2.01.
includes/Makefile includes/gnutls/gnutls.h \
lib/Makefile lib/minitasn1/Makefile lib/x509/Makefile \
libextra/Makefile libextra/openpgp/Makefile libextra/opencdk/Makefile \
+ libextra/minilzo/Makefile \
src/Makefile src/x509/Makefile src/srp/Makefile src/openpgp/Makefile \
src/cfg/Makefile src/cfg/platon/Makefile src/cfg/platon/str/Makefile \
lib/libgnutls-config libextra/libgnutls-extra-config \
#ifdef USE_LZO
# ifdef USE_MINILZO
-# include "../libextra/minilzo.h" /* get the prototypes only.
- * Since LZO is a GPLed library, the gnutls_global_init_extra() has
- * to be called, before LZO compression can be used.
- */
+/* Get the prototypes only. Since LZO is a GPLed library, the
+ * gnutls_global_init_extra() has to be called, before LZO compression
+ * can be used.
+ */
+# include "../libextra/minilzo/minilzo.h"
# else
# include <lzo1x.h>
# endif
endif
endif
-# LZO
-
-LZO_OBJECTS =
-if ENABLE_INCLUDED_LZO
-LZO_OBJECTS += lzodefs.h lzoconf.h minilzo.h minilzo.c
-endif
-
libgnutls_extra_la_LDFLAGS += -export-symbols-regex '^gnutls.*' \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
$(LZO_LIBS)
-libgnutls_extra_la_SOURCES = $(COBJECTS) $(LZO_OBJECTS) gnutls_extra.h
+libgnutls_extra_la_SOURCES = $(COBJECTS) gnutls_extra.h
libgnutls_extra_la_LIBADD += ../lib/libgnutls.la ../gl/libgnu.la
+# LZO
+
+if ENABLE_INCLUDED_LZO
+SUBDIRS += minilzo
+libgnutls_extra_la_LIBADD += minilzo/libminilzo.la
+endif
gnutls-extra-api.texi: $(COBJECTS)
@echo "" > gnutls-extra-api.texi
#include <gnutls_algorithms.h>
#ifdef USE_LZO
# ifdef USE_MINILZO
-# include "minilzo.h"
+# include "minilzo/minilzo.h"
# else
# include <lzo1x.h>
# endif
--- /dev/null
+.deps
+.libs
+Makefile
+Makefile.in
+libminilzo.la
+minilzo.lo
+testmini
--- /dev/null
+## Process this file with automake to produce Makefile.in
+# Copyright (C) 2005 Free Software Foundation
+#
+# Author: Simon Josefsson
+#
+# This file is part of GNUTLS-EXTRA.
+#
+# GNUTLS-EXTRA 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.
+#
+# GNUTLS-EXTRA 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 GNUTLS-EXTRA; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+LDADD = libminilzo.la
+
+noinst_LTLIBRARIES = libminilzo.la
+
+libminilzo_la_SOURCES = lzoconf.h lzodefs.h minilzo.c minilzo.h
+
+EXTRA_DIST = README.LZO
+
+TESTS = testmini
+check_PROGRAMS = testmini
--- /dev/null
+
+ ============================================================================
+ 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.01
+ Date : 27 Jun 2005
+
+ 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 kB (using gcc or Visual C on a i386), and
+ the sources are about 30 kB 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(char *) != sizeof(long)'.
+ After identifying the problem you can compile by adding some defines
+ like `-DSIZEOF_CHAR_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.in.
+
+
+ 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.in' 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, 1997, 1998, 1999, 2000, 2001, 2002,
+ 2003, 2004, 2005 Markus Franz Xaver Johannes Oberhumer
+
+ 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.
+
+
#ifndef __LZOCONF_H_INCLUDED
#define __LZOCONF_H_INCLUDED
-#define LZO_VERSION 0x2000
-#define LZO_VERSION_STRING "2.00"
-#define LZO_VERSION_DATE "May 30 2005"
+#define LZO_VERSION 0x2010
+#define LZO_VERSION_STRING "2.01"
+#define LZO_VERSION_DATE "Jun 27 2005"
/* internal Autoconf configuration file - only used when building LZO */
#if defined(LZO_HAVE_CONFIG_H)
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 );
+ 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 );
+ 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")
# else
# define LZO_INFO_CCVER "unknown"
# endif
+#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__)
+# define LZO_CC_SDCC 1
+# define LZO_INFO_CC "sdcc"
+# define LZO_INFO_CCVER LZO_CPP_MACRO_EXPAND(SDCC)
#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__)
# define LZO_INFO_CC "Pathscale C"
#elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__)
# define LZO_ARCH_AVR 1
# define LZO_INFO_ARCH "avr"
+#elif defined(__bfin__)
+# define LZO_ARCH_BLACKFIN 1
+# define LZO_INFO_ARCH "blackfin"
#elif (UINT_MAX == LZO_0xffffL) && defined(__C166__)
# define LZO_ARCH_C166 1
# define LZO_INFO_ARCH "c166"
+#elif defined(__cris__)
+# define LZO_ARCH_CRIS 1
+# define LZO_INFO_ARCH "cris"
+#elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+# define LZO_ARCH_H8300 1
+# define LZO_INFO_ARCH "h8300"
#elif defined(__hppa__) || defined(__hppa)
# define LZO_ARCH_HPPA 1
# define LZO_INFO_ARCH "hppa"
#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
# define LZO_ARCH_IA64 1
# define LZO_INFO_ARCH "ia64"
+#elif defined(__m32r__)
+# define LZO_ARCH_M32R 1
+# define LZO_INFO_ARCH "m32r"
#elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(_M_M68K)
# define LZO_ARCH_M68K 1
# define LZO_INFO_ARCH "m68k"
#elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8)
# define LZO_ARCH_SPARC 1
# define LZO_INFO_ARCH "sparc"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__z80)
+# define LZO_ARCH_Z80 1
+# define LZO_INFO_ARCH "z80"
#else
# define LZO_ARCH_UNKNOWN 1
# define LZO_INFO_ARCH "unknown"
# endif
#endif
#if (LZO_ARCH_I386)
-# if (UINT_MAX != LZO_0xffffffffL)
+# if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
+# error "this should not happen"
+# endif
+# if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
# error "this should not happen"
# endif
# if (ULONG_MAX != LZO_0xffffffffL)
#endif
#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
+# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__)
+# if (LZO_CC_GNUC >= 0x030300ul)
+# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0)
+# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG
+# endif
+# endif
+# endif
+#endif
+#endif
+#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
+#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
#if (LZO_ARCH_I086 && LZO_CC_DMC)
#elif (LZO_CC_CILLY) && defined(__GNUC__)
# define LZO_SIZEOF_LONG_LONG 8
# define LZO_SIZEOF_LONG_LONG 8
#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2)
#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define LZO_SIZEOF_LONG_LONG 8
#endif
# else
# error "LZO_MM"
# endif
-#elif (LZO_ARCH_AVR || LZO_ARCH_C166 || LZO_ARCH_I086 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251)
+#elif (LZO_ARCH_AVR || LZO_ARCH_C166 || LZO_ARCH_I086 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_Z80)
# define LZO_SIZEOF_VOID_P 2
+#elif (LZO_ARCH_H8300)
+# if defined(__NORMAL_MODE__)
+# define LZO_SIZEOF_VOID_P 2
+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+# define LZO_SIZEOF_VOID_P 4
+# else
+# define LZO_SIZEOF_VOID_P 2
+# endif
+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4)
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT
+# endif
#elif (LZO_OS_CONSOLE_PS2)
# define LZO_SIZEOF_VOID_P 4
#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
# else
# define LZO_INFO_CCVER "unknown"
# endif
+#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__)
+# define LZO_CC_SDCC 1
+# define LZO_INFO_CC "sdcc"
+# define LZO_INFO_CCVER LZO_CPP_MACRO_EXPAND(SDCC)
#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__)
# define LZO_INFO_CC "Pathscale C"
#elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__)
# define LZO_ARCH_AVR 1
# define LZO_INFO_ARCH "avr"
+#elif defined(__bfin__)
+# define LZO_ARCH_BLACKFIN 1
+# define LZO_INFO_ARCH "blackfin"
#elif (UINT_MAX == LZO_0xffffL) && defined(__C166__)
# define LZO_ARCH_C166 1
# define LZO_INFO_ARCH "c166"
+#elif defined(__cris__)
+# define LZO_ARCH_CRIS 1
+# define LZO_INFO_ARCH "cris"
+#elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+# define LZO_ARCH_H8300 1
+# define LZO_INFO_ARCH "h8300"
#elif defined(__hppa__) || defined(__hppa)
# define LZO_ARCH_HPPA 1
# define LZO_INFO_ARCH "hppa"
#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
# define LZO_ARCH_IA64 1
# define LZO_INFO_ARCH "ia64"
+#elif defined(__m32r__)
+# define LZO_ARCH_M32R 1
+# define LZO_INFO_ARCH "m32r"
#elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(_M_M68K)
# define LZO_ARCH_M68K 1
# define LZO_INFO_ARCH "m68k"
#elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8)
# define LZO_ARCH_SPARC 1
# define LZO_INFO_ARCH "sparc"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__z80)
+# define LZO_ARCH_Z80 1
+# define LZO_INFO_ARCH "z80"
#else
# define LZO_ARCH_UNKNOWN 1
# define LZO_INFO_ARCH "unknown"
# endif
#endif
#if (LZO_ARCH_I386)
-# if (UINT_MAX != LZO_0xffffffffL)
+# if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
+# error "this should not happen"
+# endif
+# if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
# error "this should not happen"
# endif
# if (ULONG_MAX != LZO_0xffffffffL)
#endif
#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
+# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__)
+# if (LZO_CC_GNUC >= 0x030300ul)
+# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0)
+# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG
+# endif
+# endif
+# endif
+#endif
+#endif
+#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
+#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
#if (LZO_ARCH_I086 && LZO_CC_DMC)
#elif (LZO_CC_CILLY) && defined(__GNUC__)
# define LZO_SIZEOF_LONG_LONG 8
# define LZO_SIZEOF_LONG_LONG 8
#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2)
#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define LZO_SIZEOF_LONG_LONG 8
#endif
# else
# error "LZO_MM"
# endif
-#elif (LZO_ARCH_AVR || LZO_ARCH_C166 || LZO_ARCH_I086 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251)
+#elif (LZO_ARCH_AVR || LZO_ARCH_C166 || LZO_ARCH_I086 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_Z80)
# define LZO_SIZEOF_VOID_P 2
+#elif (LZO_ARCH_H8300)
+# if defined(__NORMAL_MODE__)
+# define LZO_SIZEOF_VOID_P 2
+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+# define LZO_SIZEOF_VOID_P 4
+# else
+# define LZO_SIZEOF_VOID_P 2
+# endif
+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4)
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT
+# endif
#elif (LZO_OS_CONSOLE_PS2)
# define LZO_SIZEOF_VOID_P 4
#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
#undef LZO_HAVE_CONFIG_H
#include "minilzo.h"
-#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2000)
+#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2010)
# error "version mismatch in miniLZO source files"
#endif
#define LZO_BASE 65521u
#define LZO_NMAX 5552
-#define LZO_DO1(buf,i) {s1 += buf[i]; s2 += s1;}
+#define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1
#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1);
#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2);
#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4);
return (s2 << 16) | s1;
}
+#undef LZO_DO1
+#undef LZO_DO2
+#undef LZO_DO4
+#undef LZO_DO8
+#undef LZO_DO16
+
#undef lzo_memcmp
#undef lzo_memcpy
#undef lzo_memmove
#define lzo_hmemcpy lzo_memcpy
#define lzo_hmemmove lzo_memmove
#define lzo_hmemset lzo_memset
-#define LZO_WANT_ACCLIB_HMEMCPY 1
#define __LZOLIB_HMEMCPY_CH_INCLUDED 1
#if !defined(LZOLIB_PUBLIC)
# define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f)
#ifndef __MINILZO_H
#define __MINILZO_H
-#define MINILZO_VERSION 0x2000
+#define MINILZO_VERSION 0x2010
#ifdef __LZOCONF_H
# error "you cannot use both LZO and miniLZO"
--- /dev/null
+/* testmini.c -- very simple test program for the miniLZO library
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 1996-2005 Markus Franz Xaver Johannes Oberhumer
+
+ 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.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Markus F.X.J. Oberhumer
+ <markus@oberhumer.com>
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+/*************************************************************************
+// This program shows the basic usage of the LZO library.
+// We will compress a block of data and decompress again.
+//
+// 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/
+**************************************************************************/
+
+/* First let's include "minizo.h". */
+
+#include "minilzo.h"
+
+
+/* We want to compress the data block at `in' with length `IN_LEN' to
+ * the block at `out'. Because the input block may be incompressible,
+ * we must provide a little more output space in case that compression
+ * is not possible.
+ */
+
+#if defined(__LZO_STRICT_16BIT)
+#define IN_LEN (8*1024u)
+#elif defined(LZO_ARCH_I086) && !defined(LZO_HAVE_MM_HUGE_ARRAY)
+#define IN_LEN (60*1024u)
+#else
+#define IN_LEN (128*1024ul)
+#endif
+#define OUT_LEN (IN_LEN + IN_LEN / 16 + 64 + 3)
+
+static unsigned char __LZO_MMODEL in [ IN_LEN ];
+static unsigned char __LZO_MMODEL out [ OUT_LEN ];
+
+
+/* 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);
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+int main(int argc, char *argv[])
+{
+ int r;
+ lzo_uint in_len;
+ lzo_uint out_len;
+ lzo_uint new_len;
+
+ if (argc < 0 && argv == NULL) /* avoid warning about unused args */
+ return 0;
+
+ printf("\nLZO real-time data compression library (v%s, %s).\n",
+ lzo_version_string(), lzo_version_date());
+ printf("Copyright (C) 1996-2005 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+
+
+/*
+ * Step 1: initialize the LZO library
+ */
+ if (lzo_init() != LZO_E_OK)
+ {
+ printf("internal error - lzo_init() failed !!!\n");
+ printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable `-DLZO_DEBUG' for diagnostics)\n");
+ return 3;
+ }
+
+/*
+ * Step 2: prepare the input block that will get compressed.
+ * We just fill it with zeros in this example program,
+ * but you would use your real-world data here.
+ */
+ in_len = IN_LEN;
+ lzo_memset(in,0,in_len);
+
+/*
+ * Step 3: compress from `in' to `out' with LZO1X-1
+ */
+ r = lzo1x_1_compress(in,in_len,out,&out_len,wrkmem);
+ if (r == LZO_E_OK)
+ printf("compressed %lu bytes into %lu bytes\n",
+ (unsigned long) in_len, (unsigned long) out_len);
+ else
+ {
+ /* this should NEVER happen */
+ printf("internal error - compression failed: %d\n", r);
+ return 2;
+ }
+ /* check for an incompressible block */
+ if (out_len >= in_len)
+ {
+ printf("This block contains incompressible data.\n");
+ return 0;
+ }
+
+/*
+ * Step 4: decompress again, now going from `out' to `in'
+ */
+ r = lzo1x_decompress(out,out_len,in,&new_len,NULL);
+ if (r == LZO_E_OK && new_len == in_len)
+ printf("decompressed %lu bytes back into %lu bytes\n",
+ (unsigned long) out_len, (unsigned long) in_len);
+ else
+ {
+ /* this should NEVER happen */
+ printf("internal error - decompression failed: %d\n", r);
+ return 1;
+ }
+
+ printf("\nminiLZO simple compression test passed.\n");
+ return 0;
+}
+
+/*
+vi:ts=4
+*/
+