summaryrefslogtreecommitdiff
path: root/app/lzo/examples
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-04-08 11:38:09 +0200
committerParménides GV <parmegv@sdf.org>2014-04-08 11:43:27 +0200
commit5fc5d37330d3535a0f421632694d1e7918fc22d7 (patch)
tree1aad0c286e58962c8895854907e530b9bc9bce5a /app/lzo/examples
parentc206a91d320995f37f8abb33188bfd384249da3d (diff)
Compiles correctly: app/build-native + gradle.
Diffstat (limited to 'app/lzo/examples')
-rw-r--r--app/lzo/examples/.deps/dict.Po1
-rw-r--r--app/lzo/examples/.deps/lzopack.Po1
-rw-r--r--app/lzo/examples/.deps/overlap.Po1
-rw-r--r--app/lzo/examples/.deps/precomp.Po1
-rw-r--r--app/lzo/examples/.deps/precomp2.Po1
-rw-r--r--app/lzo/examples/.deps/simple.Po1
-rw-r--r--app/lzo/examples/Makefile.am21
-rw-r--r--app/lzo/examples/Makefile.in491
-rw-r--r--app/lzo/examples/dict.c281
-rw-r--r--app/lzo/examples/lzopack.c645
-rw-r--r--app/lzo/examples/overlap.c322
-rw-r--r--app/lzo/examples/portab.h187
-rw-r--r--app/lzo/examples/portab_a.h140
-rw-r--r--app/lzo/examples/precomp.c349
-rw-r--r--app/lzo/examples/precomp2.c401
-rw-r--r--app/lzo/examples/simple.c173
16 files changed, 3016 insertions, 0 deletions
diff --git a/app/lzo/examples/.deps/dict.Po b/app/lzo/examples/.deps/dict.Po
new file mode 100644
index 00000000..9ce06a81
--- /dev/null
+++ b/app/lzo/examples/.deps/dict.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/app/lzo/examples/.deps/lzopack.Po b/app/lzo/examples/.deps/lzopack.Po
new file mode 100644
index 00000000..9ce06a81
--- /dev/null
+++ b/app/lzo/examples/.deps/lzopack.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/app/lzo/examples/.deps/overlap.Po b/app/lzo/examples/.deps/overlap.Po
new file mode 100644
index 00000000..9ce06a81
--- /dev/null
+++ b/app/lzo/examples/.deps/overlap.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/app/lzo/examples/.deps/precomp.Po b/app/lzo/examples/.deps/precomp.Po
new file mode 100644
index 00000000..9ce06a81
--- /dev/null
+++ b/app/lzo/examples/.deps/precomp.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/app/lzo/examples/.deps/precomp2.Po b/app/lzo/examples/.deps/precomp2.Po
new file mode 100644
index 00000000..9ce06a81
--- /dev/null
+++ b/app/lzo/examples/.deps/precomp2.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/app/lzo/examples/.deps/simple.Po b/app/lzo/examples/.deps/simple.Po
new file mode 100644
index 00000000..9ce06a81
--- /dev/null
+++ b/app/lzo/examples/.deps/simple.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/app/lzo/examples/Makefile.am b/app/lzo/examples/Makefile.am
new file mode 100644
index 00000000..2c5b527e
--- /dev/null
+++ b/app/lzo/examples/Makefile.am
@@ -0,0 +1,21 @@
+## Process this file with automake to create Makefile.in
+#
+# Copyright (C) 1996-2008 Markus F.X.J. Oberhumer
+#
+
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)
+
+noinst_PROGRAMS = dict lzopack overlap precomp precomp2 simple
+
+dict_SOURCES = dict.c
+lzopack_SOURCES = lzopack.c
+overlap_SOURCES = overlap.c
+precomp_SOURCES = precomp.c
+precomp2_SOURCES = precomp2.c
+simple_SOURCES = simple.c
+
+LDADD = ../src/liblzo2.la
+DEPENDENCIES = ../src/liblzo2.la
+
+EXTRA_DIST = portab.h portab_a.h
+
diff --git a/app/lzo/examples/Makefile.in b/app/lzo/examples/Makefile.in
new file mode 100644
index 00000000..4199078b
--- /dev/null
+++ b/app/lzo/examples/Makefile.in
@@ -0,0 +1,491 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+#
+# Copyright (C) 1996-2008 Markus F.X.J. Oberhumer
+#
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+noinst_PROGRAMS = dict$(EXEEXT) lzopack$(EXEEXT) overlap$(EXEEXT) \
+ precomp$(EXEEXT) precomp2$(EXEEXT) simple$(EXEEXT)
+subdir = examples
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/autoconf/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am_dict_OBJECTS = dict.$(OBJEXT)
+dict_OBJECTS = $(am_dict_OBJECTS)
+dict_LDADD = $(LDADD)
+dict_DEPENDENCIES = ../src/liblzo2.la
+am_lzopack_OBJECTS = lzopack.$(OBJEXT)
+lzopack_OBJECTS = $(am_lzopack_OBJECTS)
+lzopack_LDADD = $(LDADD)
+lzopack_DEPENDENCIES = ../src/liblzo2.la
+am_overlap_OBJECTS = overlap.$(OBJEXT)
+overlap_OBJECTS = $(am_overlap_OBJECTS)
+overlap_LDADD = $(LDADD)
+overlap_DEPENDENCIES = ../src/liblzo2.la
+am_precomp_OBJECTS = precomp.$(OBJEXT)
+precomp_OBJECTS = $(am_precomp_OBJECTS)
+precomp_LDADD = $(LDADD)
+precomp_DEPENDENCIES = ../src/liblzo2.la
+am_precomp2_OBJECTS = precomp2.$(OBJEXT)
+precomp2_OBJECTS = $(am_precomp2_OBJECTS)
+precomp2_LDADD = $(LDADD)
+precomp2_DEPENDENCIES = ../src/liblzo2.la
+am_simple_OBJECTS = simple.$(OBJEXT)
+simple_OBJECTS = $(am_simple_OBJECTS)
+simple_LDADD = $(LDADD)
+simple_DEPENDENCIES = ../src/liblzo2.la
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(dict_SOURCES) $(lzopack_SOURCES) $(overlap_SOURCES) \
+ $(precomp_SOURCES) $(precomp2_SOURCES) $(simple_SOURCES)
+DIST_SOURCES = $(dict_SOURCES) $(lzopack_SOURCES) $(overlap_SOURCES) \
+ $(precomp_SOURCES) $(precomp2_SOURCES) $(simple_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LZO_ASM_VPATH = @LZO_ASM_VPATH@
+LZO_CFLAGS = @LZO_CFLAGS@
+LZO_CPPFLAGS = @LZO_CPPFLAGS@
+LZO_EXTRA_CFLAGS = @LZO_EXTRA_CFLAGS@
+LZO_EXTRA_CPPFLAGS = @LZO_EXTRA_CPPFLAGS@
+LZO_USE_ASM_FALSE = @LZO_USE_ASM_FALSE@
+LZO_USE_ASM_TRUE = @LZO_USE_ASM_TRUE@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+configure_CFLAGS = @configure_CFLAGS@
+configure_CPPFLAGS = @configure_CPPFLAGS@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)
+dict_SOURCES = dict.c
+lzopack_SOURCES = lzopack.c
+overlap_SOURCES = overlap.c
+precomp_SOURCES = precomp.c
+precomp2_SOURCES = precomp2.c
+simple_SOURCES = simple.c
+LDADD = ../src/liblzo2.la
+DEPENDENCIES = ../src/liblzo2.la
+EXTRA_DIST = portab.h portab_a.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu examples/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+dict$(EXEEXT): $(dict_OBJECTS) $(dict_DEPENDENCIES)
+ @rm -f dict$(EXEEXT)
+ $(LINK) $(dict_LDFLAGS) $(dict_OBJECTS) $(dict_LDADD) $(LIBS)
+lzopack$(EXEEXT): $(lzopack_OBJECTS) $(lzopack_DEPENDENCIES)
+ @rm -f lzopack$(EXEEXT)
+ $(LINK) $(lzopack_LDFLAGS) $(lzopack_OBJECTS) $(lzopack_LDADD) $(LIBS)
+overlap$(EXEEXT): $(overlap_OBJECTS) $(overlap_DEPENDENCIES)
+ @rm -f overlap$(EXEEXT)
+ $(LINK) $(overlap_LDFLAGS) $(overlap_OBJECTS) $(overlap_LDADD) $(LIBS)
+precomp$(EXEEXT): $(precomp_OBJECTS) $(precomp_DEPENDENCIES)
+ @rm -f precomp$(EXEEXT)
+ $(LINK) $(precomp_LDFLAGS) $(precomp_OBJECTS) $(precomp_LDADD) $(LIBS)
+precomp2$(EXEEXT): $(precomp2_OBJECTS) $(precomp2_DEPENDENCIES)
+ @rm -f precomp2$(EXEEXT)
+ $(LINK) $(precomp2_LDFLAGS) $(precomp2_OBJECTS) $(precomp2_LDADD) $(LIBS)
+simple$(EXEEXT): $(simple_OBJECTS) $(simple_DEPENDENCIES)
+ @rm -f simple$(EXEEXT)
+ $(LINK) $(simple_LDFLAGS) $(simple_OBJECTS) $(simple_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dict.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzopack.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/overlap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/precomp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/precomp2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstPROGRAMS ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am install-man \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/app/lzo/examples/dict.c b/app/lzo/examples/dict.c
new file mode 100644
index 00000000..04db2453
--- /dev/null
+++ b/app/lzo/examples/dict.c
@@ -0,0 +1,281 @@
+/* dict.c -- example program: how to use preset dictionaries
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996 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/
+ */
+
+
+/*************************************************************************
+// This program shows how to use preset dictionaries.
+//
+// Please study LZO.FAQ and simple.c first.
+**************************************************************************/
+
+#include "lzo/lzoconf.h"
+#include "lzo/lzo1x.h"
+
+/* portability layer */
+static const char *progname = NULL;
+#define WANT_LZO_MALLOC 1
+#define WANT_LZO_FREAD 1
+#define WANT_LZO_WILDARGV 1
+#define WANT_XMALLOC 1
+#include "examples/portab.h"
+
+
+#define DICT_LEN 0xbfff
+static lzo_bytep dict;
+static lzo_uint dict_len = 0;
+static lzo_uint32 dict_adler32;
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+static lzo_uint total_n = 0;
+static lzo_uint total_c_len = 0;
+static lzo_uint total_d_len = 0;
+
+static void print_file ( const char *name, lzo_uint d_len, lzo_uint c_len )
+{
+ double perc;
+
+ perc = (d_len > 0) ? c_len * 100.0 / d_len : 0;
+ printf(" | %-30s %9ld -> %9ld %7.2f%% |\n",
+ name, (long) d_len, (long) c_len, perc);
+
+ total_n++;
+ total_c_len += c_len;
+ total_d_len += d_len;
+}
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+int do_file ( const char *in_name, int compression_level )
+{
+ int r;
+ lzo_bytep in;
+ lzo_bytep out;
+ lzo_bytep newb;
+ lzo_voidp wrkmem;
+ lzo_uint in_len;
+ lzo_uint out_len;
+ lzo_uint new_len;
+ long l;
+ FILE *fp;
+
+/*
+ * Step 1: open the input file
+ */
+ fp = fopen(in_name,"rb");
+ if (fp == 0)
+ {
+ printf("%s: cannot open file %s\n", progname, in_name);
+ return 0; /* no error */
+ }
+ fseek(fp, 0, SEEK_END);
+ l = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ if (l <= 0)
+ {
+ printf("%s: %s: empty file -- skipping\n", progname, in_name);
+ fclose(fp); fp = NULL;
+ return 0;
+ }
+ in_len = (lzo_uint) l;
+
+/*
+ * Step 2: allocate compression buffers and read the file
+ */
+ in = (lzo_bytep) xmalloc(in_len);
+ out = (lzo_bytep) xmalloc(in_len + in_len / 16 + 64 + 3);
+ newb = (lzo_bytep) xmalloc(in_len);
+ wrkmem = (lzo_voidp) xmalloc(LZO1X_999_MEM_COMPRESS);
+ if (in == NULL || out == NULL || newb == NULL || wrkmem == NULL)
+ {
+ printf("%s: out of memory\n", progname);
+ exit(1);
+ }
+ in_len = (lzo_uint) lzo_fread(fp, in, in_len);
+ fclose(fp); fp = NULL;
+
+/*
+ * Step 3: compress from 'in' to 'out' with LZO1X-999
+ */
+ r = lzo1x_999_compress_level(in,in_len,out,&out_len,wrkmem,
+ dict, dict_len, 0, compression_level);
+ if (r != LZO_E_OK)
+ {
+ /* this should NEVER happen */
+ printf("internal error - compression failed: %d\n", r);
+ return 1;
+ }
+
+ print_file(in_name,in_len,out_len);
+
+/*
+ * Step 4: decompress again, now going from 'out' to 'newb'
+ */
+ new_len = in_len;
+ r = lzo1x_decompress_dict_safe(out,out_len,newb,&new_len,NULL,dict,dict_len);
+ if (r != LZO_E_OK)
+ {
+ /* this should NEVER happen */
+ printf("internal error - decompression failed: %d\n", r);
+ return 1;
+ }
+
+/*
+ * Step 5: verify decompression
+ */
+ if (new_len != in_len || lzo_memcmp(in,newb,in_len) != 0)
+ {
+ /* this should NEVER happen */
+ printf("internal error - decompression data error\n");
+ return 1;
+ }
+
+ /* free buffers in reverse order to help malloc() */
+ lzo_free(wrkmem);
+ lzo_free(newb);
+ lzo_free(out);
+ lzo_free(in);
+ return 0;
+}
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+int __lzo_cdecl_main main(int argc, char *argv[])
+{
+ int i = 1;
+ int r;
+ const char *dict_name;
+ FILE *fp;
+ time_t t_total;
+ int compression_level = 7;
+
+ lzo_wildargv(&argc, &argv);
+
+ printf("\nLZO real-time data compression library (v%s, %s).\n",
+ lzo_version_string(), lzo_version_date());
+ printf("Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+
+ progname = argv[0];
+
+ if (i < argc && argv[i][0] == '-' && isdigit(argv[i][1]))
+ compression_level = atoi(&argv[i++][1]);
+
+ if (i + 1 >= argc || compression_level < 1 || compression_level > 9)
+ {
+ printf("usage: %s [-level] [ dictionary-file | -n ] file...\n", progname);
+ exit(1);
+ }
+ printf("Compression level is LZO1X-999/%d\n", compression_level);
+
+/*
+ * 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");
+ exit(1);
+ }
+
+/*
+ * Step 2: prepare the dictionary
+ */
+ dict = (lzo_bytep) xmalloc(DICT_LEN);
+ if (dict == NULL)
+ {
+ printf("%s: out of memory\n", progname);
+ exit(1);
+ }
+ dict_name = argv[i++];
+ if (strcmp(dict_name,"-n") == 0)
+ {
+ dict_name = "empty";
+ dict_len = 0;
+ }
+ else
+ {
+ fp = fopen(dict_name,"rb");
+ if (!fp)
+ {
+ printf("%s: cannot open dictionary file %s\n", progname, dict_name);
+ exit(1);
+ }
+ dict_len = (lzo_uint) lzo_fread(fp, dict, DICT_LEN);
+ fclose(fp); fp = NULL;
+ }
+
+ dict_adler32 = lzo_adler32(0,NULL,0);
+ dict_adler32 = lzo_adler32(dict_adler32,dict,dict_len);
+ printf("Using dictionary '%s', %ld bytes, ID 0x%08lx.\n",
+ dict_name, (long) dict_len, (long) dict_adler32);
+
+/*
+ * Step 3: process files
+ */
+ t_total = time(NULL);
+ for (r = 0; r == 0 && i < argc; i++)
+ r = do_file(argv[i], compression_level);
+ t_total = time(NULL) - t_total;
+
+ lzo_free(dict);
+
+ if (total_n > 1)
+ print_file("***TOTALS***",total_d_len,total_c_len);
+
+ printf("Dictionary compression test %s, execution time %lu seconds.\n",
+ r == 0 ? "passed" : "FAILED", (unsigned long) t_total);
+ return r;
+}
+
+/*
+vi:ts=4:et
+*/
+
diff --git a/app/lzo/examples/lzopack.c b/app/lzo/examples/lzopack.c
new file mode 100644
index 00000000..e4e745df
--- /dev/null
+++ b/app/lzo/examples/lzopack.c
@@ -0,0 +1,645 @@
+/* lzopack.c -- LZO example program: a simple file packer
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996 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: this is an example program, so do not use to backup your data.
+//
+// This program lacks things like sophisticated file handling but is
+// pretty complete regarding compression - it should provide a good
+// starting point for adaption for your applications.
+//
+// Please study LZO.FAQ and simple.c first.
+**************************************************************************/
+
+#include "lzo/lzoconf.h"
+#include "lzo/lzo1x.h"
+
+/* portability layer */
+static const char *progname = NULL;
+#define WANT_LZO_MALLOC 1
+#define WANT_LZO_FREAD 1
+#define WANT_LZO_WILDARGV 1
+#define WANT_XMALLOC 1
+#include "examples/portab.h"
+
+
+static unsigned long total_in = 0;
+static unsigned long total_out = 0;
+static lzo_bool opt_debug = 0;
+
+/* magic file header for lzopack-compressed files */
+static const unsigned char magic[7] =
+ { 0x00, 0xe9, 0x4c, 0x5a, 0x4f, 0xff, 0x1a };
+
+
+/*************************************************************************
+// file IO
+**************************************************************************/
+
+lzo_uint xread(FILE *fp, lzo_voidp buf, lzo_uint len, lzo_bool allow_eof)
+{
+ lzo_uint l;
+
+ l = (lzo_uint) lzo_fread(fp, buf, len);
+ if (l > len)
+ {
+ fprintf(stderr, "\nsomething's wrong with your C library !!!\n");
+ exit(1);
+ }
+ if (l != len && !allow_eof)
+ {
+ fprintf(stderr, "\nread error - premature end of file\n");
+ exit(1);
+ }
+ total_in += (unsigned long) l;
+ return l;
+}
+
+lzo_uint xwrite(FILE *fp, const lzo_voidp buf, lzo_uint len)
+{
+ if (fp != NULL && lzo_fwrite(fp, buf, len) != len)
+ {
+ fprintf(stderr, "\nwrite error (disk full ?)\n");
+ exit(1);
+ }
+ total_out += (unsigned long) len;
+ return len;
+}
+
+
+int xgetc(FILE *fp)
+{
+ unsigned char c;
+ xread(fp, (lzo_voidp) &c, 1, 0);
+ return c;
+}
+
+void xputc(FILE *fp, int c)
+{
+ unsigned char cc = (unsigned char) (c & 0xff);
+ xwrite(fp, (const lzo_voidp) &cc, 1);
+}
+
+/* read and write portable 32-bit integers */
+
+lzo_uint32 xread32(FILE *fp)
+{
+ unsigned char b[4];
+ lzo_uint32 v;
+
+ xread(fp, b, 4, 0);
+ v = (lzo_uint32) b[3] << 0;
+ v |= (lzo_uint32) b[2] << 8;
+ v |= (lzo_uint32) b[1] << 16;
+ v |= (lzo_uint32) b[0] << 24;
+ return v;
+}
+
+void xwrite32(FILE *fp, lzo_xint v)
+{
+ unsigned char b[4];
+
+ b[3] = (unsigned char) ((v >> 0) & 0xff);
+ b[2] = (unsigned char) ((v >> 8) & 0xff);
+ b[1] = (unsigned char) ((v >> 16) & 0xff);
+ b[0] = (unsigned char) ((v >> 24) & 0xff);
+ xwrite(fp, b, 4);
+}
+
+
+/*************************************************************************
+// compress
+//
+// possible improvement: we could use overlapping compression to
+// save some memory - see overlap.c. This would require some minor
+// changes in the decompression code as well, because if a block
+// turns out to be incompressible we would still have to store it in its
+// "compressed" (i.e. then slightly enlarged) form because the original
+// (uncompressed) data would have been lost during the overlapping
+// compression.
+**************************************************************************/
+
+int do_compress(FILE *fi, FILE *fo, int compression_level, lzo_uint block_size)
+{
+ int r = 0;
+ lzo_bytep in = NULL;
+ lzo_bytep out = NULL;
+ lzo_voidp wrkmem = NULL;
+ lzo_uint in_len;
+ lzo_uint out_len;
+ lzo_uint32 wrk_len = 0;
+ lzo_uint32 flags = 1; /* do compute a checksum */
+ int method = 1; /* compression method: LZO1X */
+ lzo_uint32 checksum;
+
+ total_in = total_out = 0;
+
+/*
+ * Step 1: write magic header, flags & block size, init checksum
+ */
+ xwrite(fo, magic, sizeof(magic));
+ xwrite32(fo, flags);
+ xputc(fo, method); /* compression method */
+ xputc(fo, compression_level); /* compression level */
+ xwrite32(fo, block_size);
+ checksum = lzo_adler32(0, NULL, 0);
+
+/*
+ * Step 2: allocate compression buffers and work-memory
+ */
+ in = (lzo_bytep) xmalloc(block_size);
+ out = (lzo_bytep) xmalloc(block_size + block_size / 16 + 64 + 3);
+ if (compression_level == 9)
+ wrk_len = LZO1X_999_MEM_COMPRESS;
+ else
+ wrk_len = LZO1X_1_MEM_COMPRESS;
+ wrkmem = (lzo_voidp) xmalloc(wrk_len);
+ if (in == NULL || out == NULL || wrkmem == NULL)
+ {
+ printf("%s: out of memory\n", progname);
+ r = 1;
+ goto err;
+ }
+
+/*
+ * Step 3: process blocks
+ */
+ for (;;)
+ {
+ /* read block */
+ in_len = xread(fi, in, block_size, 1);
+ if (in_len == 0)
+ break;
+
+ /* update checksum */
+ if (flags & 1)
+ checksum = lzo_adler32(checksum, in, in_len);
+
+ /* clear wrkmem (not needed, only for debug/benchmark purposes) */
+ if (opt_debug)
+ lzo_memset(wrkmem, 0xff, wrk_len);
+
+ /* compress block */
+ if (compression_level == 9)
+ r = lzo1x_999_compress(in, in_len, out, &out_len, wrkmem);
+ else
+ r = lzo1x_1_compress(in, in_len, out, &out_len, wrkmem);
+ if (r != LZO_E_OK || out_len > in_len + in_len / 16 + 64 + 3)
+ {
+ /* this should NEVER happen */
+ printf("internal error - compression failed: %d\n", r);
+ r = 2;
+ goto err;
+ }
+
+ /* write uncompressed block size */
+ xwrite32(fo, in_len);
+
+ if (out_len < in_len)
+ {
+ /* write compressed block */
+ xwrite32(fo, out_len);
+ xwrite(fo, out, out_len);
+ }
+ else
+ {
+ /* not compressible - write uncompressed block */
+ xwrite32(fo, in_len);
+ xwrite(fo, in, in_len);
+ }
+ }
+
+ /* write EOF marker */
+ xwrite32(fo, 0);
+
+ /* write checksum */
+ if (flags & 1)
+ xwrite32(fo, checksum);
+
+ r = 0;
+err:
+ lzo_free(wrkmem);
+ lzo_free(out);
+ lzo_free(in);
+ return r;
+}
+
+
+/*************************************************************************
+// decompress / test
+//
+// We are using overlapping (in-place) decompression to save some
+// memory - see overlap.c.
+**************************************************************************/
+
+int do_decompress(FILE *fi, FILE *fo)
+{
+ int r = 0;
+ lzo_bytep buf = NULL;
+ lzo_uint buf_len;
+ unsigned char m [ sizeof(magic) ];
+ lzo_uint32 flags;
+ int method;
+ int compression_level;
+ lzo_uint block_size;
+ lzo_uint32 checksum;
+
+ total_in = total_out = 0;
+
+/*
+ * Step 1: check magic header, read flags & block size, init checksum
+ */
+ if (xread(fi, m, sizeof(magic),1) != sizeof(magic) ||
+ memcmp(m, magic, sizeof(magic)) != 0)
+ {
+ printf("%s: header error - this file is not compressed by lzopack\n", progname);
+ r = 1;
+ goto err;
+ }
+ flags = xread32(fi);
+ method = xgetc(fi);
+ compression_level = xgetc(fi);
+ if (method != 1)
+ {
+ printf("%s: header error - invalid method %d (level %d)\n",
+ progname, method, compression_level);
+ r = 2;
+ goto err;
+ }
+ block_size = xread32(fi);
+ if (block_size < 1024 || block_size > 8*1024*1024L)
+ {
+ printf("%s: header error - invalid block size %ld\n",
+ progname, (long) block_size);
+ r = 3;
+ goto err;
+ }
+ checksum = lzo_adler32(0,NULL,0);
+
+/*
+ * Step 2: allocate buffer for in-place decompression
+ */
+ buf_len = block_size + block_size / 16 + 64 + 3;
+ buf = (lzo_bytep) xmalloc(buf_len);
+ if (buf == NULL)
+ {
+ printf("%s: out of memory\n", progname);
+ r = 4;
+ goto err;
+ }
+
+/*
+ * Step 3: process blocks
+ */
+ for (;;)
+ {
+ lzo_bytep in;
+ lzo_bytep out;
+ lzo_uint in_len;
+ lzo_uint out_len;
+
+ /* read uncompressed size */
+ out_len = xread32(fi);
+
+ /* exit if last block (EOF marker) */
+ if (out_len == 0)
+ break;
+
+ /* read compressed size */
+ in_len = xread32(fi);
+
+ /* sanity check of the size values */
+ if (in_len > block_size || out_len > block_size ||
+ in_len == 0 || in_len > out_len)
+ {
+ printf("%s: block size error - data corrupted\n", progname);
+ r = 5;
+ goto err;
+ }
+
+ /* place compressed block at the top of the buffer */
+ in = buf + buf_len - in_len;
+ out = buf;
+
+ /* read compressed block data */
+ xread(fi, in, in_len, 0);
+
+ if (in_len < out_len)
+ {
+ /* decompress - use safe decompressor as data might be corrupted
+ * during a file transfer */
+ lzo_uint new_len = out_len;
+
+ r = lzo1x_decompress_safe(in, in_len, out, &new_len, NULL);
+ if (r != LZO_E_OK || new_len != out_len)
+ {
+ printf("%s: compressed data violation\n", progname);
+ r = 6;
+ goto err;
+ }
+ /* write decompressed block */
+ xwrite(fo, out, out_len);
+ /* update checksum */
+ if (flags & 1)
+ checksum = lzo_adler32(checksum, out, out_len);
+ }
+ else
+ {
+ /* write original (incompressible) block */
+ xwrite(fo, in, in_len);
+ /* update checksum */
+ if (flags & 1)
+ checksum = lzo_adler32(checksum, in, in_len);
+ }
+ }
+
+ /* read and verify checksum */
+ if (flags & 1)
+ {
+ lzo_uint32 c = xread32(fi);
+ if (c != checksum)
+ {
+ printf("%s: checksum error - data corrupted\n", progname);
+ r = 7;
+ goto err;
+ }
+ }
+
+ r = 0;
+err:
+ lzo_free(buf);
+ return r;
+}
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+static void usage(void)
+{
+ printf("usage: %s [-9] input-file output-file (compress)\n", progname);
+ printf("usage: %s -d input-file output-file (decompress)\n", progname);
+ printf("usage: %s -t input-file... (test)\n", progname);
+ exit(1);
+}
+
+
+/* open input file */
+static FILE *xopen_fi(const char *name)
+{
+ FILE *fp;
+
+ fp = fopen(name, "rb");
+ if (fp == NULL)
+ {
+ printf("%s: cannot open input file %s\n", progname, name);
+ exit(1);
+ }
+#if defined(HAVE_STAT) && defined(S_ISREG)
+ {
+ struct stat st;
+ int is_regular = 1;
+ if (stat(name, &st) != 0 || !S_ISREG(st.st_mode))
+ is_regular = 0;
+ if (!is_regular)
+ {
+ printf("%s: %s is not a regular file\n", progname, name);
+ fclose(fp); fp = NULL;
+ exit(1);
+ }
+ }
+#endif
+ return fp;
+}
+
+
+/* open output file */
+static FILE *xopen_fo(const char *name)
+{
+ FILE *fp;
+
+#if 0
+ /* this is an example program, so make sure we don't overwrite a file */
+ fp = fopen(name, "rb");
+ if (fp != NULL)
+ {
+ printf("%s: file %s already exists -- not overwritten\n", progname, name);
+ fclose(fp); fp = NULL;
+ exit(1);
+ }
+#endif
+ fp = fopen(name, "wb");
+ if (fp == NULL)
+ {
+ printf("%s: cannot open output file %s\n", progname, name);
+ exit(1);
+ }
+ return fp;
+}
+
+
+/* close file */
+static void xclose(FILE *fp)
+{
+ if (fp)
+ {
+ int err;
+ err = ferror(fp);
+ if (fclose(fp) != 0)
+ err = 1;
+ if (err)
+ {
+ printf("%s: error while closing file\n", progname);
+ exit(1);
+ }
+ }
+}
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+int __lzo_cdecl_main main(int argc, char *argv[])
+{
+ int i = 1;
+ int r = 0;
+ FILE *fi = NULL;
+ FILE *fo = NULL;
+ const char *in_name = NULL;
+ const char *out_name = NULL;
+ unsigned opt_decompress = 0;
+ unsigned opt_test = 0;
+ int opt_compression_level = 1;
+ lzo_uint opt_block_size;
+ const char *s;
+
+ lzo_wildargv(&argc, &argv);
+
+ progname = argv[0];
+ for (s = progname; *s; s++)
+ if ((*s == '/' || *s == '\\') && s[1])
+ progname = s + 1;
+
+ printf("\nLZO real-time data compression library (v%s, %s).\n",
+ lzo_version_string(), lzo_version_date());
+ printf("Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+
+#if 0
+ printf(
+"*** DISCLAIMER ***\n"
+" This is an example program, do not use to backup your data !\n"
+" Get LZOP if you're interested into a full-featured packer.\n"
+" See http://www.oberhumer.com/opensource/lzop/\n"
+"\n");
+#endif
+
+
+/*
+ * 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");
+ exit(1);
+ }
+
+
+/*
+ * Step 2: setup memory
+ */
+ opt_block_size = 256 * 1024L;
+
+#if defined(ACC_MM_AHSHIFT)
+ /* reduce memory requirements for ancient 16-bit DOS 640kB real-mode */
+ if (ACC_MM_AHSHIFT != 3)
+ opt_block_size = 16 * 1024L;
+#endif
+
+
+/*
+ * Step 3: get options
+ */
+
+ while (i < argc && argv[i][0] == '-')
+ {
+ if (strcmp(argv[i],"-d") == 0)
+ opt_decompress = 1;
+ else if (strcmp(argv[i],"-t") == 0)
+ opt_test = 1;
+ else if (strcmp(argv[i],"-9") == 0)
+ opt_compression_level = 9;
+ else if (argv[i][1] == 'b' && argv[i][2])
+ {
+ long b = atol(&argv[i][2]);
+ if (b >= 1024L && b <= 8*1024*1024L)
+ opt_block_size = (lzo_uint) b;
+ else
+ {
+ printf("%s: invalid block_size in option '%s'.\n", progname, argv[i]);
+ usage();
+ }
+ }
+ else if (strcmp(argv[i],"--debug") == 0)
+ opt_debug += 1;
+ else
+ usage();
+ i++;
+ }
+ if (opt_test && i >= argc)
+ usage();
+ if (!opt_test && i + 2 != argc)
+ usage();
+
+
+/*
+ * Step 4: process file(s)
+ */
+
+ if (opt_test)
+ {
+ while (i < argc && r == 0)
+ {
+ in_name = argv[i++];
+ fi = xopen_fi(in_name);
+ r = do_decompress(fi, NULL);
+ if (r == 0)
+ printf("%s: %s tested ok (%lu -> %lu bytes)\n",
+ progname, in_name, total_in, total_out);
+ xclose(fi); fi = NULL;
+ }
+ }
+ else if (opt_decompress)
+ {
+ in_name = argv[i++];
+ out_name = argv[i++];
+ fi = xopen_fi(in_name);
+ fo = xopen_fo(out_name);
+ r = do_decompress(fi, fo);
+ if (r == 0)
+ printf("%s: decompressed %lu into %lu bytes\n",
+ progname, total_in, total_out);
+ }
+ else /* compress */
+ {
+ in_name = argv[i++];
+ out_name = argv[i++];
+ fi = xopen_fi(in_name);
+ fo = xopen_fo(out_name);
+ r = do_compress(fi, fo, opt_compression_level, opt_block_size);
+ if (r == 0)
+ printf("%s: compressed %lu into %lu bytes\n",
+ progname, total_in, total_out);
+ }
+
+ xclose(fi); fi = NULL;
+ xclose(fo); fo = NULL;
+ return r;
+}
+
+/*
+vi:ts=4:et
+*/
+
diff --git a/app/lzo/examples/overlap.c b/app/lzo/examples/overlap.c
new file mode 100644
index 00000000..b2337680
--- /dev/null
+++ b/app/lzo/examples/overlap.c
@@ -0,0 +1,322 @@
+/* overlap.c -- example program: overlapping (de)compression
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996 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/
+ */
+
+
+/*************************************************************************
+// This program shows how to do overlapping compression and
+// in-place decompression.
+//
+// Please study LZO.FAQ and simple.c first.
+**************************************************************************/
+
+#include "lzo/lzoconf.h"
+#include "lzo/lzo1x.h"
+
+/* portability layer */
+static const char *progname = NULL;
+#define WANT_LZO_MALLOC 1
+#define WANT_LZO_FREAD 1
+#define WANT_LZO_WILDARGV 1
+#define WANT_XMALLOC 1
+#include "examples/portab.h"
+
+
+/* Overhead (in bytes) for the in-place decompression buffer.
+ * Most files need only 16 !
+ * (try 'overlap -16 file' or even 'overlap -8 file')
+ *
+ * Worst case (for files that are compressible by only a few bytes)
+ * is 'in_len / 16 + 64 + 3'. See step 5a) below.
+ *
+ * For overlapping compression '0xbfff + in_len / 16 + 64 + 3' bytes
+ * will be needed. See step 4a) below.
+ */
+
+static lzo_uint opt_overhead = 0; /* assume worst case */
+
+
+#if 0 && defined(LZO_USE_ASM)
+ /* just for testing */
+# include <lzo_asm.h>
+# define lzo1x_decompress lzo1x_decompress_asm_fast
+#endif
+
+
+static unsigned long total_files = 0;
+static unsigned long total_in = 0;
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+int do_file ( const char *in_name )
+{
+ int r;
+ FILE *fp = NULL;
+ long l;
+
+ lzo_voidp wrkmem = NULL;
+
+ lzo_bytep in = NULL;
+ lzo_uint in_len; /* uncompressed length */
+
+ lzo_bytep out = NULL;
+ lzo_uint out_len; /* compressed length */
+
+ lzo_bytep overlap = NULL;
+ lzo_uint overhead;
+ lzo_uint offset;
+
+ lzo_uint new_len = 0;
+
+/*
+ * Step 1: open the input file
+ */
+ fp = fopen(in_name, "rb");
+ if (fp == NULL)
+ {
+ printf("%s: %s: cannot open file\n", progname, in_name);
+ goto next_file;
+ }
+ fseek(fp, 0, SEEK_END);
+ l = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ if (l <= 0)
+ {
+ printf("%s: %s: empty file -- skipping\n", progname, in_name);
+ goto next_file;
+ }
+ in_len = (lzo_uint) l;
+
+/*
+ * Step 2: allocate compression buffers and read the file
+ */
+ in = (lzo_bytep) xmalloc(in_len);
+ out = (lzo_bytep) xmalloc(in_len + in_len / 16 + 64 + 3);
+ wrkmem = (lzo_voidp) xmalloc(LZO1X_1_MEM_COMPRESS);
+ in_len = (lzo_uint) lzo_fread(fp, in, in_len);
+ fclose(fp); fp = NULL;
+ printf("%s: %s: read %lu bytes\n", progname, in_name, (unsigned long) in_len);
+
+ total_files++;
+ total_in += (unsigned long) 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 || out_len > in_len + in_len / 16 + 64 + 3)
+ {
+ /* this should NEVER happen */
+ printf("internal error - compression failed: %d\n", r);
+ exit(1);
+ }
+ printf("%-26s %8lu -> %8lu\n", "LZO1X-1:", (unsigned long) in_len, (unsigned long) out_len);
+
+
+/***** Step 4: overlapping compression *****/
+
+/*
+ * Step 4a: allocate the 'overlap' buffer for overlapping compression
+ */
+ overhead = in_len > 0xbfff ? 0xbfff : in_len;
+ overhead += in_len / 16 + 64 + 3;
+ overlap = (lzo_bytep) xmalloc(in_len + overhead);
+
+/*
+ * Step 4b: prepare data in 'overlap' buffer.
+ * copy uncompressed data at the top of the overlap buffer
+ */
+ /*** offset = in_len + overhead - in_len; ***/
+ offset = overhead;
+ lzo_memcpy(overlap + offset, in, in_len);
+
+/*
+ * Step 4c: do an in-place compression within the 'overlap' buffer
+ */
+ r = lzo1x_1_compress(overlap+offset,in_len,overlap,&new_len,wrkmem);
+ if (r != LZO_E_OK)
+ {
+ /* this should NEVER happen */
+ printf("overlapping compression failed: %d\n", r);
+ exit(1);
+ }
+
+/*
+ * Step 4d: verify overlapping compression
+ */
+ if (new_len != out_len || lzo_memcmp(out,overlap,out_len) != 0)
+ {
+ /* As compression is non-deterministic there can be a difference
+ * in the representation of the compressed data (but this usually
+ * happens very seldom). So we have to verify the overlapping
+ * compression by doing a temporary decompression.
+ */
+ lzo_uint ll = in_len;
+ lzo_bytep tmp = (lzo_bytep) xmalloc(ll);
+ r = lzo1x_decompress_safe(overlap, new_len, tmp, &ll, NULL);
+ if (r != LZO_E_OK || ll != in_len || lzo_memcmp(in, tmp, ll) != 0)
+ {
+ /* this should NEVER happen */
+ printf("overlapping compression data error\n");
+ exit(1);
+ }
+ lzo_free(tmp);
+ }
+
+ printf("overlapping compression: %8lu -> %8lu overhead: %7lu\n",
+ (unsigned long) in_len, (unsigned long) new_len, (unsigned long) overhead);
+ lzo_free(overlap); overlap = NULL;
+
+
+/***** Step 5: overlapping decompression *****/
+
+/*
+ * Step 5a: allocate the 'overlap' buffer for in-place decompression
+ */
+ if (opt_overhead == 0 || out_len >= in_len)
+ overhead = in_len / 16 + 64 + 3;
+ else
+ overhead = opt_overhead;
+ overlap = (lzo_bytep) xmalloc(in_len + overhead);
+
+/*
+ * Step 5b: prepare data in 'overlap' buffer.
+ * copy compressed data at the top of the overlap buffer
+ */
+ offset = in_len + overhead - out_len;
+ lzo_memcpy(overlap + offset, out, out_len);
+
+/*
+ * Step 5c: do an in-place decompression within the 'overlap' buffer
+ */
+ new_len = in_len;
+ r = lzo1x_decompress(overlap+offset,out_len,overlap,&new_len,NULL);
+ if (r != LZO_E_OK)
+ {
+ /* this may happen if overhead is too small */
+ printf("overlapping decompression failed: %d - increase 'opt_overhead'\n", r);
+ exit(1);
+ }
+
+/*
+ * Step 5d: verify decompression
+ */
+ if (new_len != in_len || lzo_memcmp(in,overlap,in_len) != 0)
+ {
+ /* this may happen if overhead is too small */
+ printf("overlapping decompression data error - increase 'opt_overhead'\n");
+ exit(1);
+ }
+ printf("overlapping decompression: %8lu -> %8lu overhead: %7lu\n",
+ (unsigned long) out_len, (unsigned long) new_len, (unsigned long) overhead);
+ lzo_free(overlap); overlap = NULL;
+
+
+next_file:
+ lzo_free(overlap);
+ lzo_free(wrkmem);
+ lzo_free(out);
+ lzo_free(in);
+ if (fp) fclose(fp);
+
+ return 0;
+}
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+int __lzo_cdecl_main main(int argc, char *argv[])
+{
+ int r;
+ int i = 1;
+
+ lzo_wildargv(&argc, &argv);
+
+ printf("\nLZO real-time data compression library (v%s, %s).\n",
+ lzo_version_string(), lzo_version_date());
+ printf("Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+
+ progname = argv[0];
+ if (i < argc && argv[i][0] == '-')
+ opt_overhead = atoi(&argv[i++][1]);
+#if 1
+ if (opt_overhead != 0 && opt_overhead < 8)
+ {
+ printf("%s: invalid overhead value %ld\n", progname, (long)opt_overhead);
+ exit(1);
+ }
+#endif
+ if (i >= argc)
+ {
+ printf("usage: %s [-overhead_in_bytes] file..\n", progname);
+ exit(1);
+ }
+
+/*
+ * 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");
+ exit(1);
+ }
+
+/*
+ * Step 2: process files
+ */
+ for (r = 0; r == 0 && i < argc; i++)
+ r = do_file(argv[i]);
+
+ printf("\nDone. Successfully processed %lu bytes in %lu files.\n",
+ total_in, total_files);
+ return r;
+}
+
+/*
+vi:ts=4:et
+*/
+
diff --git a/app/lzo/examples/portab.h b/app/lzo/examples/portab.h
new file mode 100644
index 00000000..b4b5a21a
--- /dev/null
+++ b/app/lzo/examples/portab.h
@@ -0,0 +1,187 @@
+/* portab.h -- portability layer
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996 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/
+ */
+
+
+#include "lzo/lzoconf.h"
+
+#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1200))
+ /* avoid '-W4' warnings in system header files */
+# pragma warning(disable: 4201 4214 4514)
+#endif
+#if (LZO_CC_MSC && (_MSC_VER >= 1300))
+ /* avoid '-Wall' warnings in system header files */
+# pragma warning(disable: 4163 4255 4820)
+ /* avoid warnings about inlining */
+# pragma warning(disable: 4710 4711)
+#endif
+#if (LZO_CC_MSC && (_MSC_VER >= 1400))
+ /* avoid warnings when using "deprecated" POSIX functions */
+# pragma warning(disable: 4996)
+#endif
+#if (LZO_CC_PELLESC && (__POCC__ >= 290))
+# pragma warn(disable:2002)
+#endif
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+#if defined(__LZO_MMODEL_HUGE) || defined(ACC_WANT_ACCLIB_GETOPT) || !(defined(LZO_LIBC_ISOC90) || defined(LZO_LIBC_ISOC99))
+
+#include "examples/portab_a.h"
+
+#else
+
+/* INFO:
+ * The "portab_a.h" version above uses the ACC library to add
+ * support for ancient systems (like 16-bit DOS) and to provide
+ * some gimmicks like Windows high-resolution timers.
+ * Still, on any halfway modern machine you can also use the
+ * following pure ANSI-C code instead.
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <time.h>
+#if defined(CLK_TCK) && !defined(CLOCKS_PER_SEC)
+# define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#if defined(WANT_LZO_MALLOC)
+# define lzo_malloc(a) (malloc(a))
+# define lzo_free(a) (free(a))
+#endif
+#if defined(WANT_LZO_FREAD)
+# define lzo_fread(f,b,s) (fread(b,1,s,f))
+# define lzo_fwrite(f,b,s) (fwrite(b,1,s,f))
+#endif
+#if defined(WANT_LZO_UCLOCK)
+# define lzo_uclock_handle_t int
+# define lzo_uclock_t double
+# define lzo_uclock_open(a) ((void)(a))
+# define lzo_uclock_close(a) ((void)(a))
+# define lzo_uclock_read(a,b) *(b) = (clock() / (double)(CLOCKS_PER_SEC))
+# define lzo_uclock_get_elapsed(a,b,c) (*(c) - *(b))
+#endif
+#if defined(WANT_LZO_WILDARGV)
+# define lzo_wildargv(a,b) ((void)0)
+#endif
+
+#endif
+
+
+/*************************************************************************
+// misc
+**************************************************************************/
+
+/* turn on assertions */
+#undef NDEBUG
+#include <assert.h>
+
+/* just in case */
+#undef xmalloc
+#undef xfree
+#undef xread
+#undef xwrite
+#undef xputc
+#undef xgetc
+#undef xread32
+#undef xwrite32
+
+
+#if defined(WANT_XMALLOC)
+static lzo_voidp xmalloc(lzo_uint len)
+{
+ lzo_voidp p;
+ lzo_uint align = (lzo_uint) sizeof(lzo_align_t);
+
+ p = (lzo_voidp) lzo_malloc(len > 0 ? len : 1);
+ if (p == NULL)
+ {
+ printf("%s: out of memory\n", progname);
+ exit(1);
+ }
+ if (len >= align && __lzo_align_gap(p, align) != 0)
+ {
+ printf("%s: C library problem: malloc() returned misaligned pointer!\n", progname);
+ exit(1);
+ }
+ return p;
+}
+#endif
+
+
+#if defined(WANT_LZO_UCLOCK)
+
+/* High quality benchmarking.
+ *
+ * Flush the CPU cache to get more accurate benchmark values.
+ * This needs custom kernel patches. As a result - in combination with
+ * the perfctr Linux kernel patches - accurate high-quality benchmarking
+ * is possible.
+ *
+ * All other methods (rdtsc, QueryPerformanceCounter, gettimeofday, ...)
+ * are completely unreliable for our purposes, and the only other
+ * option is to boot into a legacy single-task operating system
+ * like plain MSDOS and to directly reprogram the hardware clock.
+ * [The djgpp2 port of the gcc compiler has support functions for this.]
+ *
+ * Also, for embedded systems it's best to benchmark by using a
+ * CPU emulator/simulator software that can exactly count all
+ * virtual clock ticks.
+ */
+
+#if !defined(lzo_uclock_flush_cpu_cache)
+# define lzo_uclock_flush_cpu_cache(h,flags) ((void)(h))
+#endif
+
+#endif
+
+
+/*
+vi:ts=4:et
+*/
+
diff --git a/app/lzo/examples/portab_a.h b/app/lzo/examples/portab_a.h
new file mode 100644
index 00000000..2706022d
--- /dev/null
+++ b/app/lzo/examples/portab_a.h
@@ -0,0 +1,140 @@
+/* portab_a.h -- advanced portability layer
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996 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/
+ */
+
+
+/*************************************************************************
+// use the ACC library for the hard work
+**************************************************************************/
+
+#if defined(LZO_HAVE_CONFIG_H)
+# define ACC_CONFIG_NO_HEADER 1
+#endif
+
+#define ACC_WANT_ACC_INCD_H 1
+#define ACC_WANT_ACC_INCE_H 1
+#if defined(__LZO_MMODEL_HUGE) || defined(ACC_WANT_ACCLIB_GETOPT) || defined(WANT_LZO_UCLOCK) || defined(WANT_LZO_WILDARGV)
+# define ACC_WANT_ACC_INCI_H 1
+# define ACC_WANT_ACC_LIB_H 1
+#endif
+#include "src/miniacc.h"
+
+#if defined(WANT_LZO_MALLOC)
+# if defined(__LZO_MMODEL_HUGE)
+# define ACC_WANT_ACCLIB_HALLOC 1
+# else
+# define acc_halloc(a) (malloc(a))
+# define acc_hfree(a) (free(a))
+# endif
+#endif
+#if defined(WANT_LZO_FREAD)
+# if defined(__LZO_MMODEL_HUGE)
+# define ACC_WANT_ACCLIB_HFREAD 1
+# else
+# define acc_hfread(f,b,s) (fread(b,1,s,f))
+# define acc_hfwrite(f,b,s) (fwrite(b,1,s,f))
+# endif
+#endif
+#if defined(WANT_LZO_UCLOCK)
+# define ACC_WANT_ACCLIB_PCLOCK 1
+# if 0 && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
+# define __ACCLIB_PCLOCK_USE_RDTSC 1
+# define ACC_WANT_ACCLIB_RDTSC 1
+# endif
+#endif
+#if defined(WANT_LZO_WILDARGV)
+# define ACC_WANT_ACCLIB_WILDARGV 1
+#endif
+#if (__ACCLIB_REQUIRE_HMEMCPY_CH) && !defined(__ACCLIB_HMEMCPY_CH_INCLUDED)
+# define ACC_WANT_ACCLIB_HMEMCPY 1
+#endif
+#include "src/miniacc.h"
+
+
+/*************************************************************************
+// finally pull into the LZO namespace
+**************************************************************************/
+
+#undef lzo_malloc
+#undef lzo_free
+#undef lzo_fread
+#undef lzo_fwrite
+#if defined(WANT_LZO_MALLOC)
+# if defined(acc_halloc)
+# define lzo_malloc(a) acc_halloc(a)
+# else
+# define lzo_malloc(a) __ACCLIB_FUNCNAME(acc_halloc)(a)
+# endif
+# if defined(acc_hfree)
+# define lzo_free(a) acc_hfree(a)
+# else
+# define lzo_free(a) __ACCLIB_FUNCNAME(acc_hfree)(a)
+# endif
+#endif
+#if defined(WANT_LZO_FREAD)
+# if defined(acc_hfread)
+# define lzo_fread(f,b,s) acc_hfread(f,b,s)
+# else
+# define lzo_fread(f,b,s) __ACCLIB_FUNCNAME(acc_hfread)(f,b,s)
+# endif
+# if defined(acc_hfwrite)
+# define lzo_fwrite(f,b,s) acc_hfwrite(f,b,s)
+# else
+# define lzo_fwrite(f,b,s) __ACCLIB_FUNCNAME(acc_hfwrite)(f,b,s)
+# endif
+#endif
+#if defined(WANT_LZO_UCLOCK)
+# define lzo_uclock_handle_t acc_pclock_handle_t
+# define lzo_uclock_t acc_pclock_t
+# define lzo_uclock_open(a) __ACCLIB_FUNCNAME(acc_pclock_open_default)(a)
+# define lzo_uclock_close(a) __ACCLIB_FUNCNAME(acc_pclock_close)(a)
+# define lzo_uclock_read(a,b) __ACCLIB_FUNCNAME(acc_pclock_read)(a,b)
+# define lzo_uclock_get_elapsed(a,b,c) __ACCLIB_FUNCNAME(acc_pclock_get_elapsed)(a,b,c)
+#endif
+#if defined(WANT_LZO_WILDARGV)
+# define lzo_wildargv(a,b) __ACCLIB_FUNCNAME(acc_wildargv)(a,b)
+#endif
+
+
+/*
+vi:ts=4:et
+*/
+
diff --git a/app/lzo/examples/precomp.c b/app/lzo/examples/precomp.c
new file mode 100644
index 00000000..a953827b
--- /dev/null
+++ b/app/lzo/examples/precomp.c
@@ -0,0 +1,349 @@
+/* precomp.c -- example program: how to generate pre-compressed data
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996 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/
+ */
+
+
+/*************************************************************************
+// This program shows how to generate pre-compressed data.
+//
+// Please study LZO.FAQ and simple.c first.
+//
+// We will be trying both LZO1X-999 and LZO1Y-999 and choose
+// the algorithm that achieves the best compression ratio.
+**************************************************************************/
+
+#include "lzo/lzoconf.h"
+#include "lzo/lzo1x.h"
+#include "lzo/lzo1y.h"
+
+#define USE_LZO1X 1
+#define USE_LZO1Y 1
+
+#define PARANOID 1
+
+
+/* portability layer */
+static const char *progname = NULL;
+#define WANT_LZO_MALLOC 1
+#define WANT_LZO_FREAD 1
+#define WANT_LZO_WILDARGV 1
+#define WANT_XMALLOC 1
+#include "examples/portab.h"
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+int __lzo_cdecl_main main(int argc, char *argv[])
+{
+ int r;
+
+ lzo_bytep in;
+ lzo_uint in_len;
+
+ lzo_bytep out;
+ lzo_uint out_bufsize;
+ lzo_uint out_len = 0;
+
+ lzo_voidp wrkmem;
+ lzo_uint wrk_len;
+
+ lzo_uint best_len;
+ int best_compress = -1;
+
+ lzo_uint orig_len;
+ lzo_uint32 uncompressed_checksum;
+ lzo_uint32 compressed_checksum;
+
+ FILE *fp;
+ const char *in_name = NULL;
+ const char *out_name = NULL;
+ long l;
+
+
+ lzo_wildargv(&argc, &argv);
+
+ printf("\nLZO real-time data compression library (v%s, %s).\n",
+ lzo_version_string(), lzo_version_date());
+ printf("Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+
+ progname = argv[0];
+ if (argc < 2 || argc > 3)
+ {
+ printf("usage: %s file [output-file]\n", progname);
+ exit(1);
+ }
+ in_name = argv[1];
+ if (argc > 2) out_name = argv[2];
+
+/*
+ * 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");
+ exit(1);
+ }
+
+/*
+ * Step 2: allocate the work-memory
+ */
+ wrk_len = 1;
+#ifdef USE_LZO1X
+ if (wrk_len < LZO1X_999_MEM_COMPRESS)
+ wrk_len = LZO1X_999_MEM_COMPRESS;
+#endif
+#ifdef USE_LZO1Y
+ if (wrk_len < LZO1Y_999_MEM_COMPRESS)
+ wrk_len = LZO1Y_999_MEM_COMPRESS;
+#endif
+ wrkmem = (lzo_voidp) xmalloc(wrk_len);
+ if (wrkmem == NULL)
+ {
+ printf("%s: out of memory\n", progname);
+ exit(1);
+ }
+
+/*
+ * Step 3: open the input file
+ */
+ fp = fopen(in_name,"rb");
+ if (fp == NULL)
+ {
+ printf("%s: cannot open file %s\n", progname, in_name);
+ exit(1);
+ }
+ fseek(fp, 0, SEEK_END);
+ l = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ if (l <= 0)
+ {
+ printf("%s: %s: empty file\n", progname, in_name);
+ fclose(fp); fp = NULL;
+ exit(1);
+ }
+ in_len = (lzo_uint) l;
+ out_bufsize = in_len + in_len / 16 + 64 + 3;
+ best_len = in_len;
+
+/*
+ * Step 4: allocate compression buffers and read the file
+ */
+ in = (lzo_bytep) xmalloc(in_len);
+ out = (lzo_bytep) xmalloc(out_bufsize);
+ if (in == NULL || out == NULL)
+ {
+ printf("%s: out of memory\n", progname);
+ exit(1);
+ }
+ in_len = (lzo_uint) lzo_fread(fp, in, in_len);
+ printf("%s: loaded file %s: %ld bytes\n", progname, in_name, (long) in_len);
+ fclose(fp); fp = NULL;
+
+/*
+ * Step 5: compute a checksum of the uncompressed data
+ */
+ uncompressed_checksum = lzo_adler32(0,NULL,0);
+ uncompressed_checksum = lzo_adler32(uncompressed_checksum,in,in_len);
+
+/*
+ * Step 6a: compress from 'in' to 'out' with LZO1X-999
+ */
+#ifdef USE_LZO1X
+ out_len = out_bufsize;
+ r = lzo1x_999_compress(in,in_len,out,&out_len,wrkmem);
+ if (r != LZO_E_OK)
+ {
+ /* this should NEVER happen */
+ printf("internal error - compression failed: %d\n", r);
+ exit(1);
+ }
+ printf("LZO1X-999: %8lu -> %8lu\n", (unsigned long) in_len, (unsigned long) out_len);
+ if (out_len < best_len)
+ {
+ best_len = out_len;
+ best_compress = 1; /* LZO1X-999 */
+ }
+#endif /* USE_LZO1X */
+
+/*
+ * Step 6b: compress from 'in' to 'out' with LZO1Y-999
+ */
+#ifdef USE_LZO1Y
+ out_len = out_bufsize;
+ r = lzo1y_999_compress(in,in_len,out,&out_len,wrkmem);
+ if (r != LZO_E_OK)
+ {
+ /* this should NEVER happen */
+ printf("internal error - compression failed: %d\n", r);
+ exit(1);
+ }
+ printf("LZO1Y-999: %8lu -> %8lu\n", (unsigned long) in_len, (unsigned long) out_len);
+ if (out_len < best_len)
+ {
+ best_len = out_len;
+ best_compress = 2; /* LZO1Y-999 */
+ }
+#endif /* USE_LZO1Y */
+
+/*
+ * Step 7: check if compressible
+ */
+ if (best_len >= in_len)
+ {
+ printf("This file contains incompressible data.\n");
+ return 0;
+ }
+
+/*
+ * Step 8: compress data again using the best compressor found
+ */
+ out_len = out_bufsize;
+ if (best_compress == 1)
+ r = lzo1x_999_compress(in,in_len,out,&out_len,wrkmem);
+ else if (best_compress == 2)
+ r = lzo1y_999_compress(in,in_len,out,&out_len,wrkmem);
+ else
+ r = -100;
+ assert(r == LZO_E_OK);
+ assert(out_len == best_len);
+
+/*
+ * Step 9: optimize compressed data (compressed data is in 'out' buffer)
+ */
+#if 1
+ /* Optimization does not require any data in the buffer that will
+ * hold the uncompressed data. To prove this, we clear the buffer.
+ */
+ lzo_memset(in,0,in_len);
+#endif
+
+ orig_len = in_len;
+ r = -100;
+#ifdef USE_LZO1X
+ if (best_compress == 1)
+ r = lzo1x_optimize(out,out_len,in,&orig_len,NULL);
+#endif
+#ifdef USE_LZO1Y
+ if (best_compress == 2)
+ r = lzo1y_optimize(out,out_len,in,&orig_len,NULL);
+#endif
+ if (r != LZO_E_OK || orig_len != in_len)
+ {
+ /* this should NEVER happen */
+ printf("internal error - optimization failed: %d\n", r);
+ exit(1);
+ }
+
+/*
+ * Step 10: compute a checksum of the compressed data
+ */
+ compressed_checksum = lzo_adler32(0,NULL,0);
+ compressed_checksum = lzo_adler32(compressed_checksum,out,out_len);
+
+/*
+ * Step 11: write compressed data to a file
+ */
+ printf("%s: %s: %ld -> %ld, checksum 0x%08lx 0x%08lx\n",
+ progname, in_name, (long) in_len, (long) out_len,
+ (long) uncompressed_checksum, (long) compressed_checksum);
+
+ if (out_name && out_name[0])
+ {
+ printf("%s: writing to file %s\n", progname, out_name);
+ fp = fopen(out_name,"wb");
+ if (fp == NULL)
+ {
+ printf("%s: cannot open output file %s\n", progname, out_name);
+ exit(1);
+ }
+ if (lzo_fwrite(fp, out, out_len) != out_len || fclose(fp) != 0)
+ {
+ printf("%s: write error !!\n", progname);
+ exit(1);
+ }
+ }
+
+/*
+ * Step 12: verify decompression
+ */
+#ifdef PARANOID
+ lzo_memset(in,0,in_len); /* paranoia - clear output buffer */
+ orig_len = in_len;
+ r = -100;
+#ifdef USE_LZO1X
+ if (best_compress == 1)
+ r = lzo1x_decompress_safe(out,out_len,in,&orig_len,NULL);
+#endif
+#ifdef USE_LZO1Y
+ if (best_compress == 2)
+ r = lzo1y_decompress_safe(out,out_len,in,&orig_len,NULL);
+#endif
+ if (r != LZO_E_OK || orig_len != in_len)
+ {
+ /* this should NEVER happen */
+ printf("internal error - decompression failed: %d\n", r);
+ exit(1);
+ }
+ if (uncompressed_checksum != lzo_adler32(lzo_adler32(0,NULL,0),in,in_len))
+ {
+ /* this should NEVER happen */
+ printf("internal error - decompression data error\n");
+ exit(1);
+ }
+ /* Now you could also verify decompression under similar conditions as in
+ * your application, e.g. overlapping assembler decompression etc.
+ */
+#endif
+
+ lzo_free(in);
+ lzo_free(out);
+ lzo_free(wrkmem);
+
+ return 0;
+}
+
+/*
+vi:ts=4:et
+*/
+
diff --git a/app/lzo/examples/precomp2.c b/app/lzo/examples/precomp2.c
new file mode 100644
index 00000000..d9e1b47b
--- /dev/null
+++ b/app/lzo/examples/precomp2.c
@@ -0,0 +1,401 @@
+/* precomp2.c -- example program: how to generate pre-compressed data
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996 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/
+ */
+
+
+/*************************************************************************
+// This program shows how to generate pre-compressed data.
+//
+// Please study precomp.c first.
+//
+// We will be trying LZO1X-999 and LZO1Y-999, and we will be trying
+// various parameters using the internal interface to squeeze out
+// a little bit of extra compression.
+//
+// NOTE: this program can be quite slow for highly redundant files
+**************************************************************************/
+
+#include "lzo/lzoconf.h"
+#include "lzo/lzo1x.h"
+#include "lzo/lzo1y.h"
+
+LZO_EXTERN(int)
+lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
+ lzo_bytep out, lzo_uintp out_len,
+ lzo_voidp wrkmem,
+ const lzo_bytep dict, lzo_uint dict_len,
+ lzo_callback_p cb,
+ int try_lazy,
+ lzo_uint good_length,
+ lzo_uint max_lazy,
+ lzo_uint nice_length,
+ lzo_uint max_chain,
+ lzo_uint32 flags );
+
+LZO_EXTERN(int)
+lzo1y_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
+ lzo_bytep out, lzo_uintp out_len,
+ lzo_voidp wrkmem,
+ const lzo_bytep dict, lzo_uint dict_len,
+ lzo_callback_p cb,
+ int try_lazy,
+ lzo_uint good_length,
+ lzo_uint max_lazy,
+ lzo_uint nice_length,
+ lzo_uint max_chain,
+ lzo_uint32 flags );
+
+#define USE_LZO1X 1
+#define USE_LZO1Y 1
+
+#define PARANOID 1
+
+
+/* portability layer */
+static const char *progname = NULL;
+#define WANT_LZO_MALLOC 1
+#define WANT_LZO_FREAD 1
+#define WANT_LZO_WILDARGV 1
+#define WANT_XMALLOC 1
+#include "examples/portab.h"
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+int __lzo_cdecl_main main(int argc, char *argv[])
+{
+ int r;
+ int lazy;
+ const int max_try_lazy = 5;
+ const lzo_uint big = 65536L; /* can result in very slow compression */
+ const lzo_uint32 flags = 0x1;
+
+ lzo_bytep in;
+ lzo_uint in_len;
+
+ lzo_bytep out;
+ lzo_uint out_bufsize;
+ lzo_uint out_len = 0;
+
+ lzo_voidp wrkmem;
+ lzo_uint wrk_len;
+
+ lzo_uint best_len;
+ int best_compress = -1;
+ int best_lazy = -1;
+
+ lzo_uint orig_len;
+ lzo_uint32 uncompressed_checksum;
+ lzo_uint32 compressed_checksum;
+
+ FILE *fp;
+ const char *in_name = NULL;
+ const char *out_name = NULL;
+ long l;
+
+
+ lzo_wildargv(&argc, &argv);
+
+ printf("\nLZO real-time data compression library (v%s, %s).\n",
+ lzo_version_string(), lzo_version_date());
+ printf("Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+
+ progname = argv[0];
+ if (argc < 2 || argc > 3)
+ {
+ printf("usage: %s file [output-file]\n", progname);
+ exit(1);
+ }
+ in_name = argv[1];
+ if (argc > 2) out_name = argv[2];
+
+/*
+ * 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");
+ exit(1);
+ }
+
+/*
+ * Step 2: allocate the work-memory
+ */
+ wrk_len = 1;
+#ifdef USE_LZO1X
+ if (wrk_len < LZO1X_999_MEM_COMPRESS)
+ wrk_len = LZO1X_999_MEM_COMPRESS;
+#endif
+#ifdef USE_LZO1Y
+ if (wrk_len < LZO1Y_999_MEM_COMPRESS)
+ wrk_len = LZO1Y_999_MEM_COMPRESS;
+#endif
+ wrkmem = (lzo_voidp) xmalloc(wrk_len);
+ if (wrkmem == NULL)
+ {
+ printf("%s: out of memory\n", progname);
+ exit(1);
+ }
+
+/*
+ * Step 3: open the input file
+ */
+ fp = fopen(in_name,"rb");
+ if (fp == NULL)
+ {
+ printf("%s: cannot open file %s\n", progname, in_name);
+ exit(1);
+ }
+ fseek(fp, 0, SEEK_END);
+ l = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ if (l <= 0)
+ {
+ printf("%s: %s: empty file\n", progname, in_name);
+ fclose(fp); fp = NULL;
+ exit(1);
+ }
+ in_len = (lzo_uint) l;
+ out_bufsize = in_len + in_len / 16 + 64 + 3;
+ best_len = in_len;
+
+/*
+ * Step 4: allocate compression buffers and read the file
+ */
+ in = (lzo_bytep) xmalloc(in_len);
+ out = (lzo_bytep) xmalloc(out_bufsize);
+ if (in == NULL || out == NULL)
+ {
+ printf("%s: out of memory\n", progname);
+ exit(1);
+ }
+ in_len = (lzo_uint) lzo_fread(fp, in, in_len);
+ printf("%s: loaded file %s: %ld bytes\n", progname, in_name, (long) in_len);
+ fclose(fp); fp = NULL;
+
+/*
+ * Step 5: compute a checksum of the uncompressed data
+ */
+ uncompressed_checksum = lzo_adler32(0,NULL,0);
+ uncompressed_checksum = lzo_adler32(uncompressed_checksum,in,in_len);
+
+/*
+ * Step 6a: compress from 'in' to 'out' with LZO1X-999
+ */
+#ifdef USE_LZO1X
+ for (lazy = 0; lazy <= max_try_lazy; lazy++)
+ {
+ out_len = out_bufsize;
+ r = lzo1x_999_compress_internal(in,in_len,out,&out_len,wrkmem,
+ NULL, 0, 0,
+ lazy, big, big, big, big, flags);
+ if (r != LZO_E_OK)
+ {
+ /* this should NEVER happen */
+ printf("internal error - compression failed: %d\n", r);
+ exit(1);
+ }
+ printf("LZO1X-999: lazy =%2d: %8lu -> %8lu\n",
+ lazy, (unsigned long) in_len, (unsigned long) out_len);
+ if (out_len < best_len)
+ {
+ best_len = out_len;
+ best_lazy = lazy;
+ best_compress = 1; /* LZO1X-999 */
+ }
+ }
+#endif /* USE_LZO1X */
+
+/*
+ * Step 6b: compress from 'in' to 'out' with LZO1Y-999
+ */
+#ifdef USE_LZO1Y
+ for (lazy = 0; lazy <= max_try_lazy; lazy++)
+ {
+ out_len = out_bufsize;
+ r = lzo1y_999_compress_internal(in,in_len,out,&out_len,wrkmem,
+ NULL, 0, 0,
+ lazy, big, big, big, big, flags);
+ if (r != LZO_E_OK)
+ {
+ /* this should NEVER happen */
+ printf("internal error - compression failed: %d\n", r);
+ exit(1);
+ }
+ printf("LZO1Y-999: lazy =%2d: %8lu -> %8lu\n",
+ lazy, (unsigned long) in_len, (unsigned long) out_len);
+ if (out_len < best_len)
+ {
+ best_len = out_len;
+ best_lazy = lazy;
+ best_compress = 2; /* LZO1Y-999 */
+ }
+ }
+#endif /* USE_LZO1Y */
+
+/*
+ * Step 7: check if compressible
+ */
+ if (best_len >= in_len)
+ {
+ printf("This file contains incompressible data.\n");
+ return 0;
+ }
+
+/*
+ * Step 8: compress data again using the best compressor found
+ */
+ out_len = out_bufsize;
+ if (best_compress == 1)
+ r = lzo1x_999_compress_internal(in,in_len,out,&out_len,wrkmem,
+ NULL, 0, 0,
+ best_lazy, big, big, big, big, flags);
+ else if (best_compress == 2)
+ r = lzo1y_999_compress_internal(in,in_len,out,&out_len,wrkmem,
+ NULL, 0, 0,
+ best_lazy, big, big, big, big, flags);
+ else
+ r = -100;
+ assert(r == LZO_E_OK);
+ assert(out_len == best_len);
+
+/*
+ * Step 9: optimize compressed data (compressed data is in 'out' buffer)
+ */
+#if 1
+ /* Optimization does not require any data in the buffer that will
+ * hold the uncompressed data. To prove this, we clear the buffer.
+ */
+ lzo_memset(in,0,in_len);
+#endif
+
+ orig_len = in_len;
+ r = -100;
+#ifdef USE_LZO1X
+ if (best_compress == 1)
+ r = lzo1x_optimize(out,out_len,in,&orig_len,NULL);
+#endif
+#ifdef USE_LZO1Y
+ if (best_compress == 2)
+ r = lzo1y_optimize(out,out_len,in,&orig_len,NULL);
+#endif
+ if (r != LZO_E_OK || orig_len != in_len)
+ {
+ /* this should NEVER happen */
+ printf("internal error - optimization failed: %d\n", r);
+ exit(1);
+ }
+
+/*
+ * Step 10: compute a checksum of the compressed data
+ */
+ compressed_checksum = lzo_adler32(0,NULL,0);
+ compressed_checksum = lzo_adler32(compressed_checksum,out,out_len);
+
+/*
+ * Step 11: write compressed data to a file
+ */
+ printf("%s: %s: %ld -> %ld, checksum 0x%08lx 0x%08lx\n",
+ progname, in_name, (long) in_len, (long) out_len,
+ (long) uncompressed_checksum, (long) compressed_checksum);
+
+ if (out_name && out_name[0])
+ {
+ printf("%s: writing to file %s\n", progname, out_name);
+ fp = fopen(out_name,"wb");
+ if (fp == NULL)
+ {
+ printf("%s: cannot open output file %s\n", progname, out_name);
+ exit(1);
+ }
+ if (lzo_fwrite(fp, out, out_len) != out_len || fclose(fp) != 0)
+ {
+ printf("%s: write error !!\n", progname);
+ exit(1);
+ }
+ }
+
+/*
+ * Step 12: verify decompression
+ */
+#ifdef PARANOID
+ lzo_memset(in,0,in_len); /* paranoia - clear output buffer */
+ orig_len = in_len;
+ r = -100;
+#ifdef USE_LZO1X
+ if (best_compress == 1)
+ r = lzo1x_decompress_safe(out,out_len,in,&orig_len,NULL);
+#endif
+#ifdef USE_LZO1Y
+ if (best_compress == 2)
+ r = lzo1y_decompress_safe(out,out_len,in,&orig_len,NULL);
+#endif
+ if (r != LZO_E_OK || orig_len != in_len)
+ {
+ /* this should NEVER happen */
+ printf("internal error - decompression failed: %d\n", r);
+ exit(1);
+ }
+ if (uncompressed_checksum != lzo_adler32(lzo_adler32(0,NULL,0),in,in_len))
+ {
+ /* this should NEVER happen */
+ printf("internal error - decompression data error\n");
+ exit(1);
+ }
+ /* Now you could also verify decompression under similar conditions as in
+ * your application, e.g. overlapping assembler decompression etc.
+ */
+#endif
+
+ lzo_free(in);
+ lzo_free(out);
+ lzo_free(wrkmem);
+
+ return 0;
+}
+
+/*
+vi:ts=4:et
+*/
+
diff --git a/app/lzo/examples/simple.c b/app/lzo/examples/simple.c
new file mode 100644
index 00000000..9d06cb5c
--- /dev/null
+++ b/app/lzo/examples/simple.c
@@ -0,0 +1,173 @@
+/* simple.c -- the annotated simple example program for the LZO library
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996 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/
+ */
+
+
+/*************************************************************************
+// This program shows the basic usage of the LZO library.
+// We will compress a block of data and decompress again.
+//
+// See also LZO.FAQ
+**************************************************************************/
+
+/* We will be using the LZO1X-1 algorithm, so we have
+ * to include <lzo1x.h>
+ */
+
+#include "lzo/lzoconf.h"
+#include "lzo/lzo1x.h"
+
+/* portability layer */
+static const char *progname = NULL;
+#define WANT_LZO_MALLOC 1
+#define WANT_XMALLOC 1
+#include "examples/portab.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.
+ */
+
+#ifndef IN_LEN
+#define IN_LEN (128*1024L)
+#endif
+#define OUT_LEN (IN_LEN + IN_LEN / 16 + 64 + 3)
+
+
+/*************************************************************************
+//
+**************************************************************************/
+
+int __lzo_cdecl_main main(int argc, char *argv[])
+{
+ int r;
+ lzo_bytep in;
+ lzo_bytep out;
+ lzo_voidp wrkmem;
+ 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-2011 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 4;
+ }
+
+/*
+ * Step 2: allocate blocks and the work-memory
+ */
+ in = (lzo_bytep) xmalloc(IN_LEN);
+ out = (lzo_bytep) xmalloc(OUT_LEN);
+ wrkmem = (lzo_voidp) xmalloc(LZO1X_1_MEM_COMPRESS);
+ if (in == NULL || out == NULL || wrkmem == NULL)
+ {
+ printf("out of memory\n");
+ return 3;
+ }
+
+/*
+ * Step 3: 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 4: 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 5: decompress again, now going from 'out' to 'in'
+ */
+ new_len = in_len;
+ 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;
+ }
+
+ lzo_free(wrkmem);
+ lzo_free(out);
+ lzo_free(in);
+ printf("Simple compression test passed.\n");
+ return 0;
+}
+
+/*
+vi:ts=4:et
+*/
+