diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-12 15:14:22 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-12 15:14:22 +0900 |
commit | 70b67e7e430bf0ce5dd66850082ecbdf8313ffd7 (patch) | |
tree | 32e329de8dc8ba2395bb962f1695b4702ef11fe7 /src | |
parent | a83fc9cd1e8b00df9de50d6285680a8e19d419f1 (diff) | |
download | lzop-70b67e7e430bf0ce5dd66850082ecbdf8313ffd7.tar.gz lzop-70b67e7e430bf0ce5dd66850082ecbdf8313ffd7.tar.bz2 lzop-70b67e7e430bf0ce5dd66850082ecbdf8313ffd7.zip |
Tizen 2.1 basesubmit/tizen_2.1/20130423.103513submit/tizen/20130517.051505accepted/tizen_2.1/20130423.151516accepted/tizen/20130520.1018192.1b_releasetizen_2.1
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 16 | ||||
-rw-r--r-- | src/Makefile.in | 516 | ||||
-rw-r--r-- | src/c_ansic.c | 90 | ||||
-rw-r--r-- | src/c_ansim.c | 78 | ||||
-rw-r--r-- | src/c_init.c | 169 | ||||
-rw-r--r-- | src/c_none.c | 96 | ||||
-rw-r--r-- | src/c_screen.c | 213 | ||||
-rw-r--r-- | src/compress.c | 398 | ||||
-rw-r--r-- | src/conf.h | 753 | ||||
-rw-r--r-- | src/console.h | 197 | ||||
-rw-r--r-- | src/djgpp2.c | 181 | ||||
-rw-r--r-- | src/filter.c | 167 | ||||
-rw-r--r-- | src/frames.c | 247 | ||||
-rw-r--r-- | src/frames.h | 330 | ||||
-rw-r--r-- | src/help.c | 275 | ||||
-rw-r--r-- | src/lzop.c | 3201 | ||||
-rw-r--r-- | src/mblock.c | 106 | ||||
-rw-r--r-- | src/miniacc.h | 6921 | ||||
-rw-r--r-- | src/p_lzo.c | 595 | ||||
-rw-r--r-- | src/s_curses.c | 412 | ||||
-rw-r--r-- | src/s_djgpp2.c | 378 | ||||
-rw-r--r-- | src/s_object.c | 87 | ||||
-rw-r--r-- | src/s_vcsa.c | 488 | ||||
-rw-r--r-- | src/screen.h | 106 | ||||
-rw-r--r-- | src/util.c | 681 | ||||
-rw-r--r-- | src/version.h | 3 |
26 files changed, 16704 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..051db8d --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,16 @@ +## Process this file with automake to produce Makefile.in +# +# Copyright (C) 1996-2010 Markus F.X.J. Oberhumer +# + +bin_PROGRAMS = lzop + +lzop_SOURCES = \ + lzop.c compress.c filter.c help.c mblock.c p_lzo.c util.c \ + c_init.c c_none.c c_ansim.c c_ansic.c c_screen.c \ + s_object.c s_curses.c s_djgpp2.c s_vcsa.c \ + frames.c djgpp2.c + +EXTRA_DIST = \ + conf.h console.h frames.h miniacc.h screen.h version.h + diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..ebbd843 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,516 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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-2010 Markus F.X.J. Oberhumer +# + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +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@ +bin_PROGRAMS = lzop$(EXEEXT) +subdir = src +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 = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am_lzop_OBJECTS = lzop.$(OBJEXT) compress.$(OBJEXT) filter.$(OBJEXT) \ + help.$(OBJEXT) mblock.$(OBJEXT) p_lzo.$(OBJEXT) util.$(OBJEXT) \ + c_init.$(OBJEXT) c_none.$(OBJEXT) c_ansim.$(OBJEXT) \ + c_ansic.$(OBJEXT) c_screen.$(OBJEXT) s_object.$(OBJEXT) \ + s_curses.$(OBJEXT) s_djgpp2.$(OBJEXT) s_vcsa.$(OBJEXT) \ + frames.$(OBJEXT) djgpp2.$(OBJEXT) +lzop_OBJECTS = $(am_lzop_OBJECTS) +lzop_LDADD = $(LDADD) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(lzop_SOURCES) +DIST_SOURCES = $(lzop_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +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@ +builddir = @builddir@ +configure_CFLAGS = @configure_CFLAGS@ +configure_CPPFLAGS = @configure_CPPFLAGS@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +lzop_SOURCES = \ + lzop.c compress.c filter.c help.c mblock.c p_lzo.c util.c \ + c_init.c c_none.c c_ansim.c c_ansic.c c_screen.c \ + s_object.c s_curses.c s_djgpp2.c s_vcsa.c \ + frames.c djgpp2.c + +EXTRA_DIST = \ + conf.h console.h frames.h miniacc.h screen.h version.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .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 ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/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 +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +lzop$(EXEEXT): $(lzop_OBJECTS) $(lzop_DEPENDENCIES) + @rm -f lzop$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(lzop_OBJECTS) $(lzop_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c_ansic.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c_ansim.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c_none.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c_screen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/djgpp2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frames.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/help.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mblock.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/p_lzo.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s_curses.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s_djgpp2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s_object.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s_vcsa.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@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@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@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) '$<'` + +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; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + 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; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + 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; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__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)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$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: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +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) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_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-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +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 + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS + + +# 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/src/c_ansic.c b/src/c_ansic.c new file mode 100644 index 0000000..9a1a099 --- /dev/null +++ b/src/c_ansic.c @@ -0,0 +1,90 @@ +/* c_ansic.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(USE_ANSI) + +/************************************************************************* +// +**************************************************************************/ + +static int cur_fg = -1; + + +static int init(FILE *f, int o, int now) +{ + UNUSED(f); + UNUSED(now); + if (o == CON_INIT) + return CON_INIT; /* do not use by default */ + if (o < CON_ANSI_COLOR) + return CON_INIT; /* do not use by default */ + return CON_ANSI_COLOR; +} + + +static int set_fg(FILE *f, int fg) +{ + int last_fg = cur_fg; + + if (fg < 0) + fputs("\033[0m",f); + else + { + /* try to map colors */ + static const unsigned char ansi_fg[16] = + /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 */ + { 0, 1, 2, 6, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 11, 15 }; + int e = ansi_fg[fg & 0xf]; + if (e < 8) + fprintf(f, "\033[0;%dm", 30 + (e & 7)); + else + fprintf(f, "\033[0;1;%dm", 30 + (e & 7)); + } + + cur_fg = fg; + return last_fg; +} + + +console_t console_ansi_color = +{ + init, + set_fg, + 0, + 0 +}; + +#endif /* USE_ANSI */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/c_ansim.c b/src/c_ansim.c new file mode 100644 index 0000000..bec1409 --- /dev/null +++ b/src/c_ansim.c @@ -0,0 +1,78 @@ +/* c_ansim.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(USE_ANSI) + +/************************************************************************* +// +**************************************************************************/ + +static int cur_fg = -1; + + +static int init(FILE *f, int o, int now) +{ + UNUSED(f); + UNUSED(o); + UNUSED(now); + return CON_ANSI_MONO; +} + + +static int set_fg(FILE *f, int fg) +{ + int last_fg = cur_fg; + + if (fg < 0) + fputs("\033[0m",f); + else + /* just treat any color as intense */ + fputs("\033[0;1m",f); + + cur_fg = fg; + return last_fg; +} + + +console_t console_ansi_mono = +{ + init, + set_fg, + 0, + 0 +}; + +#endif /* USE_ANSI */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/c_init.c b/src/c_init.c new file mode 100644 index 0000000..510d20e --- /dev/null +++ b/src/c_init.c @@ -0,0 +1,169 @@ +/* c_init.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(USE_CONSOLE) + +/************************************************************************* +// +**************************************************************************/ + +static console_t * const me = &console_init; +console_t * con = &console_init; + +int con_mode = CON_INIT; + + +static void try_init(console_t *c, FILE *f) +{ + int k; + + assert(c); + assert(c->init); + k = c->init(f,opt_console,con_mode); + if (k == CON_INIT) + return; +#if 0 + if (con_mode != CON_INIT && opt_console != CON_INIT) + if (k != opt_console) + return; +#endif + if (k > con_mode) + { + con_mode = k; + con = c; + con->init = 0; + if (!con->set_fg) + con->set_fg = console_none.set_fg; + if (!con->print0) + con->print0 = console_none.print0; + if (!con->intro) + con->intro = console_none.intro; + } +} + + +static int do_init(FILE *f) +{ + assert(con_mode == CON_INIT); + + try_init(&console_none,f); + assert(con != me); + assert(con == &console_none); + assert(con_mode == CON_NONE); + if (opt_console == CON_NONE) + return con_mode; + if (!acc_isatty(STDIN_FILENO) || !acc_isatty(STDOUT_FILENO) || !acc_isatty(STDERR_FILENO)) + return con_mode; + +#if defined(USE_ANSI) + try_init(&console_ansi_mono,f); + try_init(&console_ansi_color,f); +#endif +#if defined(USE_SCREEN) + try_init(&console_screen,f); +#endif +#if defined(USE_AALIB) + try_init(&console_aalib,f); +#endif + + return con_mode; +} + + +/************************************************************************* +// +**************************************************************************/ + +static int init(FILE *f, int o, int now) +{ + if (con != me) + return con_mode; + assert(o == -1); + assert(now == -1); + UNUSED(o); + UNUSED(now); + return do_init(f); +} + + +static int set_fg(FILE *f, int fg) +{ + if (con == me) + init(f,-1,-1); + assert(con != me); + return con->set_fg(f,fg); +} + + +static lzo_bool intro(FILE *f) +{ + if (con == me) + init(f,-1,-1); + assert(con != me); + return con->intro(f); +} + + +console_t console_init = +{ + init, + set_fg, + 0, + intro +}; + + +void con_fprintf(FILE *f, const char *format, ...) +{ + va_list args; + char s[80*25]; + + va_start(args,format); +#if defined(HAVE_VSNPRINTF) + vsnprintf(s,sizeof(s),format,args); +#else + vsprintf(s,format,args); +#endif + s[sizeof(s)-1] = 0; + va_end(args); + + if (con == me) + init(f,-1,-1); + assert(con != me); + con->print0(f,s); +} + +#endif /* USE_CONSOLE */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/c_none.c b/src/c_none.c new file mode 100644 index 0000000..6a19f2c --- /dev/null +++ b/src/c_none.c @@ -0,0 +1,96 @@ +/* c_none.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(USE_CONSOLE) + +/************************************************************************* +// +**************************************************************************/ + +static int init(FILE *f, int o, int now) +{ + UNUSED(f); + UNUSED(o); + UNUSED(now); + return CON_NONE; +} + + +static int set_fg(FILE *f, int fg) +{ + UNUSED(f); + UNUSED(fg); + return -1; +} + + +static void print0(FILE *f, const char *s) +{ +#if 1 + fputs(s,f); +#else + /* filter out all ANSI sequences */ + int c; + while ((c = *s++) != 0) + { + if (c == '\033' && *s == ']') + { + while (*s && *s != 'm') + s++; + } + else + fputc(c,f); + } +#endif +} + + +static lzo_bool intro(FILE *f) +{ + UNUSED(f); + return 0; +} + + +console_t console_none = +{ + init, + set_fg, + print0, + intro +}; + +#endif /* USE_CONSOLE */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/c_screen.c b/src/c_screen.c new file mode 100644 index 0000000..483531e --- /dev/null +++ b/src/c_screen.c @@ -0,0 +1,213 @@ +/* c_screen.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(USE_SCREEN) + +#include "screen.h" + +#define mask_fg 0x0f +#define mask_bg 0xf0 + + +/************************************************************************* +// +**************************************************************************/ + +static screen_t *do_construct(screen_t *s, int fd) +{ + if (!s) + return NULL; + if (s->init(s,fd) != 0) + { + s->destroy(s); + return NULL; + } + return s; +} + + +static screen_t *screen = NULL; + +static void do_destroy(void) +{ + if (screen) + { + screen->destroy(screen); + screen = NULL; + } +} + + +static int mode = -1; +static int init_fg = -1; +static int init_bg = -1; +static int cur_fg = -1; +static int cur_bg = -1; + + +static int init(FILE *f, int o, int now) +{ + int fd = fileno(f); + + UNUSED(now); + assert(screen == NULL); + atexit(do_destroy); +#if defined(__DJGPP__) + if (!screen) + screen = do_construct(screen_djgpp2_construct(),fd); +#endif +#if defined(USE_SCREEN_VCSA) + if (!screen) + screen = do_construct(screen_vcsa_construct(),fd); +#endif +#if defined(USE_SCREEN_CURSES) + if (!screen && o == CON_SCREEN) + screen = do_construct(screen_curses_construct(),fd); +#endif + if (!screen) + return CON_INIT; + mode = screen->getMode(screen); + init_fg = cur_fg = screen->getFg(screen); + init_bg = cur_bg = screen->getBg(screen); + if (mode == 7) + cur_fg = -1; + if (screen->getCols(screen) < 80 || screen->getRows(screen) < 24) + return CON_INIT; + if (cur_fg == (cur_bg >> 4)) + return CON_INIT; + if (cur_bg != BG_BLACK) + if (mode != 7) + { + /* return CON_ANSI_MONO; */ /* we could emulate ANSI mono */ + return CON_INIT; + } + + if (o == CON_SCREEN) + return CON_SCREEN; + if (o == CON_INIT) /* use by default */ + return CON_SCREEN; + if (o == CON_ANSI_COLOR) /* can emulate ANSI color */ + return CON_ANSI_COLOR; + if (o == CON_ANSI_MONO) /* can emulate ANSI mono */ + return CON_ANSI_MONO; + + return CON_INIT; +} + + +static int set_fg(FILE *f, int fg) +{ + const int last_fg = cur_fg; + int f1 = fg & mask_fg; + int f2 = init_fg & mask_fg; + + UNUSED(f); + cur_fg = fg; + if (mode == 7) + { + const int b = (init_bg & mask_bg) >> 4; + if (fg == -1) /* restore startup fg */ + f1 = f2; + else if (b == 0) + f1 = (f2 <= 8) ? 15 : 8; + else if (b <= 8) + f1 = (f2 == 0) ? 15 : 0; + else + f1 = (f2 == 0) ? 8 : 0; + } + else if (con_mode == CON_ANSI_MONO && f1 != f2) + { + f1 = f2 ^ 0x08; + } + + screen->setFg(screen,f1 & mask_fg); + return last_fg; +} + + +static void print0(FILE *f, const char *s) +{ + int c_cx, c_cy; + + UNUSED(f); + screen->getCursor(screen,&c_cx,&c_cy); + while (*s) + { + while (*s == '\n') + { + s++; + c_cy++; + c_cx = 0; + } + if (c_cy >= screen->getRows(screen)) + { + c_cy -= screen->scrollUp(screen,c_cy-screen->getRows(screen)+1); + if (c_cy < 0) + c_cy = 0; + c_cx = 0; + } + if (*s) + { + screen->putChar(screen,*s,c_cx,c_cy); + s++; + c_cx++; + } + } + screen->setCursor(screen,c_cx,c_cy); + screen->refresh(screen); +} + + +static lzo_bool intro(FILE *f) +{ + UNUSED(f); +#if defined(USE_FRAMES) + if (screen->intro) + return screen->intro(screen,screen_show_frames); +#endif + return 0; +} + + +console_t console_screen = +{ + init, + set_fg, + print0, + intro +}; + +#endif /* USE_SCREEN */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/compress.c b/src/compress.c new file mode 100644 index 0000000..eaa9407 --- /dev/null +++ b/src/compress.c @@ -0,0 +1,398 @@ +/* compress.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + + +/************************************************************************* +// +**************************************************************************/ + +int x_set_method(int m, int l) +{ + int r = -1; + +#if defined(WITH_LZO) + r = lzo_set_method(m,l); + if (r >= 0) + return r; +#endif +#if defined(WITH_NRV) + r = nrv_set_method(m,l); + if (r >= 0) + return r; +#endif +#if defined(WITH_ZLIB) + r = zlib_set_method(m,l); + if (r >= 0) + return r; +#endif + + UNUSED(r); + return -1; +} + + +int x_get_method(header_t *h) +{ + int r = -1; + +#if defined(WITH_LZO) + r = lzo_get_method(h); + if (r >= 0) + return r; +#endif +#if defined(WITH_NRV) + r = nrv_get_method(h); + if (r >= 0) + return r; +#endif +#if defined(WITH_ZLIB) + r = zlib_get_method(h); + if (r >= 0) + return 0; +#endif + + UNUSED(r); + return 14; +} + + +/************************************************************************* +// memory setup +**************************************************************************/ + +lzo_bool x_enter(const header_t *h) +{ + if (h == NULL) + { + lzo_bool ok = 1; +#if defined(WITH_LZO) + ok &= lzo_enter(NULL); +#endif +#if defined(WITH_NRV) + ok &= nrv_enter(NULL); +#endif +#if defined(WITH_ZLIB) + ok &= zlib_enter(NULL); +#endif + return ok; + } + + switch (h->method) + { +#if defined(WITH_LZO) + case M_LZO1X_1: + case M_LZO1X_1_15: + case M_LZO1X_999: + return lzo_enter(h); +#endif +#if defined(WITH_NRV) + case M_NRV1A: + case M_NRV1B: + case M_NRV2A: + case M_NRV2B: + return nrv_enter(h); +#endif +#if defined(WITH_ZLIB) + case M_ZLIB: + return zlib_enter(h); +#endif + } + return 0; +} + + +void x_leave(const header_t *h) +{ + if (h == NULL) + { +#if defined(WITH_ZLIB) + zlib_leave(NULL); +#endif +#if defined(WITH_NRV) + nrv_leave(NULL); +#endif +#if defined(WITH_LZO) + lzo_leave(NULL); +#endif + return; + } + + switch (h->method) + { +#if defined(WITH_LZO) + case M_LZO1X_1: + case M_LZO1X_1_15: + case M_LZO1X_999: + lzo_leave(h); + break; +#endif +#if defined(WITH_NRV) + case M_NRV1A: + case M_NRV1B: + case M_NRV2A: + case M_NRV2B: + nrv_leave(h); + break; +#endif +#if defined(WITH_ZLIB) + case M_ZLIB: + zlib_leave(h); + break; +#endif + } +} + + +/************************************************************************* +// compress a file +**************************************************************************/ + +lzo_bool x_compress(file_t *fip, file_t *fop, header_t *h) +{ + lzo_bool ok = 0; + + init_compress_header(h,fip,fop); + switch (h->method) + { +#if defined(WITH_LZO) + case M_LZO1X_1: + case M_LZO1X_1_15: + case M_LZO1X_999: + lzo_init_compress_header(h); + break; +#endif +#if defined(WITH_NRV) + case M_NRV1A: + case M_NRV1B: + case M_NRV2A: + case M_NRV2B: + nrv_init_compress_header(h); + break; +#endif +#if defined(WITH_ZLIB) + case M_ZLIB: + zlib_init_compress_header(h); + break; +#endif + default: + fatal(fip,"Internal error"); + break; + } + + if (!x_enter(h)) + e_memory(); + + if (opt_verbose > 1) + { + if (opt_unlink) + fprintf(con_term,"replacing %s with %s", fip->name, fop->name); + else + fprintf(con_term,"compressing %s into %s", fip->name, fop->name); + fflush(con_term); + set_err_nl(1); + } + + write_header(fop,h); + + fip->bytes_processed = fop->bytes_processed = 0; + + switch (h->method) + { +#if defined(WITH_LZO) + case M_LZO1X_1: + case M_LZO1X_1_15: + case M_LZO1X_999: + ok = lzo_compress(fip,fop,h); + break; +#endif +#if defined(WITH_NRV) + case M_NRV1A: + case M_NRV1B: + case M_NRV2A: + case M_NRV2B: + ok = nrv_compress(fip,fop,h); + break; +#endif +#if defined(WITH_ZLIB) + case M_ZLIB: + ok = zlib_compress(fip,fop,h); + break; +#endif + default: + fatal(fip,"Internal error"); + ok = 0; + break; + } + + if (opt_cmd == CMD_COMPRESS && opt_verbose > 1) + { + fprintf(con_term, ok ? "\n" : " FAILED\n"); + fflush(con_term); + } + set_err_nl(0); + + x_leave(h); + return ok; +} + + +/************************************************************************* +// decompress a file +**************************************************************************/ + +lzo_bool x_decompress(file_t *fip, file_t *fop, + const header_t *h, lzo_bool skip) +{ + lzo_bool ok = 0; + + if (!x_enter(h)) + e_memory(); + + if (skip) + { + assert(opt_cmd != CMD_TEST); + assert(fop->fd < 0); + if (opt_cmd == CMD_DECOMPRESS && opt_verbose > 0) + fprintf(con_term,"skipping %s [%s]", fip->name, fop->name); + fflush(con_term); + set_err_nl(1); + } + else if (opt_cmd == CMD_DECOMPRESS && opt_verbose > 1) + { + if (opt_unlink) + fprintf(con_term,"restoring %s into %s", fip->name, fop->name); + else + fprintf(con_term,"decompressing %s into %s", fip->name, fop->name); + fflush(con_term); + set_err_nl(1); + } + else if (opt_cmd == CMD_TEST && opt_verbose > 0) + { + /* note: gzip is quiet by default when testing, lzop is not */ + if (opt_verbose > 2) + fprintf(con_term,"testing %s [%s]", fip->name, fop->name); + else + fprintf(con_term,"testing %s", fip->name); + fflush(con_term); + set_err_nl(1); + } + + fip->bytes_processed = fop->bytes_processed = 0; + + switch (h->method) + { +#if defined(WITH_LZO) + case M_LZO1X_1: + case M_LZO1X_1_15: + case M_LZO1X_999: + ok = lzo_decompress(fip,fop,h,skip); + break; +#endif +#if defined(WITH_NRV) + case M_NRV1A: + case M_NRV1B: + case M_NRV2A: + case M_NRV2B: + ok = nrv_decompress(fip,fop,h,skip); + break; +#endif +#if defined(WITH_ZLIB) + case M_ZLIB: + ok = zlib_decompress(fip,fop,h,skip); + break; +#endif + default: + fatal(fip,"Internal error"); + ok = 0; + break; + } + + if (skip && opt_cmd == CMD_DECOMPRESS && opt_verbose > 0) + { + fprintf(con_term, ok ? "\n" : " FAILED\n"); + fflush(con_term); + } + else if (opt_cmd == CMD_DECOMPRESS && opt_verbose > 1) + { + fprintf(con_term, ok ? "\n" : " FAILED\n"); + fflush(con_term); + } + else if (opt_cmd == CMD_TEST && opt_verbose > 0) + { + fprintf(con_term, ok ? " OK\n" : " FAILED\n"); + fflush(con_term); + } + set_err_nl(0); + + if (ok && opt_cmd == CMD_TEST) + do_test(h,fop->bytes_processed,fip->bytes_processed); + if (ok && opt_cmd == CMD_LIST) + do_list(h,fop->bytes_processed,fip->bytes_processed); + if (ok && opt_cmd == CMD_LS) + do_ls(h,fop->bytes_processed,fip->bytes_processed); + if (ok && opt_cmd == CMD_INFO) + do_info(h,fop->bytes_processed,fip->bytes_processed); + + x_leave(h); + return ok; +} + + +/************************************************************************* +// +**************************************************************************/ + +void x_filter(lzo_bytep p, lzo_uint l, const header_t *h) +{ + unsigned f = (unsigned) h->filter; + lzo_bool c = (opt_cmd == CMD_COMPRESS); + + if (f == 0 || l <= 0) + return; + if (f == 1) + { + if (c) t_sub1(p,l); else t_add1(p,l); + } + else if (f <= 16) + { + if (c) t_sub(p,l,f); else t_add(p,l,f); + } + else + { + fatal(NULL,"Invalid filter"); + } +} + + + +/* +vi:ts=4:et +*/ + diff --git a/src/conf.h b/src/conf.h new file mode 100644 index 0000000..6c7e36e --- /dev/null +++ b/src/conf.h @@ -0,0 +1,753 @@ +/* conf.h -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#ifndef __LZOP_CONF_H +#define __LZOP_CONF_H 1 + +#if defined(LZOP_HAVE_CONFIG_H) +# include <config.h> +#endif +#if !defined(PACKAGE) +# define PACKAGE "lzop" +#endif + +#define WITH_LZO 1 +#if defined(WITH_LZO) +#if defined(HAVE_LZO_LZOCONF_H) && defined(HAVE_LZO_LZO1X_H) +# include <lzo/lzoconf.h> +# include <lzo/lzo1x.h> +#elif defined(HAVE_LZOCONF_H) && defined(HAVE_LZO1X_H) +# include <lzoconf.h> +# include <lzo1x.h> +#elif !defined(LZOP_HAVE_CONFIG_H) +# include <lzo/lzoconf.h> +# include <lzo/lzo1x.h> +#else +# include <lzoconf.h> +# include <lzo1x.h> +#endif +#if !defined(LZO_VERSION) +# error "you need the LZO library" +#elif (LZO_VERSION < 0x1040) +# error "please upgrade your LZO package" +#endif +#endif + + +/************************************************************************* +// +**************************************************************************/ + +#if defined(LZOP_HAVE_CONFIG_H) +# define ACC_CONFIG_NO_HEADER 1 +#endif +#define ACC_WANT_ACC_INCD_H 1 +#define ACC_WANT_ACC_INCE_H 1 +#define ACC_WANT_ACC_LIB_H 1 +#include "miniacc.h" +#undef ACC_WANT_ACC_INCD_H +#undef ACC_WANT_ACC_INCE_H +#undef ACC_WANT_ACC_LIB_H + +/* we _always_ compile lzop with assertions on */ +#undef NDEBUG +#include <assert.h> + +#if defined(acc_int64l_t) +# define lzop_long_t acc_int64l_t +# define lzop_ulong_t acc_uint64l_t +#else +# define lzop_long_t long int +# define lzop_ulong_t unsigned long int +#endif + +#if (ACC_CC_MSC && (_MSC_VER >= 1400)) + /* avoid warnings when using "deprecated" POSIX functions */ +# pragma warning(disable: 4996) +#endif + + +/************************************************************************* +// +**************************************************************************/ + +#if defined(ACC_OS_EMX) +# define DOSISH 1 +# define F_OS (_osmode == 0 ? F_OS_FAT : F_OS_OS2) +# define F_CS (_osmode == 0 ? F_CS_DOS : F_CS_NATIVE) +#elif (ACC_OS_DOS16 || ACC_OS_DOS32) +# define DOSISH 1 +# define F_OS F_OS_FAT +# define F_CS F_CS_DOS +#elif (ACC_OS_OS216 || ACC_OS_OS2) +# define DOSISH 1 +# define F_OS F_OS_OS2 +#elif (ACC_OS_TOS) +# define DOSISH 1 +# define F_OS F_OS_ATARI +#elif (ACC_OS_WIN16) +# define DOSISH 1 +# define F_OS F_OS_FAT +# define F_CS F_CS_WIN16 +#elif (ACC_OS_WIN32 || ACC_OS_WIN64 || ACC_OS_CYGWIN) +# define DOSISH 1 +# define F_OS F_OS_VFAT +# define F_CS F_CS_WIN32 +#endif + + +#if defined(DOSISH) +# define OPT_NAME_DEFAULT 1 +# if !defined(DIR_SEP) +# define DIR_SEP "/\\" +# endif +# if !defined(fn_tolower) +# define fn_tolower(x) tolower(((unsigned char)(x))) +# endif +#endif + +#if defined(__BORLANDC__) +# define SIGTYPEENTRY __cdecl +# define MODE_T unsigned short +#elif defined(__DMC__) +# define SIGTYPEENTRY __cdecl +#elif defined(_MSC_VER) +# define SIGTYPEENTRY __cdecl +# define MODE_T unsigned short +#elif defined(__WATCOMC__) +# define MODE_T unsigned short +#endif + + +/************************************************************************* +// +**************************************************************************/ + +#ifndef F_OS +# define F_OS F_OS_UNIX +#endif +#ifndef F_CS +# define F_CS F_CS_NATIVE +#endif + +#ifndef DIR_SEP +# define DIR_SEP "/" +#endif + +#ifndef fn_tolower +# define fn_tolower(x) (x) +#endif + +#ifndef OPTIONS_VAR +# define OPTIONS_VAR "LZOP" +#endif + + +/************************************************************************* +// +**************************************************************************/ + +#if defined(__DJGPP__) +# define NO_SETMODE 1 +# if ((__DJGPP__ * 100 + __DJGPP_MINOR__) < 203) +# error "need djgpp 2.03 or above" +# endif +# include <crt0.h> +# include <dpmi.h> +# include <sys/exceptn.h> +# undef kbhit /* want to be able to call kbhit from libc */ +#endif + +#if defined(ACC_OS_TOS) +# if defined(__MINT__) +# elif (ACC_CC_PUREC || ACC_CC_TURBOC) +# include <ext.h> +# define O_EXCL_BROKEN 1 +# if !defined(S_IFMT) +# if defined(S_IFREG) && defined(S_IFDIR) && defined(S_IFCHR) +# define S_IFMT (S_IFREG | S_IFDIR | S_IFCHR) +# endif +# endif +# else +# error "FIXME" +# endif +#endif + +#define ADLER32_INIT_VALUE 1 +#define CRC32_INIT_VALUE 0 + + +/************************************************************************* +// +**************************************************************************/ + +#if !defined(PATH_MAX) +# define PATH_MAX 512 +#elif (PATH_MAX < 512) +# undef PATH_MAX +# define PATH_MAX 512 +#endif + + +#ifndef RETSIGTYPE +# define RETSIGTYPE void +#endif +#ifndef SIGTYPEENTRY +# define SIGTYPEENTRY /*empty*/ +#endif + +#if !defined(MODE_T) +#if defined(SIZEOF_MODE_T) && (SIZEOF_MODE_T > 0) +# define MODE_T mode_t +#else +# define MODE_T int +#endif +#endif + + +#if defined(NO_MEMCMP) +# undef HAVE_MEMCMP +#endif +#if !defined(HAVE_MEMCMP) +# undef memcmp +# define memcmp lzo_memcmp +#endif +#if !defined(HAVE_MEMCPY) +# undef memcpy +# define memcpy lzo_memcpy +#endif +#if !defined(HAVE_MEMSET) +# undef memset +# define memset lzo_memset +#endif + + +#if !defined(HAVE_STRCASECMP) && defined(HAVE_STRICMP) +# define strcasecmp stricmp +#endif +#if !defined(HAVE_STRNCASECMP) && defined(HAVE_STRNICMP) +# define strncasecmp strnicmp +#endif + + +#ifndef STDIN_FILENO +# define STDIN_FILENO (fileno(stdin)) +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO (fileno(stdout)) +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO (fileno(stderr)) +#endif + +#if !defined(S_IFMT) && defined(_S_IFMT) +# define S_IFMT _S_IFMT +#endif +#if !defined(S_IFREG) && defined(_S_IFREG) +# define S_IFREG _S_IFREG +#endif +#if !defined(S_IFDIR) && defined(_S_IFDIR) +# define S_IFDIR _S_IFDIR +#endif +#if !defined(S_IFCHR) && defined(_S_IFCHR) +# define S_IFCHR _S_IFCHR +#endif + +#if !defined(S_ISREG) +# if defined(S_IFMT) && defined(S_IFREG) +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +# else +# error "S_ISREG" +# endif +#endif +#if !defined(S_ISDIR) +# if defined(S_IFMT) && defined(S_IFDIR) +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +# else +# error "S_ISDIR" +# endif +#endif +#if !defined(S_ISCHR) +# if defined(S_IFMT) && defined(S_IFCHR) +# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +# endif +#endif + + +/************************************************************************* +// +**************************************************************************/ + +#ifndef SUFFIX_MAX +#define SUFFIX_MAX 32 +#endif + +#define STDIN_NAME "<stdin>" +#define STDOUT_NAME "<stdout>" +#define STDERR_NAME "<stderr>" +#define UNKNOWN_NAME "<unknown>" + + +#define ALIGN_DOWN(a,b) (((a) / (b)) * (b)) +#define ALIGN_UP(a,b) ALIGN_DOWN((a) + ((b) - 1), b) + +#undef UNUSED +#define UNUSED(var) ACC_UNUSED(var) + + +/************************************************************************* +// +**************************************************************************/ + +/* exit codes of this program: 0 ok, 1 error, 2 warning */ +#define EXIT_OK 0 +#define EXIT_ERROR 1 +#define EXIT_WARN 2 + +#define EXIT_USAGE 1 +#define EXIT_FILE_READ 1 +#define EXIT_FILE_WRITE 1 +#define EXIT_MEMORY 1 +#define EXIT_CHECKSUM 1 +#define EXIT_LZO_ERROR 1 +#define EXIT_LZO_INIT 1 +#define EXIT_INTERNAL 1 + + +/************************************************************************* +// options +**************************************************************************/ + +enum { + CMD_NONE, + CMD_COMPRESS, + CMD_DECOMPRESS, CMD_TEST, CMD_LIST, CMD_LS, CMD_INFO, + CMD_SYSINFO, CMD_LICENSE, CMD_HELP, CMD_INTRO, CMD_VERSION +}; + + +enum { + M_LZO1X_1 = 1, + M_LZO1X_1_15 = 2, + M_LZO1X_999 = 3, + M_NRV1A = 0x1a, + M_NRV1B = 0x1b, + M_NRV2A = 0x2a, + M_NRV2B = 0x2b, + M_NRV2D = 0x2d, + M_ZLIB = 128, + + M_UNUSED +}; + +extern int opt_cmd; +extern int opt_method; +extern int opt_level; + +extern int opt_checksum; +extern int opt_console; +extern int opt_crc32; +extern lzo_bool opt_decompress_safe; +extern int opt_force; +extern int opt_name; +#define MAX_NUM_THREADS 64 +extern int opt_num_threads; +extern const char *opt_output_name; +extern lzo_bool opt_optimize; +extern lzo_bool opt_path; +extern lzo_bool opt_shortname; +extern int opt_stdin; +extern lzo_bool opt_stdout; +extern char opt_suffix[1+SUFFIX_MAX+1]; +extern lzo_bool opt_unlink; +extern int opt_verbose; + +#define OPT_STDIN_GUESSED 1 +#define OPT_STDIN_REQUESTED 2 + + +/************************************************************************* +// input and output files +**************************************************************************/ + +typedef struct +{ + int fd; +#if defined(USE_FOPEN) + FILE *file; +#endif + int open_flags; + struct stat st; +#if defined(HAVE_LSTAT) + struct stat lst; +#endif + lzo_uint32 f_adler32; + lzo_uint32 f_crc32; + + int opt_name; + unsigned long part; + lzop_ulong_t bytes_read; + lzop_ulong_t bytes_written; + lzo_bool warn_multipart; + lzo_bool warn_unknown_suffix; + + lzop_ulong_t bytes_processed; + +#define FILE_T_NAME_LEN ( 2*((PATH_MAX)+1) + SUFFIX_MAX + 1 ) + char name[ FILE_T_NAME_LEN ]; +} +file_t; + + +/************************************************************************* +// lzop file header +**************************************************************************/ + +/* header flags */ +#define F_ADLER32_D 0x00000001L +#define F_ADLER32_C 0x00000002L +#define F_STDIN 0x00000004L +#define F_STDOUT 0x00000008L +#define F_NAME_DEFAULT 0x00000010L +#define F_DOSISH 0x00000020L +#define F_H_EXTRA_FIELD 0x00000040L +#define F_H_GMTDIFF 0x00000080L +#define F_CRC32_D 0x00000100L +#define F_CRC32_C 0x00000200L +#define F_MULTIPART 0x00000400L +#define F_H_FILTER 0x00000800L +#define F_H_CRC32 0x00001000L +#define F_H_PATH 0x00002000L +#define F_MASK 0x00003FFFL + +/* operating system & file system that created the file [mostly unused] */ +#define F_OS_FAT 0x00000000L /* DOS, OS2, Win95 */ +#define F_OS_AMIGA 0x01000000L +#define F_OS_VMS 0x02000000L +#define F_OS_UNIX 0x03000000L +#define F_OS_VM_CMS 0x04000000L +#define F_OS_ATARI 0x05000000L +#define F_OS_OS2 0x06000000L /* OS2 */ +#define F_OS_MAC9 0x07000000L +#define F_OS_Z_SYSTEM 0x08000000L +#define F_OS_CPM 0x09000000L +#define F_OS_TOPS20 0x0a000000L +#define F_OS_NTFS 0x0b000000L /* Win NT/2000/XP */ +#define F_OS_QDOS 0x0c000000L +#define F_OS_ACORN 0x0d000000L +#define F_OS_VFAT 0x0e000000L /* Win32 */ +#define F_OS_MFS 0x0f000000L +#define F_OS_BEOS 0x10000000L +#define F_OS_TANDEM 0x11000000L +#define F_OS_SHIFT 24 +#define F_OS_MASK 0xff000000L + +/* character set for file name encoding [mostly unused] */ +#define F_CS_NATIVE 0x00000000L +#define F_CS_LATIN1 0x00100000L +#define F_CS_DOS 0x00200000L +#define F_CS_WIN32 0x00300000L +#define F_CS_WIN16 0x00400000L +#define F_CS_UTF8 0x00500000L /* filename is UTF-8 encoded */ +#define F_CS_SHIFT 20 +#define F_CS_MASK 0x00f00000L + +/* these bits must be zero */ +#define F_RESERVED ((F_MASK | F_OS_MASK | F_CS_MASK) ^ 0xffffffffL) + +typedef struct +{ + unsigned version; + unsigned lib_version; + unsigned version_needed_to_extract; + unsigned char method; + unsigned char level; + lzo_uint32 flags; + lzo_uint32 filter; + lzo_uint32 mode; + lzo_uint32 mtime_low; + lzo_uint32 mtime_high; + lzo_uint32 header_checksum; + + lzo_uint32 extra_field_len; + lzo_uint32 extra_field_checksum; + +/* info */ + const char *method_name; + + char name[255+1]; +} +header_t; + + +/************************************************************************* +// lzop.c +**************************************************************************/ + +void set_err_nl(lzo_bool x); +void warn(file_t *ft, const char *m); +void error(file_t *ft, const char *m); +void fatal(file_t *ft, const char *m); +void read_error(file_t *ft); +void write_error(file_t *ft); +void e_memory(void); + +lzo_int read_buf(file_t *ft, lzo_voidp buffer, lzo_int cnt); +void write_buf(file_t *ft, const lzo_voidp buffer, lzo_int cnt); +void read32(file_t *ft, lzo_uint32 *v); +void write32(file_t *ft, lzo_uint32 v); + +void init_compress_header(header_t *h, const file_t *fip, const file_t *fop); +void write_header(file_t *ft, const header_t *h); + +void do_test(const header_t *h, lzop_ulong_t d_len, lzop_ulong_t c_len); +void do_test_total(void); +void do_info(const header_t *h, lzop_ulong_t d_len, lzop_ulong_t c_len); +void do_ls(const header_t *h, lzop_ulong_t d_len, lzop_ulong_t c_len); +void do_list(const header_t *h, lzop_ulong_t d_len, lzop_ulong_t c_len); +void do_list_total(void); + + +/************************************************************************* +// compress.c +**************************************************************************/ + +lzo_bool x_enter(const header_t *h); +void x_leave(const header_t *h); + +lzo_bool x_compress(file_t *fip, file_t *fop, header_t *h); +lzo_bool x_decompress(file_t *fip, file_t *fop, const header_t *h, lzo_bool skip); + +int x_get_method(header_t *h); +int x_set_method(int m, int l); + +void x_filter(lzo_bytep p, lzo_uint l, const header_t *h); + + +/************************************************************************* +// p_lzo.c +**************************************************************************/ + +#if defined(WITH_LZO) + +lzo_bool lzo_enter(const header_t *h); +void lzo_leave(const header_t *h); + +lzo_bool lzo_compress(file_t *fip, file_t *fop, const header_t *h); +lzo_bool lzo_decompress(file_t *fip, file_t *fop, const header_t *h, lzo_bool skip); + +int lzo_get_method(header_t *h); +int lzo_set_method(int m, int l); +void lzo_init_compress_header(header_t *h); + +#endif + + +/************************************************************************* +// p_lzo_mt.c +**************************************************************************/ + +#if defined(WITH_LZO) && defined(WITH_THREADS) + +lzo_bool lzo_threaded_enter(const header_t *h); +void lzo_threaded_leave(const header_t *h); + +lzo_bool lzo_threaded_compress(file_t *fip, file_t *fop, const header_t *h); +lzo_bool lzo_threaded_decompress(file_t *fip, file_t *fop, const header_t *h, lzo_bool skip); + +#endif + + +/************************************************************************* +// filter.c +**************************************************************************/ + +void t_sub1(lzo_bytep p, lzo_uint l); +void t_add1(lzo_bytep p, lzo_uint l); + +void t_sub(lzo_bytep p, lzo_uint l, int n); +void t_add(lzo_bytep p, lzo_uint l, int n); + +void t_mtf(lzo_bytep p, lzo_uint l); +void t_unmtf(lzo_bytep p, lzo_uint l); + + +/************************************************************************* +// mblock.c +**************************************************************************/ + +typedef struct +{ + /* public */ + lzo_bytep mb_mem; + lzo_uint32 mb_size; + /* private */ + lzo_bytep mb_mem_alloc; + lzo_uint32 mb_size_alloc; + lzo_uint32 mb_align; + /* the following fields are not yet used but may prove useful for + * adding new algorithms */ + lzo_uint32 mb_flags; + lzo_uint32 mb_id; + lzo_uint32 mb_len; + lzo_uint32 mb_adler32; + lzo_uint32 mb_crc32; +} +mblock_t; +#define mblock_p mblock_t * + +lzo_bool mb_alloc(mblock_p m, lzo_uint32 size, lzo_uint align); +void mb_free(mblock_p m); + +lzo_bool mb_init(mblock_p m, lzo_uint32 size, lzo_uint align, + lzo_voidp heap, lzo_uint32 heap_size); + + +/************************************************************************* +// util.c +**************************************************************************/ + +enum { + SUFF_NONE, + SUFF_LZO, + SUFF_LZOP, + SUFF_NRV, + SUFF_TAR, + SUFF_TNV, + SUFF_TZO, + SUFF_USER +}; + +unsigned fn_baseindex(const char *name); +const char *fn_basename(const char *name); +void fn_addslash(char *n, lzo_bool slash); +char *fn_strlwr(char *n); +int fn_strcmp(const char *n1, const char *n2); +lzo_bool fn_is_same_file(const char *n1, const char *n2); +int fn_has_suffix(const char *name); +int fn_cleanpath(const char *name, char *newname, size_t size, int flags); + +time_t fix_time(time_t t); +time_t get_mtime(const header_t *h); +#if defined(HAVE_LOCALTIME) +void tm2str(char *s, size_t size, const struct tm *tmp); +#endif +void time2str(char *s, size_t size, const time_t *t); +void time2ls(char *s, size_t size, const time_t *t); + +lzo_bool file_exists(const char *name); + +lzo_uint32 fix_mode_for_header(lzo_uint32 mode); +MODE_T fix_mode_for_chmod(lzo_uint32 mode); +MODE_T fix_mode_for_ls(lzo_uint32 mode); +MODE_T fix_mode_for_open(MODE_T mode); + +void mode_string(MODE_T mode, char *str); +char *maybe_rename_file(const char *original_name); + + +/************************************************************************* +// other globals +**************************************************************************/ + +extern const char *progname; +extern MODE_T u_mask; +extern time_t current_time; + +void sysinfo(void); +void license(void); +void head(void); +void help(void); +void usage(void); +void version(void); + +void sysinfo_djgpp(void); + + +/************************************************************************* +// LZO section +**************************************************************************/ + +#if defined(WITH_LZO) + +#define USE_LZO1X_1 1 +#if 1 +# define USE_LZO1X_999 1 +#endif +#if !defined(ACC_OS_DOS16) +# define USE_LZO1X_1_15 1 +#endif + +#if defined(LZO_USE_ASM_1) +#if !defined(LZO_EXTERN_CDECL) +#define LZO_EXTERN_CDECL(r) LZO_EXTERN(r) +#endif +LZO_EXTERN_CDECL(int) +lzo1x_decompress_asm_fast + ( const lzo_bytep src, lzo_uint src_len, + lzo_bytep dst, lzo_uintp dst_len, + lzo_voidp wrkmem /* NOT USED */ ); +LZO_EXTERN_CDECL(int) +lzo1x_decompress_asm_fast_safe + ( const lzo_bytep src, lzo_uint src_len, + lzo_bytep dst, lzo_uintp dst_len, + lzo_voidp wrkmem /* NOT USED */ ); +# define lzo1x_decompress lzo1x_decompress_asm_fast +# define lzo1x_decompress_safe lzo1x_decompress_asm_fast_safe +#elif defined(LZO_USE_ASM_2) +LZO_EXTERN_CDECL(int) +_lzo1x_decompress_asm_fast + ( const lzo_bytep src, lzo_uint src_len, + lzo_bytep dst, lzo_uintp dst_len, + lzo_voidp wrkmem /* NOT USED */ ); +LZO_EXTERN_CDECL(int) +_lzo1x_decompress_asm_fast_safe + ( const lzo_bytep src, lzo_uint src_len, + lzo_bytep dst, lzo_uintp dst_len, + lzo_voidp wrkmem /* NOT USED */ ); +# define lzo1x_decompress _lzo1x_decompress_asm_fast +# define lzo1x_decompress_safe _lzo1x_decompress_asm_fast_safe +#endif + +#endif /* WITH_LZO */ + + +/************************************************************************* +// +**************************************************************************/ + +#include "console.h" + + +#endif /* already included */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/console.h b/src/console.h new file mode 100644 index 0000000..d55a558 --- /dev/null +++ b/src/console.h @@ -0,0 +1,197 @@ +/* console.h -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + + +/************************************************************************* +// +**************************************************************************/ + +#undef USE_CONSOLE +#undef USE_ANSI +#undef USE_SCREEN +#undef USE_SCREEN_VCSA +#undef USE_SCREEN_CURSES +#undef USE_FRAMES + + +#if 1 && defined(LZOP_ENABLE_ANSI) && !defined(DOSISH) +# define USE_ANSI 1 +#endif + +#if 1 && defined(__linux__) && defined(LZOP_ENABLE_LINUX_CONSOLE) +# define USE_SCREEN 1 +# define USE_SCREEN_VCSA 1 +# if !defined(HAVE_LINUX_KD_H) +# undef USE_SCREEN +# undef USE_SCREEN_VCSA +# endif +# if !defined(HAVE_LINUX_KDEV_T_H) || !defined(HAVE_LINUX_MAJOR_H) +# undef USE_SCREEN +# undef USE_SCREEN_VCSA +# endif +#endif + +#if 0 && defined(HAVE_NCURSES_H) && defined(HAVE_LIBNCURSES) +# define USE_SCREEN 1 +# define USE_SCREEN_CURSES 1 +#endif + +#if 0 && defined(__DJGPP__) +# define USE_SCREEN 1 +#endif + +#if 1 && defined(USE_SCREEN) +# define USE_FRAMES 1 +#endif + + +#if 0 || defined(NO_ANSI) +# undef USE_ANSI +#endif +#if 0 || defined(NO_SCREEN) +# undef USE_SCREEN +#endif +#if 0 || defined(NO_FRAMES) || !defined(USE_SCREEN) +# undef USE_FRAMES +#endif +#if !defined(WITH_LZO) +# undef USE_FRAMES +#endif + + +#if 0 || defined(USE_ANSI) || defined(USE_SCREEN) +# define USE_CONSOLE 1 +#endif + +#if 0 || defined(NO_CONSOLE) || !defined(USE_CONSOLE) +# undef USE_CONSOLE +# undef USE_ANSI +# undef USE_SCREEN +# undef USE_SCREEN_VCSA +# undef USE_SCREEN_CURSES +# undef USE_FRAMES +#endif + + +/************************************************************************* +// +**************************************************************************/ + +enum { + CON_INIT, + CON_NONE, + CON_ANSI_MONO, + CON_ANSI_COLOR, + CON_SCREEN, + CON_UNUSED +}; + + +#if defined(USE_CONSOLE) + +typedef struct +{ + int (*init)(FILE *f, int, int); + int (*set_fg)(FILE *f, int fg); + void (*print0)(FILE *f, const char *s); + lzo_bool (*intro)(FILE *f); +} +console_t; + + +#if defined(__GNUC__) +void con_fprintf(FILE *f, const char *format, ...) + __attribute__((format(printf,2,3))); +#else +void con_fprintf(FILE *f, const char *format, ...); +#endif + + +#define FG_BLACK 0x00 +#define FG_BLUE 0x01 +#define FG_GREEN 0x02 +#define FG_CYAN 0x03 +#define FG_RED 0x04 +#define FG_VIOLET 0x05 +#define FG_ORANGE 0x06 +#define FG_LTGRAY 0x07 +#define FG_DKGRAY 0x08 +#define FG_BRTBLUE 0x09 +#define FG_BRTGREEN 0x0a +#define FG_BRTCYAN 0x0b +#define FG_BRTRED 0x0c +#define FG_BRTVIOLET 0x0d +#define FG_YELLOW 0x0e +#define FG_WHITE 0x0f + +#define BG_BLACK 0x00 +#define BG_BLUE 0x10 +#define BG_GREEN 0x20 +#define BG_CYAN 0x30 +#define BG_RED 0x40 +#define BG_VIOLET 0x50 +#define BG_ORANGE 0x60 +#define BG_WHITE 0x70 + +#endif /* USE_CONSOLE */ + + +/************************************************************************* +// +**************************************************************************/ + +extern FILE *con_term; + +#if defined(USE_CONSOLE) + +extern int con_mode; +extern console_t *con; + +extern console_t console_init; +extern console_t console_none; +extern console_t console_ansi_mono; +extern console_t console_ansi_color; +extern console_t console_screen; + + +#define con_fg(f,x) con->set_fg(f,x) +#define con_intro(f) con->intro(f) + +#else + +#define con_fg(f,x) 0 +#define con_fprintf fprintf +#define con_intro(f) 0 + +#endif /* USE_CONSOLE */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/djgpp2.c b/src/djgpp2.c new file mode 100644 index 0000000..22dd993 --- /dev/null +++ b/src/djgpp2.c @@ -0,0 +1,181 @@ +/* djgpp2.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(__DJGPP__) + +#include <dpmi.h> +#include <go32.h> + + +/************************************************************************* +// init +**************************************************************************/ + +/* Minimum stack */ +unsigned _stklen = 65536; + + +/* This is called before 'main'. */ +static void __attribute__((__constructor__)) +djgpp_startup (void) +{ + const char *s; + static char lfn_y[] = "LFN=y"; + static char lfn_n[] = "LFN=n"; + + s = getenv("LZOP_LFN"); + if (s == NULL || (s[0] != 'n' && s[0] != 'N')) + putenv(lfn_y); + else + { + putenv(lfn_n); + _crt0_startup_flags |= _CRT0_FLAG_NO_LFN; + } + + _djstat_flags |= _STAT_INODE; + _djstat_flags |= _STAT_EXEC_EXT; + _djstat_flags |= _STAT_EXEC_MAGIC; + _djstat_flags |= _STAT_DIRSIZE; + _djstat_flags |= _STAT_ROOT_TIME; +} + + +/* No need for loading the environment. */ +void __crt0_load_environment_file(char *app_name) { UNUSED(app_name); } + + +/* No need for this function */ +int _is_executable(const char *filename, int fhandle, const char *extension) +{ + UNUSED(filename); + UNUSED(fhandle); + UNUSED(extension); + return 0; +} + + +/************************************************************************* +// info +**************************************************************************/ + +#if 0 + +typedef struct { + unsigned long largest_available_free_block_in_bytes; + unsigned long maximum_unlocked_page_allocation_in_pages; + unsigned long maximum_locked_page_allocation_in_pages; + unsigned long linear_address_space_size_in_pages; + unsigned long total_number_of_unlocked_pages; + unsigned long total_number_of_free_pages; + unsigned long total_number_of_physical_pages; + unsigned long free_linear_address_space_in_pages; + unsigned long size_of_paging_file_partition_in_pages; + unsigned long reserved[3]; +} __dpmi_free_mem_info; + +typedef struct { + unsigned long available_memory; + unsigned long available_pages; + unsigned long available_lockable_pages; + unsigned long linear_space; + unsigned long unlocked_pages; + unsigned long available_physical_pages; + unsigned long total_physical_pages; + unsigned long free_linear_space; + unsigned long max_pages_in_paging_file; + unsigned long reserved[3]; +} _go32_dpmi_meminfo; + +#endif + +static void meminfo(void) +{ + __dpmi_free_mem_info info; + const unsigned long err = (unsigned long) -1; + unsigned long ps = 0; + unsigned long k; + + if (__dpmi_get_page_size(&ps) != 0 || ps <= 0) + return; + if (__dpmi_get_free_memory_information(&info) != 0) + return; + +#if 0 + k = info.largest_available_free_block_in_bytes; + if (k == err) + { + k = info.maximum_unlocked_page_allocation_in_pages; + if (k != err) + k *= ps; + else + k = info.largest_available_free_block_in_bytes; + } +#endif + +#if 0 + k = info.total_number_of_physical_pages; + k = info.total_number_of_unlocked_pages; +#endif + k = info.total_number_of_free_pages; + if (k != err) + { + k = (k * ps) / 1024; + con_fprintf(con_term,"DPMI physical memory available: %6ld kB\n",k); + } + + k = info.maximum_unlocked_page_allocation_in_pages; + if (k != err) + { + k = (k * ps) / 1024; + con_fprintf(con_term,"DPMI virtual memory available: %6ld kB\n",k); + } + con_fprintf(con_term,"\n"); +} + + +void sysinfo_djgpp(void) +{ + meminfo(); + + if (_USE_LFN) + con_fprintf(con_term,"Long filenames are supported.\n"); + else + con_fprintf(con_term,"Long filenames are not supported.\n"); + con_fprintf(con_term,"\n"); +} + + +#endif /* __DJGPP__ */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/filter.c b/src/filter.c new file mode 100644 index 0000000..e2023b4 --- /dev/null +++ b/src/filter.c @@ -0,0 +1,167 @@ +/* filter.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if (ACC_CC_MSC && (_MSC_VER >= 1000)) + /* avoid '-W4' warnings */ +# pragma warning(disable: 4244) +#endif + + +/************************************************************************* +// +**************************************************************************/ + +void t_sub1(lzo_bytep p, lzo_uint l) +{ + unsigned char b = 0; + + if (l > 0) do { + *p -= b; + b += *p++; + } while (--l > 0); +} + + +void t_add1(lzo_bytep p, lzo_uint l) +{ + unsigned char b = 0; + + if (l > 0) do { + b += *p; + *p++ = b; + } while (--l > 0); +} + + +/************************************************************************* +// +**************************************************************************/ + +void t_sub(lzo_bytep p, lzo_uint l, int n) +{ + unsigned char b[16]; + int i; + + assert(n > 0 && n <= (int)sizeof(b)); + if (l <= (lzo_uint)n) + return; + + n--; + i = n; do b[i] = 0; while (--i >= 0); + + i = n; + do { + *p -= b[i]; + b[i] += *p++; + if (--i < 0) + i = n; + } while (--l > 0); +} + + +void t_add(lzo_bytep p, lzo_uint l, int n) +{ + unsigned char b[16]; + int i; + + assert(n > 0 && n <= (int)sizeof(b)); + if (l <= (lzo_uint)n) + return; + + n--; + i = n; do b[i] = 0; while (--i >= 0); + + i = n; + do { + b[i] += *p; + *p++ = b[i]; + if (--i < 0) + i = n; + } while (--l > 0); +} + + +/************************************************************************* +// +**************************************************************************/ + +void t_mtf(lzo_bytep p, lzo_uint l) +{ + unsigned char b[256]; + unsigned char c; + unsigned i; + + if (l <= 1) + return; + + i = 256; do { --i; b[i] = (unsigned char) i; } while (i != 0); + + do { + c = *p; + for (i = 0; c != b[i]; ) + i++; + *p++ = (unsigned char) i; + if (i > 0) + { + do b[i] = b[i-1]; while (--i > 0); + b[0] = c; + } + } while (--l > 0); +} + + +void t_unmtf(lzo_bytep p, lzo_uint l) +{ + unsigned char b[256]; + unsigned char c; + unsigned i; + + if (l <= 1) + return; + + i = 256; do { --i; b[i] = (unsigned char) i; } while (i != 0); + + do { + i = *p; + c = b[i]; + *p++ = c; + if (i > 0) + { + do b[i] = b[i-1]; while (--i > 0); + b[0] = c; + } + } while (--l > 0); +} + + +/* +vi:ts=4:et +*/ + diff --git a/src/frames.c b/src/frames.c new file mode 100644 index 0000000..4a065b3 --- /dev/null +++ b/src/frames.c @@ -0,0 +1,247 @@ +/* frames.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(USE_FRAMES) + +#include "screen.h" + + +/************************************************************************* +// +**************************************************************************/ + +static void recolor_line(screen_t *screen, int frame, int line, + lzo_bytep f, int len, int cy, int col) +{ + unsigned char colmap[4]; + int k; + + UNUSED(screen); + UNUSED(frame); + UNUSED(line); + UNUSED(f); + UNUSED(len); + UNUSED(cy); + + colmap[0] = 0; /* black background */ + if (col <= 0x333) + { + /* palette */ + static const unsigned char pal[4] = { 0x2, 0x3, 0x5, 0x5 }; + colmap[1] = pal[ (col >> 8) & 3 ]; + colmap[2] = pal[ (col >> 4) & 3 ]; + colmap[3] = pal[ (col >> 0) & 3 ]; + } + else + { + /* direct colors */ + colmap[1] = (col >> 16) & 0x07; + colmap[2] = (col >> 8) & 0x07; + colmap[3] = (col >> 0) & 0x07; + } + +#if 0 + for (k = 0; k < len; k += 2) + if (f[k+1] != 0) + { + if (f[k] != ' ') + f[k] = '.'; + f[k+1] = 0x10; + } + else + assert(f[k] == ' '); +#endif + +#if 1 + for (k = 0; k < len; k += 2) + { + lzo_bytep p = &f[k+1]; + if (*p != 0) + *p = (colmap[ (*p >> 4) & 3 ] << 4) | colmap[ *p & 3 ]; + } +#endif + +#if 0 + f[0*2+0] = f[77*2+0] = line / 10 + '0'; + f[0*2+1] = f[77*2+1] = 0x07; + f[1*2+0] = f[78*2+0] = line % 10 + '0'; + f[1*2+1] = f[78*2+1] = 0x07; +#if 1 + if (line == 18 - 1) + { + char s[2*80+1]; + int y = cy - 4; + + sprintf(s," %2d: %2d %2d ", frame, 0, 0); + screen->putStringAttr(screen,s,0x70,33,y+1); + for (k = 0; k < 79; k++) + { + screen->putCharAttr(screen,k%10+'0',k%10==0?0x06:0x07,k,y+3); + screen->putCharAttr(screen,k%10+'0',k%10==0?0x06:0x07,k,y+3+18+1); + } +#if 1 + usleep(200*1000); +#else + while (!screen->kbhit(screen)) + ; + while (screen->kbhit(screen)) + if (getch() == 27) + exit(0); +#endif + } +#endif +#endif +} + + +static int random_color(void) +{ + static const short c[6] = { 0x012, 0x021, 0x102, 0x120, 0x201, 0x210 }; + int t; + lzo_uint32 seed; + + seed = time(NULL); +#if 0 + seed = seed * 69069L + 5; + t = (int)(seed >> 16) % 50; +#else + seed = seed * 0x015a4e35L + 1; + t = (int)(seed >> 16) % 50; +#endif + return (t < 6 ? c[t] : 0x333); +} + + +/************************************************************************* +// +**************************************************************************/ + +#include "frames.h" + +void screen_show_frames(screen_t *screen) +{ + int i, j, k; + lzo_uint out_len = UNCOMPRESSED_SIZE; + lzo_bytep frames = NULL; + lzo_bytep frames_mem = NULL; + int c_cx, c_cy; + const int len = 79 * 2; /* size of one line */ + const int nframes = 19; /* number of frames */ + const int lines = 18; /* intro */ + const int total_lines = 24; /* head + help */ + lzo_bool hit = 0; + int col; + lzo_uint32 c; + + assert(acc_isatty(STDIN_FILENO)); + assert(out_len == (lzo_uint) (lines * len * nframes)); + +#if 0 + c = lzo_adler32(ADLER32_INIT_VALUE,compressed_frames,COMPRESSED_SIZE); + if (c != COMPRESSED_ADLER32) + exit(EXIT_ERROR); +#endif + + frames = frames_mem = (lzo_bytep) malloc(UNCOMPRESSED_SIZE + 3); + if (frames == NULL) + return; + + if ((lzo1x_decompress_safe(compressed_frames,COMPRESSED_SIZE, + frames,&out_len,NULL) != LZO_E_OK) + || (out_len != UNCOMPRESSED_SIZE)) + exit(EXIT_ERROR); +#if 0 + c = lzo_adler32(ADLER32_INIT_VALUE,frames,UNCOMPRESSED_SIZE); + if (c != UNCOMPRESSED_ADLER32) + exit(EXIT_ERROR); +#endif + + screen->getCursor(screen,&c_cx,&c_cy); + c_cy += total_lines; + if (c_cy >= screen->getRows(screen)) + c_cy -= screen->scrollUp(screen,c_cy-screen->getRows(screen)+1); + c_cy -= total_lines; + if (c_cy < 0) + c_cy = 0; + c_cx = 0; + screen->setCursor(screen,c_cx,c_cy); +#if 1 + for (k = 0; k < 4; k++) + screen->clearLine(screen,c_cy+k); +#endif + head(); + screen->getCursor(screen,&c_cx,&c_cy); +#if 1 + for (k = 0; k < lines; k++) + screen->clearLine(screen,c_cy+k); +#endif + screen->refresh(screen); + + col = random_color(); + for (i = 0; i < nframes && !hit; i++) + { + for (j = 0; j < lines; j++) + { + recolor_line(screen,i,j,frames,len,c_cy,col); + screen->updateLineN(screen,frames,c_cy+j,len); + frames += len; + } + screen->refresh(screen); + + if (i == 0) + { + for (j = 0; !(hit = screen->kbhit(screen)) && j < 10; j++) + usleep(120*1000); + } + else + { + if (!(hit = screen->kbhit(screen))) + usleep(60*1000); + } + } + + free(frames_mem); + + for (k = 0; k < lines; k++) + screen->clearLine(screen,c_cy+k); + screen->refresh(screen); + help(); + + UNUSED(c); +} + + +#endif /* USE_FRAMES */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/frames.h b/src/frames.h new file mode 100644 index 0000000..0069ffe --- /dev/null +++ b/src/frames.h @@ -0,0 +1,330 @@ +/* frames.h -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#define UNCOMPRESSED_SIZE 54036u +#define COMPRESSED_SIZE 3522u + +#define UNCOMPRESSED_ADLER32 0x3fe9a878L +#define COMPRESSED_ADLER32 0x367c5616L + +static const unsigned char compressed_frames[3522] = { +0x13, 0x20, 0x00, 0x20, 0x00, 0x2c, 0x06, 0x00, 0xb2, 0x10, 0x20, 0x24, +0x15, 0x01, 0x20, 0xa4, 0x00, 0x39, 0x85, 0x00, 0x30, 0x2e, 0x04, 0x00, +0x34, 0x9e, 0x00, 0xb1, 0x10, 0x05, 0x00, 0xb0, 0x85, 0x00, 0x20, 0x45, +0x00, 0xb0, 0x3b, 0x76, 0x02, 0xb0, 0x20, 0x61, 0x00, 0xb0, 0x27, 0x05, +0x00, 0xb1, 0x85, 0x00, 0xb0, 0x29, 0x04, 0x00, 0x2c, 0x02, 0x00, 0xb0, +0x20, 0x2e, 0x4f, 0x02, 0xb1, 0x30, 0xb0, 0x0c, 0x21, 0x35, 0x05, 0x00, +0xb0, 0x54, 0x03, 0x2f, 0x95, 0x02, 0x10, 0x2a, 0x04, 0x00, 0x3c, 0x75, +0x02, 0x20, 0x20, 0x0e, 0x00, 0x00, 0x2a, 0xf5, 0x04, 0xb2, 0x37, 0x54, +0x02, 0x2e, 0x04, 0x00, 0x2b, 0x84, 0x02, 0x20, 0x0a, 0x75, 0x02, 0xb0, +0x2d, 0x64, 0x04, 0x34, 0xc4, 0x04, 0x32, 0xdd, 0x04, 0xb1, 0x39, 0x8c, +0x04, 0x7c, 0x3a, 0x2c, 0x4c, 0x05, 0x29, 0x74, 0x00, 0x2b, 0x76, 0x02, +0xb1, 0x10, 0x3c, 0x3c, 0x09, 0x74, 0x0e, 0x34, 0x3d, 0x09, 0xb2, 0x4c, +0x3c, 0x28, 0x02, 0x00, 0xb1, 0x20, 0x2c, 0x44, 0x07, 0x35, 0x65, 0x04, +0x00, 0x36, 0x04, 0x03, 0x34, 0x74, 0x02, 0x3e, 0x54, 0x0c, 0x3a, 0xa5, +0x0b, 0xb0, 0x35, 0xb4, 0x09, 0x44, 0x03, 0x29, 0xdc, 0x04, 0x3a, 0x75, +0x01, 0xb1, 0x30, 0x9c, 0x00, 0x20, 0x0c, 0x74, 0x02, 0x37, 0x5c, 0x01, +0x35, 0xd4, 0x04, 0xc4, 0x00, 0x20, 0x02, 0xe4, 0x04, 0x35, 0xa4, 0x00, +0x20, 0x20, 0x75, 0x02, 0xb2, 0x27, 0xe6, 0x09, 0xb1, 0x20, 0x20, 0x06, +0xcc, 0x01, 0x20, 0x16, 0x74, 0x02, 0x20, 0x11, 0x64, 0x02, 0x34, 0x84, +0x0e, 0x36, 0xcd, 0x01, 0xb0, 0x20, 0x48, 0x75, 0x02, 0xb2, 0x2b, 0xb4, +0x0e, 0x36, 0x6c, 0x02, 0x9d, 0x02, 0x30, 0x20, 0x05, 0xf4, 0x04, 0x31, +0xf4, 0x0c, 0x20, 0x14, 0x75, 0x02, 0xb2, 0x2d, 0x1c, 0x11, 0x30, 0x6d, +0x02, 0xb2, 0x9c, 0xb4, 0xac, 0x03, 0x2b, 0x34, 0x0e, 0x32, 0xcc, 0x15, +0xc5, 0xb5, 0x20, 0x3b, 0x54, 0x0c, 0x34, 0xb5, 0x13, 0xb2, 0x54, 0x51, +0x7c, 0xc9, 0xed, 0x52, 0xb2, 0x33, 0x84, 0x13, 0x28, 0xed, 0x18, 0xb1, +0x2e, 0x7c, 0x00, 0x2b, 0xd4, 0x0e, 0x28, 0xce, 0x13, 0xb1, 0x30, 0xa4, +0x9d, 0x30, 0xfd, 0x18, 0xb0, 0x33, 0x46, 0x11, 0xb0, 0x10, 0x28, 0x5c, +0x1b, 0x28, 0x74, 0x1b, 0x2c, 0xc5, 0x0c, 0xb1, 0x20, 0x16, 0xbd, 0x18, +0xb0, 0x20, 0x08, 0xad, 0x18, 0xb0, 0x37, 0xac, 0x18, 0x3a, 0x04, 0x00, +0x4c, 0x28, 0x20, 0x0f, 0x28, 0x1b, 0x2b, 0xed, 0x13, 0xb1, 0x20, 0x04, +0x64, 0x02, 0x2d, 0xd5, 0x07, 0x10, 0x2e, 0x2c, 0x1b, 0x34, 0x04, 0x00, +0x74, 0xc8, 0x75, 0x36, 0xb2, 0x20, 0x02, 0x04, 0x00, 0x28, 0x85, 0x07, +0xb2, 0x31, 0x1c, 0x20, 0x65, 0x39, 0xb0, 0x27, 0x34, 0x07, 0xad, 0x01, +0xb1, 0x35, 0x34, 0x0a, 0x20, 0x00, 0x00, 0x65, 0x04, 0x00, 0xa4, 0x9b, +0x3a, 0xac, 0x1d, 0x3c, 0x4c, 0x2e, 0x2a, 0x4d, 0x0c, 0xb0, 0x84, 0x68, +0x34, 0xcd, 0x2e, 0xb1, 0x2f, 0x04, 0x00, 0x38, 0x44, 0x0c, 0x2e, 0x5c, +0x13, 0x20, 0x05, 0x54, 0x1d, 0x28, 0x0c, 0x16, 0x38, 0x01, 0x00, 0xb1, +0x2d, 0x05, 0x2a, 0xb0, 0x3d, 0x36, 0x11, 0xb1, 0x30, 0x32, 0x74, 0x02, +0x20, 0x07, 0x34, 0x1b, 0x20, 0x0d, 0x25, 0x16, 0xb1, 0x2b, 0xdd, 0x2e, +0xb0, 0x2d, 0x24, 0x02, 0x28, 0x05, 0x00, 0x20, 0x2d, 0x9c, 0x1b, 0x3a, +0x64, 0x31, 0x20, 0x05, 0xec, 0x04, 0x2a, 0xdd, 0x1a, 0xb1, 0x33, 0xbc, +0x33, 0x36, 0x4d, 0x31, 0xb1, 0x3f, 0x8e, 0x1d, 0xb1, 0x30, 0x20, 0x17, +0xdd, 0x33, 0xb1, 0x35, 0x34, 0x09, 0x2c, 0xec, 0x02, 0x2e, 0x9d, 0x27, +0xb0, 0x3b, 0x6c, 0x02, 0x3d, 0x74, 0x2f, 0x20, 0x2e, 0x74, 0x2c, 0x30, +0x7c, 0x18, 0x20, 0x05, 0x74, 0x27, 0x32, 0x9e, 0x00, 0xb2, 0x10, 0x20, +0x1d, 0xfc, 0x29, 0x20, 0x01, 0xdd, 0x2e, 0xb2, 0x20, 0x08, 0xed, 0x29, +0xb0, 0x2f, 0xf4, 0x04, 0x20, 0x1f, 0x74, 0x02, 0x28, 0xbe, 0x24, 0xb0, +0x20, 0x20, 0x0e, 0xcc, 0x06, 0x39, 0x75, 0x02, 0xb1, 0x33, 0x75, 0x02, +0xb1, 0x20, 0x18, 0x74, 0x2c, 0x37, 0x4c, 0x31, 0x3f, 0x4c, 0x0c, 0x3a, +0x75, 0x02, 0xb1, 0x20, 0x16, 0x75, 0x02, 0xb1, 0x3f, 0xdd, 0x2e, 0xb2, +0xf4, 0x79, 0x2b, 0x6c, 0x27, 0x38, 0xe4, 0x15, 0x32, 0x3d, 0x3b, 0xb0, +0x20, 0x04, 0x4c, 0x0c, 0x2c, 0x0d, 0x19, 0xb1, 0x31, 0x04, 0x11, 0x2a, +0x74, 0x25, 0x2a, 0x7c, 0x00, 0x75, 0x13, 0xb2, 0x39, 0xc4, 0x44, 0x30, +0x24, 0x40, 0x2a, 0x7c, 0x0a, 0x2e, 0x74, 0x02, 0x7d, 0x10, 0xb1, 0x2b, +0x8c, 0x2c, 0x2c, 0x5d, 0x05, 0xb2, 0x3b, 0x74, 0x18, 0x36, 0x6c, 0x2c, +0x20, 0x09, 0x14, 0x45, 0x20, 0x1b, 0x6d, 0x2c, 0xb0, 0x20, 0x00, 0x00, +0x00, 0x73, 0x6c, 0x2c, 0x20, 0x83, 0xe4, 0x2e, 0x3c, 0xed, 0x2e, 0xb1, +0x29, 0xec, 0x2e, 0xe4, 0x72, 0x2c, 0xb4, 0x0e, 0x26, 0xb4, 0x27, 0x32, +0x94, 0x54, 0x2a, 0xcc, 0x0e, 0x2a, 0xb4, 0x0e, 0x3a, 0xbe, 0x0e, 0xb1, +0x10, 0x20, 0x07, 0x15, 0x25, 0xb1, 0x20, 0x1a, 0x54, 0x5b, 0x20, 0x01, +0xdc, 0x2e, 0x34, 0x8d, 0x02, 0xb1, 0x20, 0x08, 0x9d, 0x22, 0xb0, 0x20, +0x14, 0x1c, 0x16, 0x2c, 0x64, 0x02, 0xe4, 0x26, 0xf5, 0x28, 0x20, 0x3d, +0x95, 0x20, 0xb0, 0x20, 0x0e, 0xec, 0x2e, 0x2c, 0x54, 0x1d, 0x28, 0x4c, +0x07, 0x36, 0xbc, 0x33, 0x3e, 0xdc, 0x58, 0x2a, 0xf4, 0x02, 0x31, 0x84, +0x00, 0x20, 0x0d, 0xdc, 0x5d, 0x3d, 0xd4, 0x07, 0x2e, 0xbc, 0x09, 0x20, +0x05, 0xf4, 0x29, 0x36, 0x7e, 0x02, 0xb2, 0x10, 0x20, 0x3d, 0xed, 0x58, +0xb1, 0x20, 0x10, 0xec, 0x29, 0x2a, 0x9e, 0x00, 0xb1, 0x10, 0x20, 0x1f, +0xec, 0x58, 0x3c, 0x54, 0x5b, 0x20, 0x07, 0x75, 0x02, 0xb1, 0x33, 0xf5, +0x09, 0xb0, 0x20, 0x24, 0x75, 0x2c, 0xb0, 0x37, 0xac, 0x36, 0x33, 0x95, +0x64, 0x00, 0x20, 0x08, 0xfc, 0x31, 0x20, 0x16, 0xe4, 0x04, 0x2e, 0x8c, +0x29, 0x34, 0x74, 0x2c, 0x2c, 0x54, 0x5b, 0x20, 0x0f, 0xe5, 0x09, 0xb2, +0x20, 0x08, 0x34, 0x3b, 0x2a, 0x3d, 0x0a, 0xb1, 0x2f, 0xdc, 0x3f, 0x2a, +0x74, 0x45, 0x2a, 0x74, 0x2c, 0x7d, 0x16, 0xb1, 0x3c, 0x0c, 0x27, 0x2d, +0xb4, 0x3d, 0x2a, 0x64, 0x07, 0x2e, 0x5d, 0x31, 0xb2, 0x27, 0x04, 0x00, +0x2a, 0x8c, 0x2c, 0x2a, 0xe4, 0x02, 0x20, 0x13, 0x45, 0x16, 0xb1, 0x31, +0xf4, 0x15, 0x32, 0x9c, 0x42, 0x2e, 0x7d, 0x05, 0xb0, 0x20, 0x08, 0x6c, +0x2c, 0x24, 0xfc, 0x29, 0x20, 0x17, 0x6c, 0x2c, 0x3e, 0xac, 0x18, 0x34, +0x5d, 0x05, 0xb0, 0x20, 0x06, 0x6d, 0x2c, 0xb0, 0x25, 0x6c, 0x2c, 0x3c, +0x7d, 0x2c, 0xb1, 0x2d, 0x74, 0x45, 0x2e, 0xe5, 0x13, 0xb2, 0x29, 0x94, +0x1d, 0x2c, 0x0c, 0x05, 0x20, 0x00, 0x00, 0x00, 0x1a, 0x6c, 0x2c, 0x20, +0x7d, 0xd4, 0x2e, 0x28, 0x04, 0x16, 0x38, 0xb5, 0x1d, 0xb2, 0x31, 0x74, +0x27, 0x2c, 0x14, 0x11, 0x28, 0xe4, 0x2e, 0x32, 0xb5, 0x5d, 0xb0, 0x2d, +0x04, 0x00, 0x20, 0x01, 0xe4, 0x2e, 0x20, 0x0b, 0x8d, 0x27, 0xb0, 0x20, +0x24, 0x54, 0x5b, 0x20, 0x07, 0xc4, 0x5d, 0x20, 0x0f, 0x8d, 0x27, 0xb0, +0x20, 0x06, 0x4c, 0x60, 0x2a, 0x6c, 0x02, 0x2c, 0x85, 0x4c, 0xb1, 0x27, +0x74, 0x91, 0x2e, 0xe5, 0x2e, 0xb0, 0x20, 0x20, 0x65, 0x31, 0xb1, 0xcc, +0xfe, 0x32, 0x24, 0x65, 0x3e, 0xc5, 0x5d, 0xb0, 0x20, 0x02, 0xe5, 0x4e, +0xb2, 0x3f, 0x65, 0x31, 0xb1, 0x20, 0x1c, 0x75, 0x2c, 0xb2, 0x35, 0xc6, +0x5d, 0xb0, 0x30, 0x20, 0x05, 0x6c, 0x27, 0x2f, 0x04, 0x23, 0x20, 0x3c, +0x75, 0x2c, 0xb0, 0x20, 0x17, 0xa4, 0x8c, 0x33, 0xe5, 0x04, 0xb0, 0x20, +0x2e, 0x75, 0x2c, 0xb0, 0x20, 0x10, 0x3c, 0x85, 0x20, 0x25, 0xe4, 0x04, +0x2a, 0x74, 0x2c, 0x36, 0x74, 0x94, 0x20, 0x01, 0x54, 0x09, 0x3c, 0x4c, +0x8d, 0x20, 0x15, 0xcd, 0x09, 0xb1, 0x3b, 0xc4, 0x87, 0x6c, 0x64, 0x28, +0xd5, 0x13, 0xb0, 0x20, 0x02, 0xbd, 0x87, 0xb0, 0x33, 0xec, 0x04, 0x32, +0xe5, 0x2e, 0xb2, 0x2f, 0x84, 0x2c, 0x26, 0x84, 0x27, 0x3c, 0xe4, 0x58, +0x32, 0xc4, 0x9b, 0x7d, 0x16, 0xb2, 0x31, 0x4d, 0x87, 0xb0, 0x33, 0x2c, +0x40, 0x2e, 0x45, 0x36, 0xb1, 0x20, 0x08, 0x6c, 0x2c, 0x74, 0x13, 0x20, +0x0f, 0xe4, 0x58, 0x28, 0xbd, 0x18, 0xb1, 0x20, 0x06, 0x44, 0x5b, 0x3c, +0x6c, 0x2c, 0x38, 0x1c, 0x59, 0x5c, 0x28, 0x27, 0x64, 0x71, 0x3e, 0x64, +0x2c, 0xf4, 0x28, 0x2e, 0x6c, 0x2c, 0x34, 0xbc, 0x04, 0x26, 0x6c, 0x2c, +0x20, 0x00, 0x00, 0x00, 0xb2, 0x74, 0x2c, 0x20, 0x28, 0x94, 0x2d, 0x3f, +0x1c, 0xb9, 0x20, 0x15, 0xed, 0x2e, 0xb1, 0x31, 0x64, 0x18, 0x32, 0xfd, +0x29, 0xb0, 0x31, 0x4c, 0x85, 0x30, 0x96, 0x18, 0xb0, 0x20, 0x30, 0x14, +0xb9, 0x36, 0xa4, 0x13, 0x20, 0x02, 0x7c, 0x02, 0x20, 0x04, 0xa5, 0x22, +0xb2, 0x20, 0x08, 0x95, 0x18, 0xb2, 0x20, 0x0c, 0x0c, 0x45, 0x3c, 0xd6, +0x7b, 0xb2, 0x10, 0x20, 0x05, 0x65, 0x31, 0xb2, 0x2d, 0x54, 0x1d, 0x28, +0xec, 0x04, 0x38, 0xc4, 0x5d, 0x34, 0x0c, 0x20, 0x3b, 0x04, 0xb9, 0x3b, +0xed, 0x2e, 0xb0, 0x3b, 0xcc, 0x62, 0x35, 0x84, 0x93, 0x29, 0x9c, 0x7b, +0x20, 0x0b, 0xf4, 0x29, 0x2a, 0x64, 0x05, 0x37, 0x04, 0x05, 0x20, 0x1e, +0x65, 0x5b, 0xb1, 0x35, 0x75, 0x2c, 0xb2, 0x20, 0x04, 0x6d, 0x27, 0xb1, +0x20, 0x0a, 0xc4, 0x62, 0x20, 0x0f, 0x75, 0x2c, 0xb1, 0x29, 0x04, 0x54, +0x38, 0x54, 0x29, 0x3c, 0x64, 0x09, 0x38, 0x7d, 0x07, 0xb1, 0x20, 0x18, +0x6d, 0x02, 0xb1, 0x20, 0x02, 0x55, 0x5b, 0xb0, 0x20, 0x0e, 0xf4, 0x04, +0x20, 0x23, 0xbc, 0x62, 0x3a, 0xc4, 0xc2, 0x2a, 0xf4, 0x58, 0x44, 0x9f, +0x20, 0x02, 0xc4, 0x3a, 0x38, 0xb4, 0x67, 0x3c, 0xe4, 0x2e, 0x28, 0x85, +0x2c, 0xb0, 0x39, 0xc4, 0x87, 0x38, 0x05, 0x0f, 0xb2, 0x31, 0x54, 0x5b, +0x3c, 0x2e, 0xb4, 0xb1, 0x30, 0x38, 0xe4, 0x04, 0x2f, 0xac, 0xa0, 0x20, +0x24, 0x6c, 0x2c, 0x2e, 0x54, 0x5d, 0x20, 0x27, 0x6d, 0x2c, 0x20, 0x29, +0x6d, 0x2c, 0xb2, 0x2b, 0x84, 0x18, 0x3a, 0x04, 0x00, 0x38, 0x6d, 0x2c, +0xb0, 0x37, 0xc5, 0x18, 0xb1, 0x20, 0x00, 0x00, 0x00, 0xfb, 0x6c, 0x2c, +0x20, 0x7f, 0xdc, 0x2e, 0xac, 0x9e, 0x3e, 0xf4, 0xe7, 0x20, 0x11, 0xec, +0x2e, 0x2c, 0xd4, 0xcc, 0x34, 0xc5, 0x1d, 0xb2, 0x2d, 0x14, 0xe3, 0x36, +0x34, 0xe3, 0x2c, 0x75, 0x56, 0xb1, 0x35, 0xb5, 0x73, 0xb1, 0x3e, 0xec, +0x22, 0x20, 0x0e, 0xad, 0x22, 0xb1, 0x20, 0x10, 0xc5, 0x5d, 0xb0, 0x20, +0x11, 0x55, 0xa0, 0x00, 0x20, 0x17, 0xf5, 0x58, 0xb1, 0x33, 0xa4, 0xa7, +0x2a, 0x3c, 0x8a, 0x2c, 0x05, 0x1b, 0xb0, 0x35, 0xcc, 0x5f, 0x2e, 0xe4, +0x2e, 0x3d, 0x3c, 0xad, 0x20, 0x09, 0x0d, 0x7e, 0x20, 0x20, 0x09, 0x75, +0x2c, 0xb1, 0x3f, 0xc5, 0x82, 0xb1, 0x20, 0x02, 0x05, 0x05, 0xb1, 0x20, +0x1c, 0x54, 0x8a, 0x26, 0x4c, 0x25, 0x30, 0x75, 0x2c, 0xb1, 0x20, 0x02, +0x3d, 0x85, 0xb2, 0x29, 0x2c, 0x79, 0x32, 0x7c, 0x02, 0x20, 0x09, 0xcc, +0x33, 0x20, 0x0f, 0x35, 0x8a, 0xb2, 0x20, 0x04, 0xe4, 0x06, 0x3a, 0x3c, +0xb7, 0x20, 0x15, 0xbd, 0x8c, 0xb2, 0x37, 0xa4, 0x09, 0x2b, 0x84, 0x00, +0x2b, 0x04, 0xb6, 0x39, 0xec, 0x0b, 0x35, 0x74, 0x02, 0x20, 0x03, 0xdc, +0x04, 0x2c, 0x4d, 0xcd, 0xb2, 0x2f, 0x34, 0xe0, 0x28, 0x4c, 0x54, 0x2e, +0xc5, 0xc5, 0xb2, 0x2d, 0x55, 0x5b, 0xb0, 0x27, 0x24, 0x6a, 0xec, 0x9f, +0x2e, 0xad, 0x11, 0xb2, 0x3b, 0x7d, 0xc5, 0xb0, 0x37, 0xac, 0xe0, 0x36, +0xd4, 0x2e, 0x20, 0x01, 0x6f, 0x2c, 0xb1, 0x30, 0xb0, 0x20, 0x14, 0x6d, +0x2c, 0xb1, 0x20, 0x08, 0x6c, 0x2c, 0x4c, 0x27, 0x2f, 0x04, 0x45, 0x3c, +0x65, 0x2c, 0xb0, 0x2f, 0x44, 0x16, 0x34, 0x94, 0x5d, 0x20, 0x75, 0x6c, +0x2c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x75, 0xa4, 0x2e, 0x37, 0x9c, 0xcf, +0x2e, 0x0d, 0x42, 0x20, 0x2c, 0xfd, 0xe7, 0xb0, 0x31, 0x4c, 0x20, 0x10, +0x1f, 0xc8, 0x16, 0x20, 0x1f, 0x5d, 0x8a, 0xb0, 0x20, 0x1c, 0xac, 0xb6, +0x20, 0x05, 0xfc, 0xb8, 0x20, 0x1a, 0x94, 0x27, 0x20, 0x0c, 0xc5, 0x5d, +0xb1, 0x33, 0xe5, 0xe7, 0xb0, 0x20, 0x0a, 0xc4, 0x5d, 0x36, 0xb4, 0x4c, +0x38, 0xc6, 0x62, 0xb1, 0x20, 0x30, 0x74, 0x07, 0x32, 0x4c, 0x31, 0x3a, +0xb4, 0xb1, 0x2a, 0xdc, 0x4c, 0x3e, 0x66, 0x31, 0xb2, 0x10, 0x20, 0x23, +0xe4, 0xb1, 0x2f, 0xa4, 0x27, 0x3f, 0x74, 0x04, 0x10, 0x1b, 0xfb, 0x14, +0xb0, 0x10, 0x20, 0x20, 0x16, 0x6c, 0x02, 0x2a, 0x54, 0x5b, 0x20, 0x15, +0x35, 0x8a, 0xb2, 0x20, 0x0c, 0x2d, 0x8f, 0xb0, 0x20, 0x12, 0xbd, 0xe0, +0xb1, 0x3f, 0x8e, 0xe5, 0xb1, 0x30, 0x20, 0x13, 0xac, 0x8c, 0x2e, 0x44, +0x07, 0x38, 0x6c, 0x02, 0x28, 0x8c, 0x0c, 0x2e, 0x75, 0x2c, 0xb0, 0x31, +0x8c, 0x80, 0xde, 0x03, 0x00, 0xb2, 0x3b, 0x8c, 0x0e, 0x24, 0x75, 0x2c, +0x20, 0x20, 0x08, 0x25, 0x8f, 0xb1, 0x2f, 0xad, 0xe0, 0xb0, 0x29, 0x04, +0x0f, 0x30, 0xd4, 0x2e, 0x20, 0x01, 0x5d, 0x11, 0xb2, 0x36, 0xd4, 0xb3, +0x3c, 0x94, 0xe0, 0x20, 0x0c, 0xc4, 0x87, 0x28, 0x6d, 0x2c, 0xb0, 0x20, +0x02, 0x54, 0x2c, 0x34, 0x6d, 0x2c, 0xb0, 0x35, 0xe4, 0x13, 0x20, 0x03, +0xae, 0x71, 0xb2, 0x10, 0x10, 0x3d, 0xa8, 0x2f, 0x20, 0x00, 0x00, 0x00, +0x00, 0x9d, 0x6c, 0x2c, 0x20, 0x77, 0x54, 0xb9, 0x28, 0x04, 0xa3, 0x38, +0xb4, 0xd3, 0x32, 0xf5, 0x9d, 0xb0, 0x27, 0x9c, 0x51, 0x32, 0xf4, 0xe7, +0xe4, 0x00, 0x20, 0x19, 0xad, 0x9d, 0xb1, 0x20, 0x24, 0xed, 0x2e, 0xb1, +0x20, 0x04, 0x34, 0x8a, 0x20, 0x0f, 0xc5, 0xcc, 0xb2, 0x20, 0x0c, 0xec, +0x2e, 0x36, 0x45, 0x60, 0xb1, 0x33, 0xdd, 0x2e, 0xb1, 0x35, 0xed, 0xe7, +0xb0, 0x20, 0x06, 0x85, 0x02, 0xb1, 0x20, 0x06, 0x0c, 0x2a, 0x34, 0x2c, +0xb9, 0x32, 0x14, 0x8f, 0x3a, 0x54, 0x29, 0x2c, 0x34, 0x80, 0x3d, 0x1c, +0xe1, 0x2f, 0x9e, 0x27, 0xb2, 0x10, 0x20, 0x1f, 0x55, 0x5b, 0xb2, 0x20, +0x02, 0x4c, 0x5b, 0x20, 0x01, 0x85, 0x02, 0xb2, 0x33, 0xf4, 0xd8, 0x20, +0x23, 0x54, 0x5b, 0x20, 0x03, 0xe4, 0x2e, 0x3c, 0xa5, 0xe3, 0xb1, 0x20, +0x12, 0x64, 0x02, 0x10, 0x07, 0xb0, 0x0c, 0x30, 0xf5, 0x3d, 0xb1, 0x25, +0xcd, 0x3d, 0xb0, 0x10, 0x24, 0xe8, 0x3b, 0x3e, 0xc5, 0x5d, 0xb1, 0x27, +0x6d, 0xf9, 0xb1, 0x2d, 0x9c, 0x2c, 0x16, 0x21, 0x0d, 0xb1, 0x20, 0x0e, +0x6d, 0x2c, 0xb1, 0x20, 0x08, 0x2d, 0xb4, 0xb0, 0x3e, 0x7c, 0xc0, 0x39, +0xfd, 0x58, 0xb2, 0x31, 0xf5, 0x2b, 0xb0, 0x37, 0x64, 0x2c, 0x2c, 0x24, +0x6f, 0x38, 0xd4, 0x58, 0x20, 0x75, 0x6e, 0x2c, 0xb2, 0x30, 0x20, 0x00, +0x00, 0x00, 0x00, 0x00, 0x0a, 0x6c, 0x2c, 0x20, 0x21, 0x4c, 0x8a, 0x20, +0x3d, 0x7c, 0x01, 0x2c, 0x9c, 0x1d, 0x32, 0x05, 0x19, 0xb0, 0x37, 0x8c, +0x47, 0x32, 0x8d, 0xe5, 0xb1, 0x10, 0x04, 0xd8, 0x16, 0x20, 0x2b, 0xec, +0x2e, 0x32, 0x25, 0x7e, 0xb2, 0x10, 0x20, 0xe8, 0x16, 0x3c, 0x15, 0xb9, +0xb0, 0x20, 0x08, 0xac, 0x8c, 0x20, 0x0b, 0xdd, 0x5d, 0xb1, 0x10, 0x04, +0x78, 0x43, 0x38, 0x3c, 0x8a, 0x2c, 0x7c, 0xe2, 0x28, 0xed, 0xe7, 0xb1, +0x2b, 0x54, 0x2c, 0x20, 0x05, 0x6d, 0x31, 0xb2, 0x2f, 0x44, 0xaa, 0x20, +0x09, 0x7c, 0x2c, 0x34, 0x55, 0x5b, 0xb1, 0x3b, 0x54, 0x56, 0x2c, 0xcd, +0x5d, 0xb1, 0x20, 0x08, 0x9c, 0xbb, 0x20, 0x0b, 0x64, 0x02, 0x28, 0x1c, +0x2a, 0x32, 0x7c, 0x67, 0x10, 0x23, 0xf8, 0x0c, 0x34, 0x14, 0x03, 0x30, +0xcd, 0x04, 0xb1, 0x20, 0x04, 0x64, 0x02, 0x2a, 0x7c, 0x2c, 0x34, 0x44, +0xed, 0x10, 0x01, 0x60, 0x68, 0x3a, 0x6d, 0x04, 0xb0, 0x39, 0xe5, 0x2e, +0xb1, 0x31, 0xcc, 0x04, 0x30, 0x04, 0x00, 0x2a, 0x34, 0xf7, 0x32, 0xec, +0x58, 0x34, 0x3d, 0x99, 0xb0, 0x2f, 0x9d, 0xe0, 0xb0, 0x10, 0x06, 0x98, +0x54, 0x3c, 0xcc, 0x67, 0x20, 0x0c, 0x6d, 0x2c, 0x10, 0x32, 0x6c, 0x2c, +0x36, 0x04, 0x00, 0x30, 0x6d, 0x2c, 0xb0, 0x39, 0xbc, 0x6c, 0x20, 0x73, +0x6c, 0x2c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x74, 0x2c, 0x20, +0x7d, 0x24, 0xb9, 0x20, 0x41, 0xed, 0x2e, 0xb0, 0x10, 0x02, 0x50, 0x86, +0x30, 0x85, 0x1b, 0xb2, 0x37, 0xe5, 0x1f, 0x20, 0x3d, 0x84, 0x1d, 0x10, +0x39, 0xf8, 0x27, 0x20, 0x01, 0xed, 0x2e, 0xb0, 0x20, 0x06, 0xad, 0x8c, +0xb0, 0x10, 0x2c, 0xb0, 0x45, 0x3a, 0x14, 0xed, 0x20, 0x03, 0x14, 0x2a, +0x30, 0x44, 0x8a, 0x32, 0x55, 0x5b, 0xb0, 0x33, 0x64, 0x24, 0x2c, 0xa4, +0xac, 0x20, 0x05, 0x8d, 0x02, 0xb1, 0x31, 0x25, 0xd9, 0xb0, 0x20, 0x0e, +0x64, 0xde, 0x2e, 0x85, 0x56, 0xb0, 0x3d, 0xf5, 0xe7, 0xb1, 0x20, 0x04, +0x44, 0x8f, 0x32, 0xdc, 0x2e, 0x20, 0x03, 0x7c, 0x2c, 0x28, 0x1c, 0x2a, +0x35, 0x3c, 0xb4, 0x20, 0x02, 0xbd, 0x5f, 0xb1, 0x3b, 0x7d, 0x02, 0xb2, +0x20, 0x04, 0x5c, 0x02, 0x2c, 0x54, 0x6a, 0x30, 0xc4, 0x87, 0x30, 0x6c, +0x3b, 0x10, 0x09, 0xf9, 0x3b, 0xb0, 0x10, 0x04, 0x58, 0x1e, 0x26, 0x74, +0x36, 0x39, 0x24, 0xb4, 0x20, 0x0e, 0x6c, 0x2c, 0x34, 0xe4, 0x58, 0x38, +0x1e, 0xc8, 0xb2, 0x20, 0x3c, 0x14, 0xde, 0x20, 0x0b, 0x84, 0x0c, 0x2c, +0x6c, 0x2c, 0x38, 0x0c, 0x6f, 0x20, 0x27, 0x5c, 0x2c, 0x20, 0x00, 0x00, +0x00, 0x00, 0x00, 0xe6, 0x74, 0x2c, 0x20, 0x81, 0xfe, 0xe7, 0xb1, 0x20, +0x20, 0x3f, 0xad, 0x01, 0xb1, 0x2d, 0x84, 0xd4, 0x10, 0x0f, 0x59, 0xd0, +0x20, 0x34, 0x1c, 0xa8, 0x29, 0xdd, 0x84, 0xb0, 0x10, 0x08, 0xf8, 0x5b, +0x10, 0x35, 0x70, 0x2a, 0x20, 0x01, 0x1d, 0xad, 0xb2, 0x3b, 0x4c, 0x51, +0x10, 0x07, 0x48, 0xb7, 0x34, 0x04, 0xb9, 0x20, 0x0d, 0xe4, 0x2e, 0x14, +0x01, 0xbc, 0x20, 0x20, 0x04, 0x7c, 0x85, 0x30, 0xe5, 0x35, 0xb1, 0x37, +0x35, 0x8a, 0xb1, 0x33, 0x0c, 0xb9, 0x20, 0x09, 0x1d, 0x34, 0xb2, 0x33, +0x54, 0x02, 0x20, 0x0d, 0x7c, 0x2c, 0x10, 0x0b, 0xe1, 0xaa, 0xb0, 0x3d, +0x65, 0x2c, 0xb2, 0x3d, 0xf4, 0x29, 0x34, 0x15, 0xb9, 0xb1, 0x10, 0x1a, +0x48, 0xd0, 0x2c, 0x7c, 0x2c, 0x10, 0x0b, 0x80, 0x77, 0x7c, 0x28, 0xec, +0x24, 0x34, 0xac, 0x09, 0x10, 0x17, 0xf1, 0x1b, 0xb2, 0x10, 0x1c, 0x01, +0x37, 0xb0, 0xe4, 0x29, 0x33, 0x54, 0xb1, 0x3e, 0x74, 0xf4, 0x3c, 0x3c, +0x85, 0x20, 0x0b, 0x6d, 0x2c, 0xb2, 0x10, 0x08, 0x80, 0x3e, 0x20, 0x3d, +0x64, 0x2c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x6c, 0x2c, +0x20, 0x55, 0x4c, 0xb9, 0x36, 0xed, 0x76, 0xb2, 0x33, 0x5c, 0x22, 0x30, +0x04, 0xe8, 0x20, 0x35, 0x54, 0x1d, 0x10, 0x18, 0xc0, 0x14, 0x3f, 0x1c, +0xb9, 0x10, 0x13, 0xd0, 0x16, 0x10, 0x2b, 0x79, 0x19, 0xb2, 0x10, 0x04, +0x48, 0x8d, 0x3a, 0x05, 0x59, 0xb1, 0x10, 0x08, 0x09, 0x08, 0xb0, 0x2f, +0x4c, 0x51, 0x3c, 0x0d, 0xb9, 0xb0, 0x10, 0x04, 0x60, 0x08, 0x20, 0x0f, +0x4c, 0x5b, 0x3c, 0x84, 0x2c, 0x2c, 0xbc, 0x5d, 0x28, 0x7c, 0x2c, 0x31, +0x44, 0x58, 0x10, 0x0e, 0xa1, 0xd7, 0xb0, 0x10, 0x1c, 0x69, 0x48, 0xb1, +0x31, 0x3d, 0x02, 0xb1, 0x20, 0x02, 0x6c, 0x27, 0x2a, 0x7d, 0x2c, 0xb1, +0x10, 0x0c, 0x81, 0x68, 0xb1, 0x3f, 0x64, 0x29, 0x2d, 0x2c, 0xb2, 0x20, +0x04, 0x44, 0x31, 0x10, 0x0d, 0x18, 0x90, 0x84, 0x16, 0x10, 0x10, 0xd8, +0xd4, 0x36, 0xc4, 0x67, 0x10, 0x09, 0x60, 0xad, 0x32, 0x7c, 0xef, 0x20, +0x17, 0x6c, 0x2c, 0x20, 0x2f, 0x8c, 0x2c, 0x20, 0x24, 0xfc, 0xf6, 0x20, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x05, 0x00, 0xb1, 0x27, +0x34, 0x25, 0x10, 0x0b, 0x79, 0xff, 0xb0, 0x10, 0x0c, 0x20, 0xa1, 0x2c, +0x8c, 0xe5, 0x20, 0x25, 0xec, 0xe7, 0x2e, 0xac, 0x22, 0x64, 0x00, 0x3c, +0x6d, 0x5b, 0xb1, 0x10, 0x2e, 0x30, 0xe6, 0x20, 0x11, 0xcc, 0x5d, 0x36, +0x44, 0x5b, 0x2a, 0xb4, 0x27, 0x10, 0x0d, 0x00, 0x70, 0xc4, 0x11, 0x17, +0xc2, 0x9e, 0xb1, 0x20, 0x30, 0xd4, 0x58, 0x2a, 0x94, 0x82, 0x2e, 0x3c, +0x5b, 0x10, 0x17, 0x78, 0xb7, 0x30, 0x8c, 0x04, 0x10, 0x03, 0xb8, 0x0a, +0x3e, 0x6d, 0x27, 0xb2, 0x29, 0x25, 0x36, 0xb2, 0x10, 0x0a, 0x58, 0x43, +0x37, 0xec, 0xe4, 0x2f, 0xf5, 0x2e, 0xb0, 0x10, 0x1b, 0x90, 0xd2, 0x10, +0x06, 0xe9, 0x36, 0xb1, 0x2c, 0xa4, 0x02, 0x10, 0x0a, 0x90, 0x3b, 0x10, +0x0d, 0x89, 0x4d, 0xb0, 0x85, 0x3c, 0xb2, 0x2f, 0xec, 0xc2, 0x36, 0x0c, +0xed, 0x3e, 0xb4, 0xc0, 0x20, 0x01, 0x6c, 0x2c, 0x20, 0x0b, 0x6d, 0x98, +0xb2, 0x18, 0x10, 0x60, 0x0b, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x98, 0x6c, 0x2c, 0x10, 0x2d, 0x30, 0xa1, 0x20, 0x4b, 0xec, 0x2e, +0x2c, 0x24, 0x25, 0x32, 0x3c, 0xe3, 0x36, 0x1d, 0xb9, 0xb1, 0x10, 0x29, +0xc8, 0xcf, 0x10, 0x12, 0xa9, 0xa3, 0xb0, 0x10, 0x15, 0x08, 0x61, 0x30, +0x6c, 0x5b, 0x18, 0x0c, 0x09, 0x58, 0xb1, 0x33, 0x35, 0x8a, 0x20, 0x35, +0x64, 0xaf, 0x18, 0x17, 0x78, 0x30, 0x32, 0x74, 0xe5, 0x34, 0x5c, 0x56, +0x38, 0x05, 0x27, 0xb2, 0x10, 0x0b, 0xb0, 0x4a, 0x2f, 0x2c, 0x58, 0x28, +0x04, 0xe8, 0x10, 0x1f, 0xf8, 0x45, 0x3a, 0x6c, 0x2c, 0x2c, 0xfc, 0x2e, +0x15, 0xc0, 0x1e, 0x10, 0x0c, 0x20, 0x1e, 0x10, 0x0d, 0x6a, 0x37, 0xb0, +0x03, 0x2e, 0x44, 0x36, 0x2c, 0x7d, 0x31, 0xb0, 0x20, 0x28, 0x6c, 0x2c, +0x2a, 0x64, 0x02, 0x10, 0x1d, 0x9a, 0xad, 0xb2, 0x20, 0x20, 0x03, 0x64, +0x2c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, 0x6c, 0x2c, +0x10, 0xb1, 0x28, 0xa1, 0x10, 0x39, 0x20, 0xd0, 0x2a, 0x5c, 0x27, 0x10, +0x01, 0x18, 0x08, 0x38, 0x4d, 0xb9, 0xb0, 0x10, 0x1e, 0x50, 0x8d, 0x10, +0x11, 0x90, 0x8a, 0x24, 0xbc, 0x27, 0x18, 0x23, 0xf9, 0x2d, 0x20, 0x35, +0xe4, 0x2e, 0x2e, 0xdd, 0x5d, 0xb1, 0x18, 0x0a, 0xf2, 0x72, 0xb0, 0x20, +0x2c, 0x4c, 0x5b, 0x34, 0x1c, 0x56, 0x32, 0xee, 0xdb, 0xb2, 0x30, 0x20, +0x03, 0x64, 0x02, 0x32, 0x6c, 0x2c, 0x2e, 0x7c, 0x5b, 0x18, 0x0b, 0x68, +0x41, 0x18, 0x06, 0x63, 0x04, 0x30, 0xb2, 0x23, 0x2e, 0xec, 0x5f, 0x18, +0x05, 0xc0, 0x61, 0x10, 0x25, 0xf0, 0x45, 0x20, 0x09, 0x6c, 0x2c, 0x2c, +0x04, 0x00, 0x38, 0x64, 0x94, 0x20, 0x01, 0x5c, 0x2c, 0x20, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x6c, 0x2c, 0x20, 0xaf, 0xdc, 0xb8, +0x2e, 0xac, 0x53, 0x10, 0x10, 0x29, 0x08, 0x10, 0x32, 0xd4, 0x24, 0x18, +0x09, 0x98, 0x3c, 0x20, 0x05, 0x8d, 0x24, 0xb2, 0x10, 0x26, 0xd8, 0x6a, +0x3f, 0x8c, 0x2c, 0x10, 0x14, 0x91, 0x43, 0xb2, 0x10, 0x0e, 0x58, 0x63, +0x2c, 0xe4, 0x2e, 0x10, 0x09, 0x58, 0x17, 0x20, 0x05, 0xd4, 0x2e, 0x30, +0x6c, 0x2c, 0x18, 0x07, 0x48, 0x6e, 0x30, 0x4c, 0x8a, 0x28, 0xdc, 0x87, +0x2a, 0xa5, 0x8c, 0xb0, 0x2f, 0x9d, 0x58, 0xb0, 0x37, 0x3c, 0xe8, 0x20, +0x1f, 0x6c, 0x2c, 0x20, 0x01, 0x94, 0xc0, 0x30, 0x6c, 0x2c, 0x10, 0x09, +0x10, 0x97, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x6c, +0x2c, 0x18, 0xdb, 0xf8, 0x57, 0x10, 0x53, 0x90, 0x2f, 0x10, 0x3b, 0xc8, +0x11, 0x2c, 0x94, 0xe0, 0x26, 0xcc, 0x27, 0x2a, 0xa4, 0x5b, 0x18, 0x05, +0x48, 0x73, 0x2c, 0x04, 0x83, 0x10, 0x03, 0x00, 0x08, 0x3a, 0x14, 0x8a, +0x2c, 0x75, 0x2c, 0xb1, 0x20, 0x14, 0x6c, 0x2c, 0x32, 0xec, 0x2e, 0x2a, +0x6d, 0x5b, 0xb0, 0x2d, 0xc5, 0x8c, 0xb0, 0x18, 0x12, 0xd9, 0x72, 0xb1, +0x37, 0xd5, 0x58, 0xb1, 0x20, 0x22, 0x6c, 0x2c, 0x30, 0xdc, 0x04, 0x25, +0x05, 0x2c, 0x20, 0x2e, 0xbc, 0x85, 0xbc, 0x22, 0xa4, 0x0e, 0x2a, 0xf4, +0x2e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x6c, 0x2c, +0x20, 0xc5, 0x74, 0x2c, 0x20, 0x71, 0x6c, 0x2c, 0x10, 0x0d, 0x69, 0x68, +0xb1, 0x20, 0x10, 0x9c, 0x02, 0x20, 0x0d, 0x1c, 0xb9, 0x28, 0x74, 0x2c, +0x18, 0x11, 0xd1, 0x81, 0xb0, 0x10, 0x18, 0x98, 0x0a, 0x10, 0x05, 0xf0, +0xbe, 0x2e, 0x4c, 0xb9, 0x18, 0x0b, 0x29, 0x89, 0xb2, 0x2d, 0x04, 0xb9, +0x32, 0x0c, 0x8a, 0x10, 0x25, 0xe0, 0x9e, 0x3e, 0x6c, 0x2c, 0x10, 0x03, +0xe1, 0x14, 0xb1, 0x29, 0xec, 0x87, 0x18, 0x05, 0x00, 0x49, 0x25, 0x24, +0x8f, 0x31, 0x0d, 0xb9, 0xb0, 0x2b, 0x0d, 0xb9, 0xb1, 0x20, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x6c, 0x2c, 0x20, 0xbe, 0x74, 0x2c, +0x10, 0x87, 0xa9, 0x11, 0xb0, 0x10, 0x2e, 0xf8, 0x65, 0x10, 0x35, 0x51, +0x32, 0xb1, 0x27, 0x8c, 0x2a, 0x20, 0x0f, 0x44, 0x5b, 0x2a, 0x8c, 0xe0, +0x3c, 0x3c, 0x05, 0x10, 0x01, 0xa1, 0x0f, 0xb1, 0x2b, 0x34, 0x8a, 0x3c, +0x5c, 0x02, 0x20, 0x31, 0x6c, 0x2c, 0x2d, 0x94, 0x8a, 0x31, 0x4e, 0x8a, +0xb1, 0x20, 0x10, 0x05, 0x11, 0xcb, 0xb0, 0x18, 0x08, 0x30, 0x84, 0x20, +0x05, 0x6c, 0x2c, 0x11, 0x00, 0x00 +}; diff --git a/src/help.c b/src/help.c new file mode 100644 index 0000000..7e15bf5 --- /dev/null +++ b/src/help.c @@ -0,0 +1,275 @@ +/* help.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" +#include "version.h" + + +/************************************************************************* +// +**************************************************************************/ + +static lzo_bool head_done = 0; + +void head(void) +{ + FILE *f = con_term; + int fg; + + if (head_done) + return; + head_done = 1; + + fg = con_fg(f,FG_GREEN); + con_fprintf(f, + " Lempel-Ziv-Oberhumer Packer\n" + " Copyright (C) 1996 - 2010\n" + "lzop v%-11s Markus Franz Xaver Johannes Oberhumer %20s\n" + "\n", + LZOP_VERSION_STRING, LZOP_VERSION_DATE); + fg = con_fg(f,fg); + UNUSED(fg); +} + + +/************************************************************************* +// +**************************************************************************/ + +void usage(void) +{ + FILE *f = con_term; + + con_fprintf(f,"Usage: %s [-dxlthIVL%s] [-qvcfFnNPkUp] [-o file] [-S suffix] [%sfile..]\n", progname, +#if defined(USE_LZO1X_1_15) && defined(USE_LZO1X_999) + "19", +#elif defined(USE_LZO1X_1_15) + "1", +#else + "", +#endif +#if defined(__DJGPP__) || defined(__EMX__) + "[@]"); +#else + ""); +#endif +} + + +/************************************************************************* +// +**************************************************************************/ + +void help(void) +{ + FILE *f = con_term; + int fg; + +#ifdef OPT_NAME_DEFAULT + const char *dn = ""; + const char *dN = " (default)"; +#else + const char *dn = " (default)"; + const char *dN = ""; +#endif + + head(); + usage(); + + con_fprintf(f,"\n"); + fg = con_fg(f,FG_YELLOW); + con_fprintf(f,"Commands:\n"); + fg = con_fg(f,fg); + con_fprintf(f, +#if defined(USE_LZO1X_1_15) && defined(USE_LZO1X_999) +" -1 compress faster -9 compress better\n" +#elif defined(USE_LZO1X_1_15) +" -1 compress faster\n" +#endif +" -d decompress -x extract (same as -dPp)\n" +" -l list compressed file -I display system information\n" +" -t test compressed file -V display version number\n" +" -h give this help -L display software license\n" +); + + fg = con_fg(f,FG_YELLOW); + con_fprintf(f,"Options:\n"); + fg = con_fg(f,fg); + + con_fprintf(f, +" -q be quiet -v be verbose\n" +" -c write on standard output -oFILE write output to 'FILE'\n" +" -p write output to current dir -pDIR write to path 'DIR'\n" +" -f force overwrite of output files\n" +" -n do not restore the original file name%s\n" +" -N restore the original file name%s\n" +" -P restore or save the original path and file name\n" +" -S.suf use suffix .suf on compressed files\n" +#if 0 +" -F do *not* store or verify checksum of files (a little bit faster)\n" +#endif +" -U delete input files after successful operation (like gzip and bzip2)\n" +" file.. files to (de)compress. If none given, try standard input.\n" +, dn, dN); + + UNUSED(fg); +} + + +/************************************************************************* +// +**************************************************************************/ + +void license(void) +{ + FILE *f = con_term; + + head(); + +con_fprintf(f, +" lzop and the LZO library are free software; you can redistribute them\n" +" and/or modify them under the terms of the GNU General Public License as\n" +" published by the Free Software Foundation; either version 2 of\n" +" the License, or (at your option) any later version.\n" +"\n" +" This program is distributed in the hope that it will be useful,\n" +" but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +" GNU General Public License for more details.\n" +"\n" +" You should have received a copy of the GNU General Public License\n" +" along with this program; see the file COPYING.\n" +" If not, write to the Free Software Foundation, Inc.,\n" +" 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n" +"\n" +" Markus F.X.J. Oberhumer\n" +" <markus@oberhumer.com>\n" +" http://www.oberhumer.com/opensource/lzop/\n" + ); +} + + +/************************************************************************* +// +**************************************************************************/ + +#ifndef LZOP_BUILD_DATE_TIME +#define LZOP_BUILD_DATE_TIME __DATE__ " " __TIME__ +#endif + +const char lzop_rcsid[] = + "\n$" "Id: lzop " LZOP_VERSION_STRING " built " LZOP_BUILD_DATE_TIME " $\n"; + +LZO_EXTERN(const lzo_bytep) lzo_copyright(void); + +void version(void) +{ + FILE *f = con_term; + char pp[2048]; + const lzo_bytep qq; + char *p, *q, *s; + size_t i; + + head(); + + con_fprintf(f, + "lzop version: v" LZOP_VERSION_STRING ", " LZOP_VERSION_DATE "\n" + "lzop build date: " LZOP_BUILD_DATE_TIME "\n"); + + for (i = 0, qq = lzo_copyright(); i < sizeof(pp)-1 && *qq; i++, qq++) + pp[i] = (char) *qq; + pp[i] = 0; + p = strstr(pp,"LZO version"); + if (p == NULL) + return; + s = strchr(p,'$'); + if (s == NULL) + return; + for (q = s; q > p && q[-1] == '\n'; ) + *--q = 0; + q = strchr(s+1,'$'); + if (q == NULL) + return; + q[1] = 0; + con_fprintf(f,"\n%s\n",p); + con_fprintf(f,"\n%s\n",s); +} + + +/************************************************************************* +// +**************************************************************************/ + +void sysinfo(void) +{ + FILE *f = con_term; + int fg = 0; + const char *env = NULL; + + head(); + +#if defined(HAVE_LOCALTIME) && defined(HAVE_GMTIME) + { + char s[40]; + time_t t; + + t = time(NULL); + tm2str(s, sizeof(s), localtime(&t)); + con_fprintf(f,"Local time is: %s\n",s); + tm2str(s, sizeof(s), gmtime(&t)); + con_fprintf(f,"GMT time is: %s\n\n",s); + } +#endif + +#if defined(OPTIONS_VAR) + env = getenv(OPTIONS_VAR); + if (env && env[0]) + con_fprintf(f,"Contents of environment variable %s: '%s'\n\n", + OPTIONS_VAR, env); + else + con_fprintf(f,"Environment variable '%s' is not set.\n\n", + OPTIONS_VAR); +#endif + +#if defined(USE_FOPEN) + con_fprintf(f,"This version uses stdio for opening files.\n\n"); +#endif + +#if defined(__DJGPP__) + sysinfo_djgpp(); +#endif + + UNUSED(env); + UNUSED(fg); +} + + +/* +vi:ts=4:et +*/ + diff --git a/src/lzop.c b/src/lzop.c new file mode 100644 index 0000000..5571e89 --- /dev/null +++ b/src/lzop.c @@ -0,0 +1,3201 @@ +/* lzop.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" +#include "version.h" + + +/************************************************************************* +// options +**************************************************************************/ + +int opt_cmd = CMD_NONE; +int opt_method = 0; +int opt_level = 0; +int opt_filter = 0; + +int opt_checksum = -1; +int opt_console = CON_INIT; +lzo_bool opt_crc32 = 0; +lzo_bool opt_decompress_safe = 1; +lzo_bool opt_file = 0; +int opt_force = 0; +lzo_bool opt_ignorewarn = 0; +lzo_bool opt_keep = 0; +int opt_num_threads = 1; /* NOT YET IMPLEMENTED */ +#ifdef MAINT +int opt_noheader = 0; +#endif +lzo_bool opt_nowarn = 0; +const char *opt_ls_flags = ""; +int opt_name = -1; +const char *opt_output_name = NULL; +const char *opt_output_path = NULL; +lzo_bool opt_optimize = 0; +lzo_bool opt_path = 0; +lzo_bool opt_restore_mode = 1; +lzo_bool opt_restore_time = 1; +lzo_bool opt_shortname = 0; +int opt_stdin = 0; +lzo_bool opt_stdout = 0; +char opt_suffix[1+SUFFIX_MAX+1] = { 0 }; +lzo_bool opt_unlink = 0; +int opt_verbose = 1; + +static int done_output_name = 0; +static int done_output_path = 0; +static int done_suffix = 0; + +/* invocation options */ +enum { + PGM_LZOP, + PGM_UNLZOP, + PGM_OCAT +}; + +int opt_pgm = PGM_LZOP; + + +const char *argv0 = ""; +const char *progname = ""; +MODE_T u_mask = 0700; +time_t current_time; + +FILE *con_term = NULL; + + +static int num_files = -1; +static int exit_code = EXIT_OK; + +static file_t fi; +static file_t fo; + +static unsigned long total_d_files = 0; +static unsigned long total_c_files = 0; +static lzop_ulong_t total_d_len = 0; +static lzop_ulong_t total_c_len = 0; + +/* some statistics */ +static lzop_ulong_t total_bytes_written = 0; +static lzop_ulong_t total_bytes_read = 0; + + +/************************************************************************* +// exit handlers +**************************************************************************/ + +static void do_exit(void) +{ + static lzo_bool in_exit = 0; + + if (in_exit) + exit(exit_code); + in_exit = 1; + + fflush(con_term); + fflush(stderr); + exit(exit_code); +} + + +#define EXIT_FATAL 3 + +static lzo_bool set_eec(int ec, int *eec) +{ + if (ec == EXIT_FATAL) + { + *eec = EXIT_ERROR; + return 1; + } + else if (ec < 0 || ec == EXIT_ERROR) + { + *eec = EXIT_ERROR; + } + else if (ec == EXIT_WARN) + { + if (!opt_ignorewarn) + if (*eec == EXIT_OK) + *eec = ec; + } + else if (ec == EXIT_OK) + { + /* do nothing */ + } + else + { + assert(0); + } + return 0; +} + +static lzo_bool set_ec(int ec) +{ + return set_eec(ec,&exit_code); +} + + +void e_exit(int ec) +{ + (void) set_ec(ec); + do_exit(); +} + + +void e_usage(void) +{ + usage(); + e_exit(EXIT_USAGE); +} + + +void e_memory(void) +{ + head(); + fflush(con_term); + fprintf(stderr,"%s: out of memory\n", argv0); + e_exit(EXIT_MEMORY); +} + + +void e_method(int m) +{ + fflush(con_term); +#if (UINT_MAX < LZO_0xffffffffL) + /* 16-bit DOS/Windows */ + fprintf(stderr,"%s: 16-bit versions are not officially supported\n", argv0); +#endif + fprintf(stderr,"%s: illegal method option -- %c\n", argv0, m & 255); + e_usage(); +} + + +#if defined(OPTIONS_VAR) +void e_envopt(const char *n) +{ + fflush(con_term); + if (n) + fprintf(stderr,"%s: invalid string '%s' in environment variable '%s'\n", + argv0, n, OPTIONS_VAR); + else + fprintf(stderr,"%s: illegal option in environment variable '%s'\n", + argv0, OPTIONS_VAR); + e_exit(EXIT_USAGE); +} +#endif + + +RETSIGTYPE __acc_cdecl_sighandler e_sighandler(acc_signo_t signo) +{ + UNUSED(signo); + e_exit(EXIT_FATAL); +} + + +/************************************************************************* +// error handlers +**************************************************************************/ + +static void do_error(file_t *ft, const char *n, const char *msg, int ec, int err) +{ + const char *fn; + const char *errmsg; + + fflush(con_term); + if (!(ec == EXIT_WARN && (opt_nowarn || opt_ignorewarn || opt_verbose == 0))) + { + fn = ft && ft->name[0] ? ft->name : UNKNOWN_NAME; + fprintf(stderr, "%s%s: %s: ", n, progname, fn); + if (ec == EXIT_WARN) + fprintf(stderr, "warning: "); + if (err != 0) + { + errmsg = strerror(err); + if (msg && msg[0]) + fprintf(stderr, "%s: %s\n", msg, errmsg); + else + fprintf(stderr, "%s\n", errmsg); + } + else + fprintf(stderr, "%s\n", msg); + fflush(stderr); + } + if (set_ec(ec)) + do_exit(); +} + + +static const char *err_nl = ""; +void set_err_nl(lzo_bool x) +{ + err_nl = x ? "\n" : ""; +} + + +void fatal(file_t *ft, const char *msg) +{ + do_error(ft,err_nl,msg,EXIT_FATAL,0); +} + +void error(file_t *ft, const char *msg) +{ + do_error(ft,err_nl,msg,EXIT_ERROR,0); +} + +void warn(file_t *ft, const char *msg) +{ + do_error(ft,err_nl,msg,EXIT_WARN,0); +} + +void info(file_t *ft, const char *msg) +{ + do_error(ft,err_nl,msg,EXIT_OK,0); +} + +void p_fatal(file_t *ft, const char *msg) +{ + do_error(ft,err_nl,msg,EXIT_FATAL,errno); +} + +void p_error(file_t *ft, const char *msg) +{ + do_error(ft,err_nl,msg,EXIT_ERROR,errno); +} + +void p_warn(file_t *ft, const char *msg) +{ + do_error(ft,err_nl,msg,EXIT_WARN,errno); +} + + +void read_error(file_t *ft) +{ + const char *fn = ft && ft->name[0] ? ft->name : UNKNOWN_NAME; + const char *errmsg = "unexpected end of file"; + if (errno != 0) + errmsg = strerror(errno); + fflush(con_term); + fprintf(stderr, "%s%s: %s: %s\n", err_nl, progname, errmsg, fn); + e_exit(EXIT_FATAL); +} + + +void write_error(file_t *ft) +{ + const char *fn = ft && ft->name[0] ? ft->name : UNKNOWN_NAME; + const char *errmsg = "write error"; + if (errno != 0) + errmsg = strerror(errno); + fflush(con_term); + fprintf(stderr, "%s%s: %s: %s\n", err_nl, progname, errmsg, fn); + e_exit(EXIT_FATAL); +} + + +/************************************************************************* +// file_t +**************************************************************************/ + +void f_reset(file_t *ft) +{ + ft->opt_name = opt_name; + ft->part = 0; + ft->bytes_read = 0; + ft->bytes_written = 0; + ft->warn_multipart = 0; + ft->warn_unknown_suffix = 0; +} + + +void f_init(void) +{ + memset(&fi,0,sizeof(file_t)); + memset(&fo,0,sizeof(file_t)); + fi.fd = -1; + fo.fd = -1; +#if defined(USE_FOPEN) + fi.file = NULL; + fo.file = NULL; +#endif + f_reset(&fi); + f_reset(&fo); +} + + +int f_open(file_t *ft, lzo_bool r) +{ + assert(ft->name[0]); + ft->fd = -1; +#if defined(O_BINARY) + ft->open_flags |= O_BINARY; +#endif +#if (ACC_OS_WIN32 || ACC_OS_WIN64) && defined(_O_SEQUENTIAL) + ft->open_flags |= _O_SEQUENTIAL; +#endif +#if defined(USE_FOPEN) + ft->file = NULL; + if (r) + ft->file = fopen(ft->name,"rb"); + else if (ft->open_flags & O_EXCL) + { + if (file_exists(ft->name)) + errno = EEXIST; + else + ft->file = fopen(ft->name,"wb"); + } + else + ft->file = fopen(ft->name,"wb"); + if (ft->file != NULL) + { + ft->fd = fileno(ft->file); + assert(ft->fd >= 0); + } +#else + if (r) + ft->fd = open(ft->name, ft->open_flags, 0); + else + { +#if defined(O_EXCL_BROKEN) + if ((ft->open_flags & O_EXCL) && file_exists(ft->name)) + errno = EEXIST; + else +#endif + ft->fd = open(ft->name, ft->open_flags, ft->st.st_mode); + } +#endif + if (ft->fd >= 0 && (ft->fd == STDIN_FILENO || ft->fd == STDOUT_FILENO || ft->fd == STDERR_FILENO)) + { + fatal(ft,"sanity check failed: f_open()"); + ft->fd = -1; + } + return ft->fd; +} + + +int f_close(file_t *ft) +{ + int r; + + if (ft->fd < 0) + return 0; + if (ft->fd == STDIN_FILENO || ft->fd == STDOUT_FILENO || ft->fd == STDERR_FILENO) + return 0; +#if defined(USE_FOPEN) + assert(ft->file != NULL); + r = fclose(ft->file); + ft->file = NULL; +#else + r = close(ft->fd); +#endif + ft->fd = -1; + return r; +} + + +/************************************************************************* +// read and write +// handles partial pipe writes and interrupted system calls +**************************************************************************/ + +lzo_int read_buf(file_t *ft, lzo_voidp buffer, lzo_int cnt) +{ + lzo_int n; + long l; + + assert(cnt >= 0 && cnt < LONG_MAX); + l = acc_safe_hread(ft->fd, buffer, (long) cnt); + n = (lzo_int) l; + assert(n >= 0); assert(n == l); + + ft->bytes_read += n; + total_bytes_read += n; + return n; +} + + +void write_buf(file_t *ft, const lzo_voidp buffer, lzo_int cnt) +{ + lzo_int n; + long l; + + assert(cnt >= 0 && cnt < LONG_MAX); + if (ft->fd < 0) + return; + l = acc_safe_hwrite(ft->fd, buffer, (long) cnt); + n = (lzo_int) l; + assert(n >= 0); assert(n == l); + + ft->bytes_written += n; + total_bytes_written += n; + if (n != cnt) + write_error(ft); +} + + +/************************************************************************* +// misc IO +**************************************************************************/ + +static unsigned get_be16(const unsigned char *b) +{ + unsigned v; + + v = (unsigned) b[1] << 0; + v |= (unsigned) b[0] << 8; + return v; +} + +static void set_be16(unsigned char *b, unsigned v) +{ + b[1] = (unsigned char) (v >> 0); + b[0] = (unsigned char) (v >> 8); +} + + +static lzo_uint32 get_be32(const unsigned char *b) +{ + lzo_uint32 v; + + 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; +} + +static void set_be32(unsigned char *b, lzo_uint32 v) +{ + b[3] = (unsigned char) (v >> 0); + b[2] = (unsigned char) (v >> 8); + b[1] = (unsigned char) (v >> 16); + b[0] = (unsigned char) (v >> 24); +} + + +#if 0 /* NOT USED */ +static void write8(file_t *ft, int v) +{ + unsigned char b = (unsigned char) v; + write_buf(ft,&b,1); +} +#endif + + +void read32(file_t *ft, lzo_uint32 *v) +{ + unsigned char b[4]; + if (read_buf(ft,b,4) != 4) + read_error(ft); + *v = get_be32(b); +} + +void write32(file_t *ft, lzo_uint32 v) +{ + unsigned char b[4]; + set_be32(b,v); + write_buf(ft,b,4); +} + + +static int f_read8(file_t *ft, unsigned char *b) +{ + unsigned char bb; + if (read_buf(ft,&bb,1) != 1) + read_error(ft); + ft->f_adler32 = lzo_adler32(ft->f_adler32,&bb,1); + ft->f_crc32 = lzo_crc32(ft->f_crc32,&bb,1); + if (b) + *b = bb; + return bb; +} + +static void f_write8(file_t *ft, int v) +{ + unsigned char b = (unsigned char) v; + write_buf(ft,&b,1); + ft->f_adler32 = lzo_adler32(ft->f_adler32,&b,1); + ft->f_crc32 = lzo_crc32(ft->f_crc32,&b,1); +} + + +static void f_read16(file_t *ft, unsigned *v) +{ + unsigned char b[2]; + if (read_buf(ft,b,2) != 2) + read_error(ft); + ft->f_adler32 = lzo_adler32(ft->f_adler32,b,2); + ft->f_crc32 = lzo_crc32(ft->f_crc32,b,2); + *v = get_be16(b); +} + +static void f_write16(file_t *ft, unsigned v) +{ + unsigned char b[2]; + set_be16(b,v); + write_buf(ft,b,2); + ft->f_adler32 = lzo_adler32(ft->f_adler32,b,2); + ft->f_crc32 = lzo_crc32(ft->f_crc32,b,2); +} + + +static void f_read32(file_t *ft, lzo_uint32 *v) +{ + unsigned char b[4]; + if (read_buf(ft,b,4) != 4) + read_error(ft); + ft->f_adler32 = lzo_adler32(ft->f_adler32,b,4); + ft->f_crc32 = lzo_crc32(ft->f_crc32,b,4); + *v = get_be32(b); +} + +static void f_write32(file_t *ft, lzo_uint32 v) +{ + unsigned char b[4]; + set_be32(b,v); + write_buf(ft,b,4); + ft->f_adler32 = lzo_adler32(ft->f_adler32,b,4); + ft->f_crc32 = lzo_crc32(ft->f_crc32,b,4); +} + + +static void f_write(file_t *ft, const lzo_voidp buf, lzo_int cnt) +{ + if (cnt > 0) + { + write_buf(ft,buf,cnt); + ft->f_adler32 = lzo_adler32(ft->f_adler32,(const lzo_bytep)buf,cnt); + ft->f_crc32 = lzo_crc32(ft->f_crc32,(const lzo_bytep)buf,cnt); + } +} + +static lzo_int f_read(file_t *ft, lzo_voidp buf, lzo_int cnt) +{ + cnt = read_buf(ft,buf,cnt); + if (cnt > 0) + { + ft->f_adler32 = lzo_adler32(ft->f_adler32,(const lzo_bytep)buf,cnt); + ft->f_crc32 = lzo_crc32(ft->f_crc32,(const lzo_bytep)buf,cnt); + } + return cnt; +} + + +/*********************************************************************** +// lzop file signature +************************************************************************/ + +/* + * The first nine bytes of a lzop file always contain the following values: + * + * 0 1 2 3 4 5 6 7 8 + * --- --- --- --- --- --- --- --- --- + * (hex) 89 4c 5a 4f 00 0d 0a 1a 0a + * (decimal) 137 76 90 79 0 13 10 26 10 + * (C notation - ASCII) \211 L Z O \0 \r \n \032 \n + */ + +static const unsigned char lzop_magic[9] = + { 0x89, 0x4c, 0x5a, 0x4f, 0x00, 0x0d, 0x0a, 0x1a, 0x0a }; + +static const char * const header_error[] = { + "[0]", + "not a " PACKAGE " file", /* 1 */ + "header corrupted (checksum error)", /* 2 */ + "header corrupted", /* 3 */ + "header corrupted (DOS -> UNIX conversion ?)", /* 4 */ + "header corrupted (DOS -> Mac conversion ?)", /* 5 */ + "header corrupted (UNIX -> Mac conversion ?)", /* 6 */ + "header corrupted (Mac -> UNIX conversion ?)", /* 7 */ + "header corrupted (UNIX -> DOS conversion ?)", /* 8 */ + "header corrupted (end of line conversion ?)", /* 9 */ + "header corrupted (DOS EOF conversion ?)", /* 10 */ + "header corrupted (transmitted through a 7-bit channel ?)", /* 11 */ + "header corrupted (transmitted in text mode ?)", /* 12 */ + "unknown header flags -- get a newer version of " PACKAGE, /* 13 */ + "unknown compression method -- get a newer version of " PACKAGE, /* 14 */ + "unknown compression level -- get a newer version of " PACKAGE, /* 15 */ + "you need a newer version of " PACKAGE, /* 16 */ + "compression method not supported -- recompile " PACKAGE, /* 17 */ + "decompression method not supported -- recompile " PACKAGE, /* 18 */ + NULL +}; + + +static int check_magic(const unsigned char *magic) +{ + const unsigned char *m; + + if (memcmp(magic,lzop_magic,sizeof(lzop_magic)) == 0) + return 0; + + /* We have a bad magic signature. Try to figure what possibly + * could have gone wrong. */ + + /* look at bytes 1-3: "LZO" in hex and local text format */ + if (memcmp(&magic[1],&lzop_magic[1],3) != 0 && + memcmp(&magic[1],"LZO",3) != 0) + return 1; + + /* look at byte 4 */ + if (magic[4] != lzop_magic[4]) + return 1; + + /* look at bytes 5-8 */ + m = &magic[5]; + if (memcmp(m,"\012\012\032",3) == 0) + return 7; + if (memcmp(m,"\012\012",2) == 0) + return 4; + if (memcmp(m,"\012\032",2) == 0) + return 4; + if (memcmp(m,"\015\012\012",3) == 0) + return 10; + if (memcmp(m,"\015\012\032\012",4) == 0) + return 9; + if (memcmp(m,"\015\012\032\015",4) == 0) + return 8; + if (memcmp(m,"\015\015\012\032",4) == 0) + return 8; + if (memcmp(m,"\015\015\032",3) == 0) + return 6; + if (memcmp(m,"\015\032",2) == 0) + return 5; + if (memcmp(m,&lzop_magic[5],4) != 0) + return 12; + + /* look at byte 0 */ + if (magic[0] == (unsigned char) (lzop_magic[0] & 0x7f)) + return 11; + if (magic[0] != lzop_magic[0]) + return 12; + + return 3; +} + + +/************************************************************************* +// lzop file header +**************************************************************************/ + +void init_compress_header(header_t *h, const file_t *fip, const file_t *fop) +{ + assert(opt_method > 0); + assert(opt_level > 0); + assert(fip->st.st_mode == 0 || S_ISREG(fip->st.st_mode)); + + memset(h,0,sizeof(header_t)); + + h->version = LZOP_VERSION & 0xffff; + h->version_needed_to_extract = opt_filter ? 0x0950: 0x0940; + h->lib_version = lzo_version() & 0xffff; + h->method = (unsigned char) opt_method; + h->level = (unsigned char) opt_level; + h->filter = opt_filter; + + h->flags = 0; + h->flags |= F_OS & F_OS_MASK; + h->flags |= F_CS & F_CS_MASK; + if (opt_filter) + h->flags |= F_H_FILTER; + if (fip->fd == STDIN_FILENO) + h->flags |= F_STDIN; + if (fop->fd == STDOUT_FILENO) + h->flags |= F_STDOUT; + if (!opt_file && num_files > 1) + h->flags |= F_MULTIPART; +#ifdef OPT_NAME_DEFAULT + h->flags |= F_NAME_DEFAULT; +#endif +#ifdef DOSISH + h->flags |= F_DOSISH; +#endif + if (opt_crc32) + { + h->flags |= F_H_CRC32; + if (h->version_needed_to_extract < 0x1001) + h->version_needed_to_extract = 0x1001; + } + + h->mode = fix_mode_for_header(fip->st.st_mode); + + if (fip->st.st_mtime) + { + h->mtime_low = (lzo_uint32) (fip->st.st_mtime); + h->mtime_high = (lzo_uint32) (fip->st.st_mtime >> 16 >> 16); + if ((lzo_int32) h->mtime_high < 0) + h->mtime_high = 0; + } + + if (fip->name[0] && fip->fd != STDIN_FILENO) + { + int r = 0; + if (opt_path) + { + char newname[255+1]; + r = fn_cleanpath(fip->name, newname, sizeof(newname), 0); + if (r > 0 && newname[0] && strlen(newname) <= 255) + { + strcpy(h->name, newname); + h->flags |= F_H_PATH; + if (h->version_needed_to_extract < 0x1001) + h->version_needed_to_extract = 0x1001; + } + else + r = 0; + } + if (r == 0) + { + const char *n = fn_basename(fip->name); + if (n[0] && strlen(n) <= 255) + strcpy(h->name, n); + } + } +} + + +void write_header(file_t *ft, const header_t *h) +{ + size_t l; + +#ifdef MAINT + /* undocumented option '--no-header'. just for testing. */ + if (opt_noheader > 0) + { + switch (opt_noheader) + { + case 1: + write32(ft,h->flags); + break; + case 2: + write32(ft,h->flags); + write8(ft,h->method); + write8(ft,h->level); + break; + default: + /* write no header at all */ + break; + } + return; + } +#endif + + write_buf(ft,lzop_magic,sizeof(lzop_magic)); + + ft->f_adler32 = ADLER32_INIT_VALUE; + ft->f_crc32 = CRC32_INIT_VALUE; + + f_write16(ft,h->version); + f_write16(ft,h->lib_version); + f_write16(ft,h->version_needed_to_extract); + f_write8(ft,h->method); + f_write8(ft,h->level); + f_write32(ft,h->flags); + if (h->flags & F_H_FILTER) + f_write32(ft,h->filter); + f_write32(ft,h->mode); + f_write32(ft,h->mtime_low); + f_write32(ft,h->mtime_high); + + l = strlen(h->name); + assert(l <= 255); + f_write8(ft,(int)l); + if (l > 0) + f_write(ft,h->name,(int)l); + + if (h->flags & F_H_CRC32) + f_write32(ft,ft->f_crc32); + else + f_write32(ft,ft->f_adler32); +} + + +static int read_header(file_t *ft, header_t *h) +{ + int r; + int l; + lzo_uint32 checksum; + + memset(h,0,sizeof(header_t)); + h->version_needed_to_extract = 0x0900; /* first public lzop version */ + h->level = 0; + h->method_name = "unknown"; + + ft->f_adler32 = ADLER32_INIT_VALUE; + ft->f_crc32 = CRC32_INIT_VALUE; + + f_read16(ft,&h->version); + if (h->version < 0x0900) + return 3; + f_read16(ft,&h->lib_version); + if (h->version >= 0x0940) + { + f_read16(ft,&h->version_needed_to_extract); + if (h->version_needed_to_extract > LZOP_VERSION) + return 16; + if (h->version_needed_to_extract < 0x0900) + return 3; + } + f_read8(ft,&h->method); + if (h->version >= 0x0940) + f_read8(ft,&h->level); + f_read32(ft,&h->flags); + if (h->flags & F_H_FILTER) + f_read32(ft,&h->filter); + f_read32(ft,&h->mode); +#if 1 + if (h->flags & F_STDIN) /* do not use mode from stdin compression */ + h->mode = 0; +#endif + f_read32(ft,&h->mtime_low); + if (h->version >= 0x0940) + f_read32(ft,&h->mtime_high); + if (h->version < 0x0120) { + if (h->mtime_low == 0xffffffffUL) + h->mtime_low = 0; + h->mtime_high = 0; + } + + l = f_read8(ft,NULL); + if (l > 0) { + char name[255+1]; + if (f_read(ft,name,l) != l) + read_error(ft); + name[l] = 0; + if (fn_cleanpath(name, h->name, 255+1, 1|2) < 0) + h->name[0] = 0; + } + + checksum = (h->flags & F_H_CRC32) ? ft->f_crc32 : ft->f_adler32; + f_read32(ft,&h->header_checksum); + if (h->header_checksum != checksum) + return 2; + + if (h->method <= 0) + return 14; + r = x_get_method(h); + if (r != 0) + return r; + +/* check reserved flags */ + if (h->flags & F_RESERVED) + return (opt_force >= 2) ? -13 : 13; + +/* skip extra field [not used yet] */ + if (h->flags & F_H_EXTRA_FIELD) + { + lzo_uint32 k; + + /* note: the checksum also covers the length */ + ft->f_adler32 = ADLER32_INIT_VALUE; + ft->f_crc32 = CRC32_INIT_VALUE; + f_read32(ft,&h->extra_field_len); + for (k = 0; k < h->extra_field_len; k++) + (void) f_read8(ft,NULL); + checksum = (h->flags & F_H_CRC32) ? ft->f_crc32 : ft->f_adler32; + f_read32(ft,&h->extra_field_checksum); + if (h->extra_field_checksum != checksum) + return 3; + if (opt_verbose >= 2) + info(ft,"ignoring extra field"); + } + + return 0; +} + + +/* return 0 for valid magic, -1 for EOF, or positive value for error */ +static int p_magic(file_t *ft) +{ + int r; + lzo_int l; + unsigned char magic[sizeof(lzop_magic)]; + + l = read_buf(ft,magic,sizeof(magic)); + if (ft->part > 0 && l <= 0) + return -1; + if (l == (lzo_int) sizeof(magic)) + r = check_magic(magic); + else + r = 1; + assert(r >= 0); + if (ft->part > 0 && r == 1) + { +#if 1 + /* gzip: check for trailing zero bytes */ + unsigned char b; + while (--l >= 0) + if (magic[(int)l] != '\0') + goto garbage; + while (read_buf(ft,&b,1) == 1) + if (b != '\0') + goto garbage; + if (opt_verbose >= 2) + warn(ft,"ignoring trailing zero bytes in " PACKAGE " file"); + return -1; +garbage: +#endif + warn(ft,"ignoring trailing garbage in " PACKAGE " file"); + return -1; + } + if (r != 0) + { + assert(r > 0 && r <= 18); + error(ft,header_error[r]); + } + return r; +} + + +static lzo_bool p_header(file_t *ft, header_t *h) +{ + int r; + + r = read_header(ft,h); + if (r == 0) + return 1; + if (r < 0) + { + r = -r; + assert(r > 0 && r <= 18); + error(ft,header_error[r]); + return 1; + } + else + { + assert(r > 0 && r <= 18); + error(ft,header_error[r]); + return 0; + } +} + + +/************************************************************************* +// test +**************************************************************************/ + +void do_test(const header_t *h, lzop_ulong_t d_len, lzop_ulong_t c_len) +{ + total_d_files++; + total_c_len += c_len; + total_d_len += d_len; + UNUSED(h); +} + + +void do_test_total(void) +{ + FILE *f; + + if ((total_c_files < 2 && total_d_files < 2) || opt_verbose < 2) + return; + + f = stderr; + fprintf(f,"%lu file%s successfully tested", total_c_files, + total_c_files == 1 ? " was" : "s were"); + if (total_c_files != total_d_files) + fprintf(f," [containing %lu files]", total_d_files); + fprintf(f,"\n"); + fflush(f); +} + + +/************************************************************************* +// list a file +**************************************************************************/ + +static unsigned long get_ratio(lzop_ulong_t d_len, lzop_ulong_t c_len) +{ + unsigned long n1 = 1000L * 1000L; + unsigned long n2 = 1; + const lzop_ulong_t umax = ~((lzop_ulong_t)0); + + if (d_len <= 0) + return c_len <= 0 ? 0ul : n1; + while (n1 > 1 && c_len > (umax / n1)) + { + n1 /= 10; + n2 *= 10; + } + return (unsigned long) ((c_len * n1) / (d_len / n2)); +} + + +static void pr_size(FILE *f, lzop_ulong_t a, lzop_ulong_t b, int flags) +{ + unsigned long ratio, r1, r2, al, bl; + + ratio = (flags & 1) ? get_ratio(a, b) : get_ratio(b, a); + ratio += 500; /* for rounding */ + r1 = ratio / 10000; + r2 = (ratio % 10000) / 1000; + +#if (SIZEOF_LONG >= 8) || !defined(acc_int64l_t) + al = (unsigned long) a; + bl = (unsigned long) b; + fprintf(f,"%9lu %9lu %3lu.%01lu%%", al, bl, r1, r2); +#else + al = (unsigned long) (a % 1000000000ul); + bl = (unsigned long) (b % 1000000000ul); + if (a == al && b == bl) + { + fprintf(f,"%9lu %9lu %3lu.%01lu%%", al, bl, r1, r2); + } + else if (a == al) + { + unsigned long bh = (unsigned long) (b / 1000000000ul); + fprintf(f,"%9lu %lu%09lu %3lu.%01lu%%", al, bh, bl, r1, r2); + } + else if (b == bl) + { + unsigned long ah = (unsigned long) (a / 1000000000ul); + fprintf(f,"%lu%09lu %9lu %3lu.%01lu%%", ah, al, bl, r1, r2); + } + else + { + unsigned long ah = (unsigned long) (a / 1000000000ul); + unsigned long bh = (unsigned long) (b / 1000000000ul); + fprintf(f,"%lu%09lu %lu%09lu %3lu.%01lu%%", ah, al, bh, bl, r1, r2); + } +#endif +} + + +static char *modestr(lzo_uint32 mode) +{ + static char s[10+1]; + + mode_string(fix_mode_for_ls(mode),s); + s[0] = '-'; + s[10] = 0; + return s; +} + + +void do_list(const header_t *h, lzop_ulong_t d_len, lzop_ulong_t c_len) +{ + FILE *f; + char s[40]; + time_t t; + + f = stdout; + s[0] = 0; + t = get_mtime(h); + + if (total_d_files == 0 && opt_verbose > 0) + { + if (opt_verbose >= 3) + ((void)0); + else if (opt_verbose >= 2) + { + fprintf(f,"Method Length Packed Ratio "); + fprintf(f," Date Time Name\n"); + fprintf(f,"------ ------ ------ ----- "); + fprintf(f," ---- ---- ----\n"); + } + else + { + fprintf(f,"%-11s ", "method"); + fprintf(f,"compressed uncompr. ratio"); + fprintf(f," uncompressed_name\n"); + } + fflush(f); + } + + if (opt_verbose >= 3) + { + fprintf(f,"%-10s", modestr(h->mode)); + if (t) + time2str(s,sizeof(s),&t); + fprintf(f," %-19s",s); + fprintf(f," %-20s",fi.name); + if (fo.name[0]) + fprintf(f," %s", fo.name); + } + else if (opt_verbose >= 2) + { + fprintf(f,"%-11s ", h->method_name); + pr_size(f, d_len, c_len, 1); + if (t) + time2str(s,sizeof(s),&t); + s[16] = 0; /* cut off seconds */ + fprintf(f," %-16s",s); + if (fo.name[0]) + fprintf(f," %s", fo.name); + } + else + { + fprintf(f,"%-11s ", h->method_name); + pr_size(f, c_len, d_len, 0); + if (fo.name[0]) + fprintf(f," %s", fo.name); + } + + fprintf(f,"\n"); + fflush(f); + + total_d_files++; + total_c_len += c_len; + total_d_len += d_len; +} + + +void do_list_total(void) +{ + FILE *f; + + if (total_d_files < 2 || opt_verbose == 0) + return; + if (opt_verbose >= 3) + return; + + f = stdout; + if (opt_verbose >= 2) + { + fprintf(f," ------- ------- ----- "); + fprintf(f," ----\n"); + fprintf(f,"%-11s ", ""); + pr_size(f, total_d_len, total_c_len, 1); + fprintf(f," %-16s", ""); + fprintf(f," %lu files\n", total_d_files); + } + else + { + fprintf(f,"%-11s ", ""); + pr_size(f, total_c_len, total_d_len, 0); + fprintf(f," (totals -- %lu files)\n", total_d_files); + } + fflush(f); +} + + +/************************************************************************* +// list a file similar to 'ls -ln' +**************************************************************************/ + +void do_ls(const header_t *h, lzop_ulong_t d_len, lzop_ulong_t c_len) +{ + FILE *f; + char s[40]; + time_t t; + const char *name = fo.name[0] ? fo.name : UNKNOWN_NAME; + + f = stdout; + t = get_mtime(h); + if (t == 0) + time(&t); + fprintf(f,"%-10s 1", modestr(h->mode)); + if (opt_stdin) + fprintf(f," %-8s", "user"); + else + fprintf(f," %-8ld", (long) fi.st.st_uid); + if (!strchr(opt_ls_flags,'G')) + { + if (opt_stdin) + fprintf(f," %-8s", "group"); + else + fprintf(f," %-8ld", (long) fi.st.st_gid); + } + +#if (SIZEOF_LONG >= 8) || !defined(acc_int64l_t) + fprintf(f," %8lu", (unsigned long) d_len); +#else + { + unsigned long d0, d1, d2; + d0 = (unsigned long) (d_len % 100000000ul); + if (d0 == d_len) + fprintf(f," %8lu", d0); + else + { + d1 = (unsigned long) ((d_len / 100000000ul) % 100000000ul); + d2 = (unsigned long) ((d_len / 100000000ul) / 100000000ul); + if (d2 != 0) + fprintf(f,"%lu%08lu%08lu", d2, d1, d0); + else + fprintf(f,"%lu%08lu", d1, d0); + } + } +#endif + time2ls(s, sizeof(s), &t); + fprintf(f," %-12s",s); + if (strchr(opt_ls_flags,'Q')) + fprintf(f," \"%s\"", name); + else + fprintf(f," %s", name); + if (strchr(opt_ls_flags,'F')) + if (h->mode & 0111) + fprintf(f,"*"); + fprintf(f,"\n"); + fflush(f); + + UNUSED(c_len); +} + + +/************************************************************************* +// header info +**************************************************************************/ + +static void print_version(FILE *f, unsigned v) +{ + fprintf(f,"%1x.%03x", (v >> 12) & 0xf, v & 0xfff); +} + + +static void print_os(FILE *f, lzo_uint32 flags) +{ + flags = (flags & F_OS_MASK) >> F_OS_SHIFT; + fprintf(f,"%2ld", (long) flags); +} + + +void do_info(const header_t *h, lzop_ulong_t d_len, lzop_ulong_t c_len) +{ + int v = opt_verbose; + FILE *f; + + f = stdout; + opt_verbose = 2; + ++total_d_files; /* do not print the list-header */ + do_list(h,d_len,c_len); + --total_d_files; + opt_verbose = v; + + fprintf(f," "); + print_version(f,h->version); + fprintf(f," "); + print_version(f,h->lib_version); + fprintf(f," "); + print_version(f,h->version_needed_to_extract); + fprintf(f," Fl: 0x%08lx", (long) h->flags); + fprintf(f," Mo: 0%011lo", (long) h->mode); + fprintf(f," Me: %d/%d", h->method, h->level); + fprintf(f," OS: "); + print_os(f,h->flags); + if (h->filter) + fprintf(f," Fi: %3ld", (long) h->filter); + fprintf(f,"\n"); +} + + +/************************************************************************* +// determine name of output file +**************************************************************************/ + +static lzo_bool can_restore_name(file_t *ft, const header_t *h) +{ + if (h->name[0] == 0 || ft->opt_name == 0) + return 0; + else if (ft->opt_name > 0) + return 1; +#ifdef OPT_NAME_DEFAULT +#if 1 + else + return 1; +#else + /* restore the name by default only when created on such a system */ + else if ((h->flags & F_NAME_DEFAULT)) + return 1; + else + return 0; +#endif +#else + /* do not restore the name by default */ + else + return 0; +#endif /* OPT_NAME_DEFAULT */ +} + + +static lzo_bool oname_error(void) +{ + if (opt_force >= 2 || opt_cmd == CMD_TEST) + { + warn(&fi,"can't determine name of output file -- using default"); + return 1; + } + if (opt_name != 1) + error(&fi,"can't determine name of output file (try option '-N')"); + else + error(&fi,"can't determine name of output file (use option '-o')"); + strcpy(fo.name,UNKNOWN_NAME); + return 0; +} + + +static lzo_bool p_set_oname(const header_t *h) +{ + char *base; + char *ext; + int suff; + size_t l; + const char *err_name; + const char *s; + size_t sl; + + fo.name[0] = 0; + if (opt_output_name) + { + /* name given on command line; perform no additional checks */ + strcpy(fo.name,opt_output_name); + return 1; + } + + assert(!opt_stdout); + assert(opt_file); + +#if defined(NRVP) + err_name = (opt_cmd == CMD_COMPRESS) ? "nrvp.nrv" : "nrvp.raw"; + s = opt_suffix[0] ? opt_suffix : ".nrv"; +#else + err_name = (opt_cmd == CMD_COMPRESS) ? "lzop.lzo" : "lzop.raw"; + s = opt_suffix[0] ? opt_suffix : ".lzo"; +#endif + + sl = strlen(s); + + if (opt_output_path) + { + strcpy(fo.name,opt_output_path); + fn_addslash(fo.name,1); + if (!opt_stdin) + strcat(fo.name,fn_basename(fi.name)); + } + else if (!opt_stdin) + strcpy(fo.name,fi.name); + l = strlen(fo.name); + if (l >= PATH_MAX) + { + error(&fo,"name too long (use option '-o')"); + return 0; + } + base = fo.name + fn_baseindex(fo.name); + suff = fn_has_suffix(base); + ext = strchr(base,'.'); + + if (opt_cmd == CMD_COMPRESS) + { + assert(!opt_stdin); + assert(base[0]); +#if defined(DOSISH) + if (suff == SUFF_TAR) + { +#if defined(NRVP) + strcpy(ext, opt_suffix[0] ? opt_suffix : ".tnv"); +#else + strcpy(ext, opt_suffix[0] ? opt_suffix : ".tzo"); +#endif + } + else +#endif + if (opt_shortname && ext) + strcpy(ext,s); + else + strcat(fo.name,s); + } + else + { + lzo_bool u = 0; + + if (can_restore_name(&fi,h)) + { + if (opt_path) + strcpy(base,h->name); + else + strcpy(base,fn_basename(h->name)); + } + else if (opt_stdin) + { + if (!oname_error()) + return 0; + strcpy(base,err_name); + } + else if (suff == SUFF_LZO) + fo.name[l-4] = 0; + else if (suff == SUFF_LZOP) + fo.name[l-5] = 0; + else if (suff == SUFF_NRV) + fo.name[l-4] = 0; + else if (suff == SUFF_TZO) + strcpy(&fo.name[l-4],".tar"); + else if (suff == SUFF_USER) + fo.name[l-sl] = 0; + else + { + u = 1; + if (opt_shortname && ext) + strcpy(ext,".raw"); + else + strcat(fo.name,".raw"); + } + + if (u && opt_cmd == CMD_DECOMPRESS && !opt_stdin) + { +#if 1 + if (!(opt_force >= 2)) + { + if (fi.warn_unknown_suffix == 0) + error(&fi,"unknown suffix -- ignored"); + fi.warn_unknown_suffix = 1; + return 0; + } +#else + /* gzip: '--force' doesn't override these checks */ + if (fi.warn_unknown_suffix == 0) + error(&fi,"unknown suffix -- ignored"); + fi.warn_unknown_suffix = 1; + return 0; +#endif + } + + } + + if (strlen(fo.name) >= PATH_MAX) + { + error(&fo,"name too long (use option '-o')"); + return 0; + } +#if defined(DOSISH) + s = maybe_rename_file(fo.name); + if (s == NULL) + { + if (!oname_error()) + return 0; + strcpy(base,err_name); + } + else if (s != fo.name) + { + if (strcmp(s,fo.name) != 0) + { + warn(&fo,"renaming output file to match OS conventions"); + strcpy(fo.name,s); + } + } +#endif + + UNUSED(ext); + return 1; +} + + +/************************************************************************* +// stdin/stdout +**************************************************************************/ + +static lzo_bool check_stdin(file_t *ft) +{ + if (!opt_force && acc_isatty(STDIN_FILENO)) + { + strcpy(ft->name,STDIN_NAME); + if (opt_cmd == CMD_COMPRESS) + fatal(ft,"uncompressed data not read from a terminal"); + else + fatal(ft,"compressed data not read from a terminal"); + return 0; + } + return 1; +} + + +static lzo_bool check_stdout(file_t *ft) +{ + if (!(opt_cmd == CMD_COMPRESS || opt_cmd == CMD_DECOMPRESS)) + return 1; + if (!opt_force && acc_isatty(STDOUT_FILENO)) + { + strcpy(ft->name,STDOUT_NAME); + if (opt_cmd == CMD_COMPRESS) + fatal(ft,"compressed data not written to a terminal"); + else + fatal(ft,"uncompressed data not written to a terminal"); + return 0; + } + return 1; +} + + +static lzo_bool open_stdin(file_t *ft) +{ + static lzo_bool setmode_done = 0; + + assert(ft->fd == -1); + f_reset(ft); + + strcpy(ft->name,STDIN_NAME); + ft->fd = STDIN_FILENO; + +#if !defined(NO_SETMODE) + if (!setmode_done) + { + if (acc_set_binmode(ft->fd, 1) == -1) + { + p_fatal(ft,"acc_set_binmode(stdin) failed"); + return 0; + } + } +#endif + setmode_done = 1; + + ft->st.st_mtime = time(NULL); +#if 1 && defined(HAVE_FSTAT) + { + struct stat st; + if (fstat(ft->fd, &st) == 0 && S_ISREG(st.st_mode)) + ft->st = st; + } +#endif + ft->st.st_atime = fix_time(ft->st.st_atime); + ft->st.st_mtime = fix_time(ft->st.st_mtime); + return 1; +} + + +static lzo_bool open_stdout(file_t *ft) +{ + static lzo_bool setmode_done = 0; + + assert(ft->fd == -1); + f_reset(ft); + + strcpy(ft->name,STDOUT_NAME); + if (!(opt_cmd == CMD_COMPRESS || opt_cmd == CMD_DECOMPRESS)) + { + ft->fd = -2; /* special file-handle for dummy output */ + return 1; + } + ft->fd = STDOUT_FILENO; + +#if !defined(NO_SETMODE) + if (!setmode_done) + { + if (acc_set_binmode(ft->fd, 1) == -1) + { + p_fatal(ft,"acc_set_binmode(stdout) failed"); + return 0; + } + } +#endif + setmode_done = 1; + + return 1; +} + + +/************************************************************************* +// open input file +**************************************************************************/ + +lzo_bool p_open_fi(const char *name) +{ + int r, saved_errno; +#if defined(HAVE_LSTAT) && defined(S_ISLNK) + int r2; +#endif + + if (fi.fd != -1) + return 1; + + f_reset(&fi); + +/* prepare file name */ + assert(name != NULL); + if (strlen(name) >= PATH_MAX) + { + if (strlen(name) >= sizeof(fi.name)) + strcpy(fi.name,UNKNOWN_NAME); + else + strcpy(fi.name,name); + error(&fi,"name too long"); + return 0; + } + strcpy(fi.name,name); + fn_strlwr(fi.name); + if (opt_cmd == CMD_COMPRESS) + { + int suff = fn_has_suffix(fi.name); +#if 1 + if (opt_stdout || opt_output_name) + suff = SUFF_NONE; /* do not warn */ +#endif +#if 1 + if (opt_force >= 2) + suff = SUFF_NONE; /* do not warn */ +#else + /* gzip: '--force' doesn't override these checks */ +#endif + if (suff == SUFF_LZO) + { + warn(&fi,"already has .lzo suffix -- unchanged"); + return 0; + } + else if (suff == SUFF_LZOP) + { + warn(&fi,"already has .lzop suffix -- unchanged"); + return 0; + } + else if (suff == SUFF_NRV) + { + warn(&fi,"already has .nrv suffix -- unchanged"); + return 0; + } + else if (suff == SUFF_TZO) + { + warn(&fi,"already has .tzo suffix -- unchanged"); + return 0; + } + else if (suff == SUFF_USER) + { + warn(&fi,"already has user suffix -- unchanged"); + return 0; + } + } + +/* open file */ + errno = 0; + r = stat(fi.name, &fi.st); + saved_errno = errno; + if (r != 0) + memset(&fi.st, 0, sizeof(fi.st)); +#if defined(HAVE_LSTAT) && defined(S_ISLNK) + r2 = lstat(fi.name, &fi.lst); + if (r2 != 0) + memset(&fi.lst, 0, sizeof(fi.lst)); + if (r2 == 0 && S_ISLNK(fi.lst.st_mode)) + { + if (r != 0) + { + errno = saved_errno; +#if 0 + p_error(&fi,"can't open input file -- dangling symlink"); +#else + do_error(&fi,err_nl,"can't open input file: Dangling symlink",EXIT_ERROR,0); +#endif + return 0; + } + } +#endif + if (r == 0 && !S_ISREG(fi.st.st_mode)) + { + warn(&fi,"not a regular file -- skipped"); + return 0; + } + fi.open_flags = O_RDONLY; + f_open(&fi,1); +#if 0 && defined(__DJGPP__) + /* try again without LFN */ + if (fi.fd < 0 && errno == ENOENT && _USE_LFN) + { + if (!(_crt0_startup_flags & _CRT0_FLAG_NO_LFN)) + { + int k = _crt0_startup_flags; + _crt0_startup_flags |= _CRT0_FLAG_NO_LFN; + r = stat(fi.name, &fi.st); + saved_errno = errno; + _crt0_startup_flags = k; + if (r == 0 && !S_ISREG(fi.st.st_mode)) + { + warn(&fi,"not a regular file -- skipped"); + return 0; + } + f_open(&fi,1); + } + } +#endif + if (fi.fd < 0) + { + p_error(&fi,"can't open input file"); + return 0; + } + if (r != 0) + { + errno = saved_errno; + p_error(&fi,"can't stat input file"); + (void) f_close(&fi); + return 0; + } + + fi.st.st_atime = fix_time(fi.st.st_atime); + fi.st.st_mtime = fix_time(fi.st.st_mtime); + return 1; +} + + +/************************************************************************* +// open output file +**************************************************************************/ + +lzo_bool p_open_fo(const header_t *h) +{ + if (fo.fd != -1) + return 1; + + f_reset(&fo); + + if (!p_set_oname(h)) + return 0; + fn_strlwr(fo.name); + + if (!(opt_cmd == CMD_COMPRESS || opt_cmd == CMD_DECOMPRESS)) + { + fo.fd = opt_output_name ? -2 : -1; + return 1; + } + + if (fn_is_same_file(fi.name,fo.name)) + { + if (opt_cmd == CMD_COMPRESS) + error(&fi,"can't compress to same file"); + else + error(&fi,"can't decompress to same file"); + return 0; + } + fo.open_flags = O_CREAT | O_WRONLY; + if (opt_force) + fo.open_flags |= O_TRUNC; + else + fo.open_flags |= O_EXCL; +#if defined(__MINT__) + fo.open_flags |= O_TRUNC | O_DENYRW; +#endif + fo.st.st_mode = fix_mode_for_open(fi.st.st_mode); + if (opt_cmd == CMD_DECOMPRESS && opt_path && (h->flags & F_H_PATH)) + { + /* create missing directories */ + char *name; + int n = 0; + name = fo.name; + while (name[n]) + { + while (name[n] && name[n] != '/') + n++; + if (name[n] == '/') + { + name[n] = 0; + (void) acc_mkdir(name, 0777); + name[n] = DIR_SEP[0]; + n++; + } + } + } + f_open(&fo,0); + if (fo.fd < 0) + { + if ((fo.open_flags & O_EXCL) && errno == EEXIST) + error(&fo,"already exists; not overwritten"); + else + p_error(&fo,"can't open output file"); + return 0; + } + + return 1; +} + + +/************************************************************************* +// close files +**************************************************************************/ + +static lzo_bool p_close(int i, int o) +{ + int r = 1; + + if (i && f_close(&fi) != 0) + { + p_error(&fi,"can't close input file"); + r = 0; + } + if (o && f_close(&fo) != 0) + { + p_error(&fo,"can't close output file"); + r = 0; + } + return r; +} + + +/************************************************************************* +// compress +**************************************************************************/ + +static void copy_perms(void) +{ +#if defined(HAVE_UTIME) + /* copy the time stamp */ + struct utimbuf u; + u.actime = fi.st.st_atime; + u.modtime = fi.st.st_mtime; + if (utime(fo.name,&u) != 0) + p_warn(&fo,"can't copy file time"); +#endif +#if defined(HAVE_CHMOD) + /* copy the protection mode */ + fo.st.st_mode = fi.st.st_mode; + if (chmod(fo.name, fo.st.st_mode) != 0) + p_warn(&fo,"can't copy file mode"); +#endif +#if defined(HAVE_CHOWN) + /* copy the ownership */ + if (chown(fo.name, fi.st.st_uid, fi.st.st_gid) != 0) { + /* ignore */ + } +#endif +} + + +static lzo_bool do_compress(const char *name, lzo_bool handle_perms) +{ + lzo_bool ok = 1; + header_t header; + + if (!p_open_fi(name)) + return 0; + if (!p_open_fo(NULL)) + { + if (opt_output_name || opt_stdout) + e_exit(EXIT_ERROR); + return 0; + } + + ok = x_compress(&fi,&fo,&header); + if (!ok) + return 0; + + if (handle_perms) + { + if (!p_close(1,1)) + return 0; + copy_perms(); + } + + return ok; +} + + +/************************************************************************* +// decompress +**************************************************************************/ + +static void restore_perms(const header_t *h) +{ +#if defined(HAVE_UTIME) + /* restore or copy the time stamp */ + struct utimbuf u; + if (opt_restore_time && (h->mtime_low || h->mtime_high)) + { + u.actime = u.modtime = get_mtime(h); + if (u.actime) + if (utime(fo.name,&u) != 0) + p_warn(&fo,"can't restore file time"); + } + else if (fi.st.st_atime && fi.st.st_mtime) + { + u.actime = fi.st.st_atime; + u.modtime = fi.st.st_mtime; + if (utime(fo.name,&u) != 0) + p_warn(&fo,"can't copy file time"); + } +#endif +#if defined(HAVE_CHMOD) + /* restore or copy the protection mode */ + if (opt_restore_mode && h->mode) + { + fo.st.st_mode = fix_mode_for_chmod(h->mode); + if (chmod(fo.name, fo.st.st_mode) != 0) + p_warn(&fo,"can't restore file mode"); + } + else if (fi.st.st_mode > 0) + { + fo.st.st_mode = fi.st.st_mode; + if (chmod(fo.name, fo.st.st_mode) != 0) + p_warn(&fo,"can't copy file mode"); + } +#endif +#if defined(HAVE_CHOWN) + /* copy the ownership */ + if (!opt_stdin) + if (chown(fo.name, fi.st.st_uid, fi.st.st_gid) != 0) { + /* ignore */ + } +#endif + UNUSED(h); +} + + +static lzo_bool warn_multipart(file_t *ft, const header_t *h) +{ + if (!((ft->part > 0) || (h->flags & F_MULTIPART))) + return 1; + + if (opt_stdin && opt_stdout && opt_cmd == CMD_TEST && can_restore_name(ft,h)) + return 1; + if (opt_stdout || opt_output_name) + { + if (!ft->warn_multipart) + warn(&fi,"this is a multipart archive (try option '-N')"); + ft->warn_multipart = 1; + } + else if (opt_file && !can_restore_name(ft,h)) + { + ft->opt_name = 1; + if (opt_cmd == CMD_TEST) + { + if (!ft->warn_multipart) + warn(&fi,"this is a multipart archive (try option '-N')"); + ft->warn_multipart = 1; + } + else if (can_restore_name(ft,h)) + { + if (!ft->warn_multipart) + warn(&fi,"multipart archive -- restoring file names"); + ft->warn_multipart = 1; + } + else + { + error(&fi,"multipart archive, but no filename stored (use option '-o')"); + return 0; + } + } + return 1; +} + + +static lzo_bool do_decompress(const char *name, lzo_bool handle_perms) +{ + lzo_bool ok = 1; + lzo_bool unlink_ok = 1; + lzo_bool skip = 0; + header_t header; + int r; + + if (!p_open_fi(name)) + return 0; + + for ( ; ok; fi.part++) + { + r = p_magic(&fi); + if (r > 0) + return 0; + if (fi.part == 0) + total_c_files++; + if (fi.part > 0 && (opt_file || (r < 0 && handle_perms))) + { + if (!p_close(0,1)) + return 0; + if (!skip && handle_perms && (opt_file || (r < 0 && fi.part == 1))) + restore_perms(&header); + } + if (r < 0) + { + assert(fi.part > 0); + break; + } + + if (!p_header(&fi,&header)) + { + /* use '--info -f -f' to try to list a corrupted header */ + if (opt_cmd == CMD_INFO && opt_force >= 2) + { + (void) x_get_method(&header); + do_info(&header,0,0); + } + return 0; + } + +#if 0 + /* debug */ + do_info(&header,0,0); +#endif + + if (!warn_multipart(&fi,&header)) + return 0; + + skip = 0; + ok = p_open_fo(&header); + if (!ok) + { + unlink_ok = 0; + if (opt_output_name || opt_stdout) + e_exit(EXIT_ERROR); + if (opt_cmd != CMD_TEST) + skip = 1; + } + + ok = x_decompress(&fi,&fo,&header,skip); + } + + return ok && unlink_ok; +} + + +/************************************************************************* +// process files +**************************************************************************/ + +static lzo_bool do_one_file(const char *name, lzo_bool handle_perms) +{ + lzo_bool ok; + + if (opt_cmd == CMD_COMPRESS) + ok = do_compress(name,handle_perms); + else + ok = do_decompress(name,handle_perms); + + if (!p_close(1,0)) + ok = 0; + if (opt_file && !p_close(0,1)) + ok = 0; + + if (ok && opt_unlink) + { +#if defined(HAVE_CHMOD) + (void) chmod(fi.name, 0777); +#endif + if (unlink(fi.name) != 0) + p_warn(&fi,"can't unlink file"); + } + + if (fi.fd == -1) + fi.name[0] = 0; + if (fo.fd == -1) + fo.name[0] = 0; + + return ok; +} + + +static void do_files(int i, int argc, char *argv[]) +{ + lzo_bool handle_perms; + + if (opt_cmd == CMD_COMPRESS) + handle_perms = !opt_stdin; + else if (opt_cmd == CMD_DECOMPRESS) + handle_perms = 1; + else + handle_perms = 0; + + if (opt_stdin) + { + assert(opt_stdout || opt_output_name || opt_output_path); + assert(i == argc); + assert(num_files == 0); + if (!check_stdin(&fi) || !open_stdin(&fi)) + return; + } + if (opt_stdout) + { + assert(!opt_output_name); + if (!check_stdout(&fo) || !open_stdout(&fo)) + return; + handle_perms = 0; + } + if (opt_output_name) + { + assert(!opt_stdout); + handle_perms &= (num_files == 1); + } + + if (opt_stdin) + do_one_file(NULL,handle_perms); + else + { + for ( ; i < argc; i++) + do_one_file(argv[i],handle_perms); + } + + (void) p_close(1,1); + + if (opt_cmd == CMD_LIST) + do_list_total(); + if (opt_cmd == CMD_TEST) + do_test_total(); +} + + +/************************************************************************* +// check options +**************************************************************************/ + +static void check_not_both(lzo_bool e1, lzo_bool e2, int c1, int c2) +{ + if (e1 && e2) + { + fprintf(stderr,"%s: ",argv0); + fprintf(stderr,"cannot use both '-%c' and '-%c'\n", c1, c2); + e_usage(); + } +} + + +void check_options(int i, int argc) +{ + assert(i <= argc); + + if (opt_keep) + opt_unlink = 0; + if (!(opt_cmd == CMD_COMPRESS || opt_cmd == CMD_DECOMPRESS)) + opt_unlink = 0; + + if (opt_stdin == OPT_STDIN_GUESSED && i != argc) + opt_stdin = 0; + if (opt_stdin) + { + opt_unlink = 0; +#if 0 + /* gzip: always use stdout */ + opt_stdout = 1; +#else + if (!opt_output_name && !opt_output_path) + opt_stdout = 1; +#endif + } + if (opt_stdout) + { + check_not_both(1, opt_output_name != NULL, 'c', 'o'); + check_not_both(1, opt_output_path != NULL, 'c', 'p'); + check_not_both(1, opt_suffix[0] != 0, 'c', 'S'); + opt_output_name = NULL; + opt_output_path = NULL; + opt_suffix[0] = 0; + if (opt_unlink && !opt_force) + { + fprintf(stderr,"%s: both '-c' and '-U' given (use '-f' to force)\n",argv0); + e_usage(); + } + } + if (opt_output_name) + { + check_not_both(1, opt_output_path != NULL, 'o', 'p'); + check_not_both(1, opt_suffix[0] != 0, 'o', 'S'); + opt_output_path = NULL; + opt_suffix[0] = 0; + } + + /* check number of remaining args */ + if (opt_stdin) + { + if (opt_cmd == CMD_COMPRESS && opt_output_path) + { + fprintf(stderr,"%s: cannot use '-p' when compressing stdin\n",argv0); + e_usage(); + } + + /* No more args allowed */ + if (i != argc) + { + fprintf(stderr,"%s: no filename allowed when reading from stdin\n",argv0); + e_usage(); + } + } + else + { + if (i == argc) + { + fprintf(stderr,"%s: nothing to do !\n",argv0); + e_usage(); + } + + if (opt_stdout || opt_output_name) + { +#if 1 + /* Allow multiple files */ + if (i + 1 != argc) + { + opt_name = 1; + } +#else + /* Exactly one input file */ + if (i + 1 != argc) + { + fprintf(stderr,"%s: only one file allowed\n",argv0); + e_usage(); + } +#endif + } + } + + opt_file = !opt_stdout && !opt_output_name; +} + + +/************************************************************************* +// misc +**************************************************************************/ + +void e_help(void) +{ + if (opt_pgm == PGM_LZOP) + help(); + else if (opt_pgm == PGM_UNLZOP) + help(); + else if (opt_pgm == PGM_OCAT) + { + if (opt_stdin) + check_stdin(&fi); + if (opt_stdout) + check_stdout(&fo); + usage(); + } + else + help(); + e_exit(EXIT_USAGE); +} + + +void set_term(FILE *f) +{ + if (f) + con_term = f; + else + con_term = acc_isatty(STDOUT_FILENO) ? stdout : stderr; +} + + +void set_cmd(int cmd) +{ + if (cmd == CMD_COMPRESS && (opt_pgm == PGM_UNLZOP || opt_pgm == PGM_OCAT)) + return; +#if 0 + if (opt_cmd != CMD_NONE && cmd != opt_cmd) + { + fprintf(stderr,"%s: multiple commands given\n",argv0); + e_usage(); + } + opt_cmd = cmd; +#else + /* gzip: commands have a certain priority */ + if (cmd > opt_cmd) + opt_cmd = cmd; +#endif +} + + +lzo_bool set_method(int m, int l) +{ + if (x_set_method(m,l) != 0) + return 0; + set_cmd(CMD_COMPRESS); + return 1; +} + + +void set_output_name(const char *n, lzo_bool allow_m) +{ +#if 1 + if (done_output_name > 0) + { + fprintf(stderr,"%s: option '-o' more than once given\n",argv0); + e_usage(); + } +#endif + if (!n || !n[0] || (!allow_m && n[0] == '-')) + { + fprintf(stderr,"%s: missing output name\n",argv0); + e_usage(); + } + if (strlen(n) >= PATH_MAX) + { + fprintf(stderr,"%s: output name too long\n",argv0); + e_usage(); + } + opt_output_name = n; + done_output_name++; +} + + +void set_output_path(const char *n, lzo_bool allow_m) +{ + int r; + struct stat st; + file_t f; + +#if 1 + if (done_output_path > 0) + { + fprintf(stderr,"%s: option '-p' more than once given\n",argv0); + e_usage(); + } +#endif + if (!n || (!allow_m && n[0] == '-')) + { + fprintf(stderr,"%s: missing path\n",argv0); + e_usage(); + } + if (strlen(n) >= PATH_MAX) + { + fprintf(stderr,"%s: path too long\n",argv0); + e_usage(); + } + if (n[0]) + { + r = stat(n, &st); + if (r != 0) + { + strcpy(f.name,n); + p_fatal(&f,"invalid path"); + } +#if defined(S_ISDIR) + if (!S_ISDIR(st.st_mode)) + { + strcpy(f.name,n); + fatal(&f,"invalid path - must be a directory"); + } +#endif + } +#if defined(HAVE_ACCESS) && defined(W_OK) + { + const char *p = n[0] ? n : "."; + if (access(p,W_OK) != 0) + { + strcpy(f.name,p); + p_fatal(&f,"can't write to path"); + } + } +#endif + opt_output_path = n; + done_output_path++; +} + + +lzo_bool set_suffix(const char *n) +{ + size_t l; + const char *p; + static const char * const invalid_suffixes[] = + { "ace", "arc", "arj", "bz", "bz2", "gz", "lha", "lzh", +#if !defined(NRVP) + "nrv", "tnv", +#endif + "rar", "raw", "sz", "tar", "taz", "tbz", "tgz", "tsz", + "upx", "Z", "zip", "zoo", NULL }; + const char * const *is = invalid_suffixes; + +#if 1 + if (done_suffix > 0) + { + fprintf(stderr,"%s: option '-S' more than once given\n",argv0); + e_usage(); + return 0; + } +#endif + while (n && *n == '.') + n++; + + if (!n || *n == 0 || *n == '-') + return 0; +#if 1 || defined(DOSISH) + if (strchr(n,'.')) + return 0; +#endif + for (p = n; *p; p++) + if (strchr("+*?=/\\ \t\n\r\a", *p)) + return 0; + for ( ; *is; is++) + if (strcasecmp(n,*is) == 0) + return 0; + + l = strlen(n); + if (l + 1 > SUFFIX_MAX || (opt_shortname && l > 3)) + { + fprintf(stderr,"%s: suffix '%s' is too long\n",argv0,n); + e_usage(); + return 0; + } + + opt_suffix[0] = '.'; + strcpy(opt_suffix + 1, n); + done_suffix++; + return 1; +} + + +/************************************************************************* +// get options +**************************************************************************/ + +static +char* prepare_shortopts(char *buf, const char *n, + const struct acc_getopt_longopt_t *longopts) +{ + char *o = buf; + + for ( ; n && *n; n++) + if (*n != ' ') + *o++ = *n; + *o = 0; + for ( ; longopts && longopts->name; longopts++) + { + int v = longopts->val; + if (v > 0 && v < 256 && strchr(buf,v) == NULL) + { + *o++ = (char) v; + if (longopts->has_arg >= 1) + *o++ = ':'; + if (longopts->has_arg >= 2) + *o++ = ':'; + *o = 0; + } + } + return buf; +} + + +static int do_option(acc_getopt_p g, int optc) +{ +#define mfx_optarg g->optarg + int i = 0; + int m = -1; + + switch (optc) + { + case 'c': + opt_stdout = 1; + break; + case 'C': + opt_checksum = (opt_checksum >= 1) ? opt_checksum + 1 : 1; + opt_decompress_safe = 1; + break; + case 'd': + set_cmd(CMD_DECOMPRESS); + break; + case 'f': + opt_force++; + break; + case 'F': + opt_checksum = 0; + opt_decompress_safe = 0; + break; + case 'h': + case 'H': + case '?': + set_cmd(CMD_HELP); + break; + case 'h'+256: + /* according to GNU standards */ + set_term(stdout); + opt_console = CON_NONE; + help(); + e_exit(EXIT_OK); + break; + case 'i': + case 'i'+256: + set_cmd(CMD_INFO); + break; + case 'I': + set_cmd(CMD_SYSINFO); + break; + case 'k': + opt_keep = 1; + break; + case 'l': + set_cmd(CMD_LIST); + break; + case 'L': + set_cmd(CMD_LICENSE); + break; + case 'n': + opt_name = 0; + opt_path = 0; + break; + case 'N': + opt_name = 1; + break; + case 'o': + set_output_name(mfx_optarg,1); + break; + case 'p': + case 'p'+256: + if (mfx_optarg && mfx_optarg[0]) + set_output_path(mfx_optarg,0); + else if (optc == 'p') + set_output_path("",0); + else + set_output_path(NULL,0); + break; + case 'P': + opt_path = 1; + opt_name = 1; + break; + case 'q': + opt_verbose = 0; + break; + case 'S': + if (!set_suffix(mfx_optarg)) + { + fprintf(stderr,"%s: invalid suffix '%s'\n",argv0,mfx_optarg); + e_usage(); + } + break; + case 't': + set_cmd(CMD_TEST); + break; + case 'T': + if (!(mfx_optarg && isdigit(mfx_optarg[0]))) + { + fprintf(stderr,"%s: invalid '--threads=' args: '%s'\n",argv0,mfx_optarg); + e_usage(); + } + opt_num_threads = atoi(mfx_optarg); + if (opt_num_threads < 1 || opt_num_threads > MAX_NUM_THREADS) + { + fprintf(stderr,"%s: invalid number of threads: %d\n",argv0,opt_num_threads); + e_usage(); + } +#if !defined(WITH_THREADS) + opt_num_threads = 1; +#endif + break; + case 'U': + opt_unlink = 1; + break; + case 'v': + opt_verbose = (opt_verbose < 2) ? 2 : opt_verbose + 1; + break; + case 'V': + set_cmd(CMD_VERSION); + break; + case 'V'+256: + /* according to GNU standards */ + set_term(stdout); + opt_console = CON_NONE; + fprintf(stdout,"lzop %s\n",LZOP_VERSION_STRING); + fprintf(stdout,"LZO library %s\n",lzo_version_string()); + fprintf(stdout,"Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer\n"); + e_exit(EXIT_OK); + break; + case 'x': + set_cmd(CMD_DECOMPRESS); + opt_name = 1; + opt_path = 1; + opt_restore_mode = 1; + opt_restore_time = 1; + if (!opt_output_name && !opt_output_path) + { + set_output_path("",0); + --done_output_path; + } + opt_unlink = 0; + break; + case 'Z'+256: + set_cmd(CMD_LS); + if (mfx_optarg && mfx_optarg[0]) + { + opt_ls_flags = mfx_optarg; + for (i = 0; opt_ls_flags[i]; i++) + if (!strchr("FGQ",opt_ls_flags[i])) + { + fprintf(stderr,"%s: invalid '--ls' flags: '%s'\n",argv0,mfx_optarg); + e_usage(); + } + } + break; +#ifdef MAINT + case 520: + opt_noheader++; + break; +#endif + case 522: + opt_stdin = 0; + break; + case 523: + opt_restore_mode = 0; + break; + case 524: + opt_restore_time = 0; + break; + case 525: + opt_nowarn = 1; + break; + case 526: + opt_ignorewarn = 1; + break; + case 527: + opt_crc32 = 1; + break; + + case 512: + opt_console = CON_NONE; + break; + case 513: + opt_console = CON_ANSI_MONO; + break; + case 514: + opt_console = CON_ANSI_COLOR; + break; + case 515: + set_cmd(CMD_INTRO); + break; + + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (!set_method(0,optc - '0')) + e_method(optc); + break; + +#if defined(WITH_NRV) + case 811: + if (m < 0) m = M_NRV1A; + /* fallthrough */ + case 812: + if (m < 0) m = M_NRV1B; + /* fallthrough */ + case 813: + if (m < 0) m = M_NRV2A; + /* fallthrough */ + case 814: + if (m < 0) m = M_NRV2B; + i = 1; + if (mfx_optarg && isdigit(mfx_optarg[0]) && !mfx_optarg[1]) + i = mfx_optarg[0] - '0'; + if (!set_method(m,i)) + e_usage(); + break; +#endif +#if defined(WITH_ZLIB) + case 801: + i = 6; + if (mfx_optarg && mfx_optarg[0] && !mfx_optarg[1]) + i = mfx_optarg[0] - '0'; + if (!set_method(M_ZLIB,i)) + e_usage(); + break; +#endif + + case 521: + if (!(mfx_optarg && isdigit(mfx_optarg[0]))) + { + fprintf(stderr,"%s: invalid '--filter=' args: '%s'\n",argv0,mfx_optarg); + e_usage(); + } + if (strcmp(mfx_optarg,"0") == 0) + { + opt_filter = 0; + break; + } + opt_filter = atoi(mfx_optarg); + if (opt_filter < 1 || opt_filter > 16) + { + fprintf(stderr,"%s: invalid filter: %d\n",argv0,opt_filter); + e_usage(); + } + break; + + case '\0': + return -1; + case ':': + return -2; + default: + fprintf(stderr,"%s: internal error in getopt (%d)\n",argv0,optc); + return -3; + } + + UNUSED(i); + UNUSED(m); + return 0; +#undef mfx_optarg +} + + +static void handle_opterr(acc_getopt_p g, const char *f, void *v) +{ + struct A { va_list ap; }; + struct A *a = (struct A *) v; + fprintf( stderr, "%s: ", g->progname); + if (a) + vfprintf(stderr, f, a->ap); + else + fprintf( stderr, "UNKNOWN GETOPT ERROR"); + fprintf( stderr, "\n"); +} + + +static int get_options(int argc, char **argv) +{ + +static const struct acc_getopt_longopt_t longopts[] = +{ + {"best", 0, 0, '9'}, /* compress better */ + {"decompress", 0, 0, 'd'}, /* decompress */ + {"fast", 0, 0, '1'}, /* compress faster */ + {"help", 0, 0, 'h'+256}, /* give help */ + {"info", 0, 0, 'i'+256}, + {"license", 0, 0, 'L'}, /* display software license */ + {"list", 0, 0, 'l'}, /* list .lzo file contents */ + {"ls", 2, 0, 'Z'+256}, /* list .lzo file contents */ + {"sysinfo", 0, 0, 'I'}, + {"test", 0, 0, 't'}, /* test compressed file integrity */ + {"uncompress", 0, 0, 'd'}, /* decompress */ + {"version", 0, 0, 'V'+256}, /* display version number */ +#if defined(WITH_NRV) + {"nrv1a", 0x22, 0, 811}, + {"nrv2a", 0x22, 0, 813}, + {"nrv2b", 0x22, 0, 814}, +#endif +#if defined(WITH_ZLIB) + {"zlib", 0x22, 0, 801}, +#endif + + {"checksum", 0, 0, 'C'}, + {"crc32", 0x10, 0, 527}, /* use a crc32 checksum instead of adler32 */ + {"delete", 0, 0, 'U'}, + {"extract", 0, 0, 'x'}, + {"filter", 1, 0, 521}, + {"force", 0, 0, 'f'}, /* force overwrite of output file */ + {"ignore-warn",0, 0, 526}, /* ignore any warnings */ + {"keep", 0, 0, 'k'}, + {"name", 0, 0, 'N'}, /* restore original name */ + {"no-checksum",0, 0, 'F'}, +#ifdef MAINT + {"no-header", 0, 0, 520}, +#endif + {"no-mode", 0, 0, 523}, /* don't restore original mode */ + {"no-name", 0, 0, 'n'}, /* don't restore original name */ + {"no-stdin", 0, 0, 522}, + {"no-time", 0, 0, 524}, /* don't restore original time */ + {"no-warn", 0, 0, 525}, /* do not display any warnings */ + {"output", 1, 0, 'o'}, + {"path", 1, 0, 'p'+256}, + {"quiet", 0, 0, 'q'}, /* quiet mode */ + {"silent", 0, 0, 'q'}, /* quiet mode */ + {"stdout", 0, 0, 'c'}, /* write output on standard output */ + {"suffix", 1, 0, 'S'}, /* use given suffix instead of .lzo */ + {"threads", 0x21, 0, 'T'}, /* number of threads */ + {"to-stdout", 0, 0, 'c'}, /* write output on standard output */ + {"unlink", 0, 0, 'U'}, + {"verbose", 0, 0, 'v'}, /* verbose mode */ + + {"no-color", 0, 0, 512}, + {"mono", 0, 0, 513}, + {"color", 0, 0, 514}, + {"intro", 0, 0, 515}, + + { 0, 0, 0, 0 } +}; + + acc_getopt_t mfx_getopt; + int optc; + int i; + char shortopts[128]; + + prepare_shortopts(shortopts, "123456789hH?PVp::", longopts), + acc_getopt_init(&mfx_getopt, 1, argc, argv); + mfx_getopt.progname = argv0; + mfx_getopt.opterr = handle_opterr; + while ((optc = acc_getopt(&mfx_getopt, shortopts, longopts, NULL)) >= 0) + { + if (do_option(&mfx_getopt, optc) != 0) + e_usage(); + } + + /* accept "-" as synonym for stdin */ + for (i = mfx_getopt.optind; i < argc; i++) + if (strcmp(argv[i], "-") == 0) + opt_stdin = OPT_STDIN_REQUESTED; + for (i = mfx_getopt.optind; i < argc; i++) + if (strcmp(argv[i], "-") != 0) + break; + return i; +} + + +#if defined(OPTIONS_VAR) +static void get_envoptions(int argc, char **argv) +{ + +/* only some options are allowed in the environment variable */ + +static const struct acc_getopt_longopt_t longopts[] = +{ + {"best", 0, 0, '9'}, /* compress better */ + {"checksum", 0, 0, 'C'}, + {"crc32", 0x10, 0, 527}, /* use a crc32 checksum instead of adler32 */ + {"delete", 0, 0, 'U'}, + {"fast", 0, 0, '1'}, /* compress faster */ + {"ignore-warn",0, 0, 526}, /* ignore any warnings */ + {"keep", 0, 0, 'k'}, + {"name", 0, 0, 'N'}, /* restore original name */ + {"no-checksum",0, 0, 'F'}, + {"no-mode", 0, 0, 523}, /* don't restore original mode */ + {"no-name", 0, 0, 'n'}, /* don't restore original name */ + {"no-time", 0, 0, 524}, /* don't restore original time */ + {"no-stdin", 0, 0, 522}, + {"no-warn", 0, 0, 525}, /* do not display any warnings */ + {"quiet", 0, 0, 'q'}, /* quiet mode */ + {"silent", 0, 0, 'q'}, /* quiet mode */ + {"threads", 0x21, 0, 'T'}, /* number of threads */ + {"unlink", 0, 0, 'U'}, + {"verbose", 0, 0, 'v'}, /* verbose mode */ + + {"no-color", 0, 0, 512}, + {"mono", 0, 0, 513}, + {"color", 0, 0, 514}, + + { 0, 0, 0, 0 } +}; + + char *env, *p; + int i, optc; + int nargc; + char **nargv = NULL; + static const char sep[] = " \t"; + acc_getopt_t mfx_getopt; + char shortopts[128]; + + env = (char *) getenv(OPTIONS_VAR); + if (env == NULL || !env[0]) + return; + p = (char *) malloc(strlen(env)+1); + if (p == NULL) + return; + strcpy(p,env); + env = p; + + nargc = 1; + for (;;) + { + while (*p && strchr(sep,*p)) + p++; + if (*p == '\0') + break; + nargc++; + while (*p && !strchr(sep,*p)) + p++; + if (*p == '\0') + break; + p++; + } + + if (nargc > 1) + nargv = (char **) calloc(nargc+1,sizeof(char *)); + if (nargv == NULL) + { + free(env); + return; + } + + nargv[0] = argv[0]; + p = env; + nargc = 1; + for (;;) + { + while (*p && strchr(sep,*p)) + p++; + if (*p == '\0') + break; + nargv[nargc++] = p; + while (*p && !strchr(sep,*p)) + p++; + if (*p == '\0') + break; + *p++ = '\0'; + } + nargv[nargc] = NULL; + +#if 0 + /* debug */ + fprintf(stderr,"%3d\n",nargc); + for (i = 0; i <= nargc; i++) + fprintf(stderr,"%3d '%s'\n",i,nargv[i]); +#endif + + for (i = 1; i < nargc; i++) + if (nargv[i][0] != '-' || !nargv[i][1] || strcmp(nargv[i],"--") == 0) + e_envopt(nargv[i]); + + prepare_shortopts(shortopts, "123456789P", longopts); + acc_getopt_init(&mfx_getopt, 1, nargc, nargv); + mfx_getopt.progname = argv0; + mfx_getopt.opterr = handle_opterr; + while ((optc = acc_getopt(&mfx_getopt, shortopts, longopts, NULL)) >= 0) + { + if (do_option(&mfx_getopt, optc) != 0) + e_envopt(NULL); + } + + if (mfx_getopt.optind < nargc) + e_envopt(nargv[mfx_getopt.optind]); + + free(nargv); + free(env); + UNUSED(argc); + + if (opt_checksum) + opt_checksum = -1; /* reset to default */ +} +#endif /* defined(OPTIONS_VAR) */ + + +#define ACC_WANT_ACC_CHK_CH 1 +#undef ACCCHK_ASSERT +#include "miniacc.h" +#undef ACCCHK_ASSERT + +static void sanity_check(void) +{ +#if (ACC_CC_MSC && ((_MSC_VER) < 700)) +#else +#define ACCCHK_ASSERT(expr) ACC_COMPILE_TIME_ASSERT(expr) +#include "miniacc.h" +#endif +#undef ACCCHK_ASSERT +#undef ACC_WANT_ACC_CHK_CH +} + + +/************************************************************************* +// main entry point +**************************************************************************/ + +int __acc_cdecl_main main(int argc, char *argv[]) +{ + int i; + lzo_bool foreground = 0; + static char default_argv0[] = "lzop"; + int cmdline_cmd = CMD_NONE; + + sanity_check(); + +#if defined(__MINT__) + __binmode(1); + __set_binmode(stdout, 0); + __set_binmode(stderr, 0); +#endif + acc_wildargv(&argc, &argv); + + +#if defined(__DJGPP__) + opt_shortname = !_USE_LFN; +#elif (ACC_OS_DOS16 || ACC_OS_WIN16 || ACC_OS_DOS32) + opt_shortname = 1; +#endif + + current_time = fix_time(time(NULL)); + + if (!argv[0] || !argv[0][0]) + argv[0] = default_argv0; + argv0 = argv[0]; + progname = fn_basename(argv0); +#if defined(DOSISH) + if (strcasecmp(progname,"lzop.exe") == 0) + progname = default_argv0; + else if (strcasecmp(progname,"lzop.ttp") == 0) + progname = default_argv0; +#endif + + /* For compatibility with gzip, use program name as an option. */ + if (strncasecmp(progname, "un", 2) == 0) /* unlzop */ + opt_pgm = PGM_UNLZOP; +#if 0 + if (progname[0] && strcasecmp(progname+1, "cat") == 0) /* ocat */ + opt_pgm = PGM_OCAT; +#endif + + set_term(stderr); + opt_stdin = acc_isatty(STDIN_FILENO) ? 0 : OPT_STDIN_GUESSED; + + UNUSED(foreground); +#ifdef SIGINT + foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; + if (foreground) + (void) signal(SIGINT, e_sighandler); +#endif +#ifdef SIGBREAK + if (foreground) + (void) signal(SIGBREAK, e_sighandler); +#endif +#ifdef SIGTERM + if (signal(SIGTERM, SIG_IGN) != SIG_IGN) + (void) signal(SIGTERM, e_sighandler); +#endif +#ifdef SIGHUP + if (signal(SIGHUP, SIG_IGN) != SIG_IGN) + (void) signal(SIGHUP, e_sighandler); +#endif + +#if defined(HAVE_UMASK) + u_mask = (MODE_T) umask(0700); + (void) umask(u_mask); +#endif + u_mask &= 0777; + +#if defined(WITH_LZO) + if (lzo_init() != LZO_E_OK) + { + head(); + fprintf(stderr,"lzo_init() failed - check your LZO installation !\n"); + if (LZO_VERSION != lzo_version()) + fprintf(stderr,"library version conflict (%x, %x) - check your LZO installation !\n", LZO_VERSION, lzo_version()); + e_exit(EXIT_LZO_INIT); + } +#if 0 + if (lzo_version() < LZO_VERSION) + { + head(); + fprintf(stderr,"library version conflict (%x, %x) - check your LZO installation !\n", LZO_VERSION, lzo_version()); + e_exit(EXIT_LZO_INIT); + } +#endif +#endif +#if defined(WITH_NRV) + if (nrv_init() != NRV_E_OK) + { + e_exit(EXIT_LZO_INIT); + } +#endif + + ACC_COMPILE_TIME_ASSERT(sizeof(lzo_uint32) >= 4) +#if defined(SIZEOF_SIZE_T) + ACC_COMPILE_TIME_ASSERT(sizeof(size_t) == SIZEOF_SIZE_T) +#endif + ACC_COMPILE_TIME_ASSERT(sizeof(fi.name) >= 2*(PATH_MAX)) + assert(STDIN_FILENO >= 0); + assert(STDOUT_FILENO >= 0); + assert(STDERR_FILENO >= 0); + + f_init(); +#if defined(OPTIONS_VAR) + get_envoptions(argc,argv); +#endif + assert(cmdline_cmd == CMD_NONE); + i = get_options(argc,argv); + assert(i <= argc); + + set_term(NULL); + cmdline_cmd = opt_cmd; + switch (opt_cmd) + { + case CMD_NONE: + /* For compatibility with gzip, use program name as an option. */ + if (opt_pgm == PGM_UNLZOP) + { + set_cmd(CMD_DECOMPRESS); + break; + } +#if 0 + if (opt_pgm == PGM_OCAT) + { + set_cmd(CMD_DECOMPRESS); + if (i == argc) + opt_stdin = OPT_STDIN_REQUESTED; + if (!opt_output_name) + opt_stdout = 1; + break; + } +#endif + /* default - compress */ + if (!set_method(0,3)) + e_method('3'); + break; + case CMD_COMPRESS: + break; + case CMD_DECOMPRESS: + break; + case CMD_TEST: + opt_checksum = 1; + opt_decompress_safe = 1; + break; + case CMD_LIST: + break; + case CMD_LS: + break; + case CMD_INFO: + break; + case CMD_SYSINFO: + sysinfo(); + e_exit(EXIT_OK); + break; + case CMD_LICENSE: + license(); + e_exit(EXIT_OK); + break; + case CMD_HELP: + help(); + e_exit(EXIT_OK); + break; + case CMD_INTRO: + opt_console = CON_SCREEN; + (void) ((con_intro(con_term) || (help(), 0))); + e_exit(EXIT_OK); + case CMD_VERSION: + version(); + e_exit(EXIT_OK); + break; + default: + /* ??? */ + break; + } + + if (opt_cmd != CMD_COMPRESS) + { + opt_method = 0; + opt_level = 0; + opt_filter = 0; + } + + if (!opt_stdin && !opt_stdout && opt_verbose > 0) + { + if (argc == 1) + { + /* no arguments */ + (void) (opt_pgm == PGM_LZOP && con_intro(con_term)); + e_help(); + } +#if 0 + else if (cmdline_cmd == CMD_NONE && i == argc) + { + /* no command and no file */ + e_help(); + } +#endif + } + + set_term(stderr); + check_options(i,argc); + num_files = argc - i; + + if (!x_enter(NULL)) + e_memory(); + + do_files(i,argc,argv); + + x_leave(NULL); + do_exit(); + return exit_code; +} + + +/* +vi:ts=4:et +*/ + diff --git a/src/mblock.c b/src/mblock.c new file mode 100644 index 0000000..09566cd --- /dev/null +++ b/src/mblock.c @@ -0,0 +1,106 @@ +/* mblock.c -- aligned memory blocks (cache issues) + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + + +/************************************************************************* +// +**************************************************************************/ + +static void do_init(mblock_p m, lzo_uint32 size, lzo_uint align) +{ + memset(m,0,sizeof(*m)); + m->mb_size = size; + m->mb_align = (align > 1) ? align : 1; + assert((m->mb_align & (m->mb_align - 1)) == 0); + m->mb_adler32 = ADLER32_INIT_VALUE; + m->mb_crc32 = CRC32_INIT_VALUE; +} + + +#if 0 +lzo_bool mb_init(mblock_p m, lzo_uint32 size, lzo_uint align, + lzo_voidp heap, lzo_uint32 heap_size) +{ + do_init(m,size,align); + if (m->mb_size == 0) + return 1; + + if (heap == 0) + return 0; + m->mb_mem_alloc = (lzo_bytep) heap; + m->mb_size_alloc = heap_size; + assert(m->mb_size_alloc >= m->mb_size + m->mb_align - 1); + + m->mb_mem = LZO_PTR_ALIGN_UP(m->mb_mem_alloc,m->mb_align); + assert(m->mb_mem >= m->mb_mem_alloc); + assert(m->mb_mem + m->mb_size <= m->mb_mem_alloc + m->mb_size_alloc); +#if 0 + printf("m_init: %p %p %8ld %8ld %8ld\n", m->mb_mem_alloc, m->mb_mem, + (long) m->mb_size_alloc, (long) m->mb_size, (long) m->mb_align); +#endif + return 1; +} +#endif + + +lzo_bool mb_alloc(mblock_p m, lzo_uint32 size, lzo_uint align) +{ + do_init(m,size,align); + if (m->mb_size == 0) + return 1; + + m->mb_size_alloc = m->mb_size + m->mb_align - 1; + m->mb_mem_alloc = (lzo_bytep) acc_halloc(m->mb_size_alloc); + if (m->mb_mem_alloc == NULL) + return 0; + acc_hmemset(m->mb_mem_alloc, 0, m->mb_size_alloc); + + m->mb_mem = LZO_PTR_ALIGN_UP(m->mb_mem_alloc,m->mb_align); + assert(m->mb_mem >= m->mb_mem_alloc); + assert(m->mb_mem + m->mb_size <= m->mb_mem_alloc + m->mb_size_alloc); +#if 0 + printf("m_alloc: %p %p %8ld %8ld %8ld\n", m->mb_mem_alloc, m->mb_mem, + (long) m->mb_size_alloc, (long) m->mb_size, (long) m->mb_align); +#endif + return 1; +} + + +void mb_free(mblock_p m) +{ + acc_hfree(m->mb_mem_alloc); + memset(m,0,sizeof(*m)); +} + + +/* +vi:ts=4:et +*/ + diff --git a/src/miniacc.h b/src/miniacc.h new file mode 100644 index 0000000..9170c23 --- /dev/null +++ b/src/miniacc.h @@ -0,0 +1,6921 @@ +/* ACC --- Automatic Compiler Configuration + + This file is part of the lzop file compressor. + + 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. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#ifndef __ACC_H_INCLUDED +#define __ACC_H_INCLUDED 1 +#define ACC_VERSION 20101019L +#if defined(__CYGWIN32__) && !defined(__CYGWIN__) +# define __CYGWIN__ __CYGWIN32__ +#endif +#if defined(__IBMCPP__) && !defined(__IBMC__) +# define __IBMC__ __IBMCPP__ +#endif +#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) +# define __INTEL_COMPILER __ICL +#endif +#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) +# define _ALL_SOURCE 1 +#endif +#if defined(__mips__) && defined(__R5900__) +# if !defined(__LONG_MAX__) +# define __LONG_MAX__ 9223372036854775807L +# endif +#endif +#if defined(__INTEL_COMPILER) && defined(__linux__) +# pragma warning(disable: 193) +#endif +#if defined(__KEIL__) && defined(__C166__) +# pragma warning disable = 322 +#elif 0 && defined(__C251__) +# pragma warning disable = 322 +#endif +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) +# if (_MSC_VER >= 1300) +# pragma warning(disable: 4668) +# endif +#endif +#if defined(__POCC__) && defined(_WIN32) +# if (__POCC__ >= 400) +# pragma warn(disable: 2216) +# endif +#endif +#if 0 && defined(__WATCOMC__) +# if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) +# pragma warning 203 9 +# endif +#endif +#if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) +# pragma option -h +#endif +#if (ACC_CFG_NO_CONFIG_HEADER) +#elif defined(ACC_CFG_CONFIG_HEADER) +# include ACC_CFG_CONFIG_HEADER +#else +#endif +#if (ACC_CFG_NO_LIMITS_H) +#elif (ACC_LIBC_NAKED) || (ACC_BROKEN_LIMITS_H) +#ifndef __ACC_FALLBACK_LIMITS_H_INCLUDED +#define __ACC_FALLBACK_LIMITS_H_INCLUDED 1 +#undef CHAR_BIT +#define CHAR_BIT 8 +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 1 +#endif +#ifndef __SCHAR_MAX__ +#define __SCHAR_MAX__ 127 +#endif +#ifndef __SHRT_MAX__ +#define __SHRT_MAX__ 32767 +#endif +#ifndef __INT_MAX__ +#define __INT_MAX__ 2147483647 +#endif +#ifndef __LONG_MAX__ +#if defined(__alpha__) || defined(_LP64) || defined(__MIPS_PSX2__) +#define __LONG_MAX__ 9223372036854775807L +#else +#define __LONG_MAX__ 2147483647L +#endif +#endif +#undef SCHAR_MIN +#undef SCHAR_MAX +#undef UCHAR_MAX +#define SCHAR_MIN (-1 - SCHAR_MAX) +#define SCHAR_MAX (__SCHAR_MAX__) +#define UCHAR_MAX (SCHAR_MAX * 2 + 1) +#undef SHRT_MIN +#undef SHRT_MAX +#undef USHRT_MAX +#define SHRT_MIN (-1 - SHRT_MAX) +#define SHRT_MAX (__SHRT_MAX__) +#if ((__INT_MAX__) == (__SHRT_MAX__)) +#define USHRT_MAX (SHRT_MAX * 2U + 1U) +#else +#define USHRT_MAX (SHRT_MAX * 2 + 1) +#endif +#undef INT_MIN +#undef INT_MAX +#undef UINT_MAX +#define INT_MIN (-1 - INT_MAX) +#define INT_MAX (__INT_MAX__) +#define UINT_MAX (INT_MAX * 2U + 1U) +#undef LONG_MIN +#undef LONG_MAX +#undef ULONG_MAX +#define LONG_MIN (-1L - LONG_MAX) +#define LONG_MAX ((__LONG_MAX__) + 0L) +#define ULONG_MAX (LONG_MAX * 2UL + 1UL) +#undef CHAR_MIN +#undef CHAR_MAX +#if defined(__CHAR_UNSIGNED__) || defined(_CHAR_UNSIGNED) +#define CHAR_MIN 0 +#define CHAR_MAX UCHAR_MAX +#else +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX SCHAR_MAX +#endif +#endif +#else +# include <limits.h> +#endif +#if 0 +#define ACC_0xffffL 0xfffful +#define ACC_0xffffffffL 0xfffffffful +#else +#define ACC_0xffffL 65535ul +#define ACC_0xffffffffL 4294967295ul +#endif +#if (ACC_0xffffL == ACC_0xffffffffL) +# error "your preprocessor is broken 1" +#endif +#if (16ul * 16384ul != 262144ul) +# error "your preprocessor is broken 2" +#endif +#if 0 +#if (32767 >= 4294967295ul) +# error "your preprocessor is broken 3" +#endif +#if (65535u >= 4294967295ul) +# error "your preprocessor is broken 4" +#endif +#endif +#if (UINT_MAX == ACC_0xffffL) +#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) +# if !defined(MSDOS) +# define MSDOS 1 +# endif +# if !defined(_MSDOS) +# define _MSDOS 1 +# endif +#elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) +# if (__VERSION == 520) && (MB_LEN_MAX == 1) +# if !defined(__AZTEC_C__) +# define __AZTEC_C__ __VERSION +# endif +# if !defined(__DOS__) +# define __DOS__ 1 +# endif +# endif +#endif +#endif +#if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == ACC_0xffffL) +# define ptrdiff_t long +# define _PTRDIFF_T_DEFINED 1 +#endif +#if (UINT_MAX == ACC_0xffffL) +# undef __ACC_RENAME_A +# undef __ACC_RENAME_B +# if defined(__AZTEC_C__) && defined(__DOS__) +# define __ACC_RENAME_A 1 +# elif defined(_MSC_VER) && defined(MSDOS) +# if (_MSC_VER < 600) +# define __ACC_RENAME_A 1 +# elif (_MSC_VER < 700) +# define __ACC_RENAME_B 1 +# endif +# elif defined(__TSC__) && defined(__OS2__) +# define __ACC_RENAME_A 1 +# elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) +# define __ACC_RENAME_A 1 +# elif defined(__PACIFIC__) && defined(DOS) +# if !defined(__far) +# define __far far +# endif +# if !defined(__near) +# define __near near +# endif +# endif +# if defined(__ACC_RENAME_A) +# if !defined(__cdecl) +# define __cdecl cdecl +# endif +# if !defined(__far) +# define __far far +# endif +# if !defined(__huge) +# define __huge huge +# endif +# if !defined(__near) +# define __near near +# endif +# if !defined(__pascal) +# define __pascal pascal +# endif +# if !defined(__huge) +# define __huge huge +# endif +# elif defined(__ACC_RENAME_B) +# if !defined(__cdecl) +# define __cdecl _cdecl +# endif +# if !defined(__far) +# define __far _far +# endif +# if !defined(__huge) +# define __huge _huge +# endif +# if !defined(__near) +# define __near _near +# endif +# if !defined(__pascal) +# define __pascal _pascal +# endif +# elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) +# if !defined(__cdecl) +# define __cdecl cdecl +# endif +# if !defined(__pascal) +# define __pascal pascal +# endif +# endif +# undef __ACC_RENAME_A +# undef __ACC_RENAME_B +#endif +#if (UINT_MAX == ACC_0xffffL) +#if defined(__AZTEC_C__) && defined(__DOS__) +# define ACC_BROKEN_CDECL_ALT_SYNTAX 1 +#elif defined(_MSC_VER) && defined(MSDOS) +# if (_MSC_VER < 600) +# define ACC_BROKEN_INTEGRAL_CONSTANTS 1 +# endif +# if (_MSC_VER < 700) +# define ACC_BROKEN_INTEGRAL_PROMOTION 1 +# define ACC_BROKEN_SIZEOF 1 +# endif +#elif defined(__PACIFIC__) && defined(DOS) +# define ACC_BROKEN_INTEGRAL_CONSTANTS 1 +#elif defined(__TURBOC__) && defined(__MSDOS__) +# if (__TURBOC__ < 0x0150) +# define ACC_BROKEN_CDECL_ALT_SYNTAX 1 +# define ACC_BROKEN_INTEGRAL_CONSTANTS 1 +# define ACC_BROKEN_INTEGRAL_PROMOTION 1 +# endif +# if (__TURBOC__ < 0x0200) +# define ACC_BROKEN_SIZEOF 1 +# endif +# if (__TURBOC__ < 0x0400) && defined(__cplusplus) +# define ACC_BROKEN_CDECL_ALT_SYNTAX 1 +# endif +#elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) +# define ACC_BROKEN_CDECL_ALT_SYNTAX 1 +# define ACC_BROKEN_SIZEOF 1 +#endif +#endif +#if defined(__WATCOMC__) && (__WATCOMC__ < 900) +# define ACC_BROKEN_INTEGRAL_CONSTANTS 1 +#endif +#if defined(_CRAY) && defined(_CRAY1) +# define ACC_BROKEN_SIGNED_RIGHT_SHIFT 1 +#endif +#define ACC_PP_STRINGIZE(x) #x +#define ACC_PP_MACRO_EXPAND(x) ACC_PP_STRINGIZE(x) +#define ACC_PP_CONCAT2(a,b) a ## b +#define ACC_PP_CONCAT3(a,b,c) a ## b ## c +#define ACC_PP_CONCAT4(a,b,c,d) a ## b ## c ## d +#define ACC_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e +#define ACC_PP_ECONCAT2(a,b) ACC_PP_CONCAT2(a,b) +#define ACC_PP_ECONCAT3(a,b,c) ACC_PP_CONCAT3(a,b,c) +#define ACC_PP_ECONCAT4(a,b,c,d) ACC_PP_CONCAT4(a,b,c,d) +#define ACC_PP_ECONCAT5(a,b,c,d,e) ACC_PP_CONCAT5(a,b,c,d,e) +#if 1 +#define ACC_CPP_STRINGIZE(x) #x +#define ACC_CPP_MACRO_EXPAND(x) ACC_CPP_STRINGIZE(x) +#define ACC_CPP_CONCAT2(a,b) a ## b +#define ACC_CPP_CONCAT3(a,b,c) a ## b ## c +#define ACC_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d +#define ACC_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e +#define ACC_CPP_ECONCAT2(a,b) ACC_CPP_CONCAT2(a,b) +#define ACC_CPP_ECONCAT3(a,b,c) ACC_CPP_CONCAT3(a,b,c) +#define ACC_CPP_ECONCAT4(a,b,c,d) ACC_CPP_CONCAT4(a,b,c,d) +#define ACC_CPP_ECONCAT5(a,b,c,d,e) ACC_CPP_CONCAT5(a,b,c,d,e) +#endif +#define __ACC_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) +#if 1 && defined(__cplusplus) +# if !defined(__STDC_CONSTANT_MACROS) +# define __STDC_CONSTANT_MACROS 1 +# endif +# if !defined(__STDC_LIMIT_MACROS) +# define __STDC_LIMIT_MACROS 1 +# endif +#endif +#if defined(__cplusplus) +# define ACC_EXTERN_C extern "C" +#else +# define ACC_EXTERN_C extern +#endif +#if !defined(__ACC_OS_OVERRIDE) +#if (ACC_OS_FREESTANDING) +# define ACC_INFO_OS "freestanding" +#elif (ACC_OS_EMBEDDED) +# define ACC_INFO_OS "embedded" +#elif 1 && defined(__IAR_SYSTEMS_ICC__) +# define ACC_OS_EMBEDDED 1 +# define ACC_INFO_OS "embedded" +#elif defined(__CYGWIN__) && defined(__GNUC__) +# define ACC_OS_CYGWIN 1 +# define ACC_INFO_OS "cygwin" +#elif defined(__EMX__) && defined(__GNUC__) +# define ACC_OS_EMX 1 +# define ACC_INFO_OS "emx" +#elif defined(__BEOS__) +# define ACC_OS_BEOS 1 +# define ACC_INFO_OS "beos" +#elif defined(__Lynx__) +# define ACC_OS_LYNXOS 1 +# define ACC_INFO_OS "lynxos" +#elif defined(__OS400__) +# define ACC_OS_OS400 1 +# define ACC_INFO_OS "os400" +#elif defined(__QNX__) +# define ACC_OS_QNX 1 +# define ACC_INFO_OS "qnx" +#elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) +# define ACC_OS_DOS32 1 +# define ACC_INFO_OS "dos32" +#elif defined(__BORLANDC__) && defined(__DPMI16__) +# define ACC_OS_DOS16 1 +# define ACC_INFO_OS "dos16" +#elif defined(__ZTC__) && defined(DOS386) +# define ACC_OS_DOS32 1 +# define ACC_INFO_OS "dos32" +#elif defined(__OS2__) || defined(__OS2V2__) +# if (UINT_MAX == ACC_0xffffL) +# define ACC_OS_OS216 1 +# define ACC_INFO_OS "os216" +# elif (UINT_MAX == ACC_0xffffffffL) +# define ACC_OS_OS2 1 +# define ACC_INFO_OS "os2" +# else +# error "check your limits.h header" +# endif +#elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) +# define ACC_OS_WIN64 1 +# define ACC_INFO_OS "win64" +#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) +# define ACC_OS_WIN32 1 +# define ACC_INFO_OS "win32" +#elif defined(__MWERKS__) && defined(__INTEL__) +# define ACC_OS_WIN32 1 +# define ACC_INFO_OS "win32" +#elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) +# if (UINT_MAX == ACC_0xffffL) +# define ACC_OS_WIN16 1 +# define ACC_INFO_OS "win16" +# elif (UINT_MAX == ACC_0xffffffffL) +# define ACC_OS_WIN32 1 +# define ACC_INFO_OS "win32" +# else +# error "check your limits.h header" +# endif +#elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) +# if (UINT_MAX == ACC_0xffffL) +# define ACC_OS_DOS16 1 +# define ACC_INFO_OS "dos16" +# elif (UINT_MAX == ACC_0xffffffffL) +# define ACC_OS_DOS32 1 +# define ACC_INFO_OS "dos32" +# else +# error "check your limits.h header" +# endif +#elif defined(__WATCOMC__) +# if defined(__NT__) && (UINT_MAX == ACC_0xffffL) +# define ACC_OS_DOS16 1 +# define ACC_INFO_OS "dos16" +# elif defined(__NT__) && (__WATCOMC__ < 1100) +# define ACC_OS_WIN32 1 +# define ACC_INFO_OS "win32" +# elif defined(__linux__) || defined(__LINUX__) +# define ACC_OS_POSIX 1 +# define ACC_INFO_OS "posix" +# else +# error "please specify a target using the -bt compiler option" +# endif +#elif defined(__palmos__) +# define ACC_OS_PALMOS 1 +# define ACC_INFO_OS "palmos" +#elif defined(__TOS__) || defined(__atarist__) +# define ACC_OS_TOS 1 +# define ACC_INFO_OS "tos" +#elif defined(macintosh) && !defined(__ppc__) +# define ACC_OS_MACCLASSIC 1 +# define ACC_INFO_OS "macclassic" +#elif defined(__VMS) +# define ACC_OS_VMS 1 +# define ACC_INFO_OS "vms" +#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +# define ACC_OS_CONSOLE 1 +# define ACC_OS_CONSOLE_PS2 1 +# define ACC_INFO_OS "console" +# define ACC_INFO_OS_CONSOLE "ps2" +#elif (defined(__mips__) && defined(__psp__)) +# define ACC_OS_CONSOLE 1 +# define ACC_OS_CONSOLE_PSP 1 +# define ACC_INFO_OS "console" +# define ACC_INFO_OS_CONSOLE "psp" +#else +# define ACC_OS_POSIX 1 +# define ACC_INFO_OS "posix" +#endif +#if (ACC_OS_POSIX) +# if defined(_AIX) || defined(__AIX__) || defined(__aix__) +# define ACC_OS_POSIX_AIX 1 +# define ACC_INFO_OS_POSIX "aix" +# elif defined(__FreeBSD__) +# define ACC_OS_POSIX_FREEBSD 1 +# define ACC_INFO_OS_POSIX "freebsd" +# elif defined(__hpux__) || defined(__hpux) +# define ACC_OS_POSIX_HPUX 1 +# define ACC_INFO_OS_POSIX "hpux" +# elif defined(__INTERIX) +# define ACC_OS_POSIX_INTERIX 1 +# define ACC_INFO_OS_POSIX "interix" +# elif defined(__IRIX__) || defined(__irix__) +# define ACC_OS_POSIX_IRIX 1 +# define ACC_INFO_OS_POSIX "irix" +# elif defined(__linux__) || defined(__linux) || defined(__LINUX__) +# define ACC_OS_POSIX_LINUX 1 +# define ACC_INFO_OS_POSIX "linux" +# elif defined(__APPLE__) || defined(__MACOS__) +# define ACC_OS_POSIX_MACOSX 1 +# define ACC_INFO_OS_POSIX "macosx" +# elif defined(__minix__) || defined(__minix) +# define ACC_OS_POSIX_MINIX 1 +# define ACC_INFO_OS_POSIX "minix" +# elif defined(__NetBSD__) +# define ACC_OS_POSIX_NETBSD 1 +# define ACC_INFO_OS_POSIX "netbsd" +# elif defined(__OpenBSD__) +# define ACC_OS_POSIX_OPENBSD 1 +# define ACC_INFO_OS_POSIX "openbsd" +# elif defined(__osf__) +# define ACC_OS_POSIX_OSF 1 +# define ACC_INFO_OS_POSIX "osf" +# elif defined(__solaris__) || defined(__sun) +# if defined(__SVR4) || defined(__svr4__) +# define ACC_OS_POSIX_SOLARIS 1 +# define ACC_INFO_OS_POSIX "solaris" +# else +# define ACC_OS_POSIX_SUNOS 1 +# define ACC_INFO_OS_POSIX "sunos" +# endif +# elif defined(__ultrix__) || defined(__ultrix) +# define ACC_OS_POSIX_ULTRIX 1 +# define ACC_INFO_OS_POSIX "ultrix" +# elif defined(_UNICOS) +# define ACC_OS_POSIX_UNICOS 1 +# define ACC_INFO_OS_POSIX "unicos" +# else +# define ACC_OS_POSIX_UNKNOWN 1 +# define ACC_INFO_OS_POSIX "unknown" +# endif +#endif +#endif +#if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16) +# if (UINT_MAX != ACC_0xffffL) +# error "this should not happen" +# endif +# if (ULONG_MAX != ACC_0xffffffffL) +# error "this should not happen" +# endif +#endif +#if (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_WIN32 || ACC_OS_WIN64) +# if (UINT_MAX != ACC_0xffffffffL) +# error "this should not happen" +# endif +# if (ULONG_MAX != ACC_0xffffffffL) +# error "this should not happen" +# endif +#endif +#if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) +# define ACC_CC_CILLY 1 +# define ACC_INFO_CC "Cilly" +# if defined(__CILLY__) +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__CILLY__) +# else +# define ACC_INFO_CCVER "unknown" +# endif +#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) +# define ACC_CC_SDCC 1 +# define ACC_INFO_CC "sdcc" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(SDCC) +#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) +# define ACC_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) +# define ACC_INFO_CC "Pathscale C" +# define ACC_INFO_CCVER __PATHSCALE__ +#elif defined(__INTEL_COMPILER) +# define ACC_CC_INTELC 1 +# define ACC_INFO_CC "Intel C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__INTEL_COMPILER) +# if defined(_WIN32) || defined(_WIN64) +# define ACC_CC_SYNTAX_MSC 1 +# else +# define ACC_CC_SYNTAX_GNUC 1 +# endif +#elif defined(__POCC__) && defined(_WIN32) +# define ACC_CC_PELLESC 1 +# define ACC_INFO_CC "Pelles C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__POCC__) +#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +# if defined(__GNUC_PATCHLEVEL__) +# define ACC_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +# else +# define ACC_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +# endif +# if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) +# define ACC_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) +# else +# define ACC_CC_CLANG_CLANG 0x020700L +# endif +# define ACC_CC_CLANG ACC_CC_CLANG_GNUC +# define ACC_INFO_CC "clang" +# define ACC_INFO_CCVER __VERSION__ +#elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +# if defined(__GNUC_PATCHLEVEL__) +# define ACC_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +# else +# define ACC_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +# endif +# define ACC_CC_LLVM ACC_CC_LLVM_GNUC +# define ACC_INFO_CC "llvm-gcc" +# define ACC_INFO_CCVER __VERSION__ +#elif defined(__GNUC__) && defined(__VERSION__) +# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +# define ACC_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +# elif defined(__GNUC_MINOR__) +# define ACC_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +# else +# define ACC_CC_GNUC (__GNUC__ * 0x10000L) +# endif +# define ACC_INFO_CC "gcc" +# define ACC_INFO_CCVER __VERSION__ +#elif defined(__ACK__) && defined(_ACK) +# define ACC_CC_ACK 1 +# define ACC_INFO_CC "Amsterdam Compiler Kit C" +# define ACC_INFO_CCVER "unknown" +#elif defined(__AZTEC_C__) +# define ACC_CC_AZTECC 1 +# define ACC_INFO_CC "Aztec C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__AZTEC_C__) +#elif defined(__CODEGEARC__) +# define ACC_CC_CODEGEARC 1 +# define ACC_INFO_CC "CodeGear C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__CODEGEARC__) +#elif defined(__BORLANDC__) +# define ACC_CC_BORLANDC 1 +# define ACC_INFO_CC "Borland C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__BORLANDC__) +#elif defined(_CRAYC) && defined(_RELEASE) +# define ACC_CC_CRAYC 1 +# define ACC_INFO_CC "Cray C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(_RELEASE) +#elif defined(__DMC__) && defined(__SC__) +# define ACC_CC_DMC 1 +# define ACC_INFO_CC "Digital Mars C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__DMC__) +#elif defined(__DECC) +# define ACC_CC_DECC 1 +# define ACC_INFO_CC "DEC C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__DECC) +#elif defined(__HIGHC__) +# define ACC_CC_HIGHC 1 +# define ACC_INFO_CC "MetaWare High C" +# define ACC_INFO_CCVER "unknown" +#elif defined(__IAR_SYSTEMS_ICC__) +# define ACC_CC_IARC 1 +# define ACC_INFO_CC "IAR C" +# if defined(__VER__) +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__VER__) +# else +# define ACC_INFO_CCVER "unknown" +# endif +#elif defined(__IBMC__) +# define ACC_CC_IBMC 1 +# define ACC_INFO_CC "IBM C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__IBMC__) +#elif defined(__KEIL__) && defined(__C166__) +# define ACC_CC_KEILC 1 +# define ACC_INFO_CC "Keil C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__C166__) +#elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL) +# define ACC_CC_LCCWIN32 1 +# define ACC_INFO_CC "lcc-win32" +# define ACC_INFO_CCVER "unknown" +#elif defined(__LCC__) +# define ACC_CC_LCC 1 +# define ACC_INFO_CC "lcc" +# if defined(__LCC_VERSION__) +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__LCC_VERSION__) +# else +# define ACC_INFO_CCVER "unknown" +# endif +#elif defined(_MSC_VER) +# define ACC_CC_MSC 1 +# define ACC_INFO_CC "Microsoft C" +# if defined(_MSC_FULL_VER) +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(_MSC_VER) "." ACC_PP_MACRO_EXPAND(_MSC_FULL_VER) +# else +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(_MSC_VER) +# endif +#elif defined(__MWERKS__) +# define ACC_CC_MWERKS 1 +# define ACC_INFO_CC "Metrowerks C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__MWERKS__) +#elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) +# define ACC_CC_NDPC 1 +# define ACC_INFO_CC "Microway NDP C" +# define ACC_INFO_CCVER "unknown" +#elif defined(__PACIFIC__) +# define ACC_CC_PACIFICC 1 +# define ACC_INFO_CC "Pacific C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__PACIFIC__) +#elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) +# define ACC_CC_PGI 1 +# define ACC_INFO_CC "Portland Group PGI C" +# define ACC_INFO_CCVER "unknown" +#elif defined(__PUREC__) && defined(__TOS__) +# define ACC_CC_PUREC 1 +# define ACC_INFO_CC "Pure C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__PUREC__) +#elif defined(__SC__) && defined(__ZTC__) +# define ACC_CC_SYMANTECC 1 +# define ACC_INFO_CC "Symantec C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__SC__) +#elif defined(__SUNPRO_C) +# define ACC_INFO_CC "SunPro C" +# if ((__SUNPRO_C)+0 > 0) +# define ACC_CC_SUNPROC __SUNPRO_C +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__SUNPRO_C) +# else +# define ACC_CC_SUNPROC 1 +# define ACC_INFO_CCVER "unknown" +# endif +#elif defined(__SUNPRO_CC) +# define ACC_INFO_CC "SunPro C" +# if ((__SUNPRO_CC)+0 > 0) +# define ACC_CC_SUNPROC __SUNPRO_CC +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__SUNPRO_CC) +# else +# define ACC_CC_SUNPROC 1 +# define ACC_INFO_CCVER "unknown" +# endif +#elif defined(__TINYC__) +# define ACC_CC_TINYC 1 +# define ACC_INFO_CC "Tiny C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__TINYC__) +#elif defined(__TSC__) +# define ACC_CC_TOPSPEEDC 1 +# define ACC_INFO_CC "TopSpeed C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__TSC__) +#elif defined(__WATCOMC__) +# define ACC_CC_WATCOMC 1 +# define ACC_INFO_CC "Watcom C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__WATCOMC__) +#elif defined(__TURBOC__) +# define ACC_CC_TURBOC 1 +# define ACC_INFO_CC "Turbo C" +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__TURBOC__) +#elif defined(__ZTC__) +# define ACC_CC_ZORTECHC 1 +# define ACC_INFO_CC "Zortech C" +# if (__ZTC__ == 0x310) +# define ACC_INFO_CCVER "0x310" +# else +# define ACC_INFO_CCVER ACC_PP_MACRO_EXPAND(__ZTC__) +# endif +#else +# define ACC_CC_UNKNOWN 1 +# define ACC_INFO_CC "unknown" +# define ACC_INFO_CCVER "unknown" +#endif +#if 0 && (ACC_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) +# error "ACC_CC_MSC: _MSC_FULL_VER is not defined" +#endif +#if !defined(__ACC_ARCH_OVERRIDE) && !(ACC_ARCH_GENERIC) && defined(_CRAY) +# if (UINT_MAX > ACC_0xffffffffL) && defined(_CRAY) +# if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) +# define ACC_ARCH_CRAY_MPP 1 +# elif defined(_CRAY1) +# define ACC_ARCH_CRAY_PVP 1 +# endif +# endif +#endif +#if !defined(__ACC_ARCH_OVERRIDE) +#if (ACC_ARCH_GENERIC) +# define ACC_INFO_ARCH "generic" +#elif (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16) +# define ACC_ARCH_I086 1 +# define ACC_ARCH_IA16 1 +# define ACC_INFO_ARCH "i086" +#elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) +# define ACC_ARCH_ALPHA 1 +# define ACC_INFO_ARCH "alpha" +#elif (ACC_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E)) +# define ACC_ARCH_ALPHA 1 +# define ACC_INFO_ARCH "alpha" +#elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) +# define ACC_ARCH_AMD64 1 +# define ACC_INFO_ARCH "amd64" +#elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB)) +# define ACC_ARCH_ARM 1 +# define ACC_ARCH_ARM_THUMB 1 +# define ACC_INFO_ARCH "arm_thumb" +#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) +# define ACC_ARCH_ARM 1 +# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) +# define ACC_ARCH_ARM_THUMB 1 +# define ACC_INFO_ARCH "arm_thumb" +# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) +# define ACC_INFO_ARCH "arm" +# else +# define ACC_INFO_ARCH "arm" +# endif +#elif defined(__arm__) || defined(_M_ARM) +# define ACC_ARCH_ARM 1 +# define ACC_INFO_ARCH "arm" +#elif (UINT_MAX <= ACC_0xffffL) && defined(__AVR__) +# define ACC_ARCH_AVR 1 +# define ACC_INFO_ARCH "avr" +#elif defined(__avr32__) || defined(__AVR32__) +# define ACC_ARCH_AVR32 1 +# define ACC_INFO_ARCH "avr32" +#elif defined(__bfin__) +# define ACC_ARCH_BLACKFIN 1 +# define ACC_INFO_ARCH "blackfin" +#elif (UINT_MAX == ACC_0xffffL) && defined(__C166__) +# define ACC_ARCH_C166 1 +# define ACC_INFO_ARCH "c166" +#elif defined(__cris__) +# define ACC_ARCH_CRIS 1 +# define ACC_INFO_ARCH "cris" +#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__) +# define ACC_ARCH_EZ80 1 +# define ACC_INFO_ARCH "ez80" +#elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +# define ACC_ARCH_H8300 1 +# define ACC_INFO_ARCH "h8300" +#elif defined(__hppa__) || defined(__hppa) +# define ACC_ARCH_HPPA 1 +# define ACC_INFO_ARCH "hppa" +#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) +# define ACC_ARCH_I386 1 +# define ACC_ARCH_IA32 1 +# define ACC_INFO_ARCH "i386" +#elif (ACC_CC_ZORTECHC && defined(__I86__)) +# define ACC_ARCH_I386 1 +# define ACC_ARCH_IA32 1 +# define ACC_INFO_ARCH "i386" +#elif (ACC_OS_DOS32 && ACC_CC_HIGHC) && defined(_I386) +# define ACC_ARCH_I386 1 +# define ACC_ARCH_IA32 1 +# define ACC_INFO_ARCH "i386" +#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) +# define ACC_ARCH_IA64 1 +# define ACC_INFO_ARCH "ia64" +#elif (UINT_MAX == ACC_0xffffL) && defined(__m32c__) +# define ACC_ARCH_M16C 1 +# define ACC_INFO_ARCH "m16c" +#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__) +# define ACC_ARCH_M16C 1 +# define ACC_INFO_ARCH "m16c" +#elif defined(__m32r__) +# define ACC_ARCH_M32R 1 +# define ACC_INFO_ARCH "m32r" +#elif (ACC_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K) +# define ACC_ARCH_M68K 1 +# define ACC_INFO_ARCH "m68k" +#elif (UINT_MAX == ACC_0xffffL) && defined(__C251__) +# define ACC_ARCH_MCS251 1 +# define ACC_INFO_ARCH "mcs251" +#elif (UINT_MAX == ACC_0xffffL) && defined(__C51__) +# define ACC_ARCH_MCS51 1 +# define ACC_INFO_ARCH "mcs51" +#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__) +# define ACC_ARCH_MCS51 1 +# define ACC_INFO_ARCH "mcs51" +#elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000) +# define ACC_ARCH_MIPS 1 +# define ACC_INFO_ARCH "mips" +#elif (UINT_MAX == ACC_0xffffL) && defined(__MSP430__) +# define ACC_ARCH_MSP430 1 +# define ACC_INFO_ARCH "msp430" +#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__) +# define ACC_ARCH_MSP430 1 +# define ACC_INFO_ARCH "msp430" +#elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR) +# define ACC_ARCH_POWERPC 1 +# define ACC_INFO_ARCH "powerpc" +#elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x) +# define ACC_ARCH_S390 1 +# define ACC_INFO_ARCH "s390" +#elif defined(__sh__) || defined(_M_SH) +# define ACC_ARCH_SH 1 +# define ACC_INFO_ARCH "sh" +#elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8) +# define ACC_ARCH_SPARC 1 +# define ACC_INFO_ARCH "sparc" +#elif defined(__SPU__) +# define ACC_ARCH_SPU 1 +# define ACC_INFO_ARCH "spu" +#elif (UINT_MAX == ACC_0xffffL) && defined(__z80) +# define ACC_ARCH_Z80 1 +# define ACC_INFO_ARCH "z80" +#elif (ACC_ARCH_CRAY_PVP) +# if defined(_CRAYSV1) +# define ACC_ARCH_CRAY_SV1 1 +# define ACC_INFO_ARCH "cray_sv1" +# elif (_ADDR64) +# define ACC_ARCH_CRAY_T90 1 +# define ACC_INFO_ARCH "cray_t90" +# elif (_ADDR32) +# define ACC_ARCH_CRAY_YMP 1 +# define ACC_INFO_ARCH "cray_ymp" +# else +# define ACC_ARCH_CRAY_XMP 1 +# define ACC_INFO_ARCH "cray_xmp" +# endif +#else +# define ACC_ARCH_UNKNOWN 1 +# define ACC_INFO_ARCH "unknown" +#endif +#endif +#if 1 && (ACC_ARCH_UNKNOWN) && (ACC_OS_DOS32 || ACC_OS_OS2) +# error "FIXME - missing define for CPU architecture" +#endif +#if 1 && (ACC_ARCH_UNKNOWN) && (ACC_OS_WIN32) +# error "FIXME - missing WIN32 define for CPU architecture" +#endif +#if 1 && (ACC_ARCH_UNKNOWN) && (ACC_OS_WIN64) +# error "FIXME - missing WIN64 define for CPU architecture" +#endif +#if (ACC_OS_OS216 || ACC_OS_WIN16) +# define ACC_ARCH_I086PM 1 +# define ACC_ARCH_IA16PM 1 +#elif 1 && (ACC_OS_DOS16 && defined(BLX286)) +# define ACC_ARCH_I086PM 1 +# define ACC_ARCH_IA16PM 1 +#elif 1 && (ACC_OS_DOS16 && defined(DOSX286)) +# define ACC_ARCH_I086PM 1 +# define ACC_ARCH_IA16PM 1 +#elif 1 && (ACC_OS_DOS16 && ACC_CC_BORLANDC && defined(__DPMI16__)) +# define ACC_ARCH_I086PM 1 +# define ACC_ARCH_IA16PM 1 +#endif +#if (ACC_ARCH_ARM_THUMB) && !(ACC_ARCH_ARM) +# error "this should not happen" +#endif +#if (ACC_ARCH_I086PM) && !(ACC_ARCH_I086) +# error "this should not happen" +#endif +#if (ACC_ARCH_I086) +# if (UINT_MAX != ACC_0xffffL) +# error "this should not happen" +# endif +# if (ULONG_MAX != ACC_0xffffffffL) +# error "this should not happen" +# endif +#endif +#if (ACC_ARCH_I386) +# if (UINT_MAX != ACC_0xffffL) && defined(__i386_int16__) +# error "this should not happen" +# endif +# if (UINT_MAX != ACC_0xffffffffL) && !defined(__i386_int16__) +# error "this should not happen" +# endif +# if (ULONG_MAX != ACC_0xffffffffL) +# error "this should not happen" +# endif +#endif +#if !defined(__ACC_MM_OVERRIDE) +#if (ACC_ARCH_I086) +#if (UINT_MAX != ACC_0xffffL) +# error "this should not happen" +#endif +#if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) +# define ACC_MM_TINY 1 +#elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) +# define ACC_MM_HUGE 1 +#elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) +# define ACC_MM_SMALL 1 +#elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM) +# define ACC_MM_MEDIUM 1 +#elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM) +# define ACC_MM_COMPACT 1 +#elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) +# define ACC_MM_LARGE 1 +#elif (ACC_CC_AZTECC) +# if defined(_LARGE_CODE) && defined(_LARGE_DATA) +# define ACC_MM_LARGE 1 +# elif defined(_LARGE_CODE) +# define ACC_MM_MEDIUM 1 +# elif defined(_LARGE_DATA) +# define ACC_MM_COMPACT 1 +# else +# define ACC_MM_SMALL 1 +# endif +#elif (ACC_CC_ZORTECHC && defined(__VCM__)) +# define ACC_MM_LARGE 1 +#else +# error "unknown memory model" +#endif +#if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16) +#define ACC_HAVE_MM_HUGE_PTR 1 +#define ACC_HAVE_MM_HUGE_ARRAY 1 +#if (ACC_MM_TINY) +# undef ACC_HAVE_MM_HUGE_ARRAY +#endif +#if (ACC_CC_AZTECC || ACC_CC_PACIFICC || ACC_CC_ZORTECHC) +# undef ACC_HAVE_MM_HUGE_PTR +# undef ACC_HAVE_MM_HUGE_ARRAY +#elif (ACC_CC_DMC || ACC_CC_SYMANTECC) +# undef ACC_HAVE_MM_HUGE_ARRAY +#elif (ACC_CC_MSC && defined(_QC)) +# undef ACC_HAVE_MM_HUGE_ARRAY +# if (_MSC_VER < 600) +# undef ACC_HAVE_MM_HUGE_PTR +# endif +#elif (ACC_CC_TURBOC && (__TURBOC__ < 0x0295)) +# undef ACC_HAVE_MM_HUGE_ARRAY +#endif +#if (ACC_ARCH_I086PM) && !(ACC_HAVE_MM_HUGE_PTR) +# if (ACC_OS_DOS16) +# error "this should not happen" +# elif (ACC_CC_ZORTECHC) +# else +# error "this should not happen" +# endif +#endif +#ifdef __cplusplus +extern "C" { +#endif +#if (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) + extern void __near __cdecl _AHSHIFT(void); +# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT) +#elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) + extern void __near __cdecl _AHSHIFT(void); +# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT) +#elif (ACC_CC_MSC || ACC_CC_TOPSPEEDC) + extern void __near __cdecl _AHSHIFT(void); +# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT) +#elif (ACC_CC_TURBOC && (__TURBOC__ >= 0x0295)) + extern void __near __cdecl _AHSHIFT(void); +# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT) +#elif ((ACC_CC_AZTECC || ACC_CC_PACIFICC || ACC_CC_TURBOC) && ACC_OS_DOS16) +# define ACC_MM_AHSHIFT 12 +#elif (ACC_CC_WATCOMC) + extern unsigned char _HShift; +# define ACC_MM_AHSHIFT ((unsigned) _HShift) +#else +# error "FIXME - implement ACC_MM_AHSHIFT" +#endif +#ifdef __cplusplus +} +#endif +#endif +#elif (ACC_ARCH_C166) +#if !defined(__MODEL__) +# error "FIXME - C166 __MODEL__" +#elif ((__MODEL__) == 0) +# define ACC_MM_SMALL 1 +#elif ((__MODEL__) == 1) +# define ACC_MM_SMALL 1 +#elif ((__MODEL__) == 2) +# define ACC_MM_LARGE 1 +#elif ((__MODEL__) == 3) +# define ACC_MM_TINY 1 +#elif ((__MODEL__) == 4) +# define ACC_MM_XTINY 1 +#elif ((__MODEL__) == 5) +# define ACC_MM_XSMALL 1 +#else +# error "FIXME - C166 __MODEL__" +#endif +#elif (ACC_ARCH_MCS251) +#if !defined(__MODEL__) +# error "FIXME - MCS251 __MODEL__" +#elif ((__MODEL__) == 0) +# define ACC_MM_SMALL 1 +#elif ((__MODEL__) == 2) +# define ACC_MM_LARGE 1 +#elif ((__MODEL__) == 3) +# define ACC_MM_TINY 1 +#elif ((__MODEL__) == 4) +# define ACC_MM_XTINY 1 +#elif ((__MODEL__) == 5) +# define ACC_MM_XSMALL 1 +#else +# error "FIXME - MCS251 __MODEL__" +#endif +#elif (ACC_ARCH_MCS51) +#if !defined(__MODEL__) +# error "FIXME - MCS51 __MODEL__" +#elif ((__MODEL__) == 1) +# define ACC_MM_SMALL 1 +#elif ((__MODEL__) == 2) +# define ACC_MM_LARGE 1 +#elif ((__MODEL__) == 3) +# define ACC_MM_TINY 1 +#elif ((__MODEL__) == 4) +# define ACC_MM_XTINY 1 +#elif ((__MODEL__) == 5) +# define ACC_MM_XSMALL 1 +#else +# error "FIXME - MCS51 __MODEL__" +#endif +#elif (ACC_ARCH_CRAY_PVP) +# define ACC_MM_PVP 1 +#else +# define ACC_MM_FLAT 1 +#endif +#if (ACC_MM_COMPACT) +# define ACC_INFO_MM "compact" +#elif (ACC_MM_FLAT) +# define ACC_INFO_MM "flat" +#elif (ACC_MM_HUGE) +# define ACC_INFO_MM "huge" +#elif (ACC_MM_LARGE) +# define ACC_INFO_MM "large" +#elif (ACC_MM_MEDIUM) +# define ACC_INFO_MM "medium" +#elif (ACC_MM_PVP) +# define ACC_INFO_MM "pvp" +#elif (ACC_MM_SMALL) +# define ACC_INFO_MM "small" +#elif (ACC_MM_TINY) +# define ACC_INFO_MM "tiny" +#else +# error "unknown memory model" +#endif +#endif +#if defined(SIZEOF_SHORT) +# define ACC_SIZEOF_SHORT (SIZEOF_SHORT) +#endif +#if defined(SIZEOF_INT) +# define ACC_SIZEOF_INT (SIZEOF_INT) +#endif +#if defined(SIZEOF_LONG) +# define ACC_SIZEOF_LONG (SIZEOF_LONG) +#endif +#if defined(SIZEOF_LONG_LONG) +# define ACC_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) +#endif +#if defined(SIZEOF___INT16) +# define ACC_SIZEOF___INT16 (SIZEOF___INT16) +#endif +#if defined(SIZEOF___INT32) +# define ACC_SIZEOF___INT32 (SIZEOF___INT32) +#endif +#if defined(SIZEOF___INT64) +# define ACC_SIZEOF___INT64 (SIZEOF___INT64) +#endif +#if defined(SIZEOF_VOID_P) +# define ACC_SIZEOF_VOID_P (SIZEOF_VOID_P) +#endif +#if defined(SIZEOF_SIZE_T) +# define ACC_SIZEOF_SIZE_T (SIZEOF_SIZE_T) +#endif +#if defined(SIZEOF_PTRDIFF_T) +# define ACC_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) +#endif +#define __ACC_LSR(x,b) (((x)+0ul) >> (b)) +#if !defined(ACC_SIZEOF_SHORT) +# if (ACC_ARCH_CRAY_PVP) +# define ACC_SIZEOF_SHORT 8 +# elif (USHRT_MAX == ACC_0xffffL) +# define ACC_SIZEOF_SHORT 2 +# elif (__ACC_LSR(USHRT_MAX,7) == 1) +# define ACC_SIZEOF_SHORT 1 +# elif (__ACC_LSR(USHRT_MAX,15) == 1) +# define ACC_SIZEOF_SHORT 2 +# elif (__ACC_LSR(USHRT_MAX,31) == 1) +# define ACC_SIZEOF_SHORT 4 +# elif (__ACC_LSR(USHRT_MAX,63) == 1) +# define ACC_SIZEOF_SHORT 8 +# elif (__ACC_LSR(USHRT_MAX,127) == 1) +# define ACC_SIZEOF_SHORT 16 +# else +# error "ACC_SIZEOF_SHORT" +# endif +#endif +#if !defined(ACC_SIZEOF_INT) +# if (ACC_ARCH_CRAY_PVP) +# define ACC_SIZEOF_INT 8 +# elif (UINT_MAX == ACC_0xffffL) +# define ACC_SIZEOF_INT 2 +# elif (UINT_MAX == ACC_0xffffffffL) +# define ACC_SIZEOF_INT 4 +# elif (__ACC_LSR(UINT_MAX,7) == 1) +# define ACC_SIZEOF_INT 1 +# elif (__ACC_LSR(UINT_MAX,15) == 1) +# define ACC_SIZEOF_INT 2 +# elif (__ACC_LSR(UINT_MAX,31) == 1) +# define ACC_SIZEOF_INT 4 +# elif (__ACC_LSR(UINT_MAX,63) == 1) +# define ACC_SIZEOF_INT 8 +# elif (__ACC_LSR(UINT_MAX,127) == 1) +# define ACC_SIZEOF_INT 16 +# else +# error "ACC_SIZEOF_INT" +# endif +#endif +#if !defined(ACC_SIZEOF_LONG) +# if (ULONG_MAX == ACC_0xffffffffL) +# define ACC_SIZEOF_LONG 4 +# elif (__ACC_LSR(ULONG_MAX,7) == 1) +# define ACC_SIZEOF_LONG 1 +# elif (__ACC_LSR(ULONG_MAX,15) == 1) +# define ACC_SIZEOF_LONG 2 +# elif (__ACC_LSR(ULONG_MAX,31) == 1) +# define ACC_SIZEOF_LONG 4 +# elif (__ACC_LSR(ULONG_MAX,63) == 1) +# define ACC_SIZEOF_LONG 8 +# elif (__ACC_LSR(ULONG_MAX,127) == 1) +# define ACC_SIZEOF_LONG 16 +# else +# error "ACC_SIZEOF_LONG" +# endif +#endif +#if !defined(ACC_SIZEOF_LONG_LONG) && !defined(ACC_SIZEOF___INT64) +#if (ACC_SIZEOF_LONG > 0 && ACC_SIZEOF_LONG < 8) +# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) +# if (ACC_CC_GNUC >= 0x030300ul) +# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) +# define ACC_SIZEOF_LONG_LONG ACC_SIZEOF_LONG +# elif (__ACC_LSR(__LONG_LONG_MAX__,30) == 1) +# define ACC_SIZEOF_LONG_LONG 4 +# endif +# endif +# endif +#endif +#endif +#if !defined(ACC_SIZEOF_LONG_LONG) && !defined(ACC_SIZEOF___INT64) +#if (ACC_SIZEOF_LONG > 0 && ACC_SIZEOF_LONG < 8) +#if (ACC_ARCH_I086 && ACC_CC_DMC) +#elif (ACC_CC_CILLY) && defined(__GNUC__) +# define ACC_SIZEOF_LONG_LONG 8 +#elif (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define ACC_SIZEOF_LONG_LONG 8 +#elif ((ACC_OS_WIN32 || ACC_OS_WIN64 || defined(_WIN32)) && ACC_CC_MSC && (_MSC_VER >= 1400)) +# define ACC_SIZEOF_LONG_LONG 8 +#elif (ACC_OS_WIN64 || defined(_WIN64)) +# define ACC_SIZEOF___INT64 8 +#elif (ACC_ARCH_I386 && (ACC_CC_DMC)) +# define ACC_SIZEOF_LONG_LONG 8 +#elif (ACC_ARCH_I386 && (ACC_CC_SYMANTECC && (__SC__ >= 0x700))) +# define ACC_SIZEOF_LONG_LONG 8 +#elif (ACC_ARCH_I386 && (ACC_CC_INTELC && defined(__linux__))) +# define ACC_SIZEOF_LONG_LONG 8 +#elif (ACC_ARCH_I386 && (ACC_CC_MWERKS || ACC_CC_PELLESC || ACC_CC_PGI || ACC_CC_SUNPROC)) +# define ACC_SIZEOF_LONG_LONG 8 +#elif (ACC_ARCH_I386 && (ACC_CC_INTELC || ACC_CC_MSC)) +# define ACC_SIZEOF___INT64 8 +#elif ((ACC_OS_WIN32 || defined(_WIN32)) && (ACC_CC_MSC)) +# define ACC_SIZEOF___INT64 8 +#elif (ACC_ARCH_I386 && (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) +# define ACC_SIZEOF___INT64 8 +#elif (ACC_ARCH_I386 && (ACC_CC_WATCOMC && (__WATCOMC__ >= 1100))) +# define ACC_SIZEOF___INT64 8 +#elif (ACC_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) +# define ACC_SIZEOF___INT64 8 +#elif (ACC_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +# define ACC_SIZEOF_LONG_LONG 8 +#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +# define ACC_SIZEOF_LONG_LONG 8 +#elif (ACC_CC_SDCC) && (ACC_SIZEOF_INT == 2) +#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +# define ACC_SIZEOF_LONG_LONG 8 +#endif +#endif +#endif +#if defined(__cplusplus) && (ACC_CC_GNUC) +# if (ACC_CC_GNUC < 0x020800ul) +# undef ACC_SIZEOF_LONG_LONG +# endif +#endif +#if (ACC_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) +# undef ACC_SIZEOF_LONG_LONG +#endif +#if !defined(ACC_SIZEOF_VOID_P) +#if (ACC_ARCH_I086) +# define __ACC_WORDSIZE 2 +# if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM) +# define ACC_SIZEOF_VOID_P 2 +# elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE) +# define ACC_SIZEOF_VOID_P 4 +# else +# error "ACC_MM" +# endif +#elif (ACC_ARCH_AVR || ACC_ARCH_Z80) +# define __ACC_WORDSIZE 1 +# define ACC_SIZEOF_VOID_P 2 +#elif (ACC_ARCH_C166 || ACC_ARCH_MCS51 || ACC_ARCH_MCS251 || ACC_ARCH_MSP430) +# define ACC_SIZEOF_VOID_P 2 +#elif (ACC_ARCH_H8300) +# if defined(__NORMAL_MODE__) +# define __ACC_WORDSIZE 4 +# define ACC_SIZEOF_VOID_P 2 +# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +# define __ACC_WORDSIZE 4 +# define ACC_SIZEOF_VOID_P 4 +# else +# define __ACC_WORDSIZE 2 +# define ACC_SIZEOF_VOID_P 2 +# endif +# if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x040000ul)) && (ACC_SIZEOF_INT == 4) +# define ACC_SIZEOF_SIZE_T ACC_SIZEOF_INT +# define ACC_SIZEOF_PTRDIFF_T ACC_SIZEOF_INT +# endif +#elif (ACC_ARCH_M16C) +# define __ACC_WORDSIZE 2 +# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) +# define ACC_SIZEOF_VOID_P 4 +# else +# define ACC_SIZEOF_VOID_P 2 +# endif +#elif (ACC_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +# define __ACC_WORDSIZE 8 +# define ACC_SIZEOF_VOID_P 4 +#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) +# define __ACC_WORDSIZE 8 +# define ACC_SIZEOF_VOID_P 8 +#elif (ACC_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +# define ACC_SIZEOF_VOID_P ACC_SIZEOF_LONG +# define ACC_SIZEOF_SIZE_T ACC_SIZEOF_LONG +# define ACC_SIZEOF_PTRDIFF_T ACC_SIZEOF_LONG +#elif (ACC_OS_OS400 || defined(__OS400__)) +# define __ACC_WORDSIZE ACC_SIZEOF_LONG +# define ACC_SIZEOF_VOID_P 16 +# define ACC_SIZEOF_SIZE_T ACC_SIZEOF_LONG +# define ACC_SIZEOF_PTRDIFF_T ACC_SIZEOF_LONG +#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +# define ACC_SIZEOF_VOID_P 8 +# define ACC_SIZEOF_SIZE_T ACC_SIZEOF_LONG +# define ACC_SIZEOF_PTRDIFF_T ACC_SIZEOF_LONG +#elif (ACC_ARCH_SPU) +# if 0 +# define __ACC_WORDSIZE 16 +# endif +# define ACC_SIZEOF_VOID_P 4 +#else +# define ACC_SIZEOF_VOID_P ACC_SIZEOF_LONG +#endif +#endif +#if !defined(ACC_WORDSIZE) +# if defined(__ACC_WORDSIZE) +# define ACC_WORDSIZE __ACC_WORDSIZE +# else +# define ACC_WORDSIZE ACC_SIZEOF_VOID_P +# endif +#endif +#if !defined(ACC_SIZEOF_SIZE_T) +#if (ACC_ARCH_I086 || ACC_ARCH_M16C) +# define ACC_SIZEOF_SIZE_T 2 +#else +# define ACC_SIZEOF_SIZE_T ACC_SIZEOF_VOID_P +#endif +#endif +#if !defined(ACC_SIZEOF_PTRDIFF_T) +#if (ACC_ARCH_I086) +# if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM || ACC_MM_HUGE) +# define ACC_SIZEOF_PTRDIFF_T ACC_SIZEOF_VOID_P +# elif (ACC_MM_COMPACT || ACC_MM_LARGE) +# if (ACC_CC_BORLANDC || ACC_CC_TURBOC) +# define ACC_SIZEOF_PTRDIFF_T 4 +# else +# define ACC_SIZEOF_PTRDIFF_T 2 +# endif +# else +# error "ACC_MM" +# endif +#else +# define ACC_SIZEOF_PTRDIFF_T ACC_SIZEOF_SIZE_T +#endif +#endif +#if (ACC_ABI_NEUTRAL_ENDIAN) +# undef ACC_ABI_BIG_ENDIAN +# undef ACC_ABI_LITTLE_ENDIAN +#elif !(ACC_ABI_BIG_ENDIAN) && !(ACC_ABI_LITTLE_ENDIAN) +#if (ACC_ARCH_ALPHA) && (ACC_ARCH_CRAY_MPP) +# define ACC_ABI_BIG_ENDIAN 1 +#elif (ACC_ARCH_IA64) && (ACC_OS_POSIX_LINUX || ACC_OS_WIN64) +# define ACC_ABI_LITTLE_ENDIAN 1 +#elif (ACC_ARCH_ALPHA || ACC_ARCH_AMD64 || ACC_ARCH_BLACKFIN || ACC_ARCH_CRIS || ACC_ARCH_I086 || ACC_ARCH_I386 || ACC_ARCH_MSP430) +# define ACC_ABI_LITTLE_ENDIAN 1 +#elif (ACC_ARCH_AVR32 || ACC_ARCH_M68K || ACC_ARCH_S390) +# define ACC_ABI_BIG_ENDIAN 1 +#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) +# if (__LITTLE_ENDIAN__ == 1) +# define ACC_ABI_LITTLE_ENDIAN 1 +# else +# define ACC_ABI_BIG_ENDIAN 1 +# endif +#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +# define ACC_ABI_BIG_ENDIAN 1 +#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +# define ACC_ABI_LITTLE_ENDIAN 1 +#elif 1 && (ACC_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) +# define ACC_ABI_BIG_ENDIAN 1 +#elif 1 && (ACC_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) +# define ACC_ABI_LITTLE_ENDIAN 1 +#elif 1 && (ACC_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) +# define ACC_ABI_BIG_ENDIAN 1 +#elif 1 && (ACC_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) +# define ACC_ABI_LITTLE_ENDIAN 1 +#endif +#endif +#if (ACC_ABI_BIG_ENDIAN) && (ACC_ABI_LITTLE_ENDIAN) +# error "this should not happen" +#endif +#if (ACC_ABI_BIG_ENDIAN) +# define ACC_INFO_ABI_ENDIAN "be" +#elif (ACC_ABI_LITTLE_ENDIAN) +# define ACC_INFO_ABI_ENDIAN "le" +#elif (ACC_ABI_NEUTRAL_ENDIAN) +# define ACC_INFO_ABI_ENDIAN "neutral" +#endif +#if (ACC_SIZEOF_INT == 1 && ACC_SIZEOF_LONG == 2 && ACC_SIZEOF_VOID_P == 2) +# define ACC_ABI_I8LP16 1 +# define ACC_INFO_ABI_PM "i8lp16" +#elif (ACC_SIZEOF_INT == 2 && ACC_SIZEOF_LONG == 2 && ACC_SIZEOF_VOID_P == 2) +# define ACC_ABI_ILP16 1 +# define ACC_INFO_ABI_PM "ilp16" +#elif (ACC_SIZEOF_INT == 4 && ACC_SIZEOF_LONG == 4 && ACC_SIZEOF_VOID_P == 4) +# define ACC_ABI_ILP32 1 +# define ACC_INFO_ABI_PM "ilp32" +#elif (ACC_SIZEOF_INT == 4 && ACC_SIZEOF_LONG == 4 && ACC_SIZEOF_VOID_P == 8 && ACC_SIZEOF_SIZE_T == 8) +# define ACC_ABI_LLP64 1 +# define ACC_INFO_ABI_PM "llp64" +#elif (ACC_SIZEOF_INT == 4 && ACC_SIZEOF_LONG == 8 && ACC_SIZEOF_VOID_P == 8) +# define ACC_ABI_LP64 1 +# define ACC_INFO_ABI_PM "lp64" +#elif (ACC_SIZEOF_INT == 8 && ACC_SIZEOF_LONG == 8 && ACC_SIZEOF_VOID_P == 8) +# define ACC_ABI_ILP64 1 +# define ACC_INFO_ABI_PM "ilp64" +#elif (ACC_SIZEOF_INT == 4 && ACC_SIZEOF_LONG == 8 && ACC_SIZEOF_VOID_P == 4) +# define ACC_ABI_IP32L64 1 +# define ACC_INFO_ABI_PM "ip32l64" +#endif +#if !defined(__ACC_LIBC_OVERRIDE) +#if (ACC_LIBC_NAKED) +# define ACC_INFO_LIBC "naked" +#elif (ACC_LIBC_FREESTANDING) +# define ACC_INFO_LIBC "freestanding" +#elif (ACC_LIBC_MOSTLY_FREESTANDING) +# define ACC_INFO_LIBC "mfreestanding" +#elif (ACC_LIBC_ISOC90) +# define ACC_INFO_LIBC "isoc90" +#elif (ACC_LIBC_ISOC99) +# define ACC_INFO_LIBC "isoc99" +#elif defined(__dietlibc__) +# define ACC_LIBC_DIETLIBC 1 +# define ACC_INFO_LIBC "dietlibc" +#elif defined(_NEWLIB_VERSION) +# define ACC_LIBC_NEWLIB 1 +# define ACC_INFO_LIBC "newlib" +#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) +# if defined(__UCLIBC_SUBLEVEL__) +# define ACC_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) +# else +# define ACC_LIBC_UCLIBC 0x00090bL +# endif +# define ACC_INFO_LIBC "uclibc" +#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) +# define ACC_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) +# define ACC_INFO_LIBC "glibc" +#elif (ACC_CC_MWERKS) && defined(__MSL__) +# define ACC_LIBC_MSL __MSL__ +# define ACC_INFO_LIBC "msl" +#elif 1 && defined(__IAR_SYSTEMS_ICC__) +# define ACC_LIBC_ISOC90 1 +# define ACC_INFO_LIBC "isoc90" +#else +# define ACC_LIBC_DEFAULT 1 +# define ACC_INFO_LIBC "default" +#endif +#endif +#if !defined(__acc_gnuc_extension__) +#if (ACC_CC_GNUC >= 0x020800ul) +# define __acc_gnuc_extension__ __extension__ +#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __acc_gnuc_extension__ __extension__ +#else +# define __acc_gnuc_extension__ /*empty*/ +#endif +#endif +#if !defined(__acc_ua_volatile) +# define __acc_ua_volatile volatile +#endif +#if !defined(__acc_alignof) +#if (ACC_CC_CILLY || ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE || ACC_CC_PGI) +# define __acc_alignof(e) __alignof__(e) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 700)) +# define __acc_alignof(e) __alignof__(e) +#elif (ACC_CC_MSC && (_MSC_VER >= 1300)) +# define __acc_alignof(e) __alignof(e) +#elif (ACC_CC_SUNPROC && (ACC_CC_SUNPROC >= 0x5100)) +# define __acc_alignof(e) __alignof__(e) +#endif +#endif +#if defined(__acc_alignof) +# define __acc_HAVE_alignof 1 +#endif +#if !defined(__acc_constructor) +#if (ACC_CC_GNUC >= 0x030400ul) +# define __acc_constructor __attribute__((__constructor__,__used__)) +#elif (ACC_CC_GNUC >= 0x020700ul) +# define __acc_constructor __attribute__((__constructor__)) +#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __acc_constructor __attribute__((__constructor__)) +#endif +#endif +#if defined(__acc_constructor) +# define __acc_HAVE_constructor 1 +#endif +#if !defined(__acc_destructor) +#if (ACC_CC_GNUC >= 0x030400ul) +# define __acc_destructor __attribute__((__destructor__,__used__)) +#elif (ACC_CC_GNUC >= 0x020700ul) +# define __acc_destructor __attribute__((__destructor__)) +#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __acc_destructor __attribute__((__destructor__)) +#endif +#endif +#if defined(__acc_destructor) +# define __acc_HAVE_destructor 1 +#endif +#if (__acc_HAVE_destructor) && !(__acc_HAVE_constructor) +# error "this should not happen" +#endif +#if !defined(__acc_inline) +#if (ACC_CC_TURBOC && (__TURBOC__ <= 0x0295)) +#elif defined(__cplusplus) +# define __acc_inline inline +#elif (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) +# define __acc_inline __inline +#elif (ACC_CC_CILLY || ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE || ACC_CC_PGI) +# define __acc_inline __inline__ +#elif (ACC_CC_DMC) +# define __acc_inline __inline +#elif (ACC_CC_INTELC) +# define __acc_inline __inline +#elif (ACC_CC_MWERKS && (__MWERKS__ >= 0x2405)) +# define __acc_inline __inline +#elif (ACC_CC_MSC && (_MSC_VER >= 900)) +# define __acc_inline __inline +#elif (ACC_CC_SUNPROC && (ACC_CC_SUNPROC >= 0x5100)) +# define __acc_inline __inline__ +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +# define __acc_inline inline +#endif +#endif +#if defined(__acc_inline) +# define __acc_HAVE_inline 1 +#else +# define __acc_inline /*empty*/ +#endif +#if !defined(__acc_forceinline) +#if (ACC_CC_GNUC >= 0x030200ul) +# define __acc_forceinline __inline__ __attribute__((__always_inline__)) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 450) && ACC_CC_SYNTAX_MSC) +# define __acc_forceinline __forceinline +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800) && ACC_CC_SYNTAX_GNUC) +# define __acc_forceinline __inline__ __attribute__((__always_inline__)) +#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __acc_forceinline __inline__ __attribute__((__always_inline__)) +#elif (ACC_CC_MSC && (_MSC_VER >= 1200)) +# define __acc_forceinline __forceinline +#elif (ACC_CC_SUNPROC && (ACC_CC_SUNPROC >= 0x5100)) +# define __acc_forceinline __inline__ __attribute__((__always_inline__)) +#endif +#endif +#if defined(__acc_forceinline) +# define __acc_HAVE_forceinline 1 +#else +# define __acc_forceinline /*empty*/ +#endif +#if !defined(__acc_noinline) +#if 1 && (ACC_ARCH_I386) && (ACC_CC_GNUC >= 0x040000ul) && (ACC_CC_GNUC < 0x040003ul) +# define __acc_noinline __attribute__((__noinline__,__used__)) +#elif (ACC_CC_GNUC >= 0x030200ul) +# define __acc_noinline __attribute__((__noinline__)) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 600) && ACC_CC_SYNTAX_MSC) +# define __acc_noinline __declspec(noinline) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800) && ACC_CC_SYNTAX_GNUC) +# define __acc_noinline __attribute__((__noinline__)) +#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __acc_noinline __attribute__((__noinline__)) +#elif (ACC_CC_MSC && (_MSC_VER >= 1300)) +# define __acc_noinline __declspec(noinline) +#elif (ACC_CC_MWERKS && (__MWERKS__ >= 0x3200) && (ACC_OS_WIN32 || ACC_OS_WIN64)) +# if defined(__cplusplus) +# else +# define __acc_noinline __declspec(noinline) +# endif +#elif (ACC_CC_SUNPROC && (ACC_CC_SUNPROC >= 0x5100)) +# define __acc_noinline __attribute__((__noinline__)) +#endif +#endif +#if defined(__acc_noinline) +# define __acc_HAVE_noinline 1 +#else +# define __acc_noinline /*empty*/ +#endif +#if (__acc_HAVE_forceinline || __acc_HAVE_noinline) && !(__acc_HAVE_inline) +# error "this should not happen" +#endif +#if !defined(__acc_noreturn) +#if (ACC_CC_GNUC >= 0x020700ul) +# define __acc_noreturn __attribute__((__noreturn__)) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 450) && ACC_CC_SYNTAX_MSC) +# define __acc_noreturn __declspec(noreturn) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 600) && ACC_CC_SYNTAX_GNUC) +# define __acc_noreturn __attribute__((__noreturn__)) +#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __acc_noreturn __attribute__((__noreturn__)) +#elif (ACC_CC_MSC && (_MSC_VER >= 1200)) +# define __acc_noreturn __declspec(noreturn) +#endif +#endif +#if defined(__acc_noreturn) +# define __acc_HAVE_noreturn 1 +#else +# define __acc_noreturn /*empty*/ +#endif +#if !defined(__acc_nothrow) +#if (ACC_CC_GNUC >= 0x030300ul) +# define __acc_nothrow __attribute__((__nothrow__)) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 450) && ACC_CC_SYNTAX_MSC) && defined(__cplusplus) +# define __acc_nothrow __declspec(nothrow) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 900) && ACC_CC_SYNTAX_GNUC) +# define __acc_nothrow __attribute__((__nothrow__)) +#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __acc_nothrow __attribute__((__nothrow__)) +#elif (ACC_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) +# define __acc_nothrow __declspec(nothrow) +#endif +#endif +#if defined(__acc_nothrow) +# define __acc_HAVE_nothrow 1 +#else +# define __acc_nothrow /*empty*/ +#endif +#if !defined(__acc_restrict) +#if (ACC_CC_GNUC >= 0x030400ul) +# define __acc_restrict __restrict__ +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 600) && ACC_CC_SYNTAX_GNUC) +# define __acc_restrict __restrict__ +#elif (ACC_CC_CLANG || ACC_CC_LLVM) +# define __acc_restrict __restrict__ +#elif (ACC_CC_MSC && (_MSC_VER >= 1400)) +# define __acc_restrict __restrict +#endif +#endif +#if defined(__acc_restrict) +# define __acc_HAVE_restrict 1 +#else +# define __acc_restrict /*empty*/ +#endif +#if !defined(__acc_likely) && !defined(__acc_unlikely) +#if (ACC_CC_GNUC >= 0x030200ul) +# define __acc_likely(e) (__builtin_expect(!!(e),1)) +# define __acc_unlikely(e) (__builtin_expect(!!(e),0)) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 800)) +# define __acc_likely(e) (__builtin_expect(!!(e),1)) +# define __acc_unlikely(e) (__builtin_expect(!!(e),0)) +#elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __acc_likely(e) (__builtin_expect(!!(e),1)) +# define __acc_unlikely(e) (__builtin_expect(!!(e),0)) +#endif +#endif +#if defined(__acc_likely) +# define __acc_HAVE_likely 1 +#else +# define __acc_likely(e) (e) +#endif +#if defined(__acc_unlikely) +# define __acc_HAVE_unlikely 1 +#else +# define __acc_unlikely(e) (e) +#endif +#if !defined(ACC_UNUSED) +# if (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +# define ACC_UNUSED(var) ((void) &var) +# elif (ACC_CC_BORLANDC || ACC_CC_HIGHC || ACC_CC_NDPC || ACC_CC_PELLESC || ACC_CC_TURBOC) +# define ACC_UNUSED(var) if (&var) ; else +# elif (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define ACC_UNUSED(var) ((void) var) +# elif (ACC_CC_MSC && (_MSC_VER < 900)) +# define ACC_UNUSED(var) if (&var) ; else +# elif (ACC_CC_KEILC) +# define ACC_UNUSED(var) {extern int __acc_unused[1-2*!(sizeof(var)>0)];} +# elif (ACC_CC_PACIFICC) +# define ACC_UNUSED(var) ((void) sizeof(var)) +# elif (ACC_CC_WATCOMC) && defined(__cplusplus) +# define ACC_UNUSED(var) ((void) var) +# else +# define ACC_UNUSED(var) ((void) &var) +# endif +#endif +#if !defined(ACC_UNUSED_FUNC) +# if (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +# define ACC_UNUSED_FUNC(func) ((void) func) +# elif (ACC_CC_BORLANDC || ACC_CC_NDPC || ACC_CC_TURBOC) +# define ACC_UNUSED_FUNC(func) if (func) ; else +# elif (ACC_CC_CLANG || ACC_CC_LLVM) +# define ACC_UNUSED_FUNC(func) ((void) &func) +# elif (ACC_CC_MSC && (_MSC_VER < 900)) +# define ACC_UNUSED_FUNC(func) if (func) ; else +# elif (ACC_CC_MSC) +# define ACC_UNUSED_FUNC(func) ((void) &func) +# elif (ACC_CC_KEILC || ACC_CC_PELLESC) +# define ACC_UNUSED_FUNC(func) {extern int __acc_unused[1-2*!(sizeof((int)func)>0)];} +# else +# define ACC_UNUSED_FUNC(func) ((void) func) +# endif +#endif +#if !defined(ACC_UNUSED_LABEL) +# if (ACC_CC_WATCOMC) && defined(__cplusplus) +# define ACC_UNUSED_LABEL(l) switch(0) case 1:goto l +# elif (ACC_CC_CLANG || ACC_CC_INTELC || ACC_CC_WATCOMC) +# define ACC_UNUSED_LABEL(l) if (0) goto l +# else +# define ACC_UNUSED_LABEL(l) switch(0) case 1:goto l +# endif +#endif +#if !defined(ACC_DEFINE_UNINITIALIZED_VAR) +# if 0 +# define ACC_DEFINE_UNINITIALIZED_VAR(type,var,init) type var +# elif 0 && (ACC_CC_GNUC) +# define ACC_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var +# else +# define ACC_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init +# endif +#endif +#if !defined(ACC_UNCONST_CAST) +# if 0 && defined(__cplusplus) +# define ACC_UNCONST_CAST(t,e) (const_cast<t> (e)) +# elif (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define ACC_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((acc_uintptr_t) ((const void *) (e)))))) +# else +# define ACC_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) +# endif +#endif +#if !defined(ACC_COMPILE_TIME_ASSERT_HEADER) +# if (ACC_CC_AZTECC || ACC_CC_ZORTECHC) +# define ACC_COMPILE_TIME_ASSERT_HEADER(e) extern int __acc_cta[1-!(e)]; +# elif (ACC_CC_DMC || ACC_CC_SYMANTECC) +# define ACC_COMPILE_TIME_ASSERT_HEADER(e) extern int __acc_cta[1u-2*!(e)]; +# elif (ACC_CC_TURBOC && (__TURBOC__ == 0x0295)) +# define ACC_COMPILE_TIME_ASSERT_HEADER(e) extern int __acc_cta[1-!(e)]; +# else +# define ACC_COMPILE_TIME_ASSERT_HEADER(e) extern int __acc_cta[1-2*!(e)]; +# endif +#endif +#if !defined(ACC_COMPILE_TIME_ASSERT) +# if (ACC_CC_AZTECC) +# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __acc_cta_t[1-!(e)];} +# elif (ACC_CC_DMC || ACC_CC_PACIFICC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) +# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; +# elif (ACC_CC_MSC && (_MSC_VER < 900)) +# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; +# elif (ACC_CC_TURBOC && (__TURBOC__ == 0x0295)) +# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; +# else +# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __acc_cta_t[1-2*!(e)];} +# endif +#endif +#if (ACC_ARCH_I086 || ACC_ARCH_I386) && (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) +# if (ACC_CC_GNUC || ACC_CC_HIGHC || ACC_CC_NDPC || ACC_CC_PACIFICC) +# elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) +# define __acc_cdecl __cdecl +# define __acc_cdecl_atexit /*empty*/ +# define __acc_cdecl_main __cdecl +# if (ACC_OS_OS2 && (ACC_CC_DMC || ACC_CC_SYMANTECC)) +# define __acc_cdecl_qsort __pascal +# elif (ACC_OS_OS2 && (ACC_CC_ZORTECHC)) +# define __acc_cdecl_qsort _stdcall +# else +# define __acc_cdecl_qsort __cdecl +# endif +# elif (ACC_CC_WATCOMC) +# define __acc_cdecl __cdecl +# else +# define __acc_cdecl __cdecl +# define __acc_cdecl_atexit __cdecl +# define __acc_cdecl_main __cdecl +# define __acc_cdecl_qsort __cdecl +# endif +# if (ACC_CC_GNUC || ACC_CC_HIGHC || ACC_CC_NDPC || ACC_CC_PACIFICC || ACC_CC_WATCOMC) +# elif (ACC_OS_OS2 && (ACC_CC_DMC || ACC_CC_SYMANTECC)) +# define __acc_cdecl_sighandler __pascal +# elif (ACC_OS_OS2 && (ACC_CC_ZORTECHC)) +# define __acc_cdecl_sighandler _stdcall +# elif (ACC_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) +# define __acc_cdecl_sighandler __clrcall +# elif (ACC_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) +# if defined(_DLL) +# define __acc_cdecl_sighandler _far _cdecl _loadds +# elif defined(_MT) +# define __acc_cdecl_sighandler _far _cdecl +# else +# define __acc_cdecl_sighandler _cdecl +# endif +# else +# define __acc_cdecl_sighandler __cdecl +# endif +#elif (ACC_ARCH_I386) && (ACC_CC_WATCOMC) +# define __acc_cdecl __cdecl +#elif (ACC_ARCH_M68K && ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC)) +# define __acc_cdecl cdecl +#endif +#if !defined(__acc_cdecl) +# define __acc_cdecl /*empty*/ +#endif +#if !defined(__acc_cdecl_atexit) +# define __acc_cdecl_atexit /*empty*/ +#endif +#if !defined(__acc_cdecl_main) +# define __acc_cdecl_main /*empty*/ +#endif +#if !defined(__acc_cdecl_qsort) +# define __acc_cdecl_qsort /*empty*/ +#endif +#if !defined(__acc_cdecl_sighandler) +# define __acc_cdecl_sighandler /*empty*/ +#endif +#if !defined(__acc_cdecl_va) +# define __acc_cdecl_va __acc_cdecl +#endif +#if !(ACC_CFG_NO_WINDOWS_H) +#if (ACC_OS_CYGWIN || (ACC_OS_EMX && defined(__RSXNT__)) || ACC_OS_WIN32 || ACC_OS_WIN64) +# if (ACC_CC_WATCOMC && (__WATCOMC__ < 1000)) +# elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__) +# elif ((ACC_OS_CYGWIN || defined(__MINGW32__)) && (ACC_CC_GNUC && (ACC_CC_GNUC < 0x025f00ul))) +# else +# define ACC_HAVE_WINDOWS_H 1 +# endif +#endif +#endif +#if (ACC_ARCH_ALPHA) +# define ACC_OPT_AVOID_UINT_INDEX 1 +# define ACC_OPT_AVOID_SHORT 1 +# define ACC_OPT_AVOID_USHORT 1 +#elif (ACC_ARCH_AMD64) +# define ACC_OPT_AVOID_INT_INDEX 1 +# define ACC_OPT_AVOID_UINT_INDEX 1 +# define ACC_OPT_UNALIGNED16 1 +# define ACC_OPT_UNALIGNED32 1 +# define ACC_OPT_UNALIGNED64 1 +#elif (ACC_ARCH_ARM && ACC_ARCH_ARM_THUMB) +#elif (ACC_ARCH_ARM) +# define ACC_OPT_AVOID_SHORT 1 +# define ACC_OPT_AVOID_USHORT 1 +#elif (ACC_ARCH_CRIS) +# define ACC_OPT_UNALIGNED16 1 +# define ACC_OPT_UNALIGNED32 1 +#elif (ACC_ARCH_I386) +# define ACC_OPT_UNALIGNED16 1 +# define ACC_OPT_UNALIGNED32 1 +#elif (ACC_ARCH_IA64) +# define ACC_OPT_AVOID_INT_INDEX 1 +# define ACC_OPT_AVOID_UINT_INDEX 1 +# define ACC_OPT_PREFER_POSTINC 1 +#elif (ACC_ARCH_M68K) +# define ACC_OPT_PREFER_POSTINC 1 +# define ACC_OPT_PREFER_PREDEC 1 +# if defined(__mc68020__) && !defined(__mcoldfire__) +# define ACC_OPT_UNALIGNED16 1 +# define ACC_OPT_UNALIGNED32 1 +# endif +#elif (ACC_ARCH_MIPS) +# define ACC_OPT_AVOID_UINT_INDEX 1 +#elif (ACC_ARCH_POWERPC) +# define ACC_OPT_PREFER_PREINC 1 +# define ACC_OPT_PREFER_PREDEC 1 +# if (ACC_ABI_BIG_ENDIAN) +# define ACC_OPT_UNALIGNED16 1 +# define ACC_OPT_UNALIGNED32 1 +# endif +#elif (ACC_ARCH_S390) +# define ACC_OPT_UNALIGNED16 1 +# define ACC_OPT_UNALIGNED32 1 +# if (ACC_SIZEOF_SIZE_T == 8) +# define ACC_OPT_UNALIGNED64 1 +# endif +#elif (ACC_ARCH_SH) +# define ACC_OPT_PREFER_POSTINC 1 +# define ACC_OPT_PREFER_PREDEC 1 +#endif +#ifndef ACC_CFG_NO_INLINE_ASM +#if (ACC_CC_LLVM) +# define ACC_CFG_NO_INLINE_ASM 1 +#endif +#endif +#ifndef ACC_CFG_NO_UNALIGNED +#if (ACC_ABI_NEUTRAL_ENDIAN) || (ACC_ARCH_GENERIC) +# define ACC_CFG_NO_UNALIGNED 1 +#endif +#endif +#if (ACC_CFG_NO_UNALIGNED) +# undef ACC_OPT_UNALIGNED16 +# undef ACC_OPT_UNALIGNED32 +# undef ACC_OPT_UNALIGNED64 +#endif +#if (ACC_CFG_NO_INLINE_ASM) +#elif (ACC_ARCH_I386 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC)) +# define ACC_ASM_SYNTAX_MSC 1 +#elif (ACC_OS_WIN64 && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC)) +#elif (ACC_ARCH_I386 && ACC_CC_GNUC && (ACC_CC_GNUC == 0x011f00ul)) +#elif (ACC_ARCH_I386 && (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE)) +# define ACC_ASM_SYNTAX_GNUC 1 +#elif (ACC_ARCH_AMD64 && (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE)) +# define ACC_ASM_SYNTAX_GNUC 1 +#endif +#if (ACC_ASM_SYNTAX_GNUC) +#if (ACC_ARCH_I386 && ACC_CC_GNUC && (ACC_CC_GNUC < 0x020000ul)) +# define __ACC_ASM_CLOBBER "ax" +#elif (ACC_CC_INTELC) +# define __ACC_ASM_CLOBBER "memory" +#else +# define __ACC_ASM_CLOBBER "cc", "memory" +#endif +#endif +#if defined(__ACC_INFOSTR_MM) +#elif (ACC_MM_FLAT) && (defined(__ACC_INFOSTR_PM) || defined(ACC_INFO_ABI_PM)) +# define __ACC_INFOSTR_MM "" +#elif defined(ACC_INFO_MM) +# define __ACC_INFOSTR_MM "." ACC_INFO_MM +#else +# define __ACC_INFOSTR_MM "" +#endif +#if defined(__ACC_INFOSTR_PM) +#elif defined(ACC_INFO_ABI_PM) +# define __ACC_INFOSTR_PM "." ACC_INFO_ABI_PM +#else +# define __ACC_INFOSTR_PM "" +#endif +#if defined(__ACC_INFOSTR_ENDIAN) +#elif defined(ACC_INFO_ABI_ENDIAN) +# define __ACC_INFOSTR_ENDIAN "." ACC_INFO_ABI_ENDIAN +#else +# define __ACC_INFOSTR_ENDIAN "" +#endif +#if defined(__ACC_INFOSTR_OSNAME) +#elif defined(ACC_INFO_OS_CONSOLE) +# define __ACC_INFOSTR_OSNAME ACC_INFO_OS "." ACC_INFO_OS_CONSOLE +#elif defined(ACC_INFO_OS_POSIX) +# define __ACC_INFOSTR_OSNAME ACC_INFO_OS "." ACC_INFO_OS_POSIX +#else +# define __ACC_INFOSTR_OSNAME ACC_INFO_OS +#endif +#if defined(__ACC_INFOSTR_LIBC) +#elif defined(ACC_INFO_LIBC) +# define __ACC_INFOSTR_LIBC "." ACC_INFO_LIBC +#else +# define __ACC_INFOSTR_LIBC "" +#endif +#if defined(__ACC_INFOSTR_CCVER) +#elif defined(ACC_INFO_CCVER) +# define __ACC_INFOSTR_CCVER " " ACC_INFO_CCVER +#else +# define __ACC_INFOSTR_CCVER "" +#endif +#define ACC_INFO_STRING \ + ACC_INFO_ARCH __ACC_INFOSTR_MM __ACC_INFOSTR_PM __ACC_INFOSTR_ENDIAN \ + " " __ACC_INFOSTR_OSNAME __ACC_INFOSTR_LIBC " " ACC_INFO_CC __ACC_INFOSTR_CCVER +#if (ACC_CFG_NO_CONFIG_HEADER) +#elif defined(ACC_CFG_CONFIG_HEADER) +#else +#if !(ACC_CFG_AUTO_NO_HEADERS) +#if (ACC_LIBC_NAKED) +#elif (ACC_LIBC_FREESTANDING) +# define HAVE_LIMITS_H 1 +# define HAVE_STDARG_H 1 +# define HAVE_STDDEF_H 1 +#elif (ACC_LIBC_MOSTLY_FREESTANDING) +# define HAVE_LIMITS_H 1 +# define HAVE_SETJMP_H 1 +# define HAVE_STDARG_H 1 +# define HAVE_STDDEF_H 1 +# define HAVE_STDIO_H 1 +# define HAVE_STRING_H 1 +#else +#define STDC_HEADERS 1 +#define HAVE_ASSERT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_DIRENT_H 1 +#define HAVE_ERRNO_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_SETJMP_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_TIME_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_UTIME_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_TYPES_H 1 +#if (ACC_OS_POSIX) +# if (ACC_OS_POSIX_AIX) +# define HAVE_SYS_RESOURCE_H 1 +# elif (ACC_OS_POSIX_FREEBSD || ACC_OS_POSIX_MACOSX || ACC_OS_POSIX_NETBSD || ACC_OS_POSIX_OPENBSD) +# define HAVE_STRINGS_H 1 +# undef HAVE_MALLOC_H +# elif (ACC_OS_POSIX_HPUX || ACC_OS_POSIX_INTERIX) +# define HAVE_ALLOCA_H 1 +# elif (ACC_OS_POSIX_MACOSX && ACC_LIBC_MSL) +# undef HAVE_SYS_TIME_H +# undef HAVE_SYS_TYPES_H +# elif (ACC_OS_POSIX_SOLARIS || ACC_OS_POSIX_SUNOS) +# define HAVE_ALLOCA_H 1 +# endif +# if (ACC_LIBC_DIETLIBC || ACC_LIBC_GLIBC || ACC_LIBC_UCLIBC) +# define HAVE_STRINGS_H 1 +# define HAVE_SYS_MMAN_H 1 +# define HAVE_SYS_RESOURCE_H 1 +# define HAVE_SYS_WAIT_H 1 +# endif +# if (ACC_LIBC_NEWLIB) +# undef HAVE_STRINGS_H +# endif +#elif (ACC_OS_CYGWIN) +# define HAVE_IO_H 1 +#elif (ACC_OS_EMX) +# define HAVE_ALLOCA_H 1 +# define HAVE_IO_H 1 +#elif (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) +# if !defined(__MINT__) +# undef HAVE_MALLOC_H +# endif +#elif (ACC_ARCH_M68K && ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC)) +# undef HAVE_DIRENT_H +# undef HAVE_FCNTL_H +# undef HAVE_MALLOC_H +# undef HAVE_MEMORY_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_STAT_H +# undef HAVE_SYS_TIME_H +# undef HAVE_SYS_TYPES_H +#endif +#if (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) +#define HAVE_CONIO_H 1 +#define HAVE_DIRECT_H 1 +#define HAVE_DOS_H 1 +#define HAVE_IO_H 1 +#define HAVE_SHARE_H 1 +#if (ACC_CC_AZTECC) +# undef HAVE_CONIO_H +# undef HAVE_DIRECT_H +# undef HAVE_DIRENT_H +# undef HAVE_MALLOC_H +# undef HAVE_SHARE_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_STAT_H +# undef HAVE_SYS_TIME_H +# undef HAVE_SYS_TYPES_H +#elif (ACC_CC_BORLANDC) +# undef HAVE_UNISTD_H +# undef HAVE_SYS_TIME_H +# if (ACC_OS_WIN32 || ACC_OS_WIN64) +# undef HAVE_DIRENT_H +# endif +# if (__BORLANDC__ < 0x0400) +# undef HAVE_DIRENT_H +# undef HAVE_UTIME_H +# endif +#elif (ACC_CC_DMC) +# undef HAVE_DIRENT_H +# undef HAVE_UNISTD_H +# define HAVE_SYS_DIRENT_H 1 +#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) +#elif (ACC_OS_DOS32 && ACC_CC_HIGHC) +# define HAVE_ALLOCA_H 1 +# undef HAVE_DIRENT_H +# undef HAVE_UNISTD_H +#elif (ACC_CC_IBMC && ACC_OS_OS2) +# undef HAVE_DOS_H +# undef HAVE_DIRENT_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_TIME_H +# define HAVE_SYS_UTIME_H 1 +#elif (ACC_CC_INTELC || ACC_CC_MSC) +# undef HAVE_DIRENT_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_TIME_H +# define HAVE_SYS_UTIME_H 1 +#elif (ACC_CC_LCCWIN32) +# undef HAVE_DIRENT_H +# undef HAVE_DOS_H +# undef HAVE_UNISTD_H +# undef HAVE_SYS_TIME_H +#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__MINGW32__) +# undef HAVE_UTIME_H +# define HAVE_SYS_UTIME_H 1 +#elif (ACC_OS_WIN32 && ACC_LIBC_MSL) +# define HAVE_ALLOCA_H 1 +# undef HAVE_DOS_H +# undef HAVE_SHARE_H +# undef HAVE_SYS_TIME_H +#elif (ACC_CC_NDPC) +# undef HAVE_DIRENT_H +# undef HAVE_DOS_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_TIME_H +#elif (ACC_CC_PACIFICC) +# undef HAVE_DIRECT_H +# undef HAVE_DIRENT_H +# undef HAVE_FCNTL_H +# undef HAVE_IO_H +# undef HAVE_MALLOC_H +# undef HAVE_MEMORY_H +# undef HAVE_SHARE_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_STAT_H +# undef HAVE_SYS_TIME_H +# undef HAVE_SYS_TYPES_H +#elif (ACC_OS_WIN32 && ACC_CC_PELLESC) +# undef HAVE_DIRENT_H +# undef HAVE_DOS_H +# undef HAVE_MALLOC_H +# undef HAVE_SHARE_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_TIME_H +# if (__POCC__ < 280) +# else +# define HAVE_SYS_UTIME_H 1 +# endif +#elif (ACC_OS_WIN32 && ACC_CC_PGI) && defined(__MINGW32__) +# undef HAVE_UTIME_H +# define HAVE_SYS_UTIME_H 1 +#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__) +#elif (ACC_CC_SYMANTECC) +# undef HAVE_DIRENT_H +# undef HAVE_UNISTD_H +# if (__SC__ < 0x700) +# undef HAVE_UTIME_H +# undef HAVE_SYS_TIME_H +# endif +#elif (ACC_CC_TOPSPEEDC) +# undef HAVE_DIRENT_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_STAT_H +# undef HAVE_SYS_TIME_H +# undef HAVE_SYS_TYPES_H +#elif (ACC_CC_TURBOC) +# undef HAVE_UNISTD_H +# undef HAVE_SYS_TIME_H +# undef HAVE_SYS_TYPES_H +# if (ACC_OS_WIN32 || ACC_OS_WIN64) +# undef HAVE_DIRENT_H +# endif +# if (__TURBOC__ < 0x0200) +# undef HAVE_SIGNAL_H +# endif +# if (__TURBOC__ < 0x0400) +# undef HAVE_DIRECT_H +# undef HAVE_DIRENT_H +# undef HAVE_MALLOC_H +# undef HAVE_MEMORY_H +# undef HAVE_UTIME_H +# endif +#elif (ACC_CC_WATCOMC) +# undef HAVE_DIRENT_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_TIME_H +# define HAVE_SYS_UTIME_H 1 +# if (__WATCOMC__ < 950) +# undef HAVE_UNISTD_H +# endif +#elif (ACC_CC_ZORTECHC) +# undef HAVE_DIRENT_H +# undef HAVE_MEMORY_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_TIME_H +#endif +#endif +#if (ACC_OS_CONSOLE) +# undef HAVE_DIRENT_H +#endif +#if (ACC_OS_EMBEDDED) +# undef HAVE_DIRENT_H +#endif +#if (ACC_LIBC_ISOC90 || ACC_LIBC_ISOC99) +# undef HAVE_DIRENT_H +# undef HAVE_FCNTL_H +# undef HAVE_MALLOC_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_STAT_H +# undef HAVE_SYS_TIME_H +# undef HAVE_SYS_TYPES_H +#endif +#if (ACC_LIBC_GLIBC >= 0x020100ul) +# define HAVE_STDINT_H 1 +#elif (ACC_LIBC_DIETLIBC) +# undef HAVE_STDINT_H +#elif (ACC_LIBC_UCLIBC) +# define HAVE_STDINT_H 1 +#elif (ACC_CC_BORLANDC) && (__BORLANDC__ >= 0x560) +# undef HAVE_STDINT_H +#elif (ACC_CC_DMC) && (__DMC__ >= 0x825) +# define HAVE_STDINT_H 1 +#endif +#if (HAVE_SYS_TIME_H && HAVE_TIME_H) +# define TIME_WITH_SYS_TIME 1 +#endif +#endif +#endif +#if !(ACC_CFG_AUTO_NO_FUNCTIONS) +#if (ACC_LIBC_NAKED) +#elif (ACC_LIBC_FREESTANDING) +#elif (ACC_LIBC_MOSTLY_FREESTANDING) +# define HAVE_LONGJMP 1 +# define HAVE_MEMCMP 1 +# define HAVE_MEMCPY 1 +# define HAVE_MEMMOVE 1 +# define HAVE_MEMSET 1 +# define HAVE_SETJMP 1 +#else +#define HAVE_ACCESS 1 +#define HAVE_ALLOCA 1 +#define HAVE_ATEXIT 1 +#define HAVE_ATOI 1 +#define HAVE_ATOL 1 +#define HAVE_CHMOD 1 +#define HAVE_CHOWN 1 +#define HAVE_CTIME 1 +#define HAVE_DIFFTIME 1 +#define HAVE_FILENO 1 +#define HAVE_FSTAT 1 +#define HAVE_GETENV 1 +#define HAVE_GETTIMEOFDAY 1 +#define HAVE_GMTIME 1 +#define HAVE_ISATTY 1 +#define HAVE_LOCALTIME 1 +#define HAVE_LONGJMP 1 +#define HAVE_LSTAT 1 +#define HAVE_MEMCMP 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMSET 1 +#define HAVE_MKDIR 1 +#define HAVE_MKTIME 1 +#define HAVE_QSORT 1 +#define HAVE_RAISE 1 +#define HAVE_RMDIR 1 +#define HAVE_SETJMP 1 +#define HAVE_SIGNAL 1 +#define HAVE_SNPRINTF 1 +#define HAVE_STAT 1 +#define HAVE_STRCHR 1 +#define HAVE_STRDUP 1 +#define HAVE_STRERROR 1 +#define HAVE_STRFTIME 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_TIME 1 +#define HAVE_UMASK 1 +#define HAVE_UTIME 1 +#define HAVE_VSNPRINTF 1 +#if (ACC_OS_BEOS || ACC_OS_CYGWIN || ACC_OS_POSIX || ACC_OS_QNX || ACC_OS_VMS) +# define HAVE_STRCASECMP 1 +# define HAVE_STRNCASECMP 1 +#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__) +# define HAVE_STRCASECMP 1 +# define HAVE_STRNCASECMP 1 +#else +# define HAVE_STRICMP 1 +# define HAVE_STRNICMP 1 +#endif +#if (ACC_OS_POSIX) +# if (ACC_OS_POSIX_AIX) +# define HAVE_GETRUSAGE 1 +# elif (ACC_OS_POSIX_MACOSX && ACC_LIBC_MSL) +# undef HAVE_CHOWN +# undef HAVE_LSTAT +# elif (ACC_OS_POSIX_UNICOS) +# undef HAVE_ALLOCA +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# endif +# if (ACC_CC_TINYC) +# undef HAVE_ALLOCA +# endif +# if (ACC_LIBC_DIETLIBC || ACC_LIBC_GLIBC || ACC_LIBC_UCLIBC) +# define HAVE_GETRUSAGE 1 +# define HAVE_GETPAGESIZE 1 +# define HAVE_MMAP 1 +# define HAVE_MPROTECT 1 +# define HAVE_MUNMAP 1 +# endif +#elif (ACC_OS_CYGWIN) +# if (ACC_CC_GNUC < 0x025a00ul) +# undef HAVE_GETTIMEOFDAY +# undef HAVE_LSTAT +# endif +# if (ACC_CC_GNUC < 0x025f00ul) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# endif +#elif (ACC_OS_EMX) +# undef HAVE_CHOWN +# undef HAVE_LSTAT +#elif (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) +# if !defined(__MINT__) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# endif +#elif (ACC_ARCH_M68K && ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC)) +# undef HAVE_ALLOCA +# undef HAVE_ACCESS +# undef HAVE_CHMOD +# undef HAVE_CHOWN +# undef HAVE_FSTAT +# undef HAVE_GETTIMEOFDAY +# undef HAVE_LSTAT +# undef HAVE_SNPRINTF +# undef HAVE_UMASK +# undef HAVE_UTIME +# undef HAVE_VSNPRINTF +#endif +#if (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) +#undef HAVE_CHOWN +#undef HAVE_GETTIMEOFDAY +#undef HAVE_LSTAT +#undef HAVE_UMASK +#if (ACC_CC_AZTECC) +# undef HAVE_ALLOCA +# undef HAVE_DIFFTIME +# undef HAVE_FSTAT +# undef HAVE_STRDUP +# undef HAVE_SNPRINTF +# undef HAVE_UTIME +# undef HAVE_VSNPRINTF +#elif (ACC_CC_BORLANDC) +# if (__BORLANDC__ < 0x0400) +# undef HAVE_ALLOCA +# undef HAVE_UTIME +# endif +# if ((__BORLANDC__ < 0x0410) && ACC_OS_WIN16) +# undef HAVE_ALLOCA +# endif +# if (__BORLANDC__ < 0x0550) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# endif +#elif (ACC_CC_DMC) +# if (ACC_OS_WIN16) +# undef HAVE_ALLOCA +# endif +# define snprintf _snprintf +# define vsnprintf _vsnprintf +#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +#elif (ACC_OS_DOS32 && ACC_CC_HIGHC) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +#elif (ACC_CC_IBMC) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +#elif (ACC_CC_INTELC) +# ifndef snprintf +# define snprintf _snprintf +# endif +# ifndef vsnprintf +# define vsnprintf _vsnprintf +# endif +#elif (ACC_CC_LCCWIN32) +# define utime _utime +#elif (ACC_CC_MSC) +# if (_MSC_VER < 600) +# undef HAVE_STRFTIME +# endif +# if (_MSC_VER < 700) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# elif (_MSC_VER < 1500) +# ifndef snprintf +# define snprintf _snprintf +# endif +# ifndef vsnprintf +# define vsnprintf _vsnprintf +# endif +# else +# ifndef snprintf +# define snprintf _snprintf +# endif +# endif +# if ((_MSC_VER < 800) && ACC_OS_WIN16) +# undef HAVE_ALLOCA +# endif +# if (ACC_ARCH_I086) && defined(__cplusplus) +# undef HAVE_LONGJMP +# undef HAVE_SETJMP +# endif +#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__MINGW32__) +# if (ACC_CC_GNUC < 0x025f00ul) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# else +# define snprintf _snprintf +# define vsnprintf _vsnprintf +# endif +#elif (ACC_OS_WIN32 && ACC_LIBC_MSL) +# if (__MSL__ < 0x8000ul) +# undef HAVE_CHMOD +# endif +#elif (ACC_CC_NDPC) +# undef HAVE_ALLOCA +# undef HAVE_SNPRINTF +# undef HAVE_STRNICMP +# undef HAVE_UTIME +# undef HAVE_VSNPRINTF +# if defined(__cplusplus) +# undef HAVE_STAT +# endif +#elif (ACC_CC_PACIFICC) +# undef HAVE_ACCESS +# undef HAVE_ALLOCA +# undef HAVE_CHMOD +# undef HAVE_DIFFTIME +# undef HAVE_FSTAT +# undef HAVE_MKTIME +# undef HAVE_RAISE +# undef HAVE_SNPRINTF +# undef HAVE_STRFTIME +# undef HAVE_UTIME +# undef HAVE_VSNPRINTF +#elif (ACC_OS_WIN32 && ACC_CC_PELLESC) +# if (__POCC__ < 280) +# define alloca _alloca +# undef HAVE_UTIME +# endif +#elif (ACC_OS_WIN32 && ACC_CC_PGI) && defined(__MINGW32__) +# define snprintf _snprintf +# define vsnprintf _vsnprintf +#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +#elif (ACC_CC_SYMANTECC) +# if (ACC_OS_WIN16 && (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE)) +# undef HAVE_ALLOCA +# endif +# if (__SC__ < 0x600) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# else +# define snprintf _snprintf +# define vsnprintf _vsnprintf +# endif +# if (__SC__ < 0x700) +# undef HAVE_DIFFTIME +# undef HAVE_UTIME +# endif +#elif (ACC_CC_TOPSPEEDC) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +#elif (ACC_CC_TURBOC) +# undef HAVE_ALLOCA +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# if (__TURBOC__ < 0x0200) +# undef HAVE_RAISE +# undef HAVE_SIGNAL +# endif +# if (__TURBOC__ < 0x0295) +# undef HAVE_MKTIME +# undef HAVE_STRFTIME +# endif +# if (__TURBOC__ < 0x0400) +# undef HAVE_UTIME +# endif +#elif (ACC_CC_WATCOMC) +# if (__WATCOMC__ < 1100) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# elif (__WATCOMC__ < 1200) +# define snprintf _snprintf +# define vsnprintf _vsnprintf +# endif +#elif (ACC_CC_ZORTECHC) +# if (ACC_OS_WIN16 && (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE)) +# undef HAVE_ALLOCA +# endif +# undef HAVE_DIFFTIME +# undef HAVE_SNPRINTF +# undef HAVE_UTIME +# undef HAVE_VSNPRINTF +#endif +#endif +#if (ACC_OS_CONSOLE) +# undef HAVE_ACCESS +# undef HAVE_CHMOD +# undef HAVE_CHOWN +# undef HAVE_GETTIMEOFDAY +# undef HAVE_LSTAT +# undef HAVE_TIME +# undef HAVE_UMASK +# undef HAVE_UTIME +#endif +#if (ACC_LIBC_ISOC90 || ACC_LIBC_ISOC99) +# undef HAVE_ACCESS +# undef HAVE_CHMOD +# undef HAVE_CHOWN +# undef HAVE_FSTAT +# undef HAVE_GETTIMEOFDAY +# undef HAVE_LSTAT +# undef HAVE_STAT +# undef HAVE_UMASK +# undef HAVE_UTIME +# if 1 +# undef HAVE_ALLOCA +# undef HAVE_ISATTY +# undef HAVE_MKDIR +# undef HAVE_RMDIR +# undef HAVE_STRDUP +# undef HAVE_STRICMP +# undef HAVE_STRNICMP +# endif +#endif +#endif +#endif +#if !(ACC_CFG_AUTO_NO_SIZES) +#if !defined(SIZEOF_SHORT) && defined(ACC_SIZEOF_SHORT) +# define SIZEOF_SHORT ACC_SIZEOF_SHORT +#endif +#if !defined(SIZEOF_INT) && defined(ACC_SIZEOF_INT) +# define SIZEOF_INT ACC_SIZEOF_INT +#endif +#if !defined(SIZEOF_LONG) && defined(ACC_SIZEOF_LONG) +# define SIZEOF_LONG ACC_SIZEOF_LONG +#endif +#if !defined(SIZEOF_LONG_LONG) && defined(ACC_SIZEOF_LONG_LONG) +# define SIZEOF_LONG_LONG ACC_SIZEOF_LONG_LONG +#endif +#if !defined(SIZEOF___INT32) && defined(ACC_SIZEOF___INT32) +# define SIZEOF___INT32 ACC_SIZEOF___INT32 +#endif +#if !defined(SIZEOF___INT64) && defined(ACC_SIZEOF___INT64) +# define SIZEOF___INT64 ACC_SIZEOF___INT64 +#endif +#if !defined(SIZEOF_VOID_P) && defined(ACC_SIZEOF_VOID_P) +# define SIZEOF_VOID_P ACC_SIZEOF_VOID_P +#endif +#if !defined(SIZEOF_SIZE_T) && defined(ACC_SIZEOF_SIZE_T) +# define SIZEOF_SIZE_T ACC_SIZEOF_SIZE_T +#endif +#if !defined(SIZEOF_PTRDIFF_T) && defined(ACC_SIZEOF_PTRDIFF_T) +# define SIZEOF_PTRDIFF_T ACC_SIZEOF_PTRDIFF_T +#endif +#endif +#if (HAVE_SIGNAL) && !defined(RETSIGTYPE) +# define RETSIGTYPE void +#endif +#endif +#if (ACC_CFG_NO_ACC_TYPE_H) +#else +#if (ACC_SIZEOF_LONG_LONG+0 > 0) +__acc_gnuc_extension__ typedef long long acc_llong_t; +__acc_gnuc_extension__ typedef unsigned long long acc_ullong_t; +#endif +#if (!(ACC_SIZEOF_SHORT+0 > 0 && ACC_SIZEOF_INT+0 > 0 && ACC_SIZEOF_LONG+0 > 0)) +# error "missing defines for sizes" +#endif +#if (!(ACC_SIZEOF_PTRDIFF_T+0 > 0 && ACC_SIZEOF_SIZE_T+0 > 0 && ACC_SIZEOF_VOID_P+0 > 0)) +# error "missing defines for sizes" +#endif +#if !defined(acc_int16e_t) +#if (ACC_SIZEOF_LONG == 2) +# define acc_int16e_t long +# define acc_uint16e_t unsigned long +#elif (ACC_SIZEOF_INT == 2) +# define acc_int16e_t int +# define acc_uint16e_t unsigned int +#elif (ACC_SIZEOF_SHORT == 2) +# define acc_int16e_t short int +# define acc_uint16e_t unsigned short int +#elif 1 && !(ACC_CFG_TYPE_NO_MODE_HI) && (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x025f00ul) || ACC_CC_LLVM) + typedef int __acc_int16e_hi_t __attribute__((__mode__(__HI__))); + typedef unsigned int __acc_uint16e_hi_t __attribute__((__mode__(__HI__))); +# define acc_int16e_t __acc_int16e_hi_t +# define acc_uint16e_t __acc_uint16e_hi_t +#elif (ACC_SIZEOF___INT16 == 2) +# define acc_int16e_t __int16 +# define acc_uint16e_t unsigned __int16 +#else +#endif +#endif +#if defined(acc_int16e_t) +# define ACC_SIZEOF_ACC_INT16E_T 2 +#endif +#if !defined(acc_int32e_t) +#if (ACC_SIZEOF_LONG == 4) +# define acc_int32e_t long int +# define acc_uint32e_t unsigned long int +#elif (ACC_SIZEOF_INT == 4) +# define acc_int32e_t int +# define acc_uint32e_t unsigned int +#elif (ACC_SIZEOF_SHORT == 4) +# define acc_int32e_t short int +# define acc_uint32e_t unsigned short int +#elif (ACC_SIZEOF_LONG_LONG == 4) +# define acc_int32e_t acc_llong_t +# define acc_uint32e_t acc_ullong_t +#elif 1 && !(ACC_CFG_TYPE_NO_MODE_SI) && (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x025f00ul) || ACC_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) + typedef int __acc_int32e_si_t __attribute__((__mode__(__SI__))); + typedef unsigned int __acc_uint32e_si_t __attribute__((__mode__(__SI__))); +# define acc_int32e_t __acc_int32e_si_t +# define acc_uint32e_t __acc_uint32e_si_t +#elif 1 && !(ACC_CFG_TYPE_NO_MODE_SI) && (ACC_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) + typedef int __acc_int32e_si_t __attribute__((__mode__(__SI__))); + typedef unsigned int __acc_uint32e_si_t __attribute__((__mode__(__SI__))); +# define acc_int32e_t __acc_int32e_si_t +# define acc_uint32e_t __acc_uint32e_si_t +# define ACC_INT32_C(c) c##LL +# define ACC_UINT32_C(c) c##ULL +#elif (ACC_SIZEOF___INT32 == 4) +# define acc_int32e_t __int32 +# define acc_uint32e_t unsigned __int32 +#else +#endif +#endif +#if defined(acc_int32e_t) +# define ACC_SIZEOF_ACC_INT32E_T 4 +#endif +#if !defined(acc_int64e_t) +#if (ACC_SIZEOF___INT64 == 8) +# if (ACC_CC_BORLANDC) && !(ACC_CFG_TYPE_PREFER___INT64) +# define ACC_CFG_TYPE_PREFER___INT64 1 +# endif +#endif +#if (ACC_SIZEOF_INT == 8) && (ACC_SIZEOF_INT < ACC_SIZEOF_LONG) +# define acc_int64e_t int +# define acc_uint64e_t unsigned int +# define ACC_SIZEOF_ACC_INT64E_T ACC_SIZEOF_INT +#elif (ACC_SIZEOF_LONG == 8) +# define acc_int64e_t long int +# define acc_uint64e_t unsigned long int +# define ACC_SIZEOF_ACC_INT64E_T ACC_SIZEOF_LONG +#elif (ACC_SIZEOF_LONG_LONG == 8) && !(ACC_CFG_TYPE_PREFER___INT64) +# define acc_int64e_t acc_llong_t +# define acc_uint64e_t acc_ullong_t +# if (ACC_CC_BORLANDC) +# define ACC_INT64_C(c) ((c) + 0ll) +# define ACC_UINT64_C(c) ((c) + 0ull) +# else +# define ACC_INT64_C(c) c##LL +# define ACC_UINT64_C(c) c##ULL +# endif +# define ACC_SIZEOF_ACC_INT64E_T ACC_SIZEOF_LONG_LONG +#elif (ACC_SIZEOF___INT64 == 8) +# define acc_int64e_t __int64 +# define acc_uint64e_t unsigned __int64 +# if (ACC_CC_BORLANDC) +# define ACC_INT64_C(c) ((c) + 0i64) +# define ACC_UINT64_C(c) ((c) + 0ui64) +# else +# define ACC_INT64_C(c) c##i64 +# define ACC_UINT64_C(c) c##ui64 +# endif +# define ACC_SIZEOF_ACC_INT64E_T ACC_SIZEOF___INT64 +#else +#endif +#endif +#if !defined(acc_int32l_t) +#if defined(acc_int32e_t) +# define acc_int32l_t acc_int32e_t +# define acc_uint32l_t acc_uint32e_t +# define ACC_SIZEOF_ACC_INT32L_T ACC_SIZEOF_ACC_INT32E_T +#elif (ACC_SIZEOF_INT >= 4) && (ACC_SIZEOF_INT < ACC_SIZEOF_LONG) +# define acc_int32l_t int +# define acc_uint32l_t unsigned int +# define ACC_SIZEOF_ACC_INT32L_T ACC_SIZEOF_INT +#elif (ACC_SIZEOF_LONG >= 4) +# define acc_int32l_t long int +# define acc_uint32l_t unsigned long int +# define ACC_SIZEOF_ACC_INT32L_T ACC_SIZEOF_LONG +#else +# error "acc_int32l_t" +#endif +#endif +#if !defined(acc_int64l_t) +#if defined(acc_int64e_t) +# define acc_int64l_t acc_int64e_t +# define acc_uint64l_t acc_uint64e_t +# define ACC_SIZEOF_ACC_INT64L_T ACC_SIZEOF_ACC_INT64E_T +#else +#endif +#endif +#if !defined(acc_int32f_t) +#if (ACC_SIZEOF_SIZE_T >= 8) +# define acc_int32f_t acc_int64l_t +# define acc_uint32f_t acc_uint64l_t +# define ACC_SIZEOF_ACC_INT32F_T ACC_SIZEOF_ACC_INT64L_T +#else +# define acc_int32f_t acc_int32l_t +# define acc_uint32f_t acc_uint32l_t +# define ACC_SIZEOF_ACC_INT32F_T ACC_SIZEOF_ACC_INT32L_T +#endif +#endif +#if !defined(acc_intptr_t) +#if 1 && (ACC_OS_OS400 && (ACC_SIZEOF_VOID_P == 16)) +# define __ACC_INTPTR_T_IS_POINTER 1 + typedef char* acc_intptr_t; + typedef char* acc_uintptr_t; +# define acc_intptr_t acc_intptr_t +# define acc_uintptr_t acc_uintptr_t +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_VOID_P +#elif (ACC_CC_MSC && (_MSC_VER >= 1300) && (ACC_SIZEOF_VOID_P == 4) && (ACC_SIZEOF_INT == 4)) + typedef __w64 int acc_intptr_t; + typedef __w64 unsigned int acc_uintptr_t; +# define acc_intptr_t acc_intptr_t +# define acc_uintptr_t acc_uintptr_t +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_INT +#elif (ACC_SIZEOF_SHORT == ACC_SIZEOF_VOID_P) && (ACC_SIZEOF_INT > ACC_SIZEOF_VOID_P) +# define acc_intptr_t short +# define acc_uintptr_t unsigned short +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_SHORT +#elif (ACC_SIZEOF_INT >= ACC_SIZEOF_VOID_P) && (ACC_SIZEOF_INT < ACC_SIZEOF_LONG) +# define acc_intptr_t int +# define acc_uintptr_t unsigned int +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_INT +#elif (ACC_SIZEOF_LONG >= ACC_SIZEOF_VOID_P) +# define acc_intptr_t long +# define acc_uintptr_t unsigned long +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_LONG +#elif (ACC_SIZEOF_ACC_INT64L_T >= ACC_SIZEOF_VOID_P) +# define acc_intptr_t acc_int64l_t +# define acc_uintptr_t acc_uint64l_t +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_ACC_INT64L_T +#else +# error "acc_intptr_t" +#endif +#endif +#if !defined(acc_word_t) +#if defined(ACC_WORDSIZE) && (ACC_WORDSIZE > 0) +#if (ACC_WORDSIZE == ACC_SIZEOF_ACC_INTPTR_T) && !defined(__ACC_INTPTR_T_IS_POINTER) +# define acc_word_t acc_uintptr_t +# define acc_sword_t acc_intptr_t +# define ACC_SIZEOF_ACC_WORD_T ACC_SIZEOF_ACC_INTPTR_T +#elif (ACC_WORDSIZE == ACC_SIZEOF_LONG) +# define acc_word_t unsigned long +# define acc_sword_t long +# define ACC_SIZEOF_ACC_WORD_T ACC_SIZEOF_LONG +#elif (ACC_WORDSIZE == ACC_SIZEOF_INT) +# define acc_word_t unsigned int +# define acc_sword_t int +# define ACC_SIZEOF_ACC_WORD_T ACC_SIZEOF_INT +#elif (ACC_WORDSIZE == ACC_SIZEOF_SHORT) +# define acc_word_t unsigned short +# define acc_sword_t short +# define ACC_SIZEOF_ACC_WORD_T ACC_SIZEOF_SHORT +#elif (ACC_WORDSIZE == 1) +# define acc_word_t unsigned char +# define acc_sword_t signed char +# define ACC_SIZEOF_ACC_WORD_T 1 +#elif (ACC_WORDSIZE == ACC_SIZEOF_ACC_INT64L_T) +# define acc_word_t acc_uint64l_t +# define acc_sword_t acc_int64l_t +# define ACC_SIZEOF_ACC_WORD_T ACC_SIZEOF_ACC_INT64L_T +#elif (ACC_ARCH_SPU) && (ACC_CC_GNUC) +#if 0 + typedef unsigned acc_word_t __attribute__((__mode__(__V16QI__))); + typedef int acc_sword_t __attribute__((__mode__(__V16QI__))); +# define acc_word_t acc_word_t +# define acc_sword_t acc_sword_t +# define ACC_SIZEOF_ACC_WORD_T 16 +#endif +#else +# error "acc_word_t" +#endif +#endif +#endif +#if !defined(ACC_INT16_C) +# if (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_INT >= 2) +# define ACC_INT16_C(c) ((c) + 0) +# define ACC_UINT16_C(c) ((c) + 0U) +# elif (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_LONG >= 2) +# define ACC_INT16_C(c) ((c) + 0L) +# define ACC_UINT16_C(c) ((c) + 0UL) +# elif (ACC_SIZEOF_INT >= 2) +# define ACC_INT16_C(c) c +# define ACC_UINT16_C(c) c##U +# elif (ACC_SIZEOF_LONG >= 2) +# define ACC_INT16_C(c) c##L +# define ACC_UINT16_C(c) c##UL +# else +# error "ACC_INT16_C" +# endif +#endif +#if !defined(ACC_INT32_C) +# if (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_INT >= 4) +# define ACC_INT32_C(c) ((c) + 0) +# define ACC_UINT32_C(c) ((c) + 0U) +# elif (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_LONG >= 4) +# define ACC_INT32_C(c) ((c) + 0L) +# define ACC_UINT32_C(c) ((c) + 0UL) +# elif (ACC_SIZEOF_INT >= 4) +# define ACC_INT32_C(c) c +# define ACC_UINT32_C(c) c##U +# elif (ACC_SIZEOF_LONG >= 4) +# define ACC_INT32_C(c) c##L +# define ACC_UINT32_C(c) c##UL +# elif (ACC_SIZEOF_LONG_LONG >= 4) +# define ACC_INT32_C(c) c##LL +# define ACC_UINT32_C(c) c##ULL +# else +# error "ACC_INT32_C" +# endif +#endif +#if !defined(ACC_INT64_C) && defined(acc_int64l_t) +# if (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_INT >= 8) +# define ACC_INT64_C(c) ((c) + 0) +# define ACC_UINT64_C(c) ((c) + 0U) +# elif (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_LONG >= 8) +# define ACC_INT64_C(c) ((c) + 0L) +# define ACC_UINT64_C(c) ((c) + 0UL) +# elif (ACC_SIZEOF_INT >= 8) +# define ACC_INT64_C(c) c +# define ACC_UINT64_C(c) c##U +# elif (ACC_SIZEOF_LONG >= 8) +# define ACC_INT64_C(c) c##L +# define ACC_UINT64_C(c) c##UL +# else +# error "ACC_INT64_C" +# endif +#endif +#if !defined(SIZEOF_ACC_INT16E_T) && defined(ACC_SIZEOF_ACC_INT16E_T) +# define SIZEOF_ACC_INT16E_T ACC_SIZEOF_ACC_INT16E_T +#endif +#if !defined(SIZEOF_ACC_INT32E_T) && defined(ACC_SIZEOF_ACC_INT32E_T) +# define SIZEOF_ACC_INT32E_T ACC_SIZEOF_ACC_INT32E_T +#endif +#if !defined(SIZEOF_ACC_INT64E_T) && defined(ACC_SIZEOF_ACC_INT64E_T) +# define SIZEOF_ACC_INT64E_T ACC_SIZEOF_ACC_INT64E_T +#endif +#if !defined(SIZEOF_ACC_INT32L_T) && defined(ACC_SIZEOF_ACC_INT32L_T) +# define SIZEOF_ACC_INT32L_T ACC_SIZEOF_ACC_INT32L_T +#endif +#if !defined(SIZEOF_ACC_INT64L_T) && defined(ACC_SIZEOF_ACC_INT64L_T) +# define SIZEOF_ACC_INT64L_T ACC_SIZEOF_ACC_INT64L_T +#endif +#if !defined(SIZEOF_ACC_INT32F_T) && defined(ACC_SIZEOF_ACC_INT32F_T) +# define SIZEOF_ACC_INT32F_T ACC_SIZEOF_ACC_INT32F_T +#endif +#if !defined(SIZEOF_ACC_INTPTR_T) && defined(ACC_SIZEOF_ACC_INTPTR_T) +# define SIZEOF_ACC_INTPTR_T ACC_SIZEOF_ACC_INTPTR_T +#endif +#if !defined(SIZEOF_ACC_WORD_T) && defined(ACC_SIZEOF_ACC_WORD_T) +# define SIZEOF_ACC_WORD_T ACC_SIZEOF_ACC_WORD_T +#endif +#if 1 && !defined(acc_signo_t) && defined(__linux__) && defined(__dietlibc__) && (ACC_SIZEOF_INT != 4) +# define acc_signo_t acc_int32e_t +#endif +#if !defined(acc_signo_t) +# define acc_signo_t int +#endif +#if defined(__cplusplus) +extern "C" { +#endif +#if (ACC_BROKEN_CDECL_ALT_SYNTAX) +typedef void __acc_cdecl_sighandler (*acc_sighandler_t)(acc_signo_t); +#elif defined(RETSIGTYPE) +typedef RETSIGTYPE (__acc_cdecl_sighandler *acc_sighandler_t)(acc_signo_t); +#else +typedef void (__acc_cdecl_sighandler *acc_sighandler_t)(acc_signo_t); +#endif +#if defined(__cplusplus) +} +#endif +# if (ACC_CFG_NO_ACC_UA_H) +# else +#if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020700ul)) +#elif (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020800ul)) && defined(__cplusplus) +#elif (ACC_CC_INTELC) && defined(_WIN32) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER < 700)) +#elif (ACC_CC_LLVM) +#elif (ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE) +#if !defined(__acc_ua16_t) && (ACC_OPT_UNALIGNED16) && defined(acc_int16e_t) + typedef struct { __acc_ua_volatile acc_uint16e_t v __attribute__((__packed__)); } __acc_ua16_t; +# define __acc_ua16_t __acc_ua16_t +#endif +#if !defined(__acc_ua32_t) && (ACC_OPT_UNALIGNED32) && defined(acc_int32e_t) + typedef struct { __acc_ua_volatile acc_uint32e_t v __attribute__((__packed__)); } __acc_ua32_t; +# define __acc_ua32_t __acc_ua32_t +#endif +#if !defined(__acc_ua64_t) && (ACC_OPT_UNALIGNED64) && defined(acc_int64l_t) + typedef struct { __acc_ua_volatile acc_uint64l_t v __attribute__((__packed__)); } __acc_ua64_t; +# define __acc_ua64_t __acc_ua64_t +#endif +#endif +#if (ACC_OPT_UNALIGNED16) && defined(acc_int16e_t) +#define ACC_UA_GET16(p) (* (__acc_ua_volatile const acc_uint16e_t*) (__acc_ua_volatile const void*) (p)) +#define ACC_UA_SET16(p,v) ((* (__acc_ua_volatile acc_uint16e_t*) (__acc_ua_volatile void*) (p)) = (acc_uint16e_t) (v)) +#if (ACC_ABI_BIG_ENDIAN) +# define ACC_UA_GET_BE16(p) ACC_UA_GET16(p) +# define ACC_UA_SET_BE16(p,v) ACC_UA_SET16(p,v) +#elif (ACC_ABI_LITTLE_ENDIAN) +# define ACC_UA_GET_LE16(p) ACC_UA_GET16(p) +# define ACC_UA_SET_LE16(p,v) ACC_UA_SET16(p,v) +#endif +#if !(ACC_CFG_NO_INLINE_ASM) && (__acc_HAVE_forceinline) +#if (ACC_ARCH_POWERPC && ACC_ABI_BIG_ENDIAN) && (ACC_CC_GNUC) +#if !defined(ACC_UA_GET_LE16) +extern __acc_forceinline unsigned long __ACC_UA_GET_LE16(__acc_ua_volatile const void* pp); +extern __acc_forceinline unsigned long __ACC_UA_GET_LE16(__acc_ua_volatile const void* pp) { + __acc_ua_volatile const acc_uint16e_t* p = (__acc_ua_volatile const acc_uint16e_t*) pp; + unsigned long v; + __asm__ __volatile__("lhbrx %0,0,%1" : "=r" (v) : "r" (p), "m" (*p)); + return v; +} +#define ACC_UA_GET_LE16(p) __ACC_UA_GET_LE16(p) +#endif +#if !defined(ACC_UA_SET_LE16) +extern __acc_forceinline void __ACC_UA_SET_LE16(__acc_ua_volatile void* pp, unsigned long v); +extern __acc_forceinline void __ACC_UA_SET_LE16(__acc_ua_volatile void* pp, unsigned long v) { + __acc_ua_volatile acc_uint16e_t* p = (__acc_ua_volatile acc_uint16e_t*) pp; + __asm__ __volatile__("sthbrx %2,0,%1" : "=m" (*p) : "r" (p), "r" (v)); +} +#define ACC_UA_SET_LE16(p,v) __ACC_UA_SET_LE16(p,v) +#endif +#endif +#endif +#if !defined(ACC_UA_COPY16) +# define ACC_UA_COPY16(d,s) ACC_UA_SET16(d, ACC_UA_GET16(s)) +#endif +#endif +#if (ACC_OPT_UNALIGNED32) && defined(acc_int32e_t) +#define ACC_UA_GET32(p) (* (__acc_ua_volatile const acc_uint32e_t*) (__acc_ua_volatile const void*) (p)) +#define ACC_UA_SET32(p,v) ((* (__acc_ua_volatile acc_uint32e_t*) (__acc_ua_volatile void*) (p)) = (acc_uint32e_t) (v)) +#if (ACC_ABI_BIG_ENDIAN) +# define ACC_UA_GET_BE32(p) ACC_UA_GET32(p) +# define ACC_UA_SET_BE32(p,v) ACC_UA_SET32(p,v) +#elif (ACC_ABI_LITTLE_ENDIAN) +# define ACC_UA_GET_LE32(p) ACC_UA_GET32(p) +# define ACC_UA_SET_LE32(p,v) ACC_UA_SET32(p,v) +#endif +#if !(ACC_CFG_NO_INLINE_ASM) && (__acc_HAVE_forceinline) +#if (ACC_ARCH_POWERPC && ACC_ABI_BIG_ENDIAN) && (ACC_CC_GNUC) +#if !defined(ACC_UA_GET_LE32) +extern __acc_forceinline unsigned long __ACC_UA_GET_LE32(__acc_ua_volatile const void* pp); +extern __acc_forceinline unsigned long __ACC_UA_GET_LE32(__acc_ua_volatile const void* pp) { + __acc_ua_volatile const acc_uint32e_t* p = (__acc_ua_volatile const acc_uint32e_t*) pp; + unsigned long v; + __asm__ __volatile__("lwbrx %0,0,%1" : "=r" (v) : "r" (p), "m" (*p)); + return v; +} +#define ACC_UA_GET_LE32(p) __ACC_UA_GET_LE32(p) +#endif +#if !defined(ACC_UA_SET_LE32) +extern __acc_forceinline void __ACC_UA_SET_LE32(__acc_ua_volatile void* pp, unsigned long v); +extern __acc_forceinline void __ACC_UA_SET_LE32(__acc_ua_volatile void* pp, unsigned long v) { + __acc_ua_volatile acc_uint32e_t* p = (__acc_ua_volatile acc_uint32e_t*) pp; + __asm__ __volatile__("stwbrx %2,0,%1" : "=m" (*p) : "r" (p), "r" (v)); +} +#define ACC_UA_SET_LE32(p,v) __ACC_UA_SET_LE32(p,v) +#endif +#endif +#endif +#if !defined(ACC_UA_COPY32) +# define ACC_UA_COPY32(d,s) ACC_UA_SET32(d, ACC_UA_GET32(s)) +#endif +#endif +#if (ACC_OPT_UNALIGNED64) && defined(acc_int64l_t) +#define ACC_UA_GET64(p) (* (__acc_ua_volatile const acc_uint64l_t*) (__acc_ua_volatile const void*) (p)) +#define ACC_UA_SET64(p,v) ((* (__acc_ua_volatile acc_uint64l_t*) (__acc_ua_volatile void*) (p)) = (acc_uint64l_t) (v)) +#if (ACC_ABI_BIG_ENDIAN) +# define ACC_UA_GET_BE64(p) ACC_UA_GET64(p) +# define ACC_UA_SET_BE64(p,v) ACC_UA_SET64(p,v) +#elif (ACC_ABI_LITTLE_ENDIAN) +# define ACC_UA_GET_LE64(p) ACC_UA_GET64(p) +# define ACC_UA_SET_LE64(p,v) ACC_UA_SET64(p,v) +#endif +#if !defined(ACC_UA_COPY64) +# define ACC_UA_COPY64(d,s) ACC_UA_SET64(d, ACC_UA_GET64(s)) +#endif +#endif +# endif +#endif +#endif +#if defined(ACC_WANT_ACC_TYPE_H) +# undef ACC_WANT_ACC_TYPE_H +# if defined(ACC_CFG_NO_ACC_TYPE_H) +# error "ACC_WANT_ACC_TYPE_H with ACC_CFG_NO_ACC_TYPE_H" +# endif +#if (ACC_SIZEOF_LONG_LONG+0 > 0) +__acc_gnuc_extension__ typedef long long acc_llong_t; +__acc_gnuc_extension__ typedef unsigned long long acc_ullong_t; +#endif +#if (!(ACC_SIZEOF_SHORT+0 > 0 && ACC_SIZEOF_INT+0 > 0 && ACC_SIZEOF_LONG+0 > 0)) +# error "missing defines for sizes" +#endif +#if (!(ACC_SIZEOF_PTRDIFF_T+0 > 0 && ACC_SIZEOF_SIZE_T+0 > 0 && ACC_SIZEOF_VOID_P+0 > 0)) +# error "missing defines for sizes" +#endif +#if !defined(acc_int16e_t) +#if (ACC_SIZEOF_LONG == 2) +# define acc_int16e_t long +# define acc_uint16e_t unsigned long +#elif (ACC_SIZEOF_INT == 2) +# define acc_int16e_t int +# define acc_uint16e_t unsigned int +#elif (ACC_SIZEOF_SHORT == 2) +# define acc_int16e_t short int +# define acc_uint16e_t unsigned short int +#elif 1 && !(ACC_CFG_TYPE_NO_MODE_HI) && (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x025f00ul) || ACC_CC_LLVM) + typedef int __acc_int16e_hi_t __attribute__((__mode__(__HI__))); + typedef unsigned int __acc_uint16e_hi_t __attribute__((__mode__(__HI__))); +# define acc_int16e_t __acc_int16e_hi_t +# define acc_uint16e_t __acc_uint16e_hi_t +#elif (ACC_SIZEOF___INT16 == 2) +# define acc_int16e_t __int16 +# define acc_uint16e_t unsigned __int16 +#else +#endif +#endif +#if defined(acc_int16e_t) +# define ACC_SIZEOF_ACC_INT16E_T 2 +#endif +#if !defined(acc_int32e_t) +#if (ACC_SIZEOF_LONG == 4) +# define acc_int32e_t long int +# define acc_uint32e_t unsigned long int +#elif (ACC_SIZEOF_INT == 4) +# define acc_int32e_t int +# define acc_uint32e_t unsigned int +#elif (ACC_SIZEOF_SHORT == 4) +# define acc_int32e_t short int +# define acc_uint32e_t unsigned short int +#elif (ACC_SIZEOF_LONG_LONG == 4) +# define acc_int32e_t acc_llong_t +# define acc_uint32e_t acc_ullong_t +#elif 1 && !(ACC_CFG_TYPE_NO_MODE_SI) && (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x025f00ul) || ACC_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) + typedef int __acc_int32e_si_t __attribute__((__mode__(__SI__))); + typedef unsigned int __acc_uint32e_si_t __attribute__((__mode__(__SI__))); +# define acc_int32e_t __acc_int32e_si_t +# define acc_uint32e_t __acc_uint32e_si_t +#elif 1 && !(ACC_CFG_TYPE_NO_MODE_SI) && (ACC_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) + typedef int __acc_int32e_si_t __attribute__((__mode__(__SI__))); + typedef unsigned int __acc_uint32e_si_t __attribute__((__mode__(__SI__))); +# define acc_int32e_t __acc_int32e_si_t +# define acc_uint32e_t __acc_uint32e_si_t +# define ACC_INT32_C(c) c##LL +# define ACC_UINT32_C(c) c##ULL +#elif (ACC_SIZEOF___INT32 == 4) +# define acc_int32e_t __int32 +# define acc_uint32e_t unsigned __int32 +#else +#endif +#endif +#if defined(acc_int32e_t) +# define ACC_SIZEOF_ACC_INT32E_T 4 +#endif +#if !defined(acc_int64e_t) +#if (ACC_SIZEOF___INT64 == 8) +# if (ACC_CC_BORLANDC) && !(ACC_CFG_TYPE_PREFER___INT64) +# define ACC_CFG_TYPE_PREFER___INT64 1 +# endif +#endif +#if (ACC_SIZEOF_INT == 8) && (ACC_SIZEOF_INT < ACC_SIZEOF_LONG) +# define acc_int64e_t int +# define acc_uint64e_t unsigned int +# define ACC_SIZEOF_ACC_INT64E_T ACC_SIZEOF_INT +#elif (ACC_SIZEOF_LONG == 8) +# define acc_int64e_t long int +# define acc_uint64e_t unsigned long int +# define ACC_SIZEOF_ACC_INT64E_T ACC_SIZEOF_LONG +#elif (ACC_SIZEOF_LONG_LONG == 8) && !(ACC_CFG_TYPE_PREFER___INT64) +# define acc_int64e_t acc_llong_t +# define acc_uint64e_t acc_ullong_t +# if (ACC_CC_BORLANDC) +# define ACC_INT64_C(c) ((c) + 0ll) +# define ACC_UINT64_C(c) ((c) + 0ull) +# else +# define ACC_INT64_C(c) c##LL +# define ACC_UINT64_C(c) c##ULL +# endif +# define ACC_SIZEOF_ACC_INT64E_T ACC_SIZEOF_LONG_LONG +#elif (ACC_SIZEOF___INT64 == 8) +# define acc_int64e_t __int64 +# define acc_uint64e_t unsigned __int64 +# if (ACC_CC_BORLANDC) +# define ACC_INT64_C(c) ((c) + 0i64) +# define ACC_UINT64_C(c) ((c) + 0ui64) +# else +# define ACC_INT64_C(c) c##i64 +# define ACC_UINT64_C(c) c##ui64 +# endif +# define ACC_SIZEOF_ACC_INT64E_T ACC_SIZEOF___INT64 +#else +#endif +#endif +#if !defined(acc_int32l_t) +#if defined(acc_int32e_t) +# define acc_int32l_t acc_int32e_t +# define acc_uint32l_t acc_uint32e_t +# define ACC_SIZEOF_ACC_INT32L_T ACC_SIZEOF_ACC_INT32E_T +#elif (ACC_SIZEOF_INT >= 4) && (ACC_SIZEOF_INT < ACC_SIZEOF_LONG) +# define acc_int32l_t int +# define acc_uint32l_t unsigned int +# define ACC_SIZEOF_ACC_INT32L_T ACC_SIZEOF_INT +#elif (ACC_SIZEOF_LONG >= 4) +# define acc_int32l_t long int +# define acc_uint32l_t unsigned long int +# define ACC_SIZEOF_ACC_INT32L_T ACC_SIZEOF_LONG +#else +# error "acc_int32l_t" +#endif +#endif +#if !defined(acc_int64l_t) +#if defined(acc_int64e_t) +# define acc_int64l_t acc_int64e_t +# define acc_uint64l_t acc_uint64e_t +# define ACC_SIZEOF_ACC_INT64L_T ACC_SIZEOF_ACC_INT64E_T +#else +#endif +#endif +#if !defined(acc_int32f_t) +#if (ACC_SIZEOF_SIZE_T >= 8) +# define acc_int32f_t acc_int64l_t +# define acc_uint32f_t acc_uint64l_t +# define ACC_SIZEOF_ACC_INT32F_T ACC_SIZEOF_ACC_INT64L_T +#else +# define acc_int32f_t acc_int32l_t +# define acc_uint32f_t acc_uint32l_t +# define ACC_SIZEOF_ACC_INT32F_T ACC_SIZEOF_ACC_INT32L_T +#endif +#endif +#if !defined(acc_intptr_t) +#if 1 && (ACC_OS_OS400 && (ACC_SIZEOF_VOID_P == 16)) +# define __ACC_INTPTR_T_IS_POINTER 1 + typedef char* acc_intptr_t; + typedef char* acc_uintptr_t; +# define acc_intptr_t acc_intptr_t +# define acc_uintptr_t acc_uintptr_t +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_VOID_P +#elif (ACC_CC_MSC && (_MSC_VER >= 1300) && (ACC_SIZEOF_VOID_P == 4) && (ACC_SIZEOF_INT == 4)) + typedef __w64 int acc_intptr_t; + typedef __w64 unsigned int acc_uintptr_t; +# define acc_intptr_t acc_intptr_t +# define acc_uintptr_t acc_uintptr_t +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_INT +#elif (ACC_SIZEOF_SHORT == ACC_SIZEOF_VOID_P) && (ACC_SIZEOF_INT > ACC_SIZEOF_VOID_P) +# define acc_intptr_t short +# define acc_uintptr_t unsigned short +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_SHORT +#elif (ACC_SIZEOF_INT >= ACC_SIZEOF_VOID_P) && (ACC_SIZEOF_INT < ACC_SIZEOF_LONG) +# define acc_intptr_t int +# define acc_uintptr_t unsigned int +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_INT +#elif (ACC_SIZEOF_LONG >= ACC_SIZEOF_VOID_P) +# define acc_intptr_t long +# define acc_uintptr_t unsigned long +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_LONG +#elif (ACC_SIZEOF_ACC_INT64L_T >= ACC_SIZEOF_VOID_P) +# define acc_intptr_t acc_int64l_t +# define acc_uintptr_t acc_uint64l_t +# define ACC_SIZEOF_ACC_INTPTR_T ACC_SIZEOF_ACC_INT64L_T +#else +# error "acc_intptr_t" +#endif +#endif +#if !defined(acc_word_t) +#if defined(ACC_WORDSIZE) && (ACC_WORDSIZE > 0) +#if (ACC_WORDSIZE == ACC_SIZEOF_ACC_INTPTR_T) && !defined(__ACC_INTPTR_T_IS_POINTER) +# define acc_word_t acc_uintptr_t +# define acc_sword_t acc_intptr_t +# define ACC_SIZEOF_ACC_WORD_T ACC_SIZEOF_ACC_INTPTR_T +#elif (ACC_WORDSIZE == ACC_SIZEOF_LONG) +# define acc_word_t unsigned long +# define acc_sword_t long +# define ACC_SIZEOF_ACC_WORD_T ACC_SIZEOF_LONG +#elif (ACC_WORDSIZE == ACC_SIZEOF_INT) +# define acc_word_t unsigned int +# define acc_sword_t int +# define ACC_SIZEOF_ACC_WORD_T ACC_SIZEOF_INT +#elif (ACC_WORDSIZE == ACC_SIZEOF_SHORT) +# define acc_word_t unsigned short +# define acc_sword_t short +# define ACC_SIZEOF_ACC_WORD_T ACC_SIZEOF_SHORT +#elif (ACC_WORDSIZE == 1) +# define acc_word_t unsigned char +# define acc_sword_t signed char +# define ACC_SIZEOF_ACC_WORD_T 1 +#elif (ACC_WORDSIZE == ACC_SIZEOF_ACC_INT64L_T) +# define acc_word_t acc_uint64l_t +# define acc_sword_t acc_int64l_t +# define ACC_SIZEOF_ACC_WORD_T ACC_SIZEOF_ACC_INT64L_T +#elif (ACC_ARCH_SPU) && (ACC_CC_GNUC) +#if 0 + typedef unsigned acc_word_t __attribute__((__mode__(__V16QI__))); + typedef int acc_sword_t __attribute__((__mode__(__V16QI__))); +# define acc_word_t acc_word_t +# define acc_sword_t acc_sword_t +# define ACC_SIZEOF_ACC_WORD_T 16 +#endif +#else +# error "acc_word_t" +#endif +#endif +#endif +#if !defined(ACC_INT16_C) +# if (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_INT >= 2) +# define ACC_INT16_C(c) ((c) + 0) +# define ACC_UINT16_C(c) ((c) + 0U) +# elif (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_LONG >= 2) +# define ACC_INT16_C(c) ((c) + 0L) +# define ACC_UINT16_C(c) ((c) + 0UL) +# elif (ACC_SIZEOF_INT >= 2) +# define ACC_INT16_C(c) c +# define ACC_UINT16_C(c) c##U +# elif (ACC_SIZEOF_LONG >= 2) +# define ACC_INT16_C(c) c##L +# define ACC_UINT16_C(c) c##UL +# else +# error "ACC_INT16_C" +# endif +#endif +#if !defined(ACC_INT32_C) +# if (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_INT >= 4) +# define ACC_INT32_C(c) ((c) + 0) +# define ACC_UINT32_C(c) ((c) + 0U) +# elif (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_LONG >= 4) +# define ACC_INT32_C(c) ((c) + 0L) +# define ACC_UINT32_C(c) ((c) + 0UL) +# elif (ACC_SIZEOF_INT >= 4) +# define ACC_INT32_C(c) c +# define ACC_UINT32_C(c) c##U +# elif (ACC_SIZEOF_LONG >= 4) +# define ACC_INT32_C(c) c##L +# define ACC_UINT32_C(c) c##UL +# elif (ACC_SIZEOF_LONG_LONG >= 4) +# define ACC_INT32_C(c) c##LL +# define ACC_UINT32_C(c) c##ULL +# else +# error "ACC_INT32_C" +# endif +#endif +#if !defined(ACC_INT64_C) && defined(acc_int64l_t) +# if (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_INT >= 8) +# define ACC_INT64_C(c) ((c) + 0) +# define ACC_UINT64_C(c) ((c) + 0U) +# elif (ACC_BROKEN_INTEGRAL_CONSTANTS) && (ACC_SIZEOF_LONG >= 8) +# define ACC_INT64_C(c) ((c) + 0L) +# define ACC_UINT64_C(c) ((c) + 0UL) +# elif (ACC_SIZEOF_INT >= 8) +# define ACC_INT64_C(c) c +# define ACC_UINT64_C(c) c##U +# elif (ACC_SIZEOF_LONG >= 8) +# define ACC_INT64_C(c) c##L +# define ACC_UINT64_C(c) c##UL +# else +# error "ACC_INT64_C" +# endif +#endif +#if !defined(SIZEOF_ACC_INT16E_T) && defined(ACC_SIZEOF_ACC_INT16E_T) +# define SIZEOF_ACC_INT16E_T ACC_SIZEOF_ACC_INT16E_T +#endif +#if !defined(SIZEOF_ACC_INT32E_T) && defined(ACC_SIZEOF_ACC_INT32E_T) +# define SIZEOF_ACC_INT32E_T ACC_SIZEOF_ACC_INT32E_T +#endif +#if !defined(SIZEOF_ACC_INT64E_T) && defined(ACC_SIZEOF_ACC_INT64E_T) +# define SIZEOF_ACC_INT64E_T ACC_SIZEOF_ACC_INT64E_T +#endif +#if !defined(SIZEOF_ACC_INT32L_T) && defined(ACC_SIZEOF_ACC_INT32L_T) +# define SIZEOF_ACC_INT32L_T ACC_SIZEOF_ACC_INT32L_T +#endif +#if !defined(SIZEOF_ACC_INT64L_T) && defined(ACC_SIZEOF_ACC_INT64L_T) +# define SIZEOF_ACC_INT64L_T ACC_SIZEOF_ACC_INT64L_T +#endif +#if !defined(SIZEOF_ACC_INT32F_T) && defined(ACC_SIZEOF_ACC_INT32F_T) +# define SIZEOF_ACC_INT32F_T ACC_SIZEOF_ACC_INT32F_T +#endif +#if !defined(SIZEOF_ACC_INTPTR_T) && defined(ACC_SIZEOF_ACC_INTPTR_T) +# define SIZEOF_ACC_INTPTR_T ACC_SIZEOF_ACC_INTPTR_T +#endif +#if !defined(SIZEOF_ACC_WORD_T) && defined(ACC_SIZEOF_ACC_WORD_T) +# define SIZEOF_ACC_WORD_T ACC_SIZEOF_ACC_WORD_T +#endif +#if 1 && !defined(acc_signo_t) && defined(__linux__) && defined(__dietlibc__) && (ACC_SIZEOF_INT != 4) +# define acc_signo_t acc_int32e_t +#endif +#if !defined(acc_signo_t) +# define acc_signo_t int +#endif +#if defined(__cplusplus) +extern "C" { +#endif +#if (ACC_BROKEN_CDECL_ALT_SYNTAX) +typedef void __acc_cdecl_sighandler (*acc_sighandler_t)(acc_signo_t); +#elif defined(RETSIGTYPE) +typedef RETSIGTYPE (__acc_cdecl_sighandler *acc_sighandler_t)(acc_signo_t); +#else +typedef void (__acc_cdecl_sighandler *acc_sighandler_t)(acc_signo_t); +#endif +#if defined(__cplusplus) +} +#endif +# if !defined(ACC_CFG_NO_ACC_UA_H) +#if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020700ul)) +#elif (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020800ul)) && defined(__cplusplus) +#elif (ACC_CC_INTELC) && defined(_WIN32) +#elif (ACC_CC_INTELC && (__INTEL_COMPILER < 700)) +#elif (ACC_CC_LLVM) +#elif (ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE) +#if !defined(__acc_ua16_t) && (ACC_OPT_UNALIGNED16) && defined(acc_int16e_t) + typedef struct { __acc_ua_volatile acc_uint16e_t v __attribute__((__packed__)); } __acc_ua16_t; +# define __acc_ua16_t __acc_ua16_t +#endif +#if !defined(__acc_ua32_t) && (ACC_OPT_UNALIGNED32) && defined(acc_int32e_t) + typedef struct { __acc_ua_volatile acc_uint32e_t v __attribute__((__packed__)); } __acc_ua32_t; +# define __acc_ua32_t __acc_ua32_t +#endif +#if !defined(__acc_ua64_t) && (ACC_OPT_UNALIGNED64) && defined(acc_int64l_t) + typedef struct { __acc_ua_volatile acc_uint64l_t v __attribute__((__packed__)); } __acc_ua64_t; +# define __acc_ua64_t __acc_ua64_t +#endif +#endif +#if (ACC_OPT_UNALIGNED16) && defined(acc_int16e_t) +#define ACC_UA_GET16(p) (* (__acc_ua_volatile const acc_uint16e_t*) (__acc_ua_volatile const void*) (p)) +#define ACC_UA_SET16(p,v) ((* (__acc_ua_volatile acc_uint16e_t*) (__acc_ua_volatile void*) (p)) = (acc_uint16e_t) (v)) +#if (ACC_ABI_BIG_ENDIAN) +# define ACC_UA_GET_BE16(p) ACC_UA_GET16(p) +# define ACC_UA_SET_BE16(p,v) ACC_UA_SET16(p,v) +#elif (ACC_ABI_LITTLE_ENDIAN) +# define ACC_UA_GET_LE16(p) ACC_UA_GET16(p) +# define ACC_UA_SET_LE16(p,v) ACC_UA_SET16(p,v) +#endif +#if !(ACC_CFG_NO_INLINE_ASM) && (__acc_HAVE_forceinline) +#if (ACC_ARCH_POWERPC && ACC_ABI_BIG_ENDIAN) && (ACC_CC_GNUC) +#if !defined(ACC_UA_GET_LE16) +extern __acc_forceinline unsigned long __ACC_UA_GET_LE16(__acc_ua_volatile const void* pp); +extern __acc_forceinline unsigned long __ACC_UA_GET_LE16(__acc_ua_volatile const void* pp) { + __acc_ua_volatile const acc_uint16e_t* p = (__acc_ua_volatile const acc_uint16e_t*) pp; + unsigned long v; + __asm__ __volatile__("lhbrx %0,0,%1" : "=r" (v) : "r" (p), "m" (*p)); + return v; +} +#define ACC_UA_GET_LE16(p) __ACC_UA_GET_LE16(p) +#endif +#if !defined(ACC_UA_SET_LE16) +extern __acc_forceinline void __ACC_UA_SET_LE16(__acc_ua_volatile void* pp, unsigned long v); +extern __acc_forceinline void __ACC_UA_SET_LE16(__acc_ua_volatile void* pp, unsigned long v) { + __acc_ua_volatile acc_uint16e_t* p = (__acc_ua_volatile acc_uint16e_t*) pp; + __asm__ __volatile__("sthbrx %2,0,%1" : "=m" (*p) : "r" (p), "r" (v)); +} +#define ACC_UA_SET_LE16(p,v) __ACC_UA_SET_LE16(p,v) +#endif +#endif +#endif +#if !defined(ACC_UA_COPY16) +# define ACC_UA_COPY16(d,s) ACC_UA_SET16(d, ACC_UA_GET16(s)) +#endif +#endif +#if (ACC_OPT_UNALIGNED32) && defined(acc_int32e_t) +#define ACC_UA_GET32(p) (* (__acc_ua_volatile const acc_uint32e_t*) (__acc_ua_volatile const void*) (p)) +#define ACC_UA_SET32(p,v) ((* (__acc_ua_volatile acc_uint32e_t*) (__acc_ua_volatile void*) (p)) = (acc_uint32e_t) (v)) +#if (ACC_ABI_BIG_ENDIAN) +# define ACC_UA_GET_BE32(p) ACC_UA_GET32(p) +# define ACC_UA_SET_BE32(p,v) ACC_UA_SET32(p,v) +#elif (ACC_ABI_LITTLE_ENDIAN) +# define ACC_UA_GET_LE32(p) ACC_UA_GET32(p) +# define ACC_UA_SET_LE32(p,v) ACC_UA_SET32(p,v) +#endif +#if !(ACC_CFG_NO_INLINE_ASM) && (__acc_HAVE_forceinline) +#if (ACC_ARCH_POWERPC && ACC_ABI_BIG_ENDIAN) && (ACC_CC_GNUC) +#if !defined(ACC_UA_GET_LE32) +extern __acc_forceinline unsigned long __ACC_UA_GET_LE32(__acc_ua_volatile const void* pp); +extern __acc_forceinline unsigned long __ACC_UA_GET_LE32(__acc_ua_volatile const void* pp) { + __acc_ua_volatile const acc_uint32e_t* p = (__acc_ua_volatile const acc_uint32e_t*) pp; + unsigned long v; + __asm__ __volatile__("lwbrx %0,0,%1" : "=r" (v) : "r" (p), "m" (*p)); + return v; +} +#define ACC_UA_GET_LE32(p) __ACC_UA_GET_LE32(p) +#endif +#if !defined(ACC_UA_SET_LE32) +extern __acc_forceinline void __ACC_UA_SET_LE32(__acc_ua_volatile void* pp, unsigned long v); +extern __acc_forceinline void __ACC_UA_SET_LE32(__acc_ua_volatile void* pp, unsigned long v) { + __acc_ua_volatile acc_uint32e_t* p = (__acc_ua_volatile acc_uint32e_t*) pp; + __asm__ __volatile__("stwbrx %2,0,%1" : "=m" (*p) : "r" (p), "r" (v)); +} +#define ACC_UA_SET_LE32(p,v) __ACC_UA_SET_LE32(p,v) +#endif +#endif +#endif +#if !defined(ACC_UA_COPY32) +# define ACC_UA_COPY32(d,s) ACC_UA_SET32(d, ACC_UA_GET32(s)) +#endif +#endif +#if (ACC_OPT_UNALIGNED64) && defined(acc_int64l_t) +#define ACC_UA_GET64(p) (* (__acc_ua_volatile const acc_uint64l_t*) (__acc_ua_volatile const void*) (p)) +#define ACC_UA_SET64(p,v) ((* (__acc_ua_volatile acc_uint64l_t*) (__acc_ua_volatile void*) (p)) = (acc_uint64l_t) (v)) +#if (ACC_ABI_BIG_ENDIAN) +# define ACC_UA_GET_BE64(p) ACC_UA_GET64(p) +# define ACC_UA_SET_BE64(p,v) ACC_UA_SET64(p,v) +#elif (ACC_ABI_LITTLE_ENDIAN) +# define ACC_UA_GET_LE64(p) ACC_UA_GET64(p) +# define ACC_UA_SET_LE64(p,v) ACC_UA_SET64(p,v) +#endif +#if !defined(ACC_UA_COPY64) +# define ACC_UA_COPY64(d,s) ACC_UA_SET64(d, ACC_UA_GET64(s)) +#endif +#endif +# endif +#endif +#if defined(ACC_WANT_ACC_INCD_H) +# undef ACC_WANT_ACC_INCD_H +#ifndef __ACC_INCD_H_INCLUDED +#define __ACC_INCD_H_INCLUDED 1 +#if (ACC_LIBC_NAKED) +#ifndef __ACC_FALLBACK_STDDEF_H_INCLUDED +#define __ACC_FALLBACK_STDDEF_H_INCLUDED 1 +#if defined(__PTRDIFF_TYPE__) +typedef __PTRDIFF_TYPE__ acc_fallback_ptrdiff_t; +#elif defined(__MIPS_PSX2__) +typedef int acc_fallback_ptrdiff_t; +#else +typedef long acc_fallback_ptrdiff_t; +#endif +#if defined(__SIZE_TYPE__) +typedef __SIZE_TYPE__ acc_fallback_size_t; +#elif defined(__MIPS_PSX2__) +typedef unsigned int acc_fallback_size_t; +#else +typedef unsigned long acc_fallback_size_t; +#endif +#if !defined(ptrdiff_t) +typedef acc_fallback_ptrdiff_t ptrdiff_t; +#ifndef _PTRDIFF_T_DEFINED +#define _PTRDIFF_T_DEFINED 1 +#endif +#endif +#if !defined(size_t) +typedef acc_fallback_size_t size_t; +#ifndef _SIZE_T_DEFINED +#define _SIZE_T_DEFINED 1 +#endif +#endif +#if !defined(__cplusplus) && !defined(wchar_t) +typedef unsigned short wchar_t; +#ifndef _WCHAR_T_DEFINED +#define _WCHAR_T_DEFINED 1 +#endif +#endif +#ifndef NULL +#if defined(__cplusplus) && defined(__GNUC__) && (__GNUC__ >= 4) +#define NULL __null +#elif defined(__cplusplus) +#define NULL 0 +#else +#define NULL ((void*)0) +#endif +#endif +#ifndef offsetof +#define offsetof(s,m) ((size_t)((ptrdiff_t)&(((s*)0)->m))) +#endif +#endif +#elif (ACC_LIBC_FREESTANDING) +# if HAVE_STDDEF_H +# include <stddef.h> +# endif +# if HAVE_STDINT_H +# include <stdint.h> +# endif +#elif (ACC_LIBC_MOSTLY_FREESTANDING) +# if HAVE_STDIO_H +# include <stdio.h> +# endif +# if HAVE_STDDEF_H +# include <stddef.h> +# endif +# if HAVE_STDINT_H +# include <stdint.h> +# endif +#else +#include <stdio.h> +#if (HAVE_TIME_H) && defined(__MSL__) && defined(__cplusplus) +# include <time.h> +#endif +#if HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#if HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#if STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# if HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#if HAVE_STRINGS_H +# include <strings.h> +#endif +#if HAVE_INTTYPES_H +# include <inttypes.h> +#else +# if HAVE_STDINT_H +# include <stdint.h> +# endif +#endif +#if HAVE_UNISTD_H +# include <unistd.h> +#endif +#endif +#endif +#endif +#if defined(ACC_WANT_ACC_INCE_H) +# undef ACC_WANT_ACC_INCE_H +#ifndef __ACC_INCE_H_INCLUDED +#define __ACC_INCE_H_INCLUDED 1 +#if (ACC_LIBC_NAKED) +#elif (ACC_LIBC_FREESTANDING) +#elif (ACC_LIBC_MOSTLY_FREESTANDING) +# if (HAVE_SETJMP_H) +# include <setjmp.h> +# endif +#else +#if (HAVE_STDARG_H) +# include <stdarg.h> +#endif +#if (HAVE_CTYPE_H) +# include <ctype.h> +#endif +#if (HAVE_ERRNO_H) +# include <errno.h> +#endif +#if (HAVE_MALLOC_H) +# include <malloc.h> +#endif +#if (HAVE_ALLOCA_H) +# include <alloca.h> +#endif +#if (HAVE_FCNTL_H) +# include <fcntl.h> +#endif +#if (HAVE_DIRENT_H) +# include <dirent.h> +#endif +#if (HAVE_SETJMP_H) +# include <setjmp.h> +#endif +#if (HAVE_SIGNAL_H) +# include <signal.h> +#endif +#if (TIME_WITH_SYS_TIME) +# include <sys/time.h> +# include <time.h> +#elif (HAVE_TIME_H) +# include <time.h> +#endif +#if (HAVE_UTIME_H) +# include <utime.h> +#elif (HAVE_SYS_UTIME_H) +# include <sys/utime.h> +#endif +#if (HAVE_IO_H) +# include <io.h> +#endif +#if (HAVE_DOS_H) +# include <dos.h> +#endif +#if (HAVE_DIRECT_H) +# include <direct.h> +#endif +#if (HAVE_SHARE_H) +# include <share.h> +#endif +#if (ACC_CC_NDPC) +# include <os.h> +#endif +#if defined(__TOS__) && (defined(__PUREC__) || defined(__TURBOC__)) +# include <ext.h> +#endif +#endif +#endif +#endif +#if defined(ACC_WANT_ACC_INCI_H) +# undef ACC_WANT_ACC_INCI_H +#ifndef __ACC_INCI_H_INCLUDED +#define __ACC_INCI_H_INCLUDED 1 +#if (ACC_LIBC_NAKED) +#elif (ACC_LIBC_FREESTANDING) +#elif (ACC_LIBC_MOSTLY_FREESTANDING) +#else +#if (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC)) +# include <tos.h> +#elif (ACC_HAVE_WINDOWS_H) +# if 1 && !defined(WIN32_LEAN_AND_MEAN) +# define WIN32_LEAN_AND_MEAN 1 +# endif +# if 1 && !defined(_WIN32_WINNT) +# define _WIN32_WINNT 0x0400 +# endif +# include <windows.h> +# if (ACC_CC_BORLANDC || ACC_CC_TURBOC) +# include <dir.h> +# endif +#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_WIN16) +# if (ACC_CC_AZTECC) +# include <model.h> +# include <stat.h> +# elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) +# include <alloc.h> +# include <dir.h> +# elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) +# include <sys/exceptn.h> +# elif (ACC_CC_PACIFICC) +# include <unixio.h> +# include <stat.h> +# include <sys.h> +# elif (ACC_CC_WATCOMC) +# include <i86.h> +# endif +#elif (ACC_OS_OS216) +# if (ACC_CC_WATCOMC) +# include <i86.h> +# endif +#endif +#if (HAVE_SYS_MMAN_H) +# include <sys/mman.h> +#endif +#if (HAVE_SYS_RESOURCE_H) +# include <sys/resource.h> +#endif +#if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16) +# if defined(FP_OFF) +# define ACC_PTR_FP_OFF(x) FP_OFF(x) +# elif defined(_FP_OFF) +# define ACC_PTR_FP_OFF(x) _FP_OFF(x) +# else +# define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) +# endif +# if defined(FP_SEG) +# define ACC_PTR_FP_SEG(x) FP_SEG(x) +# elif defined(_FP_SEG) +# define ACC_PTR_FP_SEG(x) _FP_SEG(x) +# else +# define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) +# endif +# if defined(MK_FP) +# define ACC_PTR_MK_FP(s,o) MK_FP(s,o) +# elif defined(_MK_FP) +# define ACC_PTR_MK_FP(s,o) _MK_FP(s,o) +# else +# define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) +# endif +# if 0 +# undef ACC_PTR_FP_OFF +# undef ACC_PTR_FP_SEG +# undef ACC_PTR_MK_FP +# define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) +# define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) +# define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) +# endif +#endif +#endif +#endif +#endif +#if defined(ACC_WANT_ACC_LIB_H) +# undef ACC_WANT_ACC_LIB_H +#ifndef __ACC_LIB_H_INCLUDED +#define __ACC_LIB_H_INCLUDED 1 +#if !defined(__ACCLIB_FUNCNAME) +# define __ACCLIB_FUNCNAME(f) f +#endif +#if !defined(ACCLIB_EXTERN) +# define ACCLIB_EXTERN(r,f) extern r __ACCLIB_FUNCNAME(f) +#endif +#if !defined(ACCLIB_EXTERN_NOINLINE) +# if defined(__acc_noinline) +# define ACCLIB_EXTERN_NOINLINE(r,f) extern __acc_noinline r __ACCLIB_FUNCNAME(f) +# else +# define ACCLIB_EXTERN_NOINLINE(r,f) extern r __ACCLIB_FUNCNAME(f) +# endif +#endif +#if !defined(__ACCLIB_CONST_CAST_RETURN) +#if 1 && (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __ACCLIB_CONST_CAST_RETURN(type,var) return (type) (acc_uintptr_t) (var); +#elif (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __ACCLIB_CONST_CAST_RETURN(type,var) \ + { union { type a; const type b; } u; u.b = (var); return u.a; } +#else +# define __ACCLIB_CONST_CAST_RETURN(type,var) return (type) (var); +#endif +#endif +#if (ACC_OS_WIN64) +# define acclib_handle_t acc_int64l_t +# define acclib_uhandle_t acc_uint64l_t +#elif (ACC_ARCH_I386 && ACC_CC_MSC && (_MSC_VER >= 1300)) + typedef __w64 long acclib_handle_t; + typedef __w64 unsigned long acclib_uhandle_t; +# define acclib_handle_t acclib_handle_t +# define acclib_uhandle_t acclib_uhandle_t +#else +# define acclib_handle_t long +# define acclib_uhandle_t unsigned long +#endif +#if 0 +ACCLIB_EXTERN(int, acc_ascii_digit) (int); +ACCLIB_EXTERN(int, acc_ascii_islower) (int); +ACCLIB_EXTERN(int, acc_ascii_isupper) (int); +ACCLIB_EXTERN(int, acc_ascii_tolower) (int); +ACCLIB_EXTERN(int, acc_ascii_toupper) (int); +ACCLIB_EXTERN(int, acc_ascii_utolower) (int); +ACCLIB_EXTERN(int, acc_ascii_utoupper) (int); +#endif +#define acc_ascii_isdigit(c) (((unsigned)(c) - 48) < 10) +#define acc_ascii_islower(c) (((unsigned)(c) - 97) < 26) +#define acc_ascii_isupper(c) (((unsigned)(c) - 65) < 26) +#define acc_ascii_tolower(c) ((int)(c) + (acc_ascii_isupper(c) << 5)) +#define acc_ascii_toupper(c) ((int)(c) - (acc_ascii_islower(c) << 5)) +#define acc_ascii_utolower(c) acc_ascii_tolower((unsigned char)(c)) +#define acc_ascii_utoupper(c) acc_ascii_toupper((unsigned char)(c)) +#ifndef acc_hsize_t +#if (ACC_HAVE_MM_HUGE_PTR) +# define acc_hsize_t unsigned long +# define acc_hvoid_p void __huge * +# define acc_hchar_p char __huge * +# define acc_hchar_pp char __huge * __huge * +# define acc_hbyte_p unsigned char __huge * +#else +# define acc_hsize_t size_t +# define acc_hvoid_p void * +# define acc_hchar_p char * +# define acc_hchar_pp char ** +# define acc_hbyte_p unsigned char * +#endif +#endif +ACCLIB_EXTERN(acc_hvoid_p, acc_halloc) (acc_hsize_t); +ACCLIB_EXTERN(void, acc_hfree) (acc_hvoid_p); +#if (ACC_OS_DOS16 || ACC_OS_OS216) +ACCLIB_EXTERN(void __far*, acc_dos_alloc) (unsigned long); +ACCLIB_EXTERN(int, acc_dos_free) (void __far*); +#endif +ACCLIB_EXTERN(int, acc_hmemcmp) (const acc_hvoid_p, const acc_hvoid_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p, const acc_hvoid_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p, const acc_hvoid_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hvoid_p, acc_hmemset) (acc_hvoid_p, int, acc_hsize_t); +ACCLIB_EXTERN(acc_hsize_t, acc_hstrlen) (const acc_hchar_p); +ACCLIB_EXTERN(int, acc_hstrcmp) (const acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(int, acc_hstrncmp)(const acc_hchar_p, const acc_hchar_p, acc_hsize_t); +ACCLIB_EXTERN(int, acc_ascii_hstricmp) (const acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(int, acc_ascii_hstrnicmp)(const acc_hchar_p, const acc_hchar_p, acc_hsize_t); +ACCLIB_EXTERN(int, acc_ascii_hmemicmp) (const acc_hvoid_p, const acc_hvoid_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hchar_p, acc_hstrstr) (const acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstristr) (const acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(acc_hvoid_p, acc_hmemmem) (const acc_hvoid_p, acc_hsize_t, const acc_hvoid_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemimem) (const acc_hvoid_p, acc_hsize_t, const acc_hvoid_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hchar_p, acc_hstrcpy) (acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(acc_hchar_p, acc_hstrcat) (acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(acc_hsize_t, acc_hstrlcpy) (acc_hchar_p, const acc_hchar_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hsize_t, acc_hstrlcat) (acc_hchar_p, const acc_hchar_p, acc_hsize_t); +ACCLIB_EXTERN(int, acc_hstrscpy) (acc_hchar_p, const acc_hchar_p, acc_hsize_t); +ACCLIB_EXTERN(int, acc_hstrscat) (acc_hchar_p, const acc_hchar_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hchar_p, acc_hstrccpy) (acc_hchar_p, const acc_hchar_p, int); +ACCLIB_EXTERN(acc_hvoid_p, acc_hmemccpy) (acc_hvoid_p, const acc_hvoid_p, int, acc_hsize_t); +ACCLIB_EXTERN(acc_hchar_p, acc_hstrchr) (const acc_hchar_p, int); +ACCLIB_EXTERN(acc_hchar_p, acc_hstrrchr) (const acc_hchar_p, int); +ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrichr) (const acc_hchar_p, int); +ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrrichr) (const acc_hchar_p, int); +ACCLIB_EXTERN(acc_hvoid_p, acc_hmemchr) (const acc_hvoid_p, int, acc_hsize_t); +ACCLIB_EXTERN(acc_hvoid_p, acc_hmemrchr) (const acc_hvoid_p, int, acc_hsize_t); +ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemichr) (const acc_hvoid_p, int, acc_hsize_t); +ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemrichr) (const acc_hvoid_p, int, acc_hsize_t); +ACCLIB_EXTERN(acc_hsize_t, acc_hstrspn) (const acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(acc_hsize_t, acc_hstrrspn) (const acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(acc_hsize_t, acc_hstrcspn) (const acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(acc_hsize_t, acc_hstrrcspn) (const acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(acc_hchar_p, acc_hstrpbrk) (const acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(acc_hchar_p, acc_hstrrpbrk) (const acc_hchar_p, const acc_hchar_p); +ACCLIB_EXTERN(acc_hchar_p, acc_hstrsep) (acc_hchar_pp, const acc_hchar_p); +ACCLIB_EXTERN(acc_hchar_p, acc_hstrrsep) (acc_hchar_pp, const acc_hchar_p); +ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrlwr) (acc_hchar_p); +ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrupr) (acc_hchar_p); +ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemlwr) (acc_hvoid_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemupr) (acc_hvoid_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hsize_t, acc_hfread) (void *, acc_hvoid_p, acc_hsize_t); +ACCLIB_EXTERN(acc_hsize_t, acc_hfwrite) (void *, const acc_hvoid_p, acc_hsize_t); +#if (ACC_HAVE_MM_HUGE_PTR) +ACCLIB_EXTERN(long, acc_hread) (int, acc_hvoid_p, long); +ACCLIB_EXTERN(long, acc_hwrite) (int, const acc_hvoid_p, long); +#endif +ACCLIB_EXTERN(long, acc_safe_hread) (int, acc_hvoid_p, long); +ACCLIB_EXTERN(long, acc_safe_hwrite) (int, const acc_hvoid_p, long); +ACCLIB_EXTERN(unsigned, acc_ua_get_be16) (const acc_hvoid_p); +ACCLIB_EXTERN(acc_uint32l_t, acc_ua_get_be24) (const acc_hvoid_p); +ACCLIB_EXTERN(acc_uint32l_t, acc_ua_get_be32) (const acc_hvoid_p); +ACCLIB_EXTERN(void, acc_ua_set_be16) (acc_hvoid_p, unsigned); +ACCLIB_EXTERN(void, acc_ua_set_be24) (acc_hvoid_p, acc_uint32l_t); +ACCLIB_EXTERN(void, acc_ua_set_be32) (acc_hvoid_p, acc_uint32l_t); +ACCLIB_EXTERN(unsigned, acc_ua_get_le16) (const acc_hvoid_p); +ACCLIB_EXTERN(acc_uint32l_t, acc_ua_get_le24) (const acc_hvoid_p); +ACCLIB_EXTERN(acc_uint32l_t, acc_ua_get_le32) (const acc_hvoid_p); +ACCLIB_EXTERN(void, acc_ua_set_le16) (acc_hvoid_p, unsigned); +ACCLIB_EXTERN(void, acc_ua_set_le24) (acc_hvoid_p, acc_uint32l_t); +ACCLIB_EXTERN(void, acc_ua_set_le32) (acc_hvoid_p, acc_uint32l_t); +#if defined(acc_int64l_t) +ACCLIB_EXTERN(acc_uint64l_t, acc_ua_get_be64) (const acc_hvoid_p); +ACCLIB_EXTERN(void, acc_ua_set_be64) (acc_hvoid_p, acc_uint64l_t); +ACCLIB_EXTERN(acc_uint64l_t, acc_ua_get_le64) (const acc_hvoid_p); +ACCLIB_EXTERN(void, acc_ua_set_le64) (acc_hvoid_p, acc_uint64l_t); +#endif +ACCLIB_EXTERN_NOINLINE(short, acc_vget_short) (short, int); +ACCLIB_EXTERN_NOINLINE(int, acc_vget_int) (int, int); +ACCLIB_EXTERN_NOINLINE(long, acc_vget_long) (long, int); +#if defined(acc_int64l_t) +ACCLIB_EXTERN_NOINLINE(acc_int64l_t, acc_vget_acc_int64l_t) (acc_int64l_t, int); +#endif +ACCLIB_EXTERN_NOINLINE(acc_hsize_t, acc_vget_acc_hsize_t) (acc_hsize_t, int); +#if !(ACC_CFG_NO_FLOAT) +ACCLIB_EXTERN_NOINLINE(float, acc_vget_float) (float, int); +#endif +#if !(ACC_CFG_NO_DOUBLE) +ACCLIB_EXTERN_NOINLINE(double, acc_vget_double) (double, int); +#endif +ACCLIB_EXTERN_NOINLINE(acc_hvoid_p, acc_vget_acc_hvoid_p) (acc_hvoid_p, int); +ACCLIB_EXTERN_NOINLINE(const acc_hvoid_p, acc_vget_acc_hvoid_cp) (const acc_hvoid_p, int); +#if !defined(ACC_FN_PATH_MAX) +#if (ACC_OS_DOS16 || ACC_OS_WIN16) +# define ACC_FN_PATH_MAX 143 +#elif (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN32 || ACC_OS_WIN64) +# define ACC_FN_PATH_MAX 259 +#elif (ACC_OS_TOS) +# define ACC_FN_PATH_MAX 259 +#endif +#endif +#if !defined(ACC_FN_PATH_MAX) +# define ACC_FN_PATH_MAX 1023 +#endif +#if !defined(ACC_FN_NAME_MAX) +#if (ACC_OS_DOS16 || ACC_OS_WIN16) +# define ACC_FN_NAME_MAX 12 +#elif (ACC_ARCH_M68K && ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC)) +# define ACC_FN_NAME_MAX 12 +#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) +#elif (ACC_OS_DOS32) +# define ACC_FN_NAME_MAX 12 +#endif +#endif +#if !defined(ACC_FN_NAME_MAX) +# define ACC_FN_NAME_MAX ACC_FN_PATH_MAX +#endif +#define ACC_FNMATCH_NOESCAPE 1 +#define ACC_FNMATCH_PATHNAME 2 +#define ACC_FNMATCH_PATHSTAR 4 +#define ACC_FNMATCH_PERIOD 8 +#define ACC_FNMATCH_ASCII_CASEFOLD 16 +ACCLIB_EXTERN(int, acc_fnmatch) (const acc_hchar_p, const acc_hchar_p, int); +#undef __ACCLIB_USE_OPENDIR +#if (HAVE_DIRENT_H || ACC_CC_WATCOMC) +# define __ACCLIB_USE_OPENDIR 1 +# if (ACC_OS_DOS32 && defined(__BORLANDC__)) +# elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) +# elif (ACC_OS_OS2 || ACC_OS_OS216) +# elif (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) +# elif (ACC_OS_WIN32 && !(ACC_HAVE_WINDOWS_H)) +# elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_TOS || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) +# undef __ACCLIB_USE_OPENDIR +# endif +#endif +typedef struct +{ +#if defined(__ACCLIB_USE_OPENDIR) + void* u_dirp; +# if (ACC_CC_WATCOMC) + unsigned short f_time; + unsigned short f_date; + unsigned long f_size; +# endif + char f_name[ACC_FN_NAME_MAX+1]; +#elif (ACC_OS_WIN32 || ACC_OS_WIN64) + acclib_handle_t u_handle; + unsigned f_attr; + unsigned f_size_low; + unsigned f_size_high; + char f_name[ACC_FN_NAME_MAX+1]; +#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_TOS || ACC_OS_WIN16) + char u_dta[21]; + unsigned char f_attr; + unsigned short f_time; + unsigned short f_date; + unsigned short f_size_low; + unsigned short f_size_high; + char f_name[ACC_FN_NAME_MAX+1]; + char u_dirp; +#else + void* u_dirp; + char f_name[ACC_FN_NAME_MAX+1]; +#endif +} acc_dir_t; +#ifndef acc_dir_p +#define acc_dir_p acc_dir_t * +#endif +ACCLIB_EXTERN(int, acc_opendir) (acc_dir_p, const char*); +ACCLIB_EXTERN(int, acc_readdir) (acc_dir_p); +ACCLIB_EXTERN(int, acc_closedir) (acc_dir_p); +#if (ACC_CC_GNUC) && (defined(__CYGWIN__) || defined(__MINGW32__)) +# define acc_alloca(x) __builtin_alloca((x)) +#elif (ACC_CC_GNUC) && (ACC_OS_CONSOLE_PS2) +# define acc_alloca(x) __builtin_alloca((x)) +#elif (ACC_CC_BORLANDC || ACC_CC_LCC) && defined(__linux__) +#elif (HAVE_ALLOCA) +# define acc_alloca(x) ((void *) (alloca((x)))) +#endif +#if (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) +# define acc_stackavail() stackavail() +#elif (ACC_ARCH_I086 && ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0410)) +# define acc_stackavail() stackavail() +#elif (ACC_ARCH_I086 && ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0400)) +# if (ACC_OS_WIN16) && (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM) +# else +# define acc_stackavail() stackavail() +# endif +#elif ((ACC_ARCH_I086 || ACC_ARCH_I386) && (ACC_CC_DMC || ACC_CC_SYMANTECC)) +# define acc_stackavail() stackavail() +#elif ((ACC_ARCH_I086) && ACC_CC_MSC && (_MSC_VER >= 700)) +# define acc_stackavail() _stackavail() +#elif ((ACC_ARCH_I086) && ACC_CC_MSC) +# define acc_stackavail() stackavail() +#elif ((ACC_ARCH_I086 || ACC_ARCH_I386) && ACC_CC_TURBOC && (__TURBOC__ >= 0x0450)) +# define acc_stackavail() stackavail() +#elif (ACC_ARCH_I086 && ACC_CC_TURBOC && (__TURBOC__ >= 0x0400)) + ACC_EXTERN_C size_t __cdecl stackavail(void); +# define acc_stackavail() stackavail() +#elif ((ACC_ARCH_I086 || ACC_ARCH_I386) && (ACC_CC_WATCOMC)) +# define acc_stackavail() stackavail() +#elif (ACC_ARCH_I086 && ACC_CC_ZORTECHC) +# define acc_stackavail() _chkstack() +#endif +ACCLIB_EXTERN(acclib_handle_t, acc_get_osfhandle) (int); +ACCLIB_EXTERN(const char *, acc_getenv) (const char *); +ACCLIB_EXTERN(int, acc_isatty) (int); +ACCLIB_EXTERN(int, acc_mkdir) (const char*, unsigned); +ACCLIB_EXTERN(int, acc_rmdir) (const char*); +ACCLIB_EXTERN(int, acc_response) (int*, char***); +ACCLIB_EXTERN(int, acc_set_binmode) (int, int); +#if defined(acc_int32e_t) +ACCLIB_EXTERN(acc_int32e_t, acc_muldiv32s) (acc_int32e_t, acc_int32e_t, acc_int32e_t); +ACCLIB_EXTERN(acc_uint32e_t, acc_muldiv32u) (acc_uint32e_t, acc_uint32e_t, acc_uint32e_t); +#endif +ACCLIB_EXTERN(void, acc_wildargv) (int*, char***); +ACCLIB_EXTERN_NOINLINE(void, acc_debug_break) (void); +ACCLIB_EXTERN_NOINLINE(void, acc_debug_nop) (void); +ACCLIB_EXTERN_NOINLINE(int, acc_debug_align_check_query) (void); +ACCLIB_EXTERN_NOINLINE(int, acc_debug_align_check_enable) (int); +ACCLIB_EXTERN_NOINLINE(unsigned, acc_debug_running_on_qemu) (void); +ACCLIB_EXTERN_NOINLINE(unsigned, acc_debug_running_on_valgrind) (void); +#if !defined(acc_int64l_t) || (ACC_CFG_NO_DOUBLE) +# undef __ACCLIB_PCLOCK_USE_RDTSC +# undef __ACCLIB_PCLOCK_USE_PERFCTR +# undef __ACCLIB_UCLOCK_USE_RDTSC +# undef __ACCLIB_UCLOCK_USE_PERFCTR +#else +typedef struct { + void* h; + int mode; + double tsc_to_seconds; + unsigned cpu_type, cpu_features, cpu_khz, cpu_nrctrs; + const char* cpu_name; +} acc_perfctr_handle_t; +typedef struct { + acc_uint64l_t tsc; +#if (ACC_OS_POSIX_LINUX) + acc_uint64l_t pmc[18]; +#else + acc_uint64l_t pmc[1]; +#endif +} acc_perfctr_clock_t; +#ifndef acc_perfctr_handle_p +#define acc_perfctr_handle_p acc_perfctr_handle_t * +#endif +#ifndef acc_perfctr_clock_p +#define acc_perfctr_clock_p acc_perfctr_clock_t * +#endif +ACCLIB_EXTERN(int, acc_perfctr_open) (acc_perfctr_handle_p); +ACCLIB_EXTERN(int, acc_perfctr_close) (acc_perfctr_handle_p); +ACCLIB_EXTERN(void, acc_perfctr_read) (acc_perfctr_handle_p, acc_perfctr_clock_p); +#if !(ACC_CFG_NO_DOUBLE) +ACCLIB_EXTERN(double, acc_perfctr_get_elapsed) (acc_perfctr_handle_p, const acc_perfctr_clock_p, const acc_perfctr_clock_p); +ACCLIB_EXTERN(double, acc_perfctr_get_elapsed_tsc) (acc_perfctr_handle_p, acc_uint64l_t); +#endif +ACCLIB_EXTERN(int, acc_perfctr_flush_cpu_cache) (acc_perfctr_handle_p, unsigned); +#endif +#if defined(acc_int32e_t) +ACCLIB_EXTERN(int, acc_tsc_read) (acc_uint32e_t*); +#else +# undef __ACCLIB_PCLOCK_USE_RDTSC +# undef __ACCLIB_UCLOCK_USE_RDTSC +#endif +struct acc_pclock_handle_t; +struct acc_pclock_t; +typedef struct acc_pclock_handle_t acc_pclock_handle_t; +typedef struct acc_pclock_t acc_pclock_t; +#ifndef acc_pclock_handle_p +#define acc_pclock_handle_p acc_pclock_handle_t * +#endif +#ifndef acc_pclock_p +#define acc_pclock_p acc_pclock_t * +#endif +#define ACC_PCLOCK_REALTIME 0 +#define ACC_PCLOCK_MONOTONIC 1 +#define ACC_PCLOCK_PROCESS_CPUTIME_ID 2 +#define ACC_PCLOCK_THREAD_CPUTIME_ID 3 +struct acc_pclock_handle_t { + acclib_handle_t h; + int mode; + int read_error; + const char* name; + int (*gettime) (acc_pclock_handle_p, acc_pclock_p); +#if defined(acc_int64l_t) + acc_uint64l_t ticks_base; +#endif +#if (__ACCLIB_PCLOCK_USE_PERFCTR) + acc_perfctr_handle_t pch; +#endif +}; +struct acc_pclock_t { +#if defined(acc_int64l_t) + acc_int64l_t tv_sec; +#else + acc_int32l_t tv_sec_high; + acc_uint32l_t tv_sec_low; +#endif + acc_uint32l_t tv_nsec; +}; +ACCLIB_EXTERN(int, acc_pclock_open) (acc_pclock_handle_p, int); +ACCLIB_EXTERN(int, acc_pclock_open_default) (acc_pclock_handle_p); +ACCLIB_EXTERN(int, acc_pclock_close) (acc_pclock_handle_p); +ACCLIB_EXTERN(void, acc_pclock_read) (acc_pclock_handle_p, acc_pclock_p); +#if !(ACC_CFG_NO_DOUBLE) +ACCLIB_EXTERN(double, acc_pclock_get_elapsed) (acc_pclock_handle_p, const acc_pclock_p, const acc_pclock_p); +#endif +ACCLIB_EXTERN(int, acc_pclock_flush_cpu_cache) (acc_pclock_handle_p, unsigned); +#if !defined(acc_int64l_t) || (ACC_CFG_NO_DOUBLE) +# undef __ACCLIB_UCLOCK_USE_QPC +#elif (ACC_OS_CYGWIN || ACC_OS_EMX || ACC_OS_WIN32 || ACC_OS_WIN64) && (ACC_HAVE_WINDOWS_H) +# define __ACCLIB_UCLOCK_USE_QPC 1 +#else +# undef __ACCLIB_UCLOCK_USE_QPC +#endif +typedef struct { + acclib_handle_t h; + int mode; + int read_error; + const char* name; +#if (__ACCLIB_UCLOCK_USE_PERFCTR) + acc_perfctr_handle_t pch; +#endif +#if (__ACCLIB_UCLOCK_USE_QPC) + double qpf; +#endif +} acc_uclock_handle_t; +typedef struct { + union { + acc_uint32l_t t32; +#if !(ACC_OS_DOS16 || ACC_OS_WIN16) +# if !(ACC_CFG_NO_DOUBLE) + double td; +# endif +# if defined(acc_int64l_t) + acc_int64l_t t64; +# endif +#endif + } ticks; +#if (__ACCLIB_UCLOCK_USE_RDTSC) + acc_uint64l_t tsc; +#endif +#if (__ACCLIB_UCLOCK_USE_PERFCTR) + acc_perfctr_clock_t pcc; +#endif +#if (__ACCLIB_UCLOCK_USE_QPC) + acc_int64l_t qpc; +#endif +} acc_uclock_t; +#ifndef acc_uclock_handle_p +#define acc_uclock_handle_p acc_uclock_handle_t * +#endif +#ifndef acc_uclock_p +#define acc_uclock_p acc_uclock_t * +#endif +ACCLIB_EXTERN(int, acc_uclock_open) (acc_uclock_handle_p); +ACCLIB_EXTERN(int, acc_uclock_close) (acc_uclock_handle_p); +ACCLIB_EXTERN(void, acc_uclock_read) (acc_uclock_handle_p, acc_uclock_p); +#if !(ACC_CFG_NO_DOUBLE) +ACCLIB_EXTERN(double, acc_uclock_get_elapsed) (acc_uclock_handle_p, const acc_uclock_p, const acc_uclock_p); +#endif +ACCLIB_EXTERN(int, acc_uclock_flush_cpu_cache) (acc_uclock_handle_p, unsigned); +struct acc_getopt_t; +typedef struct acc_getopt_t acc_getopt_t; +#ifndef acc_getopt_p +#define acc_getopt_p acc_getopt_t * +#endif +struct acc_getopt_longopt_t; +typedef struct acc_getopt_longopt_t acc_getopt_longopt_t; +#ifndef acc_getopt_longopt_p +#define acc_getopt_longopt_p acc_getopt_longopt_t * +#endif +struct acc_getopt_longopt_t { + const char* name; + int has_arg; + int* flag; + int val; +}; +struct acc_getopt_t { + void *user; + const char *progname; + int bad_option; + char *optarg; + void (*opterr)(acc_getopt_p, const char*, void *); + int optind; + int optopt; + int errcount; + int argc; char** argv; + int eof; int shortpos; + int pending_rotate_first, pending_rotate_middle; +}; +enum { ACC_GETOPT_NO_ARG, ACC_GETOPT_REQUIRED_ARG, ACC_GETOPT_OPTIONAL_ARG, ACC_GETOPT_EXACT_ARG = 0x10 }; +enum { ACC_GETOPT_PERMUTE, ACC_GETOPT_RETURN_IN_ORDER, ACC_GETOPT_REQUIRE_ORDER }; +ACCLIB_EXTERN(void, acc_getopt_init) (acc_getopt_p g, + int start_argc, int argc, char** argv); +ACCLIB_EXTERN(int, acc_getopt) (acc_getopt_p g, + const char* shortopts, + const acc_getopt_longopt_p longopts, + int* longind); +typedef struct { + acc_uint32l_t seed; +} acc_rand31_t; +#ifndef acc_rand31_p +#define acc_rand31_p acc_rand31_t * +#endif +ACCLIB_EXTERN(void, acc_srand31) (acc_rand31_p, acc_uint32l_t); +ACCLIB_EXTERN(acc_uint32l_t, acc_rand31) (acc_rand31_p); +#if defined(acc_int64l_t) +typedef struct { + acc_uint64l_t seed; +} acc_rand48_t; +#ifndef acc_rand48_p +#define acc_rand48_p acc_rand48_t * +#endif +ACCLIB_EXTERN(void, acc_srand48) (acc_rand48_p, acc_uint32l_t); +ACCLIB_EXTERN(acc_uint32l_t, acc_rand48) (acc_rand48_p); +ACCLIB_EXTERN(acc_uint32l_t, acc_rand48_r32) (acc_rand48_p); +#endif +#if defined(acc_int64l_t) +typedef struct { + acc_uint64l_t seed; +} acc_rand64_t; +#ifndef acc_rand64_p +#define acc_rand64_p acc_rand64_t * +#endif +ACCLIB_EXTERN(void, acc_srand64) (acc_rand64_p, acc_uint64l_t); +ACCLIB_EXTERN(acc_uint32l_t, acc_rand64) (acc_rand64_p); +ACCLIB_EXTERN(acc_uint32l_t, acc_rand64_r32) (acc_rand64_p); +#endif +typedef struct { + unsigned n; + acc_uint32l_t s[624]; +} acc_randmt_t; +#ifndef acc_randmt_p +#define acc_randmt_p acc_randmt_t * +#endif +ACCLIB_EXTERN(void, acc_srandmt) (acc_randmt_p, acc_uint32l_t); +ACCLIB_EXTERN(acc_uint32l_t, acc_randmt) (acc_randmt_p); +ACCLIB_EXTERN(acc_uint32l_t, acc_randmt_r32) (acc_randmt_p); +#if defined(acc_int64l_t) +typedef struct { + unsigned n; + acc_uint64l_t s[312]; +} acc_randmt64_t; +#ifndef acc_randmt64_p +#define acc_randmt64_p acc_randmt64_t * +#endif +ACCLIB_EXTERN(void, acc_srandmt64) (acc_randmt64_p, acc_uint64l_t); +ACCLIB_EXTERN(acc_uint64l_t, acc_randmt64_r64) (acc_randmt64_p); +#endif +#define ACC_SPAWN_P_WAIT 0 +#define ACC_SPAWN_P_NOWAIT 1 +ACCLIB_EXTERN(int, acc_spawnv) (int mode, const char* fn, const char* const * argv); +ACCLIB_EXTERN(int, acc_spawnvp) (int mode, const char* fn, const char* const * argv); +ACCLIB_EXTERN(int, acc_spawnve) (int mode, const char* fn, const char* const * argv, const char * const envp); +#endif +#endif +#if defined(ACC_WANT_ACC_CXX_H) +# undef ACC_WANT_ACC_CXX_H +#ifndef __ACC_CXX_H_INCLUDED +#define __ACC_CXX_H_INCLUDED 1 +#if defined(__cplusplus) +#if defined(ACC_CXX_NOTHROW) +#elif (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020800ul)) +#elif (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0450)) +#elif (ACC_CC_HIGHC) +#elif (ACC_CC_MSC && (_MSC_VER < 1100)) +#elif (ACC_CC_NDPC) +#elif (ACC_CC_TURBOC) +#elif (ACC_CC_WATCOMC && !defined(_CPPUNWIND)) +#elif (ACC_CC_ZORTECHC) +#else +# define ACC_CXX_NOTHROW throw() +#endif +#if !defined(ACC_CXX_NOTHROW) +# define ACC_CXX_NOTHROW /*empty*/ +#endif +#if defined(__ACC_CXX_DO_NEW) +#elif (ACC_CC_NDPC || ACC_CC_PGI) +# define __ACC_CXX_DO_NEW { return 0; } +#elif ((ACC_CC_BORLANDC || ACC_CC_TURBOC) && ACC_ARCH_I086) +# define __ACC_CXX_DO_NEW { return 0; } +#else +# define __ACC_CXX_DO_NEW ; +#endif +#if defined(__ACC_CXX_DO_DELETE) +#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) +# define __ACC_CXX_DO_DELETE { } +#else +# define __ACC_CXX_DO_DELETE ACC_CXX_NOTHROW { } +#endif +#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0450)) +#elif (ACC_CC_MSC && ACC_MM_HUGE) +# define ACC_CXX_DISABLE_NEW_DELETE private: +#elif (ACC_CC_MSC && (_MSC_VER < 1100)) +#elif (ACC_CC_NDPC) +#elif (ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) +#elif (ACC_CC_TURBOC) +#elif (ACC_CC_WATCOMC && (__WATCOMC__ < 1100)) +#else +# define __ACC_CXX_HAVE_ARRAY_NEW 1 +#endif +#if (__ACC_CXX_HAVE_ARRAY_NEW) +# define __ACC_CXX_HAVE_PLACEMENT_NEW 1 +#endif +#if (__ACC_CXX_HAVE_PLACEMENT_NEW) +# if (ACC_CC_GNUC >= 0x030000ul) +# define __ACC_CXX_HAVE_PLACEMENT_DELETE 1 +# elif (ACC_CC_INTELC) +# define __ACC_CXX_HAVE_PLACEMENT_DELETE 1 +# elif (ACC_CC_MSC && (_MSC_VER >= 1200)) +# define __ACC_CXX_HAVE_PLACEMENT_DELETE 1 +# elif (ACC_CC_CLANG || ACC_CC_LLVM || ACC_CC_PATHSCALE) +# define __ACC_CXX_HAVE_PLACEMENT_DELETE 1 +# elif (ACC_CC_PGI) +# define __ACC_CXX_HAVE_PLACEMENT_DELETE 1 +# endif +#endif +#if defined(ACC_CXX_DISABLE_NEW_DELETE) +#elif defined(new) || defined(delete) +# define ACC_CXX_DISABLE_NEW_DELETE private: +#elif (ACC_CC_GNUC && (ACC_CC_GNUC < 0x025b00ul)) +# define ACC_CXX_DISABLE_NEW_DELETE private: +#elif (ACC_CC_HIGHC) +# define ACC_CXX_DISABLE_NEW_DELETE private: +#elif !(__ACC_CXX_HAVE_ARRAY_NEW) +# define ACC_CXX_DISABLE_NEW_DELETE \ + protected: static void operator delete(void*) __ACC_CXX_DO_DELETE \ + protected: static void* operator new(size_t) __ACC_CXX_DO_NEW \ + private: +#else +# define ACC_CXX_DISABLE_NEW_DELETE \ + protected: static void operator delete(void*) __ACC_CXX_DO_DELETE \ + static void operator delete[](void*) __ACC_CXX_DO_DELETE \ + private: static void* operator new(size_t) __ACC_CXX_DO_NEW \ + static void* operator new[](size_t) __ACC_CXX_DO_NEW +#endif +#if defined(ACC_CXX_TRIGGER_FUNCTION) +#else +# define ACC_CXX_TRIGGER_FUNCTION \ + protected: virtual const void* acc_cxx_trigger_function() const; \ + private: +#endif +#if defined(ACC_CXX_TRIGGER_FUNCTION_IMPL) +#else +# define ACC_CXX_TRIGGER_FUNCTION_IMPL(klass) \ + const void* klass::acc_cxx_trigger_function() const { return 0; } +#endif +#endif +#endif +#endif +#if defined(ACC_WANT_ACC_CHK_CH) +# undef ACC_WANT_ACC_CHK_CH +#if !defined(ACCCHK_ASSERT) +# define ACCCHK_ASSERT(expr) ACC_COMPILE_TIME_ASSERT_HEADER(expr) +#endif +#if !defined(ACCCHK_ASSERT_SIGN_T) +# define ACCCHK_ASSERT_SIGN_T(type,relop) \ + ACCCHK_ASSERT( (type) (-1) relop (type) 0 ) \ + ACCCHK_ASSERT( (type) (~(type)0) relop (type) 0 ) \ + ACCCHK_ASSERT( (type) (~(type)0) == (type) (-1) ) +#endif +#if !defined(ACCCHK_ASSERT_IS_SIGNED_T) +# define ACCCHK_ASSERT_IS_SIGNED_T(type) ACCCHK_ASSERT_SIGN_T(type,<) +#endif +#if !defined(ACCCHK_ASSERT_IS_UNSIGNED_T) +# if (ACC_BROKEN_INTEGRAL_PROMOTION) +# define ACCCHK_ASSERT_IS_UNSIGNED_T(type) \ + ACCCHK_ASSERT( (type) (-1) > (type) 0 ) +# else +# define ACCCHK_ASSERT_IS_UNSIGNED_T(type) ACCCHK_ASSERT_SIGN_T(type,>) +# endif +#endif +#if (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0550) && (__BORLANDC__ < 0x0560)) +# pragma option push -w-8055 +#elif (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0530) && (__BORLANDC__ < 0x0550)) +# pragma option push -w-osh +#endif +#if (ACC_0xffffffffL - ACC_UINT32_C(4294967294) != 1) +# error "preprocessor error 1" +#endif +#if (ACC_0xffffffffL - ACC_UINT32_C(0xfffffffd) != 2) +# error "preprocessor error 2" +#endif +#define ACCCHK_VAL 1 +#define ACCCHK_TMP1 ACCCHK_VAL +#undef ACCCHK_VAL +#define ACCCHK_VAL 2 +#define ACCCHK_TMP2 ACCCHK_VAL +#if (ACCCHK_TMP1 != 2) +# error "preprocessor error 3a" +#endif +#if (ACCCHK_TMP2 != 2) +# error "preprocessor error 3b" +#endif +#undef ACCCHK_VAL +#if (ACCCHK_TMP2) +# error "preprocessor error 3c" +#endif +#if (ACCCHK_TMP2 + 0 != 0) +# error "preprocessor error 3d" +#endif +#undef ACCCHK_TMP1 +#undef ACCCHK_TMP2 +#if 0 || defined(ACCCHK_CFG_PEDANTIC) +# if (ACC_ARCH_MIPS) && defined(_MIPS_SZINT) + ACCCHK_ASSERT((_MIPS_SZINT) == 8 * sizeof(int)) +# endif +# if (ACC_ARCH_MIPS) && defined(_MIPS_SZLONG) + ACCCHK_ASSERT((_MIPS_SZLONG) == 8 * sizeof(long)) +# endif +# if (ACC_ARCH_MIPS) && defined(_MIPS_SZPTR) + ACCCHK_ASSERT((_MIPS_SZPTR) == 8 * sizeof(void *)) +# endif +#endif + ACCCHK_ASSERT(1 == 1) + ACCCHK_ASSERT(__ACC_MASK_GEN(1u,2) == 3) + ACCCHK_ASSERT(__ACC_MASK_GEN(1u,8) == 255) +#if (SIZEOF_INT >= 2) + ACCCHK_ASSERT(__ACC_MASK_GEN(1,15) == 32767) + ACCCHK_ASSERT(__ACC_MASK_GEN(1u,16) == 0xffffU) +#else + ACCCHK_ASSERT(__ACC_MASK_GEN(1ul,16) == 0xffffUL) +#endif +#if (SIZEOF_INT >= 4) + ACCCHK_ASSERT(__ACC_MASK_GEN(1,31) == 2147483647) + ACCCHK_ASSERT(__ACC_MASK_GEN(1u,32) == 0xffffffffU) +#endif +#if (SIZEOF_LONG >= 4) + ACCCHK_ASSERT(__ACC_MASK_GEN(1ul,32) == 0xffffffffUL) +#endif +#if (SIZEOF_LONG >= 8) + ACCCHK_ASSERT(__ACC_MASK_GEN(1ul,64) == 0xffffffffffffffffUL) +#endif +#if !(ACC_BROKEN_INTEGRAL_PROMOTION) + ACCCHK_ASSERT(__ACC_MASK_GEN(1u,SIZEOF_INT*8) == ~0u) + ACCCHK_ASSERT(__ACC_MASK_GEN(1ul,SIZEOF_LONG*8) == ~0ul) +#endif +#if !(ACC_BROKEN_SIGNED_RIGHT_SHIFT) + ACCCHK_ASSERT(((-1) >> 7) == -1) +#endif + ACCCHK_ASSERT(((1) >> 7) == 0) + ACCCHK_ASSERT((~0l & ~0) == ~0l) + ACCCHK_ASSERT((~0l & ~0u) == ~0u) + ACCCHK_ASSERT((~0ul & ~0) == ~0ul) + ACCCHK_ASSERT((~0ul & ~0u) == ~0u) +#if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0150) +#elif (SIZEOF_INT == 2) + ACCCHK_ASSERT((~0l & ~0u) == 0xffffU) + ACCCHK_ASSERT((~0ul & ~0u) == 0xffffU) +#elif (SIZEOF_INT == 4) + ACCCHK_ASSERT((~0l & ~0u) == 0xffffffffU) + ACCCHK_ASSERT((~0ul & ~0u) == 0xffffffffU) +#endif + ACCCHK_ASSERT_IS_SIGNED_T(signed char) + ACCCHK_ASSERT_IS_UNSIGNED_T(unsigned char) + ACCCHK_ASSERT(sizeof(signed char) == sizeof(char)) + ACCCHK_ASSERT(sizeof(unsigned char) == sizeof(char)) + ACCCHK_ASSERT(sizeof(char) == 1) +#if (ACC_CC_CILLY) && (!defined(__CILLY__) || (__CILLY__ < 0x010302L)) +#else + ACCCHK_ASSERT(sizeof(char) == sizeof((char)0)) +#endif +#if defined(__cplusplus) + ACCCHK_ASSERT(sizeof('\0') == sizeof(char)) +#else +# if (ACC_CC_DMC) +# else + ACCCHK_ASSERT(sizeof('\0') == sizeof(int)) +# endif +#endif +#if defined(__acc_alignof) + ACCCHK_ASSERT(__acc_alignof(char) == 1) + ACCCHK_ASSERT(__acc_alignof(signed char) == 1) + ACCCHK_ASSERT(__acc_alignof(unsigned char) == 1) +#if defined(acc_int16e_t) + ACCCHK_ASSERT(__acc_alignof(acc_int16e_t) >= 1) + ACCCHK_ASSERT(__acc_alignof(acc_int16e_t) <= 2) +#endif +#if defined(acc_int32e_t) + ACCCHK_ASSERT(__acc_alignof(acc_int32e_t) >= 1) + ACCCHK_ASSERT(__acc_alignof(acc_int32e_t) <= 4) +#endif +#endif + ACCCHK_ASSERT_IS_SIGNED_T(short) + ACCCHK_ASSERT_IS_UNSIGNED_T(unsigned short) + ACCCHK_ASSERT(sizeof(short) == sizeof(unsigned short)) +#if !(ACC_ABI_I8LP16) + ACCCHK_ASSERT(sizeof(short) >= 2) +#endif + ACCCHK_ASSERT(sizeof(short) >= sizeof(char)) +#if (ACC_CC_CILLY) && (!defined(__CILLY__) || (__CILLY__ < 0x010302L)) +#else + ACCCHK_ASSERT(sizeof(short) == sizeof((short)0)) +#endif +#if (SIZEOF_SHORT > 0) + ACCCHK_ASSERT(sizeof(short) == SIZEOF_SHORT) +#endif + ACCCHK_ASSERT_IS_SIGNED_T(int) + ACCCHK_ASSERT_IS_UNSIGNED_T(unsigned int) + ACCCHK_ASSERT(sizeof(int) == sizeof(unsigned int)) +#if !(ACC_ABI_I8LP16) + ACCCHK_ASSERT(sizeof(int) >= 2) +#endif + ACCCHK_ASSERT(sizeof(int) >= sizeof(short)) + ACCCHK_ASSERT(sizeof(int) == sizeof(0)) + ACCCHK_ASSERT(sizeof(int) == sizeof((int)0)) +#if (SIZEOF_INT > 0) + ACCCHK_ASSERT(sizeof(int) == SIZEOF_INT) +#endif + ACCCHK_ASSERT(sizeof(0) == sizeof(int)) + ACCCHK_ASSERT_IS_SIGNED_T(long) + ACCCHK_ASSERT_IS_UNSIGNED_T(unsigned long) + ACCCHK_ASSERT(sizeof(long) == sizeof(unsigned long)) +#if !(ACC_ABI_I8LP16) + ACCCHK_ASSERT(sizeof(long) >= 4) +#endif + ACCCHK_ASSERT(sizeof(long) >= sizeof(int)) + ACCCHK_ASSERT(sizeof(long) == sizeof(0L)) + ACCCHK_ASSERT(sizeof(long) == sizeof((long)0)) +#if (SIZEOF_LONG > 0) + ACCCHK_ASSERT(sizeof(long) == SIZEOF_LONG) +#endif + ACCCHK_ASSERT(sizeof(0L) == sizeof(long)) + ACCCHK_ASSERT_IS_UNSIGNED_T(size_t) + ACCCHK_ASSERT(sizeof(size_t) >= sizeof(int)) + ACCCHK_ASSERT(sizeof(size_t) == sizeof(sizeof(0))) +#if (SIZEOF_SIZE_T > 0) + ACCCHK_ASSERT(sizeof(size_t) == SIZEOF_SIZE_T) +#endif + ACCCHK_ASSERT_IS_SIGNED_T(ptrdiff_t) + ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(int)) + ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t)) +#if !(ACC_BROKEN_SIZEOF) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof((char*)0 - (char*)0)) +# if (ACC_HAVE_MM_HUGE_PTR) + ACCCHK_ASSERT(4 == sizeof((char __huge*)0 - (char __huge*)0)) +# endif +#endif +#if (SIZEOF_PTRDIFF_T > 0) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == SIZEOF_PTRDIFF_T) +#endif + ACCCHK_ASSERT(sizeof(void*) >= sizeof(char*)) +#if (SIZEOF_VOID_P > 0) + ACCCHK_ASSERT(sizeof(void*) == SIZEOF_VOID_P) + ACCCHK_ASSERT(sizeof(char*) == SIZEOF_VOID_P) +#endif +#if (ACC_HAVE_MM_HUGE_PTR) + ACCCHK_ASSERT(4 == sizeof(void __huge*)) + ACCCHK_ASSERT(4 == sizeof(char __huge*)) +#endif +#if (ACC_ABI_I8LP16) + ACCCHK_ASSERT((((1u << 7) + 1) >> 7) == 1) + ACCCHK_ASSERT((((1ul << 15) + 1) >> 15) == 1) +#else + ACCCHK_ASSERT((((1u << 15) + 1) >> 15) == 1) + ACCCHK_ASSERT((((1ul << 31) + 1) >> 31) == 1) +#endif +#if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0150) +#elif 1 && (ACC_CC_SUNPROC) && !defined(ACCCHK_CFG_PEDANTIC) +#else + ACCCHK_ASSERT((1 << (8*SIZEOF_INT-1)) < 0) +#endif + ACCCHK_ASSERT((1u << (8*SIZEOF_INT-1)) > 0) +#if 1 && (ACC_CC_SUNPROC) && !defined(ACCCHK_CFG_PEDANTIC) +#else + ACCCHK_ASSERT((1l << (8*SIZEOF_LONG-1)) < 0) +#endif + ACCCHK_ASSERT((1ul << (8*SIZEOF_LONG-1)) > 0) +#if defined(acc_int16e_t) + ACCCHK_ASSERT(sizeof(acc_int16e_t) == 2) + ACCCHK_ASSERT(sizeof(acc_int16e_t) == SIZEOF_ACC_INT16E_T) + ACCCHK_ASSERT(sizeof(acc_uint16e_t) == 2) + ACCCHK_ASSERT(sizeof(acc_int16e_t) == sizeof(acc_uint16e_t)) + ACCCHK_ASSERT_IS_SIGNED_T(acc_int16e_t) + ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uint16e_t) +#if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0150) +#else + ACCCHK_ASSERT(((acc_uint16e_t)(~(acc_uint16e_t)0ul) >> 15) == 1) +#endif + ACCCHK_ASSERT( (acc_int16e_t) (1 + ~(acc_int16e_t)0) == 0) +#if defined(ACCCHK_CFG_PEDANTIC) + ACCCHK_ASSERT( (acc_uint16e_t)(1 + ~(acc_uint16e_t)0) == 0) +#endif +#endif +#if defined(acc_int32e_t) + ACCCHK_ASSERT(sizeof(acc_int32e_t) == 4) + ACCCHK_ASSERT(sizeof(acc_int32e_t) == SIZEOF_ACC_INT32E_T) + ACCCHK_ASSERT(sizeof(acc_uint32e_t) == 4) + ACCCHK_ASSERT(sizeof(acc_int32e_t) == sizeof(acc_uint32e_t)) + ACCCHK_ASSERT_IS_SIGNED_T(acc_int32e_t) + ACCCHK_ASSERT(((( (acc_int32e_t)1 << 30) + 1) >> 30) == 1) + ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uint32e_t) + ACCCHK_ASSERT(((( (acc_uint32e_t)1 << 31) + 1) >> 31) == 1) + ACCCHK_ASSERT(((acc_uint32e_t)(~(acc_uint32e_t)0ul) >> 31) == 1) + ACCCHK_ASSERT( (acc_int32e_t) (1 + ~(acc_int32e_t)0) == 0) +#if defined(ACCCHK_CFG_PEDANTIC) + ACCCHK_ASSERT( (acc_uint32e_t)(1 + ~(acc_uint32e_t)0) == 0) +#endif +#endif +#if defined(acc_int32e_t) + ACCCHK_ASSERT(sizeof(acc_int32l_t) >= sizeof(acc_int32e_t)) +#endif + ACCCHK_ASSERT(sizeof(acc_int32l_t) >= 4) + ACCCHK_ASSERT(sizeof(acc_int32l_t) == SIZEOF_ACC_INT32L_T) + ACCCHK_ASSERT(sizeof(acc_uint32l_t) >= 4) + ACCCHK_ASSERT(sizeof(acc_int32l_t) == sizeof(acc_uint32l_t)) + ACCCHK_ASSERT_IS_SIGNED_T(acc_int32l_t) + ACCCHK_ASSERT(((( (acc_int32l_t)1 << 30) + 1) >> 30) == 1) + ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uint32l_t) + ACCCHK_ASSERT(((( (acc_uint32l_t)1 << 31) + 1) >> 31) == 1) + ACCCHK_ASSERT(sizeof(acc_int32f_t) >= sizeof(int)) +#if defined(acc_int32e_t) + ACCCHK_ASSERT(sizeof(acc_int32f_t) >= sizeof(acc_int32e_t)) +#endif + ACCCHK_ASSERT(sizeof(acc_int32f_t) >= sizeof(acc_int32l_t)) + ACCCHK_ASSERT(sizeof(acc_int32f_t) >= 4) + ACCCHK_ASSERT(sizeof(acc_int32f_t) >= sizeof(acc_int32l_t)) + ACCCHK_ASSERT(sizeof(acc_int32f_t) == SIZEOF_ACC_INT32F_T) + ACCCHK_ASSERT(sizeof(acc_uint32f_t) >= 4) + ACCCHK_ASSERT(sizeof(acc_uint32f_t) >= sizeof(acc_uint32l_t)) + ACCCHK_ASSERT(sizeof(acc_int32f_t) == sizeof(acc_uint32f_t)) + ACCCHK_ASSERT_IS_SIGNED_T(acc_int32f_t) + ACCCHK_ASSERT(((( (acc_int32f_t)1 << 30) + 1) >> 30) == 1) + ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uint32f_t) + ACCCHK_ASSERT(((( (acc_uint32f_t)1 << 31) + 1) >> 31) == 1) +#if defined(acc_int64e_t) + ACCCHK_ASSERT(sizeof(acc_int64e_t) == 8) + ACCCHK_ASSERT(sizeof(acc_int64e_t) == SIZEOF_ACC_INT64E_T) + ACCCHK_ASSERT(sizeof(acc_uint64e_t) == 8) + ACCCHK_ASSERT(sizeof(acc_int64e_t) == sizeof(acc_uint64e_t)) + ACCCHK_ASSERT_IS_SIGNED_T(acc_int64e_t) +#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0530)) +#else + ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uint64e_t) +#endif +#endif +#if defined(acc_int64l_t) +#if defined(acc_int64e_t) + ACCCHK_ASSERT(sizeof(acc_int64l_t) >= sizeof(acc_int64e_t)) +#endif + ACCCHK_ASSERT(sizeof(acc_int64l_t) >= 8) + ACCCHK_ASSERT(sizeof(acc_int64l_t) == SIZEOF_ACC_INT64L_T) + ACCCHK_ASSERT(sizeof(acc_uint64l_t) >= 8) + ACCCHK_ASSERT(sizeof(acc_int64l_t) == sizeof(acc_uint64l_t)) + ACCCHK_ASSERT_IS_SIGNED_T(acc_int64l_t) + ACCCHK_ASSERT(((( (acc_int64l_t)1 << 62) + 1) >> 62) == 1) + ACCCHK_ASSERT(((( ACC_INT64_C(1) << 62) + 1) >> 62) == 1) +#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0530)) +#else + ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uint64l_t) + ACCCHK_ASSERT(ACC_UINT64_C(18446744073709551615) > 0) +#endif + ACCCHK_ASSERT(((( (acc_uint64l_t)1 << 63) + 1) >> 63) == 1) + ACCCHK_ASSERT(((( ACC_UINT64_C(1) << 63) + 1) >> 63) == 1) +#if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020600ul)) + ACCCHK_ASSERT(ACC_INT64_C(9223372036854775807) > ACC_INT64_C(0)) +#else + ACCCHK_ASSERT(ACC_INT64_C(9223372036854775807) > 0) +#endif + ACCCHK_ASSERT(ACC_INT64_C(-9223372036854775807) - 1 < 0) + ACCCHK_ASSERT( ACC_INT64_C(9223372036854775807) % ACC_INT32_C(2147483629) == 721) + ACCCHK_ASSERT( ACC_INT64_C(9223372036854775807) % ACC_INT32_C(2147483647) == 1) + ACCCHK_ASSERT(ACC_UINT64_C(9223372036854775807) % ACC_UINT32_C(2147483629) == 721) + ACCCHK_ASSERT(ACC_UINT64_C(9223372036854775807) % ACC_UINT32_C(2147483647) == 1) +#endif +#if !defined(__ACC_INTPTR_T_IS_POINTER) + ACCCHK_ASSERT_IS_SIGNED_T(acc_intptr_t) + ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uintptr_t) +#endif + ACCCHK_ASSERT(sizeof(acc_intptr_t) >= sizeof(void *)) + ACCCHK_ASSERT(sizeof(acc_intptr_t) == SIZEOF_ACC_INTPTR_T) + ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(acc_uintptr_t)) +#if defined(acc_word_t) + ACCCHK_ASSERT(ACC_WORDSIZE == SIZEOF_ACC_WORD_T) + ACCCHK_ASSERT_IS_UNSIGNED_T(acc_word_t) + ACCCHK_ASSERT_IS_SIGNED_T(acc_sword_t) + ACCCHK_ASSERT(sizeof(acc_word_t) == SIZEOF_ACC_WORD_T) + ACCCHK_ASSERT(sizeof(acc_word_t) == sizeof(acc_sword_t)) +#endif +#if defined(ACC_INT16_C) + ACCCHK_ASSERT(sizeof(ACC_INT16_C(0)) >= 2) + ACCCHK_ASSERT(sizeof(ACC_UINT16_C(0)) >= 2) + ACCCHK_ASSERT((ACC_UINT16_C(0xffff) >> 15) == 1) +#endif +#if defined(ACC_INT32_C) + ACCCHK_ASSERT(sizeof(ACC_INT32_C(0)) >= 4) + ACCCHK_ASSERT(sizeof(ACC_UINT32_C(0)) >= 4) + ACCCHK_ASSERT((ACC_UINT32_C(0xffffffff) >> 31) == 1) +#endif +#if defined(ACC_INT64_C) +#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0560)) +#else + ACCCHK_ASSERT(sizeof(ACC_INT64_C(0)) >= 8) + ACCCHK_ASSERT(sizeof(ACC_UINT64_C(0)) >= 8) +#endif + ACCCHK_ASSERT((ACC_UINT64_C(0xffffffffffffffff) >> 63) == 1) + ACCCHK_ASSERT((ACC_UINT64_C(0xffffffffffffffff) & ~0) == ACC_UINT64_C(0xffffffffffffffff)) + ACCCHK_ASSERT((ACC_UINT64_C(0xffffffffffffffff) & ~0l) == ACC_UINT64_C(0xffffffffffffffff)) +#if (SIZEOF_INT == 4) +# if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020000ul)) +# else + ACCCHK_ASSERT((ACC_UINT64_C(0xffffffffffffffff) & ~0u) == 0xffffffffu) +# endif +#endif +#if (SIZEOF_LONG == 4) +# if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020000ul)) +# else + ACCCHK_ASSERT((ACC_UINT64_C(0xffffffffffffffff) & ~0ul) == 0xfffffffful) +# endif +#endif +#endif +#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM) + ACCCHK_ASSERT(sizeof(void*) == 2) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == 2) +#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE) + ACCCHK_ASSERT(sizeof(void*) == 4) +#endif +#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_COMPACT) + ACCCHK_ASSERT(sizeof(void (*)(void)) == 2) +#elif (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE) + ACCCHK_ASSERT(sizeof(void (*)(void)) == 4) +#endif +#if (ACC_ABI_ILP32) + ACCCHK_ASSERT(sizeof(int) == 4) + ACCCHK_ASSERT(sizeof(long) == 4) + ACCCHK_ASSERT(sizeof(void*) == 4) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(void*)) + ACCCHK_ASSERT(sizeof(size_t) == sizeof(void*)) + ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *)) +#endif +#if (ACC_ABI_ILP64) + ACCCHK_ASSERT(sizeof(int) == 8) + ACCCHK_ASSERT(sizeof(long) == 8) + ACCCHK_ASSERT(sizeof(void*) == 8) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(void*)) + ACCCHK_ASSERT(sizeof(size_t) == sizeof(void*)) + ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *)) +#endif +#if (ACC_ABI_IP32L64) + ACCCHK_ASSERT(sizeof(int) == 4) + ACCCHK_ASSERT(sizeof(long) == 8) + ACCCHK_ASSERT(sizeof(void*) == 4) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(void*)) + ACCCHK_ASSERT(sizeof(size_t) == sizeof(void*)) + ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *)) +#endif +#if (ACC_ABI_LLP64) + ACCCHK_ASSERT(sizeof(int) == 4) + ACCCHK_ASSERT(sizeof(long) == 4) + ACCCHK_ASSERT(sizeof(void*) == 8) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(void*)) + ACCCHK_ASSERT(sizeof(size_t) == sizeof(void*)) + ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *)) +#endif +#if (ACC_ABI_LP32) + ACCCHK_ASSERT(sizeof(int) == 2) + ACCCHK_ASSERT(sizeof(long) == 4) + ACCCHK_ASSERT(sizeof(void*) == 4) + ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *)) +#endif +#if (ACC_ABI_LP64) + ACCCHK_ASSERT(sizeof(int) == 4) + ACCCHK_ASSERT(sizeof(long) == 8) + ACCCHK_ASSERT(sizeof(void*) == 8) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(void*)) + ACCCHK_ASSERT(sizeof(size_t) == sizeof(void*)) + ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *)) +#endif +#if (ACC_ARCH_I086) + ACCCHK_ASSERT(sizeof(size_t) == 2) + ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *)) +#elif (ACC_ARCH_I386 || ACC_ARCH_M68K) + ACCCHK_ASSERT(sizeof(size_t) == 4) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == 4) + ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *)) +#endif +#if (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_WIN32) + ACCCHK_ASSERT(sizeof(size_t) == 4) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == 4) + ACCCHK_ASSERT(sizeof(void (*)(void)) == 4) +#elif (ACC_OS_WIN64) + ACCCHK_ASSERT(sizeof(size_t) == 8) + ACCCHK_ASSERT(sizeof(ptrdiff_t) == 8) + ACCCHK_ASSERT(sizeof(void (*)(void)) == 8) +#endif +#if (ACC_CC_NDPC) +#elif (SIZEOF_INT > 1) + ACCCHK_ASSERT( (int) ((unsigned char) ((signed char) -1)) == 255) +#endif +#if (ACC_CC_KEILC) +#elif (ACC_CC_NDPC) +#elif 1 && (ACC_CC_LCC || ACC_CC_LCCWIN32) && !defined(ACCCHK_CFG_PEDANTIC) +#elif 1 && (ACC_CC_SUNPROC) && !defined(ACCCHK_CFG_PEDANTIC) +#elif !(ACC_BROKEN_INTEGRAL_PROMOTION) && (SIZEOF_INT > 1) + ACCCHK_ASSERT( (((unsigned char)128) << (int)(8*sizeof(int)-8)) < 0) +#endif +#if (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0530) && (__BORLANDC__ < 0x0560)) +# pragma option pop +#endif +#endif +#if defined(ACC_WANT_ACCLIB_UA) +# undef ACC_WANT_ACCLIB_UA +#define __ACCLIB_UA_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +ACCLIB_PUBLIC(unsigned, acc_ua_get_be16) (const acc_hvoid_p p) +{ +#if defined(ACC_UA_GET_BE16) + return ACC_UA_GET_BE16(p); +#else + const acc_hbyte_p b = (const acc_hbyte_p) p; + return ((unsigned)b[1]) | ((unsigned)b[0] << 8); +#endif +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_ua_get_be24) (const acc_hvoid_p p) +{ + const acc_hbyte_p b = (const acc_hbyte_p) p; + return ((acc_uint32l_t)b[2]) | ((acc_uint32l_t)b[1] << 8) | ((acc_uint32l_t)b[0] << 16); +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_ua_get_be32) (const acc_hvoid_p p) +{ +#if defined(ACC_UA_GET_BE32) + return ACC_UA_GET_BE32(p); +#else + const acc_hbyte_p b = (const acc_hbyte_p) p; + return ((acc_uint32l_t)b[3]) | ((acc_uint32l_t)b[2] << 8) | ((acc_uint32l_t)b[1] << 16) | ((acc_uint32l_t)b[0] << 24); +#endif +} +ACCLIB_PUBLIC(void, acc_ua_set_be16) (acc_hvoid_p p, unsigned v) +{ +#if defined(ACC_UA_SET_BE16) + ACC_UA_SET_BE16(p, v); +#else + acc_hbyte_p b = (acc_hbyte_p) p; + b[1] = (unsigned char) ((v >> 0) & 0xff); + b[0] = (unsigned char) ((v >> 8) & 0xff); +#endif +} +ACCLIB_PUBLIC(void, acc_ua_set_be24) (acc_hvoid_p p, acc_uint32l_t v) +{ + acc_hbyte_p b = (acc_hbyte_p) p; + b[2] = (unsigned char) ((v >> 0) & 0xff); + b[1] = (unsigned char) ((v >> 8) & 0xff); + b[0] = (unsigned char) ((v >> 16) & 0xff); +} +ACCLIB_PUBLIC(void, acc_ua_set_be32) (acc_hvoid_p p, acc_uint32l_t v) +{ +#if defined(ACC_UA_SET_BE32) + ACC_UA_SET_BE32(p, v); +#else + acc_hbyte_p b = (acc_hbyte_p) p; + 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); +#endif +} +ACCLIB_PUBLIC(unsigned, acc_ua_get_le16) (const acc_hvoid_p p) +{ +#if defined(ACC_UA_GET_LE16) + return ACC_UA_GET_LE16(p); +#else + const acc_hbyte_p b = (const acc_hbyte_p) p; + return ((unsigned)b[0]) | ((unsigned)b[1] << 8); +#endif +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_ua_get_le24) (const acc_hvoid_p p) +{ + const acc_hbyte_p b = (const acc_hbyte_p) p; + return ((acc_uint32l_t)b[0]) | ((acc_uint32l_t)b[1] << 8) | ((acc_uint32l_t)b[2] << 16); +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_ua_get_le32) (const acc_hvoid_p p) +{ +#if defined(ACC_UA_GET_LE32) + return ACC_UA_GET_LE32(p); +#else + const acc_hbyte_p b = (const acc_hbyte_p) p; + return ((acc_uint32l_t)b[0]) | ((acc_uint32l_t)b[1] << 8) | ((acc_uint32l_t)b[2] << 16) | ((acc_uint32l_t)b[3] << 24); +#endif +} +ACCLIB_PUBLIC(void, acc_ua_set_le16) (acc_hvoid_p p, unsigned v) +{ +#if defined(ACC_UA_SET_LE16) + ACC_UA_SET_LE16(p, v); +#else + acc_hbyte_p b = (acc_hbyte_p) p; + b[0] = (unsigned char) ((v >> 0) & 0xff); + b[1] = (unsigned char) ((v >> 8) & 0xff); +#endif +} +ACCLIB_PUBLIC(void, acc_ua_set_le24) (acc_hvoid_p p, acc_uint32l_t v) +{ + acc_hbyte_p b = (acc_hbyte_p) p; + b[0] = (unsigned char) ((v >> 0) & 0xff); + b[1] = (unsigned char) ((v >> 8) & 0xff); + b[2] = (unsigned char) ((v >> 16) & 0xff); +} +ACCLIB_PUBLIC(void, acc_ua_set_le32) (acc_hvoid_p p, acc_uint32l_t v) +{ +#if defined(ACC_UA_SET_LE32) + ACC_UA_SET_LE32(p, v); +#else + acc_hbyte_p b = (acc_hbyte_p) p; + b[0] = (unsigned char) ((v >> 0) & 0xff); + b[1] = (unsigned char) ((v >> 8) & 0xff); + b[2] = (unsigned char) ((v >> 16) & 0xff); + b[3] = (unsigned char) ((v >> 24) & 0xff); +#endif +} +#if defined(acc_int64l_t) +ACCLIB_PUBLIC(acc_uint64l_t, acc_ua_get_be64) (const acc_hvoid_p p) +{ +#if defined(ACC_UA_GET_BE64) + return ACC_UA_GET_BE64(p); +#elif defined(ACC_UA_GET_BE32) + const acc_hbyte_p b = (const acc_hbyte_p) p; + acc_uint32e_t v0, v1; + v1 = ACC_UA_GET_BE32(b + 0); + v0 = ACC_UA_GET_BE32(b + 4); + return ((acc_uint64l_t)v0) | ((acc_uint64l_t)v1 << 32); +#elif (ACC_SIZEOF_LONG >= 8) || (ACC_SIZEOF_SIZE_T >= 8) + const acc_hbyte_p b = (const acc_hbyte_p) p; + return ((acc_uint64l_t)b[7]) | ((acc_uint64l_t)b[6] << 8) | ((acc_uint64l_t)b[5] << 16) | ((acc_uint64l_t)b[4] << 24) | ((acc_uint64l_t)b[3] << 32) | ((acc_uint64l_t)b[2] << 40) | ((acc_uint64l_t)b[1] << 48) | ((acc_uint64l_t)b[0] << 56); +#else + const acc_hbyte_p b = (const acc_hbyte_p) p; + acc_uint32l_t v0, v1; + v1 = ((acc_uint32l_t)b[3]) | ((acc_uint32l_t)b[2] << 8) | ((acc_uint32l_t)b[1] << 16) | ((acc_uint32l_t)b[0] << 24); + b += 4; + v0 = ((acc_uint32l_t)b[3]) | ((acc_uint32l_t)b[2] << 8) | ((acc_uint32l_t)b[1] << 16) | ((acc_uint32l_t)b[0] << 24); + return ((acc_uint64l_t)v0) | ((acc_uint64l_t)v1 << 32); +#endif +} +ACCLIB_PUBLIC(void, acc_ua_set_be64) (acc_hvoid_p p, acc_uint64l_t v) +{ +#if defined(ACC_UA_SET_BE64) + ACC_UA_SET_BE64(p, v); +#elif defined(ACC_UA_SET_BE32) + acc_hbyte_p b = (acc_hbyte_p) p; + ACC_UA_SET_BE32(b + 4, (v >> 0)); + ACC_UA_SET_BE32(b + 0, (v >> 32)); +#elif (ACC_SIZEOF_LONG >= 8) || (ACC_SIZEOF_SIZE_T >= 8) + acc_hbyte_p b = (acc_hbyte_p) p; + b[7] = (unsigned char) ((v >> 0) & 0xff); + b[6] = (unsigned char) ((v >> 8) & 0xff); + b[5] = (unsigned char) ((v >> 16) & 0xff); + b[4] = (unsigned char) ((v >> 24) & 0xff); + b[3] = (unsigned char) ((v >> 32) & 0xff); + b[2] = (unsigned char) ((v >> 40) & 0xff); + b[1] = (unsigned char) ((v >> 48) & 0xff); + b[0] = (unsigned char) ((v >> 56) & 0xff); +#else + acc_hbyte_p b = (acc_hbyte_p) p; + acc_uint32l_t x; + x = (acc_uint32l_t) (v >> 0); + b[7] = (unsigned char) ((x >> 0) & 0xff); + b[6] = (unsigned char) ((x >> 8) & 0xff); + b[5] = (unsigned char) ((x >> 16) & 0xff); + b[4] = (unsigned char) ((x >> 24) & 0xff); + x = (acc_uint32l_t) (v >> 32); + b[3] = (unsigned char) ((x >> 0) & 0xff); + b[2] = (unsigned char) ((x >> 8) & 0xff); + b[1] = (unsigned char) ((x >> 16) & 0xff); + b[0] = (unsigned char) ((x >> 24) & 0xff); +#endif +} +#endif +#if defined(acc_int64l_t) +ACCLIB_PUBLIC(acc_uint64l_t, acc_ua_get_le64) (const acc_hvoid_p p) +{ +#if defined(ACC_UA_GET_LE64) + return ACC_UA_GET_LE64(p); +#elif defined(ACC_UA_GET_LE32) + const acc_hbyte_p b = (const acc_hbyte_p) p; + acc_uint32e_t v0, v1; + v0 = ACC_UA_GET_LE32(b + 0); + v1 = ACC_UA_GET_LE32(b + 4); + return ((acc_uint64l_t)v0) | ((acc_uint64l_t)v1 << 32); +#elif (ACC_SIZEOF_LONG >= 8) || (ACC_SIZEOF_SIZE_T >= 8) + const acc_hbyte_p b = (const acc_hbyte_p) p; + return ((acc_uint64l_t)b[0]) | ((acc_uint64l_t)b[1] << 8) | ((acc_uint64l_t)b[2] << 16) | ((acc_uint64l_t)b[3] << 24) | ((acc_uint64l_t)b[4] << 32) | ((acc_uint64l_t)b[5] << 40) | ((acc_uint64l_t)b[6] << 48) | ((acc_uint64l_t)b[7] << 56); +#else + const acc_hbyte_p b = (const acc_hbyte_p) p; + acc_uint32l_t v0, v1; + v0 = ((acc_uint32l_t)b[0]) | ((acc_uint32l_t)b[1] << 8) | ((acc_uint32l_t)b[2] << 16) | ((acc_uint32l_t)b[3] << 24); + b += 4; + v1 = ((acc_uint32l_t)b[0]) | ((acc_uint32l_t)b[1] << 8) | ((acc_uint32l_t)b[2] << 16) | ((acc_uint32l_t)b[3] << 24); + return ((acc_uint64l_t)v0) | ((acc_uint64l_t)v1 << 32); +#endif +} +ACCLIB_PUBLIC(void, acc_ua_set_le64) (acc_hvoid_p p, acc_uint64l_t v) +{ +#if defined(ACC_UA_SET_LE64) + ACC_UA_SET_LE64(p, v); +#elif defined(ACC_UA_SET_LE32) + acc_hbyte_p b = (acc_hbyte_p) p; + ACC_UA_SET_LE32(b + 0, (v >> 0)); + ACC_UA_SET_LE32(b + 4, (v >> 32)); +#elif (ACC_SIZEOF_LONG >= 8) || (ACC_SIZEOF_SIZE_T >= 8) + acc_hbyte_p b = (acc_hbyte_p) p; + b[0] = (unsigned char) ((v >> 0) & 0xff); + b[1] = (unsigned char) ((v >> 8) & 0xff); + b[2] = (unsigned char) ((v >> 16) & 0xff); + b[3] = (unsigned char) ((v >> 24) & 0xff); + b[4] = (unsigned char) ((v >> 32) & 0xff); + b[5] = (unsigned char) ((v >> 40) & 0xff); + b[6] = (unsigned char) ((v >> 48) & 0xff); + b[7] = (unsigned char) ((v >> 56) & 0xff); +#else + acc_hbyte_p b = (acc_hbyte_p) p; + acc_uint32l_t x; + x = (acc_uint32l_t) (v >> 0); + b[0] = (unsigned char) ((x >> 0) & 0xff); + b[1] = (unsigned char) ((x >> 8) & 0xff); + b[2] = (unsigned char) ((x >> 16) & 0xff); + b[3] = (unsigned char) ((x >> 24) & 0xff); + x = (acc_uint32l_t) (v >> 32); + b[4] = (unsigned char) ((x >> 0) & 0xff); + b[5] = (unsigned char) ((x >> 8) & 0xff); + b[6] = (unsigned char) ((x >> 16) & 0xff); + b[7] = (unsigned char) ((x >> 24) & 0xff); +#endif +} +#endif +#endif +#if defined(ACC_WANT_ACCLIB_VGET) +# undef ACC_WANT_ACCLIB_VGET +#define __ACCLIB_VGET_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +#if !defined(ACCLIB_PUBLIC_NOINLINE) +# if !defined(__acc_noinline) +# define ACCLIB_PUBLIC_NOINLINE(r,f) r __ACCLIB_FUNCNAME(f) +# elif (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x030400ul) || ACC_CC_LLVM) +# define ACCLIB_PUBLIC_NOINLINE(r,f) __acc_noinline __attribute__((__used__)) r __ACCLIB_FUNCNAME(f) +# else +# define ACCLIB_PUBLIC_NOINLINE(r,f) __acc_noinline r __ACCLIB_FUNCNAME(f) +# endif +#endif +#if (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x030400ul) || ACC_CC_LLVM) +extern void* volatile __acc_vget_ptr; +void* volatile __attribute__((__used__)) __acc_vget_ptr = (void *) 0; +#else +extern void* volatile __acc_vget_ptr; +void* volatile __acc_vget_ptr = (void *) 0; +#endif +#ifndef __ACCLIB_VGET_BODY +#define __ACCLIB_VGET_BODY(T) \ + if __acc_unlikely(__acc_vget_ptr) { \ + * (T *) __acc_vget_ptr = v; \ + * (int *) __acc_vget_ptr = expr; \ + v = * (T *) __acc_vget_ptr; \ + } \ + return v; +#endif +ACCLIB_PUBLIC_NOINLINE(short, acc_vget_short) (short v, int expr) +{ + __ACCLIB_VGET_BODY(short) +} +ACCLIB_PUBLIC_NOINLINE(int, acc_vget_int) (int v, int expr) +{ + __ACCLIB_VGET_BODY(int) +} +ACCLIB_PUBLIC_NOINLINE(long, acc_vget_long) (long v, int expr) +{ + __ACCLIB_VGET_BODY(long) +} +#if defined(acc_int64l_t) +ACCLIB_PUBLIC_NOINLINE(acc_int64l_t, acc_vget_acc_int64l_t) (acc_int64l_t v, int expr) +{ + __ACCLIB_VGET_BODY(acc_int64l_t) +} +#endif +ACCLIB_PUBLIC_NOINLINE(acc_hsize_t, acc_vget_acc_hsize_t) (acc_hsize_t v, int expr) +{ + __ACCLIB_VGET_BODY(acc_hsize_t) +} +#if !(ACC_CFG_NO_FLOAT) +ACCLIB_PUBLIC_NOINLINE(float, acc_vget_float) (float v, int expr) +{ + __ACCLIB_VGET_BODY(float) +} +#endif +#if !(ACC_CFG_NO_DOUBLE) +ACCLIB_PUBLIC_NOINLINE(double, acc_vget_double) (double v, int expr) +{ + __ACCLIB_VGET_BODY(double) +} +#endif +ACCLIB_PUBLIC_NOINLINE(acc_hvoid_p, acc_vget_acc_hvoid_p) (acc_hvoid_p v, int expr) +{ + __ACCLIB_VGET_BODY(acc_hvoid_p) +} +#if (ACC_ARCH_I086 && ACC_CC_TURBOC && (__TURBOC__ == 0x0295)) && !defined(__cplusplus) +ACCLIB_PUBLIC_NOINLINE(acc_hvoid_p, acc_vget_acc_hvoid_cp) (const acc_hvoid_p vv, int expr) +{ + acc_hvoid_p v = (acc_hvoid_p) vv; + __ACCLIB_VGET_BODY(acc_hvoid_p) +} +#else +ACCLIB_PUBLIC_NOINLINE(const acc_hvoid_p, acc_vget_acc_hvoid_cp) (const acc_hvoid_p v, int expr) +{ + __ACCLIB_VGET_BODY(const acc_hvoid_p) +} +#endif +#endif +#if defined(ACC_WANT_ACCLIB_HMEMCPY) +# undef ACC_WANT_ACCLIB_HMEMCPY +#define __ACCLIB_HMEMCPY_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +ACCLIB_PUBLIC(int, acc_hmemcmp) (const acc_hvoid_p s1, const acc_hvoid_p s2, acc_hsize_t len) +{ +#if (ACC_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP) + const acc_hbyte_p p1 = (const acc_hbyte_p) s1; + const acc_hbyte_p p2 = (const acc_hbyte_p) s2; + if __acc_likely(len > 0) do + { + int d = *p1 - *p2; + if (d != 0) + return d; + p1++; p2++; + } while __acc_likely(--len > 0); + return 0; +#else + return memcmp(s1, s2, len); +#endif +} +ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len) +{ +#if (ACC_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY) + acc_hbyte_p p1 = (acc_hbyte_p) dest; + const acc_hbyte_p p2 = (const acc_hbyte_p) src; + if (!(len > 0) || p1 == p2) + return dest; + do + *p1++ = *p2++; + while __acc_likely(--len > 0); + return dest; +#else + return memcpy(dest, src, len); +#endif +} +ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len) +{ +#if (ACC_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE) + acc_hbyte_p p1 = (acc_hbyte_p) dest; + const acc_hbyte_p p2 = (const acc_hbyte_p) src; + if (!(len > 0) || p1 == p2) + return dest; + if (p1 < p2) + { + do + *p1++ = *p2++; + while __acc_likely(--len > 0); + } + else + { + p1 += len; + p2 += len; + do + *--p1 = *--p2; + while __acc_likely(--len > 0); + } + return dest; +#else + return memmove(dest, src, len); +#endif +} +ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemset) (acc_hvoid_p s, int c, acc_hsize_t len) +{ +#if (ACC_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET) + acc_hbyte_p p = (acc_hbyte_p) s; + if __acc_likely(len > 0) do + *p++ = (unsigned char) c; + while __acc_likely(--len > 0); + return s; +#else + return memset(s, c, len); +#endif +} +#endif +#if defined(ACC_WANT_ACCLIB_RAND) +# undef ACC_WANT_ACCLIB_RAND +#define __ACCLIB_RAND_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +ACCLIB_PUBLIC(void, acc_srand31) (acc_rand31_p r, acc_uint32l_t seed) +{ + r->seed = seed & ACC_UINT32_C(0xffffffff); +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_rand31) (acc_rand31_p r) +{ + r->seed = r->seed * ACC_UINT32_C(1103515245) + 12345; + r->seed &= ACC_UINT32_C(0x7fffffff); + return r->seed; +} +#if defined(acc_int64l_t) +ACCLIB_PUBLIC(void, acc_srand48) (acc_rand48_p r, acc_uint32l_t seed) +{ + r->seed = seed & ACC_UINT32_C(0xffffffff); + r->seed <<= 16; r->seed |= 0x330e; +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_rand48) (acc_rand48_p r) +{ + r->seed = r->seed * ACC_UINT64_C(25214903917) + 11; + r->seed &= ACC_UINT64_C(0xffffffffffff); + return (acc_uint32l_t) (r->seed >> 17); +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_rand48_r32) (acc_rand48_p r) +{ + r->seed = r->seed * ACC_UINT64_C(25214903917) + 11; + r->seed &= ACC_UINT64_C(0xffffffffffff); + return (acc_uint32l_t) (r->seed >> 16); +} +#endif +#if defined(acc_int64l_t) +ACCLIB_PUBLIC(void, acc_srand64) (acc_rand64_p r, acc_uint64l_t seed) +{ + r->seed = seed & ACC_UINT64_C(0xffffffffffffffff); +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_rand64) (acc_rand64_p r) +{ + r->seed = r->seed * ACC_UINT64_C(6364136223846793005) + 1; +#if (ACC_SIZEOF_ACC_INT64L_T > 8) + r->seed &= ACC_UINT64_C(0xffffffffffffffff); +#endif + return (acc_uint32l_t) (r->seed >> 33); +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_rand64_r32) (acc_rand64_p r) +{ + r->seed = r->seed * ACC_UINT64_C(6364136223846793005) + 1; +#if (ACC_SIZEOF_ACC_INT64L_T > 8) + r->seed &= ACC_UINT64_C(0xffffffffffffffff); +#endif + return (acc_uint32l_t) (r->seed >> 32); +} +#endif +ACCLIB_PUBLIC(void, acc_srandmt) (acc_randmt_p r, acc_uint32l_t seed) +{ + unsigned i = 0; + do { + r->s[i++] = (seed &= ACC_UINT32_C(0xffffffff)); + seed ^= seed >> 30; + seed = seed * ACC_UINT32_C(0x6c078965) + i; + } while (i != 624); + r->n = i; +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_randmt) (acc_randmt_p r) +{ + return (__ACCLIB_FUNCNAME(acc_randmt_r32)(r)) >> 1; +} +ACCLIB_PUBLIC(acc_uint32l_t, acc_randmt_r32) (acc_randmt_p r) +{ + acc_uint32l_t v; + if __acc_unlikely(r->n == 624) { + unsigned i = 0, j; + r->n = 0; + do { + j = i - 623; if ((int) j < 0) j += 624; + v = (r->s[i] & ACC_UINT32_C(0x80000000)) ^ (r->s[j] & ACC_UINT32_C(0x7fffffff)); + j = i - 227; if ((int) j < 0) j += 624; + r->s[i] = r->s[j] ^ (v >> 1); + if (v & 1) r->s[i] ^= ACC_UINT32_C(0x9908b0df); + } while (++i != 624); + } + v = r->s[r->n++]; + v ^= v >> 11; v ^= (v & ACC_UINT32_C(0x013a58ad)) << 7; + v ^= (v & ACC_UINT32_C(0x0001df8c)) << 15; v ^= v >> 18; + return v; +} +#if defined(acc_int64l_t) +ACCLIB_PUBLIC(void, acc_srandmt64) (acc_randmt64_p r, acc_uint64l_t seed) +{ + unsigned i = 0; + do { + r->s[i++] = (seed &= ACC_UINT64_C(0xffffffffffffffff)); + seed ^= seed >> 62; + seed = seed * ACC_UINT64_C(0x5851f42d4c957f2d) + i; + } while (i != 312); + r->n = i; +} +#if 0 +ACCLIB_PUBLIC(acc_uint32l_t, acc_randmt64) (acc_randmt64_p r) +{ + acc_uint64l_t v; + v = (__ACCLIB_FUNCNAME(acc_randmt64_r64)(r)) >> 33; + return (acc_uint32l_t) v; +} +#endif +ACCLIB_PUBLIC(acc_uint64l_t, acc_randmt64_r64) (acc_randmt64_p r) +{ + acc_uint64l_t v; + if __acc_unlikely(r->n == 312) { + unsigned i = 0, j; + r->n = 0; + do { + j = i - 311; if ((int) j < 0) j += 312; + v = (r->s[i] & ACC_UINT64_C(0xffffffff80000000)) ^ (r->s[j] & ACC_UINT64_C(0x7fffffff)); + j = i - 156; if ((int) j < 0) j += 312; + r->s[i] = r->s[j] ^ (v >> 1); + if (v & 1) r->s[i] ^= ACC_UINT64_C(0xb5026f5aa96619e9); + } while (++i != 312); + } + v = r->s[r->n++]; + v ^= (v & ACC_UINT64_C(0xaaaaaaaaa0000000)) >> 29; + v ^= (v & ACC_UINT64_C(0x38eb3ffff6d3)) << 17; + v ^= (v & ACC_UINT64_C(0x7ffbf77)) << 37; + return v ^ (v >> 43); +} +#endif +#endif +#if defined(ACC_WANT_ACCLIB_RDTSC) +# undef ACC_WANT_ACCLIB_RDTSC +#define __ACCLIB_RDTSC_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +#if defined(acc_int32e_t) +#if (ACC_OS_WIN32 && ACC_CC_PELLESC && (__POCC__ >= 290)) +# pragma warn(push) +# pragma warn(disable:2007) +#endif +#if (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC) +#if (ACC_ARCH_AMD64 && ACC_CC_PATHSCALE) +# define __ACCLIB_RDTSC_REGS : : "c" (t) : "cc", "memory", "rax", "rdx" +#elif (ACC_ARCH_AMD64 && ACC_CC_INTELC) +# define __ACCLIB_RDTSC_REGS : : "r" (t) : "memory", "rax", "rdx" +#elif (ACC_ARCH_AMD64) +# define __ACCLIB_RDTSC_REGS : : "r" (t) : "cc", "memory", "rax", "rdx" +#elif (ACC_ARCH_I386 && ACC_CC_GNUC && (ACC_CC_GNUC < 0x020000ul)) +# define __ACCLIB_RDTSC_REGS : : "r" (t) : "ax", "dx" +#elif (ACC_ARCH_I386 && ACC_CC_INTELC) +# define __ACCLIB_RDTSC_REGS : : "r" (t) : "memory", "eax", "edx" +#elif (ACC_ARCH_I386 && ACC_CC_PATHSCALE) +# define __ACCLIB_RDTSC_REGS : : "c" (t) : "memory", "eax", "edx" +#else +# define __ACCLIB_RDTSC_REGS : : "r" (t) : "cc", "memory", "eax", "edx" +#endif +#endif +ACCLIB_PUBLIC(int, acc_tsc_read) (acc_uint32e_t* t) +{ +#if (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC) + __asm__ __volatile__( + "clc \n" ".byte 0x0f,0x31\n" + "movl %%eax,(%0)\n" "movl %%edx,4(%0)\n" + __ACCLIB_RDTSC_REGS + ); + return 0; +#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_MSC) + ACC_UNUSED(t); + __asm { + mov ecx, t + clc +# if (ACC_CC_MSC && (_MSC_VER < 1200)) + _emit 0x0f + _emit 0x31 +# else + rdtsc +# endif + mov [ecx], eax + mov [ecx+4], edx + } + return 0; +#else + t[0] = t[1] = 0; return -1; +#endif +} +#if (ACC_OS_WIN32 && ACC_CC_PELLESC && (__POCC__ >= 290)) +# pragma warn(pop) +#endif +#endif +#endif +#if defined(ACC_WANT_ACCLIB_DOSALLOC) +# undef ACC_WANT_ACCLIB_DOSALLOC +#define __ACCLIB_DOSALLOC_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +#if (ACC_OS_OS216) +ACC_EXTERN_C unsigned short __far __pascal DosAllocHuge(unsigned short, unsigned short, unsigned short __far *, unsigned short, unsigned short); +ACC_EXTERN_C unsigned short __far __pascal DosFreeSeg(unsigned short); +#endif +#if (ACC_OS_DOS16 || ACC_OS_WIN16) +#if !(ACC_CC_AZTECC) +ACCLIB_PUBLIC(void __far*, acc_dos_alloc) (unsigned long size) +{ + void __far* p = 0; + union REGS ri, ro; + if ((long)size <= 0) + return p; + size = (size + 15) >> 4; + if (size > 0xffffu) + return p; + ri.x.ax = 0x4800; + ri.x.bx = (unsigned short) size; + int86(0x21, &ri, &ro); + if ((ro.x.cflag & 1) == 0) + p = (void __far*) ACC_PTR_MK_FP(ro.x.ax, 0); + return p; +} +ACCLIB_PUBLIC(int, acc_dos_free) (void __far* p) +{ + union REGS ri, ro; + struct SREGS rs; + if (!p) + return 0; + if (ACC_PTR_FP_OFF(p) != 0) + return -1; + segread(&rs); + ri.x.ax = 0x4900; + rs.es = ACC_PTR_FP_SEG(p); + int86x(0x21, &ri, &ro, &rs); + if (ro.x.cflag & 1) + return -1; + return 0; +} +#endif +#endif +#if (ACC_OS_OS216) +ACCLIB_PUBLIC(void __far*, acc_dos_alloc) (unsigned long size) +{ + void __far* p = 0; + unsigned short sel = 0; + if ((long)size <= 0) + return p; + if (DosAllocHuge((unsigned short)(size >> 16), (unsigned short)size, &sel, 0, 0) == 0) + p = (void __far*) ACC_PTR_MK_FP(sel, 0); + return p; +} +ACCLIB_PUBLIC(int, acc_dos_free) (void __far* p) +{ + if (!p) + return 0; + if (ACC_PTR_FP_OFF(p) != 0) + return -1; + if (DosFreeSeg(ACC_PTR_FP_SEG(p)) != 0) + return -1; + return 0; +} +#endif +#endif +#if defined(ACC_WANT_ACCLIB_GETOPT) +# undef ACC_WANT_ACCLIB_GETOPT +#define __ACCLIB_GETOPT_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +ACCLIB_PUBLIC(void, acc_getopt_init) (acc_getopt_p g, + int start_argc, int argc, char** argv) +{ + memset(g, 0, sizeof(*g)); + g->optind = start_argc; + g->argc = argc; g->argv = argv; + g->optopt = -1; +} +static int __ACCLIB_FUNCNAME(acc_getopt_rotate) (char** p, int first, int middle, int last) +{ + int i = middle, n = middle - first; + if (first >= middle || middle >= last) return 0; + for (;;) + { + char* t = p[first]; p[first] = p[i]; p[i] = t; + if (++first == middle) + { + if (++i == last) break; + middle = i; + } + else if (++i == last) + i = middle; + } + return n; +} +static int __ACCLIB_FUNCNAME(acc_getopt_perror) (acc_getopt_p g, int ret, const char* f, ...) +{ + if (g->opterr) + { +#if (HAVE_STDARG_H) + struct { va_list ap; } s; + va_start(s.ap, f); + g->opterr(g, f, &s); + va_end(s.ap); +#else + g->opterr(g, f, NULL); +#endif + } + ++g->errcount; + return ret; +} +ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g, + const char* shortopts, + const acc_getopt_longopt_p longopts, + int* longind) +{ +#define pe __ACCLIB_FUNCNAME(acc_getopt_perror) + int ordering = ACC_GETOPT_PERMUTE; + int missing_arg_ret = g->bad_option; + char* a; + if (shortopts) + { + if (*shortopts == '-' || *shortopts == '+') + ordering = *shortopts++ == '-' ? ACC_GETOPT_RETURN_IN_ORDER : ACC_GETOPT_REQUIRE_ORDER; + if (*shortopts == ':') + missing_arg_ret = *shortopts++; + } + g->optarg = NULL; + if (g->optopt == -1) + g->optopt = g->bad_option; + if (longind) + *longind = -1; + if (g->eof) + return -1; + if (g->shortpos) + goto acc_label_next_shortopt; + g->optind -= __ACCLIB_FUNCNAME(acc_getopt_rotate)(g->argv, g->pending_rotate_first, g->pending_rotate_middle, g->optind); + g->pending_rotate_first = g->pending_rotate_middle = g->optind; + if (ordering == ACC_GETOPT_PERMUTE) + { + while (g->optind < g->argc && !(g->argv[g->optind][0] == '-' && g->argv[g->optind][1])) + ++g->optind; + g->pending_rotate_middle = g->optind; + } + if (g->optind >= g->argc) + { + g->optind = g->pending_rotate_first; + goto acc_label_eof; + } + a = g->argv[g->optind]; + if (a[0] == '-' && a[1] == '-') + { + size_t l = 0; + const acc_getopt_longopt_p o; + const acc_getopt_longopt_p o1 = NULL; + const acc_getopt_longopt_p o2 = NULL; + int need_exact = 0; + ++g->optind; + if (!a[2]) + goto acc_label_eof; + for (a += 2; a[l] && a[l] != '=' && a[l] != '#'; ) + ++l; + for (o = longopts; l && o && o->name; ++o) + { + if (strncmp(a, o->name, l) != 0) + continue; + if (!o->name[l]) + goto acc_label_found_o; + need_exact |= o->has_arg & ACC_GETOPT_EXACT_ARG; + if (o1) o2 = o; + else o1 = o; + } + if (!o1 || need_exact) + return pe(g, g->bad_option, "unrecognized option '--%s'", a); + if (o2) + return pe(g, g->bad_option, "option '--%s' is ambiguous (could be '--%s' or '--%s')", a, o1->name, o2->name); + o = o1; + acc_label_found_o: + a += l; + switch (o->has_arg & 0x2f) + { + case ACC_GETOPT_OPTIONAL_ARG: + if (a[0]) + g->optarg = a + 1; + break; + case ACC_GETOPT_REQUIRED_ARG: + if (a[0]) + g->optarg = a + 1; + else if (g->optind < g->argc) + g->optarg = g->argv[g->optind++]; + if (!g->optarg) + return pe(g, missing_arg_ret, "option '--%s' requires an argument", o->name); + break; + case ACC_GETOPT_REQUIRED_ARG | 0x20: + if (a[0] && a[1]) + g->optarg = a + 1; + if (!g->optarg) + return pe(g, missing_arg_ret, "option '--%s=' requires an argument", o->name); + break; + default: + if (a[0]) + return pe(g, g->bad_option, "option '--%s' doesn't allow an argument", o->name); + break; + } + if (longind) + *longind = (int) (o - longopts); + if (o->flag) + { + *o->flag = o->val; + return 0; + } + return o->val; + } + if (a[0] == '-' && a[1]) + { + unsigned char c; + const char* s; + acc_label_next_shortopt: + a = g->argv[g->optind] + ++g->shortpos; + c = (unsigned char) *a++; s = NULL; + if (c != ':' && shortopts) + s = strchr(shortopts, c); + if (!s || s[1] != ':') + { + if (!a[0]) + ++g->optind, g->shortpos = 0; + if (!s) + { + g->optopt = c; + return pe(g, g->bad_option, "invalid option '-%c'", c); + } + } + else + { + ++g->optind, g->shortpos = 0; + if (a[0]) + g->optarg = a; + else if (s[2] != ':') + { + if (g->optind < g->argc) + g->optarg = g->argv[g->optind++]; + else + { + g->optopt = c; + return pe(g, missing_arg_ret, "option '-%c' requires an argument", c); + } + } + } + return c; + } + if (ordering == ACC_GETOPT_RETURN_IN_ORDER) + { + ++g->optind; + g->optarg = a; + return 1; + } +acc_label_eof: + g->optind -= __ACCLIB_FUNCNAME(acc_getopt_rotate)(g->argv, g->pending_rotate_first, g->pending_rotate_middle, g->optind); + g->pending_rotate_first = g->pending_rotate_middle = g->optind; + g->eof = 1; + return -1; +#undef pe +} +#endif +#if defined(ACC_WANT_ACCLIB_HALLOC) +# undef ACC_WANT_ACCLIB_HALLOC +#define __ACCLIB_HALLOC_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +#if (ACC_HAVE_MM_HUGE_PTR) +#if 1 && (ACC_OS_DOS16 && defined(BLX286)) +# define __ACCLIB_HALLOC_USE_DAH 1 +#elif 1 && (ACC_OS_DOS16 && defined(DOSX286)) +# define __ACCLIB_HALLOC_USE_DAH 1 +#elif 1 && (ACC_OS_OS216) +# define __ACCLIB_HALLOC_USE_DAH 1 +#elif 1 && (ACC_OS_WIN16) +# define __ACCLIB_HALLOC_USE_GA 1 +#elif 1 && (ACC_OS_DOS16) && (ACC_CC_BORLANDC) && defined(__DPMI16__) +# define __ACCLIB_HALLOC_USE_GA 1 +#endif +#endif +#if (__ACCLIB_HALLOC_USE_DAH) +#if 0 && (ACC_OS_OS216) +#include <os2.h> +#else +ACC_EXTERN_C unsigned short __far __pascal DosAllocHuge(unsigned short, unsigned short, unsigned short __far *, unsigned short, unsigned short); +ACC_EXTERN_C unsigned short __far __pascal DosFreeSeg(unsigned short); +#endif +#endif +#if (__ACCLIB_HALLOC_USE_GA) +#if 0 +#define STRICT 1 +#include <windows.h> +#else +ACC_EXTERN_C const void __near* __far __pascal GlobalAlloc(unsigned, unsigned long); +ACC_EXTERN_C const void __near* __far __pascal GlobalFree(const void __near*); +ACC_EXTERN_C unsigned long __far __pascal GlobalHandle(unsigned); +ACC_EXTERN_C void __far* __far __pascal GlobalLock(const void __near*); +ACC_EXTERN_C int __far __pascal GlobalUnlock(const void __near*); +#endif +#endif +ACCLIB_PUBLIC(acc_hvoid_p, acc_halloc) (acc_hsize_t size) +{ + acc_hvoid_p p = 0; + if (!(size > 0)) + return p; +#if 0 && defined(__palmos__) + p = MemPtrNew(size); +#elif !(ACC_HAVE_MM_HUGE_PTR) + if (size < (size_t) -1) + p = malloc((size_t) size); +#else + if ((long)size <= 0) + return p; +{ +#if (__ACCLIB_HALLOC_USE_DAH) + unsigned short sel = 0; + if (DosAllocHuge((unsigned short)(size >> 16), (unsigned short)size, &sel, 0, 0) == 0) + p = (acc_hvoid_p) ACC_PTR_MK_FP(sel, 0); +#elif (__ACCLIB_HALLOC_USE_GA) + const void __near* h = GlobalAlloc(2, size); + if (h) { + p = GlobalLock(h); + if (p && ACC_PTR_FP_OFF(p) != 0) { + GlobalUnlock(h); + p = 0; + } + if (!p) + GlobalFree(h); + } +#elif (ACC_CC_MSC && (_MSC_VER >= 700)) + p = _halloc(size, 1); +#elif (ACC_CC_MSC || ACC_CC_WATCOMC) + p = halloc(size, 1); +#elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) + p = farmalloc(size); +#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) + p = farmalloc(size); +#elif (ACC_CC_AZTECC) + p = lmalloc(size); +#else + if (size < (size_t) -1) + p = malloc((size_t) size); +#endif +} +#endif + return p; +} +ACCLIB_PUBLIC(void, acc_hfree) (acc_hvoid_p p) +{ + if (!p) + return; +#if 0 && defined(__palmos__) + MemPtrFree(p); +#elif !(ACC_HAVE_MM_HUGE_PTR) + free(p); +#else +#if (__ACCLIB_HALLOC_USE_DAH) + if (ACC_PTR_FP_OFF(p) == 0) + DosFreeSeg((unsigned short) ACC_PTR_FP_SEG(p)); +#elif (__ACCLIB_HALLOC_USE_GA) + if (ACC_PTR_FP_OFF(p) == 0) { + const void __near* h = (const void __near*) (unsigned) GlobalHandle(ACC_PTR_FP_SEG(p)); + if (h) { + GlobalUnlock(h); + GlobalFree(h); + } + } +#elif (ACC_CC_MSC && (_MSC_VER >= 700)) + _hfree(p); +#elif (ACC_CC_MSC || ACC_CC_WATCOMC) + hfree(p); +#elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) + farfree((void __far*) p); +#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) + farfree((void __far*) p); +#elif (ACC_CC_AZTECC) + lfree(p); +#else + free(p); +#endif +#endif +} +#endif +#if defined(ACC_WANT_ACCLIB_HFREAD) +# undef ACC_WANT_ACCLIB_HFREAD +#define __ACCLIB_HFREAD_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +ACCLIB_PUBLIC(acc_hsize_t, acc_hfread) (void* vfp, acc_hvoid_p buf, acc_hsize_t size) +{ + FILE* fp = (FILE *) vfp; +#if (ACC_HAVE_MM_HUGE_PTR) +#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM) +#define __ACCLIB_REQUIRE_HMEMCPY_CH 1 + unsigned char tmp[512]; + acc_hsize_t l = 0; + while (l < size) + { + size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l); + n = fread(tmp, 1, n, fp); + if (n == 0) + break; + __ACCLIB_FUNCNAME(acc_hmemcpy)((acc_hbyte_p)buf + l, tmp, (acc_hsize_t)n); + l += n; + } + return l; +#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE) + acc_hbyte_p b = (acc_hbyte_p) buf; + acc_hsize_t l = 0; + while (l < size) + { + size_t n; + n = ACC_PTR_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n); + if ((acc_hsize_t) n > size - l) + n = (size_t) (size - l); + n = fread((void __far*)b, 1, n, fp); + if (n == 0) + break; + b += n; l += n; + } + return l; +#else +# error "unknown memory model" +#endif +#else + return fread(buf, 1, size, fp); +#endif +} +ACCLIB_PUBLIC(acc_hsize_t, acc_hfwrite) (void* vfp, const acc_hvoid_p buf, acc_hsize_t size) +{ + FILE* fp = (FILE *) vfp; +#if (ACC_HAVE_MM_HUGE_PTR) +#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM) +#define __ACCLIB_REQUIRE_HMEMCPY_CH 1 + unsigned char tmp[512]; + acc_hsize_t l = 0; + while (l < size) + { + size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l); + __ACCLIB_FUNCNAME(acc_hmemcpy)(tmp, (const acc_hbyte_p)buf + l, (acc_hsize_t)n); + n = fwrite(tmp, 1, n, fp); + if (n == 0) + break; + l += n; + } + return l; +#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE) + const acc_hbyte_p b = (const acc_hbyte_p) buf; + acc_hsize_t l = 0; + while (l < size) + { + size_t n; + n = ACC_PTR_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n); + if ((acc_hsize_t) n > size - l) + n = (size_t) (size - l); + n = fwrite((void __far*)b, 1, n, fp); + if (n == 0) + break; + b += n; l += n; + } + return l; +#else +# error "unknown memory model" +#endif +#else + return fwrite(buf, 1, size, fp); +#endif +} +#endif +#if defined(ACC_WANT_ACCLIB_HSREAD) +# undef ACC_WANT_ACCLIB_HSREAD +#define __ACCLIB_HSREAD_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +ACCLIB_PUBLIC(long, acc_safe_hread) (int fd, acc_hvoid_p buf, long size) +{ + acc_hbyte_p b = (acc_hbyte_p) buf; + long l = 0; + int saved_errno; + saved_errno = errno; + while (l < size) + { + long n = size - l; +#if (ACC_HAVE_MM_HUGE_PTR) +# define __ACCLIB_REQUIRE_HREAD_CH 1 + errno = 0; n = acc_hread(fd, b, n); +#elif (ACC_OS_DOS32) && defined(__DJGPP__) + errno = 0; n = _read(fd, b, n); +#else + errno = 0; n = read(fd, b, n); +#endif + if (n == 0) + break; + if (n < 0) { +#if defined(EAGAIN) + if (errno == (EAGAIN)) continue; +#endif +#if defined(EINTR) + if (errno == (EINTR)) continue; +#endif + if (errno == 0) errno = 1; + return l; + } + b += n; l += n; + } + errno = saved_errno; + return l; +} +ACCLIB_PUBLIC(long, acc_safe_hwrite) (int fd, const acc_hvoid_p buf, long size) +{ + const acc_hbyte_p b = (const acc_hbyte_p) buf; + long l = 0; + int saved_errno; + saved_errno = errno; + while (l < size) + { + long n = size - l; +#if (ACC_HAVE_MM_HUGE_PTR) +# define __ACCLIB_REQUIRE_HREAD_CH 1 + errno = 0; n = acc_hwrite(fd, b, n); +#elif (ACC_OS_DOS32) && defined(__DJGPP__) + errno = 0; n = _write(fd, b, n); +#else + errno = 0; n = write(fd, b, n); +#endif + if (n == 0) + break; + if (n < 0) { +#if defined(EAGAIN) + if (errno == (EAGAIN)) continue; +#endif +#if defined(EINTR) + if (errno == (EINTR)) continue; +#endif + if (errno == 0) errno = 1; + return l; + } + b += n; l += n; + } + errno = saved_errno; + return l; +} +#endif +#if defined(ACC_WANT_ACCLIB_PCLOCK) +# undef ACC_WANT_ACCLIB_PCLOCK +#define __ACCLIB_PCLOCK_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +#if 0 && (ACC_OS_POSIX_LINUX && ACC_ARCH_AMD64 && ACC_ASM_SYNTAX_GNUC) +#ifndef acc_pclock_syscall_clock_gettime +#define acc_pclock_syscall_clock_gettime acc_pclock_syscall_clock_gettime +#endif +static __acc_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct timespec *ts) +{ + long r; + __asm__ __volatile__("syscall\n" : "=a" (r) : "0" (228), "D" (clockid), "S" (ts) : __ACC_ASM_CLOBBER); + return r; +} +#endif +#if 0 && (ACC_OS_POSIX_LINUX && ACC_ARCH_I386 && ACC_ASM_SYNTAX_GNUC) +#ifndef acc_pclock_syscall_clock_gettime +#define acc_pclock_syscall_clock_gettime acc_pclock_syscall_clock_gettime +#endif +static __acc_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct timespec *ts) +{ + long r; + __asm__ __volatile__("int $0x80\n" : "=a" (r) : "0" (265), "b" (clockid), "c" (ts) : __ACC_ASM_CLOBBER); + return r; +} +#endif +#if 0 && defined(acc_pclock_syscall_clock_gettime) +#ifndef acc_pclock_read_clock_gettime_r_syscall +#define acc_pclock_read_clock_gettime_r_syscall acc_pclock_read_clock_gettime_r_syscall +#endif +static int acc_pclock_read_clock_gettime_r_syscall(acc_pclock_handle_p h, acc_pclock_p c) +{ + struct timespec ts; + if (acc_pclock_syscall_clock_gettime(0, &ts) != 0) + return -1; + c->tv_sec = ts.tv_sec; + c->tv_nsec = ts.tv_nsec; + ACC_UNUSED(h); return 0; +} +#endif +#if (HAVE_GETTIMEOFDAY) +#ifndef acc_pclock_read_gettimeofday +#define acc_pclock_read_gettimeofday acc_pclock_read_gettimeofday +#endif +static int acc_pclock_read_gettimeofday(acc_pclock_handle_p h, acc_pclock_p c) +{ + struct timeval tv; + if (gettimeofday(&tv, 0) != 0) + return -1; +#if defined(acc_int64l_t) + c->tv_sec = tv.tv_sec; +#else + c->tv_sec_high = 0; + c->tv_sec_low = tv.tv_sec; +#endif + c->tv_nsec = (acc_uint32l_t) (tv.tv_usec * 1000u); + ACC_UNUSED(h); return 0; +} +#endif +#if defined(CLOCKS_PER_SEC) +#ifndef acc_pclock_read_clock +#define acc_pclock_read_clock acc_pclock_read_clock +#endif +static int acc_pclock_read_clock(acc_pclock_handle_p h, acc_pclock_p c) +{ + clock_t ticks; + double secs; +#if defined(acc_int64l_t) + acc_uint64l_t nsecs; + ticks = clock(); + secs = (double)ticks / (CLOCKS_PER_SEC); + nsecs = (acc_uint64l_t) (secs * 1000000000.0); + c->tv_sec = (acc_int64l_t) (nsecs / 1000000000ul); + c->tv_nsec = (acc_uint32l_t) (nsecs % 1000000000ul); +#else + ticks = clock(); + secs = (double)ticks / (CLOCKS_PER_SEC); + c->tv_sec_high = 0; + c->tv_sec_low = (acc_uint32l_t) (secs + 0.5); + c->tv_nsec = 0; +#endif + ACC_UNUSED(h); return 0; +} +#endif +#if 1 && defined(acc_pclock_syscall_clock_gettime) +#ifndef acc_pclock_read_clock_gettime_m_syscall +#define acc_pclock_read_clock_gettime_m_syscall acc_pclock_read_clock_gettime_m_syscall +#endif +static int acc_pclock_read_clock_gettime_m_syscall(acc_pclock_handle_p h, acc_pclock_p c) +{ + struct timespec ts; + if (acc_pclock_syscall_clock_gettime(1, &ts) != 0) + return -1; + c->tv_sec = ts.tv_sec; + c->tv_nsec = ts.tv_nsec; + ACC_UNUSED(h); return 0; +} +#endif +#if (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) && defined(UCLOCKS_PER_SEC) +#ifndef acc_pclock_read_uclock +#define acc_pclock_read_uclock acc_pclock_read_uclock +#endif +static int acc_pclock_read_uclock(acc_pclock_handle_p h, acc_pclock_p c) +{ + acc_uint64l_t ticks; + double secs; + acc_uint64l_t nsecs; + ticks = uclock(); + secs = (double)ticks / (UCLOCKS_PER_SEC); + nsecs = (acc_uint64l_t) (secs * 1000000000.0); + c->tv_sec = nsecs / 1000000000ul; + c->tv_nsec = (acc_uint32l_t) (nsecs % 1000000000ul); + ACC_UNUSED(h); return 0; +} +#endif +#if 0 && (HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID) && defined(acc_int64l_t) +#ifndef acc_pclock_read_clock_gettime_p_libc +#define acc_pclock_read_clock_gettime_p_libc acc_pclock_read_clock_gettime_p_libc +#endif +static int acc_pclock_read_clock_gettime_p_libc(acc_pclock_handle_p h, acc_pclock_p c) +{ + struct timespec ts; + if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) != 0) + return -1; + c->tv_sec = ts.tv_sec; + c->tv_nsec = ts.tv_nsec; + ACC_UNUSED(h); return 0; +} +#endif +#if 1 && defined(acc_pclock_syscall_clock_gettime) +#ifndef acc_pclock_read_clock_gettime_p_syscall +#define acc_pclock_read_clock_gettime_p_syscall acc_pclock_read_clock_gettime_p_syscall +#endif +static int acc_pclock_read_clock_gettime_p_syscall(acc_pclock_handle_p h, acc_pclock_p c) +{ + struct timespec ts; + if (acc_pclock_syscall_clock_gettime(2, &ts) != 0) + return -1; + c->tv_sec = ts.tv_sec; + c->tv_nsec = ts.tv_nsec; + ACC_UNUSED(h); return 0; +} +#endif +#if (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64) && (ACC_HAVE_WINDOWS_H) && defined(acc_int64l_t) +#ifndef acc_pclock_read_getprocesstimes +#define acc_pclock_read_getprocesstimes acc_pclock_read_getprocesstimes +#endif +static int acc_pclock_read_getprocesstimes(acc_pclock_handle_p h, acc_pclock_p c) +{ + FILETIME ct, et, kt, ut; + acc_uint64l_t ticks; + if (GetProcessTimes(GetCurrentProcess(), &ct, &et, &kt, &ut) == 0) + return -1; + ticks = ((acc_uint64l_t)ut.dwHighDateTime << 32) | ut.dwLowDateTime; + if __acc_unlikely(h->ticks_base == 0) + h->ticks_base = ticks; + else + ticks -= h->ticks_base; + c->tv_sec = (acc_int64l_t) (ticks / 10000000ul); + c->tv_nsec = (acc_uint32l_t)(ticks % 10000000ul) * 100u; + ACC_UNUSED(h); return 0; +} +#endif +#if (HAVE_GETRUSAGE) && defined(RUSAGE_SELF) +#ifndef acc_pclock_read_getrusage +#define acc_pclock_read_getrusage acc_pclock_read_getrusage +#endif +static int acc_pclock_read_getrusage(acc_pclock_handle_p h, acc_pclock_p c) +{ + struct rusage ru; + if (getrusage(RUSAGE_SELF, &ru) != 0) + return -1; +#if defined(acc_int64l_t) + c->tv_sec = ru.ru_utime.tv_sec; +#else + c->tv_sec_high = 0; + c->tv_sec_low = ru.ru_utime.tv_sec; +#endif + c->tv_nsec = (acc_uint32l_t) (ru.ru_utime.tv_usec * 1000u); + ACC_UNUSED(h); return 0; +} +#endif +#if (__ACCLIB_PCLOCK_USE_PERFCTR) +#ifndef acc_pclock_read_perfctr +#define acc_pclock_read_perfctr acc_pclock_read_perfctr +#endif +static int acc_pclock_read_perfctr(acc_pclock_handle_p h, acc_pclock_p c) +{ + acc_perfctr_clock_t pcc; + double secs; + acc_uint64l_t nsecs; + __ACCLIB_FUNCNAME(acc_perfctr_read)(&h->pch, &pcc); + if __acc_unlikely(h->ticks_base == 0) + h->ticks_base = pcc.tsc; + else + pcc.tsc -= h->ticks_base; + secs = pcc.tsc * h->pch.tsc_to_seconds; + nsecs = (acc_uint64l_t) (secs * 1000000000.0); + c->tv_sec = nsecs / 1000000000ul; + c->tv_nsec = (acc_uint32l_t) (nsecs % 1000000000ul); + ACC_UNUSED(h); return 0; +} +#endif +#if 0 && (HAVE_CLOCK_GETTIME) && defined(CLOCK_THREAD_CPUTIME_ID) && defined(acc_int64l_t) +#ifndef acc_pclock_read_clock_gettime_t_libc +#define acc_pclock_read_clock_gettime_t_libc acc_pclock_read_clock_gettime_t_libc +#endif +static int acc_pclock_read_clock_gettime_t_libc(acc_pclock_handle_p h, acc_pclock_p c) +{ + struct timespec ts; + if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0) + return -1; + c->tv_sec = ts.tv_sec; + c->tv_nsec = ts.tv_nsec; + ACC_UNUSED(h); return 0; +} +#endif +#if 1 && defined(acc_pclock_syscall_clock_gettime) +#ifndef acc_pclock_read_clock_gettime_t_syscall +#define acc_pclock_read_clock_gettime_t_syscall acc_pclock_read_clock_gettime_t_syscall +#endif +static int acc_pclock_read_clock_gettime_t_syscall(acc_pclock_handle_p h, acc_pclock_p c) +{ + struct timespec ts; + if (acc_pclock_syscall_clock_gettime(3, &ts) != 0) + return -1; + c->tv_sec = ts.tv_sec; + c->tv_nsec = ts.tv_nsec; + ACC_UNUSED(h); return 0; +} +#endif +#if (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64) && (ACC_HAVE_WINDOWS_H) && defined(acc_int64l_t) +#ifndef acc_pclock_read_getthreadtimes +#define acc_pclock_read_getthreadtimes acc_pclock_read_getthreadtimes +#endif +static int acc_pclock_read_getthreadtimes(acc_pclock_handle_p h, acc_pclock_p c) +{ + FILETIME ct, et, kt, ut; + acc_uint64l_t ticks; + if (GetThreadTimes(GetCurrentThread(), &ct, &et, &kt, &ut) == 0) + return -1; + ticks = ((acc_uint64l_t)ut.dwHighDateTime << 32) | ut.dwLowDateTime; + if __acc_unlikely(h->ticks_base == 0) + h->ticks_base = ticks; + else + ticks -= h->ticks_base; + c->tv_sec = (acc_int64l_t) (ticks / 10000000ul); + c->tv_nsec = (acc_uint32l_t)(ticks % 10000000ul) * 100; + ACC_UNUSED(h); return 0; +} +#endif +ACCLIB_PUBLIC(int, acc_pclock_open) (acc_pclock_handle_p h, int mode) +{ + acc_pclock_t c; + int i; + h->h = (acclib_handle_t) 0; + h->mode = -1; + h->read_error = 2; + h->name = NULL; + h->gettime = 0; +#if defined(acc_int64l_t) + h->ticks_base = 0; +#endif + switch (mode) + { + case ACC_PCLOCK_REALTIME: +# if defined(acc_pclock_read_clock_gettime_r_syscall) + if (acc_pclock_read_clock_gettime_r_syscall(h, &c) == 0) { + h->gettime = acc_pclock_read_clock_gettime_r_syscall; + h->name = "CLOCK_REALTIME/syscall"; + break; + } +# endif +# if defined(acc_pclock_read_gettimeofday) + if (acc_pclock_read_gettimeofday(h, &c) == 0) { + h->gettime = acc_pclock_read_gettimeofday; + h->name = "gettimeofday"; + break; + } +# endif + break; + case ACC_PCLOCK_MONOTONIC: +# if defined(acc_pclock_read_clock_gettime_m_syscall) + if (acc_pclock_read_clock_gettime_m_syscall(h, &c) == 0) { + h->gettime = acc_pclock_read_clock_gettime_m_syscall; + h->name = "CLOCK_MONOTONIC/syscall"; + break; + } +# endif +# if defined(acc_pclock_read_uclock) + if (acc_pclock_read_uclock(h, &c) == 0) { + h->gettime = acc_pclock_read_uclock; + h->name = "uclock"; + break; + } +# endif +# if defined(acc_pclock_read_clock) + if (acc_pclock_read_clock(h, &c) == 0) { + h->gettime = acc_pclock_read_clock; + h->name = "clock"; + break; + } +# endif + break; + case ACC_PCLOCK_PROCESS_CPUTIME_ID: +# if defined(acc_pclock_read_perfctr) + if (__ACCLIB_FUNCNAME(acc_perfctr_open)(&h->pch) == 0) { + h->gettime = acc_pclock_read_perfctr; + h->name = "perfctr"; + break; + } +# endif +# if defined(acc_pclock_read_getprocesstimes) + if (acc_pclock_read_getprocesstimes(h, &c) == 0) { + h->gettime = acc_pclock_read_getprocesstimes; + h->name = "GetProcessTimes"; + break; + } +# endif +# if defined(acc_pclock_read_clock_gettime_p_syscall) + if (acc_pclock_read_clock_gettime_p_syscall(h, &c) == 0) { + h->gettime = acc_pclock_read_clock_gettime_p_syscall; + h->name = "CLOCK_PROCESS_CPUTIME_ID/syscall"; + break; + } +# endif +# if defined(acc_pclock_read_clock_gettime_p_libc) + if (acc_pclock_read_clock_gettime_p_libc(h, &c) == 0) { + h->gettime = acc_pclock_read_clock_gettime_p_libc; + h->name = "CLOCK_PROCESS_CPUTIME_ID/libc"; + break; + } +# endif +# if defined(acc_pclock_read_getrusage) + if (acc_pclock_read_getrusage(h, &c) == 0) { + h->gettime = acc_pclock_read_getrusage; + h->name = "getrusage"; + break; + } +# endif + break; + case ACC_PCLOCK_THREAD_CPUTIME_ID: +# if defined(acc_pclock_read_getthreadtimes) + if (acc_pclock_read_getthreadtimes(h, &c) == 0) { + h->gettime = acc_pclock_read_getthreadtimes; + h->name = "GetThreadTimes"; + } +# endif +# if defined(acc_pclock_read_clock_gettime_t_syscall) + if (acc_pclock_read_clock_gettime_t_syscall(h, &c) == 0) { + h->gettime = acc_pclock_read_clock_gettime_t_syscall; + h->name = "CLOCK_THREAD_CPUTIME_ID/syscall"; + break; + } +# endif +# if defined(acc_pclock_read_clock_gettime_t_libc) + if (acc_pclock_read_clock_gettime_t_libc(h, &c) == 0) { + h->gettime = acc_pclock_read_clock_gettime_t_libc; + h->name = "CLOCK_THREAD_CPUTIME_ID/libc"; + break; + } +# endif + break; + } + if (!h->gettime) + return -1; + if (!h->h) + h->h = (acclib_handle_t) 1; + h->mode = mode; + h->read_error = 0; + if (!h->name) + h->name = "unknown"; + for (i = 0; i < 10; i++) { + __ACCLIB_FUNCNAME(acc_pclock_read)(h, &c); + } + return 0; +} +ACCLIB_PUBLIC(int, acc_pclock_open_default) (acc_pclock_handle_p h) +{ + if (__ACCLIB_FUNCNAME(acc_pclock_open)(h, ACC_PCLOCK_PROCESS_CPUTIME_ID) == 0) + return 0; + if (__ACCLIB_FUNCNAME(acc_pclock_open)(h, ACC_PCLOCK_MONOTONIC) == 0) + return 0; + if (__ACCLIB_FUNCNAME(acc_pclock_open)(h, ACC_PCLOCK_REALTIME) == 0) + return 0; + if (__ACCLIB_FUNCNAME(acc_pclock_open)(h, ACC_PCLOCK_THREAD_CPUTIME_ID) == 0) + return 0; + return -1; +} +ACCLIB_PUBLIC(int, acc_pclock_close) (acc_pclock_handle_p h) +{ + h->h = (acclib_handle_t) 0; + h->mode = -1; + h->name = NULL; + h->gettime = 0; +#if (__ACCLIB_PCLOCK_USE_PERFCTR) + __ACCLIB_FUNCNAME(acc_perfctr_close)(&h->pch); +#endif + return 0; +} +ACCLIB_PUBLIC(void, acc_pclock_read) (acc_pclock_handle_p h, acc_pclock_p c) +{ + if (h->gettime) { + if (h->gettime(h, c) == 0) + return; + } + h->read_error = 1; +#if defined(acc_int64l_t) + c->tv_sec = 0; +#else + c->tv_sec_high = 0; + c->tv_sec_low = 0; +#endif + c->tv_nsec = 0; +} +#if !(ACC_CFG_NO_DOUBLE) +ACCLIB_PUBLIC(double, acc_pclock_get_elapsed) (acc_pclock_handle_p h, const acc_pclock_p start, const acc_pclock_p stop) +{ + double tstop, tstart; + if (!h->h) { + h->mode = -1; + return 0.0; + } +#if defined(acc_int64l_t) + tstop = stop->tv_sec + stop->tv_nsec / 1000000000.0; + tstart = start->tv_sec + start->tv_nsec / 1000000000.0; +#else + tstop = stop->tv_sec_low + stop->tv_nsec / 1000000000.0; + tstart = start->tv_sec_low + start->tv_nsec / 1000000000.0; +#endif + return tstop - tstart; +} +#endif +ACCLIB_PUBLIC(int, acc_pclock_flush_cpu_cache) (acc_pclock_handle_p h, unsigned flags) +{ + if (h->h) { +#if (__ACCLIB_PCLOCK_USE_PERFCTR) + return __ACCLIB_FUNCNAME(acc_perfctr_flush_cpu_cache)(&h->pch, flags); +#endif + } + ACC_UNUSED(h); ACC_UNUSED(flags); + return -1; +} +#if defined(__ACCLIB_PCLOCK_NEED_WARN_POP) +# if (ACC_CC_MSC && (_MSC_VER >= 1200)) +# pragma warning(pop) +# else +# error "__ACCLIB_PCLOCK_NEED_WARN_POP" +# endif +# undef __ACCLIB_PCLOCK_NEED_WARN_POP +#endif +#endif +#if defined(ACC_WANT_ACCLIB_UCLOCK) +# undef ACC_WANT_ACCLIB_UCLOCK +#define __ACCLIB_UCLOCK_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +#if (ACC_OS_DOS16 || ACC_OS_WIN16) +#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) +#elif (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64) && (ACC_HAVE_WINDOWS_H) +# if ((ACC_CC_DMC && (__DMC__ < 0x838)) || ACC_CC_LCCWIN32) +# define __ACCLIB_UCLOCK_USE_CLOCK 1 +# else +# define __ACCLIB_UCLOCK_USE_WINMM 1 +# if (ACC_CC_MSC && (_MSC_VER >= 1200)) +# pragma warning(push) +# define __ACCLIB_UCLOCK_NEED_WARN_POP 1 +# endif +# if (ACC_CC_MSC && (_MSC_VER >= 900)) +# pragma warning(disable: 4201) +# elif (ACC_CC_MWERKS) +# define LPUINT __ACC_MMSYSTEM_H_LPUINT +# endif +# if 1 +# include <mmsystem.h> +# else +# if (ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC) + ACC_EXTERN_C __declspec(dllimport) unsigned long __stdcall timeGetTime(void); +# else + ACC_EXTERN_C unsigned long __stdcall timeGetTime(void); +# endif +# endif +# if (ACC_CC_DMC) +# pragma DMC includelib "winmm.lib" +# elif (ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC) +# pragma comment(lib, "winmm.lib") +# elif (ACC_CC_MWERKS && (__MWERKS__ >= 0x3000)) +# pragma comment(lib, "winmm.lib") +# elif (ACC_CC_SYMANTECC) +# pragma SC includelib "winmm.lib" +# elif (ACC_CC_WATCOMC && (__WATCOMC__ >= 1050)) +# pragma library("winmm.lib") +# endif +# endif +#elif (ACC_OS_CYGWIN || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_TOS || ACC_OS_WIN32 || ACC_OS_WIN64) +# define __ACCLIB_UCLOCK_USE_CLOCK 1 +#elif (ACC_OS_CONSOLE) && defined(CLOCKS_PER_SEC) +# define __ACCLIB_UCLOCK_USE_CLOCK 1 +#elif (ACC_LIBC_ISOC90 || ACC_LIBC_ISOC99) && defined(CLOCKS_PER_SEC) +# define __ACCLIB_UCLOCK_USE_CLOCK 1 +#endif +#if (__ACCLIB_UCLOCK_USE_CLOCK) && !defined(CLOCKS_PER_SEC) +# if defined(CLK_TCK) +# define CLOCKS_PER_SEC CLK_TCK +# else +# undef __ACCLIB_UCLOCK_USE_CLOCK +# endif +#endif +#if (__ACCLIB_UCLOCK_USE_GETRUSAGE) +# if !defined(RUSAGE_SELF) +# undef __ACCLIB_UCLOCK_USE_GETRUSAGE +# endif +#endif +ACCLIB_PUBLIC(int, acc_uclock_open) (acc_uclock_handle_p h) +{ + int i; +#if (__ACCLIB_UCLOCK_USE_QPC) + LARGE_INTEGER li; +#endif + h->h = (acclib_handle_t) 1; + h->mode = 0; + h->read_error = 0; + h->name = NULL; +#if (__ACCLIB_UCLOCK_USE_PERFCTR) + h->pch.h = 0; + if (h->mode == 0 && __ACCLIB_FUNCNAME(acc_perfctr_open)(&h->pch) == 0) + h->mode = 2; +#endif +#if (__ACCLIB_UCLOCK_USE_QPC) + h->qpf = 0.0; + if (h->mode == 0 && QueryPerformanceFrequency(&li) != 0) { + double d = (double) li.QuadPart; + if (d > 0.0 && QueryPerformanceCounter(&li) != 0) { + h->mode = 3; + h->qpf = d; + } + } +#endif + for (i = 0; i < 10; i++) { + acc_uclock_t c; + __ACCLIB_FUNCNAME(acc_uclock_read)(h, &c); + } + return 0; +} +ACCLIB_PUBLIC(int, acc_uclock_close) (acc_uclock_handle_p h) +{ + h->h = (acclib_handle_t) 0; + h->mode = -1; + h->name = NULL; +#if (__ACCLIB_UCLOCK_USE_PERFCTR) + __ACCLIB_FUNCNAME(acc_perfctr_close)(&h->pch); +#endif + return 0; +} +ACCLIB_PUBLIC(void, acc_uclock_read) (acc_uclock_handle_p h, acc_uclock_p c) +{ +#if (__ACCLIB_UCLOCK_USE_RDTSC) + __ACCLIB_FUNCNAME(acc_tsc_read)((acc_uint32e_t*) (void*) &c->tsc); +#endif +#if (__ACCLIB_UCLOCK_USE_PERFCTR) + if (h->pch.h) { + __ACCLIB_FUNCNAME(acc_perfctr_read)(&h->pch, &c->pcc); + if (h->mode > 0 && h->mode <= 2) + return; + } +#endif +#if (__ACCLIB_UCLOCK_USE_QPC) + if (h->qpf > 0.0) { + LARGE_INTEGER li; + if (QueryPerformanceCounter(&li) != 0) { + c->qpc = (acc_int64l_t) li.QuadPart; + if (h->mode > 0 && h->mode <= 3) + return; + } else { + h->mode = 0; h->qpf = 0.0; c->qpc = 0; + h->read_error = 1; + } + } +#endif + { +#if (ACC_OS_DOS16 || ACC_OS_WIN16) +# if (ACC_CC_AZTECC) + c->ticks.t32 = 0; +# else + union REGS ri, ro; + ri.x.ax = 0x2c00; int86(0x21, &ri, &ro); + c->ticks.t32 = ro.h.ch*60UL*60UL*100UL + ro.h.cl*60UL*100UL + ro.h.dh*100UL + ro.h.dl; +# endif +#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) + c->ticks.t64 = uclock(); +#elif (__ACCLIB_UCLOCK_USE_CLOCK) && defined(acc_int64l_t) + c->ticks.t64 = clock(); +#elif (__ACCLIB_UCLOCK_USE_CLOCK) + c->ticks.t32 = clock(); +#elif (__ACCLIB_UCLOCK_USE_WINMM) + c->ticks.t32 = timeGetTime(); +#elif (__ACCLIB_UCLOCK_USE_GETRUSAGE) + struct rusage ru; + if (getrusage(RUSAGE_SELF, &ru) != 0) c->ticks.td = 0; + else c->ticks.td = ru.ru_utime.tv_sec + ru.ru_utime.tv_usec / 1000000.0; +#elif (HAVE_GETTIMEOFDAY) + struct timeval tv; + if (gettimeofday(&tv, 0) != 0) c->ticks.td = 0; + else c->ticks.td = tv.tv_sec + tv.tv_usec / 1000000.0; +#else + ACC_UNUSED(c); +#endif + } + ACC_UNUSED(h); +} +ACCLIB_PUBLIC(double, acc_uclock_get_elapsed) (acc_uclock_handle_p h, const acc_uclock_p start, const acc_uclock_p stop) +{ + double d; + if (!h->h) { + h->mode = -1; + return 0.0; + } +#if (__ACCLIB_UCLOCK_USE_RDTSC) + if (h->mode == 1) { + if (!h->name) h->name = "rdtsc"; + d = (double) ((acc_int64l_t)stop->tsc - (acc_int64l_t)start->tsc); + return d / 1000000000.0; + } +#endif +#if (__ACCLIB_UCLOCK_USE_PERFCTR) + if (h->pch.h && h->mode == 2) { + if (!h->name) h->name = "perfctr"; + return __ACCLIB_FUNCNAME(acc_perfctr_get_elapsed)(&h->pch, &start->pcc, &stop->pcc); + } +#endif +#if (__ACCLIB_UCLOCK_USE_QPC) + if (h->qpf > 0.0 && h->mode == 3) { + if (!h->name) h->name = "qpc"; + if (start->qpc == 0 || stop->qpc == 0) return 0.0; + return (double) (stop->qpc - start->qpc) / h->qpf; + } +#endif +#if (ACC_OS_DOS16 || ACC_OS_WIN16) + h->mode = 11; + if (!h->name) h->name = "uclock"; + d = (double) (stop->ticks.t32 - start->ticks.t32) / 100.0; + if (d < 0.0) d += 86400.0; +#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) + h->mode = 12; + if (!h->name) h->name = "uclock"; + d = (double) (stop->ticks.t64 - start->ticks.t64) / (UCLOCKS_PER_SEC); +#elif (__ACCLIB_UCLOCK_USE_CLOCK) && defined(acc_int64l_t) + h->mode = 13; + if (!h->name) h->name = "clock"; + { + acc_int64l_t t; + t = stop->ticks.t64 - start->ticks.t64; + if (t < 0) + t += sizeof(clock_t) == 4 ? ACC_INT64_C(0x100000000) : ACC_INT64_C(0); + d = (double) t / (CLOCKS_PER_SEC); + } +#elif (__ACCLIB_UCLOCK_USE_CLOCK) + h->mode = 14; + if (!h->name) h->name = "clock"; + d = (double) (stop->ticks.t32 - start->ticks.t32) / (CLOCKS_PER_SEC); +#elif (__ACCLIB_UCLOCK_USE_WINMM) + h->mode = 15; + if (!h->name) h->name = "timeGetTime"; + d = (double) (stop->ticks.t32 - start->ticks.t32) / 1000.0; +#elif (__ACCLIB_UCLOCK_USE_GETRUSAGE) + h->mode = 16; + if (!h->name) h->name = "getrusage"; + d = stop->ticks.td - start->ticks.td; +#elif (HAVE_GETTIMEOFDAY) + h->mode = 17; + if (!h->name) h->name = "gettimeofday"; + d = stop->ticks.td - start->ticks.td; +#else + h->mode = 0; + d = 0.0; +#endif + return d; +} +ACCLIB_PUBLIC(int, acc_uclock_flush_cpu_cache) (acc_uclock_handle_p h, unsigned flags) +{ + if (h->h) { +#if (__ACCLIB_UCLOCK_USE_PERFCTR) + return __ACCLIB_FUNCNAME(acc_perfctr_flush_cpu_cache)(&h->pch, flags); +#endif + } + ACC_UNUSED(h); ACC_UNUSED(flags); + return -1; +} +#if defined(__ACCLIB_UCLOCK_NEED_WARN_POP) +# if (ACC_CC_MSC && (_MSC_VER >= 1200)) +# pragma warning(pop) +# else +# error "__ACCLIB_UCLOCK_NEED_WARN_POP" +# endif +# undef __ACCLIB_UCLOCK_NEED_WARN_POP +#endif +#endif +#if defined(ACC_WANT_ACCLIB_MISC) +# undef ACC_WANT_ACCLIB_MISC +#define __ACCLIB_MISC_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +#if !defined(ACCLIB_PUBLIC_NOINLINE) +# if !defined(__acc_noinline) +# define ACCLIB_PUBLIC_NOINLINE(r,f) r __ACCLIB_FUNCNAME(f) +# elif (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x030400ul) || ACC_CC_LLVM) +# define ACCLIB_PUBLIC_NOINLINE(r,f) __acc_noinline __attribute__((__used__)) r __ACCLIB_FUNCNAME(f) +# else +# define ACCLIB_PUBLIC_NOINLINE(r,f) __acc_noinline r __ACCLIB_FUNCNAME(f) +# endif +#endif +#if (ACC_OS_WIN32 && ACC_CC_PELLESC && (__POCC__ >= 290)) +# pragma warn(push) +# pragma warn(disable:2007) +#endif +ACCLIB_PUBLIC(const char *, acc_getenv) (const char *s) +{ +#if (HAVE_GETENV) + return getenv(s); +#else + ACC_UNUSED(s); return (const char *) 0; +#endif +} +ACCLIB_PUBLIC(acclib_handle_t, acc_get_osfhandle) (int fd) +{ + if (fd < 0) + return -1; +#if (ACC_OS_CYGWIN) + return get_osfhandle(fd); +#elif (ACC_OS_EMX && defined(__RSXNT__)) + return -1; +#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__) + return -1; +#elif (ACC_OS_WIN32 || ACC_OS_WIN64) +# if (ACC_CC_PELLESC && (__POCC__ < 280)) + return -1; +# elif (ACC_CC_WATCOMC && (__WATCOMC__ < 1000)) + return -1; +# elif (ACC_CC_WATCOMC && (__WATCOMC__ < 1100)) + return _os_handle(fd); +# else + return _get_osfhandle(fd); +# endif +#else + return fd; +#endif +} +ACCLIB_PUBLIC(int, acc_set_binmode) (int fd, int binary) +{ +#if (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) && defined(__MINT__) + FILE* fp; int old_binary; + if (fd == STDIN_FILENO) fp = stdin; + else if (fd == STDOUT_FILENO) fp = stdout; + else if (fd == STDERR_FILENO) fp = stderr; + else return -1; + old_binary = fp->__mode.__binary; + __set_binmode(fp, binary ? 1 : 0); + return old_binary ? 1 : 0; +#elif (ACC_ARCH_M68K && ACC_OS_TOS) + ACC_UNUSED(fd); ACC_UNUSED(binary); + return -1; +#elif (ACC_OS_DOS16 && (ACC_CC_AZTECC || ACC_CC_PACIFICC)) + ACC_UNUSED(fd); ACC_UNUSED(binary); + return -1; +#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) + int r; unsigned old_flags = __djgpp_hwint_flags; + ACC_COMPILE_TIME_ASSERT(O_BINARY > 0) + ACC_COMPILE_TIME_ASSERT(O_TEXT > 0) + if (fd < 0) return -1; + r = setmode(fd, binary ? O_BINARY : O_TEXT); + if ((old_flags & 1u) != (__djgpp_hwint_flags & 1u)) + __djgpp_set_ctrl_c(!(old_flags & 1)); + if (r == -1) return -1; + return (r & O_TEXT) ? 0 : 1; +#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__) + if (fd < 0) return -1; + ACC_UNUSED(binary); + return 1; +#elif (ACC_OS_DOS32 && ACC_CC_HIGHC) + FILE* fp; int r; + if (fd == fileno(stdin)) fp = stdin; + else if (fd == fileno(stdout)) fp = stdout; + else if (fd == fileno(stderr)) fp = stderr; + else return -1; + r = _setmode(fp, binary ? _BINARY : _TEXT); + if (r == -1) return -1; + return (r & _BINARY) ? 1 : 0; +#elif (ACC_OS_WIN32 && ACC_CC_MWERKS) && defined(__MSL__) + ACC_UNUSED(fd); ACC_UNUSED(binary); + return -1; +#elif (ACC_OS_CYGWIN && (ACC_CC_GNUC < 0x025a00ul)) + ACC_UNUSED(fd); ACC_UNUSED(binary); + return -1; +#elif (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) + int r; +#if !(ACC_CC_ZORTECHC) + ACC_COMPILE_TIME_ASSERT(O_BINARY > 0) +#endif + ACC_COMPILE_TIME_ASSERT(O_TEXT > 0) + if (fd < 0) return -1; + r = setmode(fd, binary ? O_BINARY : O_TEXT); + if (r == -1) return -1; + return (r & O_TEXT) ? 0 : 1; +#else + if (fd < 0) return -1; + ACC_UNUSED(binary); + return 1; +#endif +} +ACCLIB_PUBLIC(int, acc_isatty) (int fd) +{ + if (fd < 0) + return 0; +#if (ACC_OS_DOS16 && !(ACC_CC_AZTECC)) + { + union REGS ri, ro; + ri.x.ax = 0x4400; ri.x.bx = fd; + int86(0x21, &ri, &ro); + if ((ro.x.cflag & 1) == 0) + if ((ro.x.ax & 0x83) != 0x83) + return 0; + } +#elif (ACC_OS_DOS32 && ACC_CC_WATCOMC) + { + union REGS ri, ro; + ri.w.ax = 0x4400; ri.w.bx = (unsigned short) fd; + int386(0x21, &ri, &ro); + if ((ro.w.cflag & 1) == 0) + if ((ro.w.ax & 0x83) != 0x83) + return 0; + } +#elif (ACC_HAVE_WINDOWS_H) + { + acclib_handle_t h = __ACCLIB_FUNCNAME(acc_get_osfhandle)(fd); + if ((HANDLE)h != INVALID_HANDLE_VALUE) + { + DWORD d = 0; + if (GetConsoleMode((HANDLE)h, &d) == 0) + return 0; + } + } +#endif +#if (HAVE_ISATTY) + return (isatty(fd)) ? 1 : 0; +#else + return 0; +#endif +} +ACCLIB_PUBLIC(int, acc_mkdir) (const char* name, unsigned mode) +{ +#if !(HAVE_MKDIR) + ACC_UNUSED(name); ACC_UNUSED(mode); + return -1; +#elif (ACC_ARCH_M68K && ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC)) + ACC_UNUSED(mode); + return Dcreate(name); +#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__) + return mkdir(name, mode); +#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__) + return mkdir(name, mode); +#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) + ACC_UNUSED(mode); +# if (ACC_CC_HIGHC || ACC_CC_PACIFICC) + return mkdir((char*) name); +# else + return mkdir(name); +# endif +#elif (ACC_CC_WATCOMC) + return mkdir(name, (mode_t) mode); +#else + return mkdir(name, mode); +#endif +} +ACCLIB_PUBLIC(int, acc_rmdir) (const char* name) +{ +#if !(HAVE_RMDIR) + ACC_UNUSED(name); + return -1; +#elif ((ACC_OS_DOS16 || ACC_OS_DOS32) && (ACC_CC_HIGHC || ACC_CC_PACIFICC)) + return rmdir((char *) name); +#else + return rmdir(name); +#endif +} +#if defined(acc_int32e_t) +ACCLIB_PUBLIC(acc_int32e_t, acc_muldiv32s) (acc_int32e_t a, acc_int32e_t b, acc_int32e_t x) +{ + acc_int32e_t r = 0; + if __acc_likely(x != 0) + { +#if defined(acc_int64l_t) + r = (acc_int32e_t) (((acc_int64l_t) a * b) / x); +#else + ACC_UNUSED(a); ACC_UNUSED(b); +#endif + } + return r; +} +ACCLIB_PUBLIC(acc_uint32e_t, acc_muldiv32u) (acc_uint32e_t a, acc_uint32e_t b, acc_uint32e_t x) +{ + acc_uint32e_t r = 0; + if __acc_likely(x != 0) + { +#if defined(acc_int64l_t) + r = (acc_uint32e_t) (((acc_uint64l_t) a * b) / x); +#else + ACC_UNUSED(a); ACC_UNUSED(b); +#endif + } + return r; +} +#endif +#if 0 +ACCLIB_PUBLIC_NOINLINE(int, acc_syscall_clock_gettime) (int c) +{ +} +#endif +#if (ACC_OS_WIN16) +ACC_EXTERN_C void __far __pascal DebugBreak(void); +#endif +ACCLIB_PUBLIC_NOINLINE(void, acc_debug_break) (void) +{ +#if (ACC_OS_WIN16) + DebugBreak(); +#elif (ACC_ARCH_I086) +#elif (ACC_OS_WIN64) && (ACC_HAVE_WINDOWS_H) + DebugBreak(); +#elif (ACC_CFG_NO_INLINE_ASM) && (ACC_OS_WIN32) && (ACC_HAVE_WINDOWS_H) + DebugBreak(); +#elif (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC) + __asm__ __volatile__("int $3\n" : : : __ACC_ASM_CLOBBER); +#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_MSC) + __asm { int 3 } +#elif (ACC_OS_WIN32) && (ACC_HAVE_WINDOWS_H) + DebugBreak(); +#else + * (volatile int *) 0x1 = -1; +#endif +} +ACCLIB_PUBLIC_NOINLINE(void, acc_debug_nop) (void) +{ +} +ACCLIB_PUBLIC_NOINLINE(int, acc_debug_align_check_query) (void) +{ +#if (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC) + size_t r; + __asm__ __volatile__("pushf\n pop %0\n" : "=a" (r) : : __ACC_ASM_CLOBBER); + return (int)(r >> 18) & 1; +#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_MSC) + unsigned long r; + __asm { + pushf + pop eax + mov r,eax + } + return (int)(r >> 18) & 1; +#else + return -1; +#endif +} +ACCLIB_PUBLIC_NOINLINE(int, acc_debug_align_check_enable) (int v) +{ + int r; +#if (ACC_ARCH_AMD64) && (ACC_ASM_SYNTAX_GNUC) + if (v) { + __asm__ __volatile__("pushf\n orl $262144,(%%rsp)\n popf\n" : : : __ACC_ASM_CLOBBER); + } else { + __asm__ __volatile__("pushf\n andl $-262145,(%%rsp)\n popf\n" : : : __ACC_ASM_CLOBBER); + } + r = 0; +#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC) + if (v) { + __asm__ __volatile__("pushf\n orl $262144,(%%esp)\n popf\n" : : : __ACC_ASM_CLOBBER); + } else { + __asm__ __volatile__("pushf\n andl $-262145,(%%esp)\n popf\n" : : : __ACC_ASM_CLOBBER); + } + r = 0; +#elif (ACC_ARCH_I386) && (ACC_ASM_SYNTAX_MSC) + if (v) { __asm { + pushf + or dword ptr [esp],262144 + popf + }} else { __asm { + pushf + and dword ptr [esp],-262145 + popf + }} + r = 0; +#else + r = -1; +#endif + ACC_UNUSED(v); return r; +} +ACCLIB_PUBLIC_NOINLINE(unsigned, acc_debug_running_on_qemu) (void) +{ + unsigned r = 0; +#if (ACC_OS_POSIX_LINUX || ACC_OS_WIN32 || ACC_OS_WIN64) + const char* p; + p = __ACCLIB_FUNCNAME(acc_getenv)("ACC_ENV_RUNNING_ON_QEMU"); + if (p) { + if (p[0] == 0) r = 0; + else if ((p[0] >= '0' && p[0] <= '9') && p[1] == 0) r = p[0] - '0'; + else r = 1; + } +#endif + return r; +} +ACCLIB_PUBLIC_NOINLINE(unsigned, acc_debug_running_on_valgrind) (void) +{ +#if (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_ASM_SYNTAX_GNUC) + volatile unsigned long args[5] = { 0x1001, 0, 0, 0, 0 }; + unsigned long r = 0; + __asm__ __volatile__(".byte 0xc1,0xc0,0x1d,0xc1,0xc0,0x03,0xc1,0xc8,0x1b,0xc1,0xc8,0x05,0xc1,0xc0,0x0d,0xc1,0xc0,0x13\n" : "=d" (r) : "a" (&args[0]), "d" (r) : __ACC_ASM_CLOBBER); + return (unsigned) r; +#else + return 0; +#endif +} +#if (ACC_OS_WIN32 && ACC_CC_PELLESC && (__POCC__ >= 290)) +# pragma warn(pop) +#endif +#endif +#if defined(ACC_WANT_ACCLIB_WILDARGV) +# undef ACC_WANT_ACCLIB_WILDARGV +#define __ACCLIB_WILDARGV_CH_INCLUDED 1 +#if !defined(ACCLIB_PUBLIC) +# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f) +#endif +#if (ACC_OS_DOS16 || ACC_OS216 || ACC_OS_WIN16) +#if 0 && (ACC_CC_MSC) +ACC_EXTERN_C int __acc_cdecl __setargv(void); +ACC_EXTERN_C int __acc_cdecl _setargv(void); +ACC_EXTERN_C int __acc_cdecl _setargv(void) { return __setargv(); } +#endif +#endif +#if (ACC_OS_WIN32 || ACC_OS_WIN64) +#if (ACC_CC_INTELC || ACC_CC_MSC) +ACC_EXTERN_C int __acc_cdecl __setargv(void); +ACC_EXTERN_C int __acc_cdecl _setargv(void); +ACC_EXTERN_C int __acc_cdecl _setargv(void) { return __setargv(); } +#endif +#endif +#if (ACC_OS_EMX) +#define __ACCLIB_HAVE_ACC_WILDARGV 1 +ACCLIB_PUBLIC(void, acc_wildargv) (int* argc, char*** argv) +{ + if (argc && argv) { + _response(argc, argv); + _wildcard(argc, argv); + } +} +#endif +#if (ACC_OS_CONSOLE_PSP) && defined(__PSPSDK_DEBUG__) +#define __ACCLIB_HAVE_ACC_WILDARGV 1 +ACC_EXTERN_C int acc_psp_init_module(int*, char***, int); +ACCLIB_PUBLIC(void, acc_wildargv) (int* argc, char*** argv) +{ + acc_psp_init_module(argc, argv, -1); +} +#endif +#if !(__ACCLIB_HAVE_ACC_WILDARGV) +#define __ACCLIB_HAVE_ACC_WILDARGV 1 +ACCLIB_PUBLIC(void, acc_wildargv) (int* argc, char*** argv) +{ +#if 1 && (ACC_ARCH_I086PM) + if (ACC_MM_AHSHIFT != 3) { exit(1); } +#elif 1 && (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) && defined(__MINT__) + __binmode(1); + if (isatty(1)) __set_binmode(stdout, 0); + if (isatty(2)) __set_binmode(stderr, 0); +#endif + ACC_UNUSED(argc); ACC_UNUSED(argv); +} +#endif +#endif + +/* vim:set ts=4 et: */ diff --git a/src/p_lzo.c b/src/p_lzo.c new file mode 100644 index 0000000..bacb28d --- /dev/null +++ b/src/p_lzo.c @@ -0,0 +1,595 @@ +/* p_lzo.c -- LZO compression + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + + +#if defined(WITH_LZO) + + +/************************************************************************* +// +**************************************************************************/ + +int lzo_set_method(int m, int level) +{ + int l = level & 0xff; + + if (m != 0 || l < 1 || l > 9) + return -1; /* not a LZO method */ + +#if defined(USE_LZO1X_1_15) + if (l == 1) + m = M_LZO1X_1_15; + else +#endif +#if defined(USE_LZO1X_1) + if (l <= 6) + { + m = M_LZO1X_1; + l = 5; + } +#endif +#if defined(USE_LZO1X_999) + if (l >= 7 && l <= 9) + { + m = M_LZO1X_999; + } +#endif + + if (m == 0) + return 1; /* error */ + + opt_method = m; + opt_level = l; + return 0; +} + + +int lzo_get_method(header_t *h) +{ +/* check method */ + if (h->method == M_LZO1X_1) + { + h->method_name = "LZO1X-1"; + if (h->level == 0) + h->level = 3; + } + else if (h->method == M_LZO1X_1_15) + { + h->method_name = "LZO1X-1(15)"; + if (h->level == 0) + h->level = 1; + } + else if (h->method == M_LZO1X_999) + { + static char s[11+1] = "LZO1X-999 "; + s[9] = 0; + if (h->level == 0) + h->level = 9; + else if (h->version >= 0x0950 && h->lib_version >= 0x1020) + { + s[9] = '/'; + s[10] = (char) (h->level + '0'); + } + h->method_name = s; + } + else + return -1; /* not a LZO method */ + +/* check compression level */ + if (h->level < 1 || h->level > 9) + return 15; + + return 0; +} + + +void lzo_init_compress_header(header_t *h) +{ + if (opt_checksum) + { + if (opt_crc32) + { + h->flags |= F_CRC32_D; + if (opt_checksum >= 2) + h->flags |= F_CRC32_C; + } + else + { + h->flags |= F_ADLER32_D; + if (opt_checksum >= 2) + h->flags |= F_ADLER32_C; + } + } +} + + +/************************************************************************* +// memory setup +**************************************************************************/ + +#if defined(ACC_OS_DOS16) && !defined(ACC_ARCH_I086PM) +# define BLOCK_SIZE (128*1024l) +#else +# define BLOCK_SIZE (256*1024l) +#endif +#define MAX_BLOCK_SIZE (64*1024l*1024l) /* DO NOT CHANGE */ + +#if defined(USE_LZO1X_999) +# define WRK_LEN LZO1X_999_MEM_COMPRESS +#elif defined(USE_LZO1X_1_15) +# define WRK_LEN LZO1X_1_15_MEM_COMPRESS +#elif defined(USE_LZO1X_1) +# define WRK_LEN LZO1X_1_MEM_COMPRESS +#else +# error +#endif + + +#if 1 +# define ALIGN_SIZE 4096 +#else +# define ALIGN_SIZE 1 +#endif + +/* LZO may expand uncompressible data by a small amount */ +#define MAX_COMPRESSED_SIZE(x) ((x) + (x) / 16 + 64 + 3) + + +static mblock_t blocks[2]; +static mblock_t wrkmem; + + +static void free_mem(void) +{ + mb_free(&wrkmem); + mb_free(&blocks[1]); + mb_free(&blocks[0]); +} + + +static lzo_bool alloc_mem(lzo_uint32 s1, lzo_uint32 s2, lzo_uint32 w) +{ + lzo_bool r = 1; + + r &= mb_alloc(&blocks[0], s1, ALIGN_SIZE); + r &= mb_alloc(&blocks[1], s2, ALIGN_SIZE); + r &= mb_alloc(&wrkmem, w, ALIGN_SIZE); + if (!r) + free_mem(); + return r; +} + + +/************************************************************************* +// enter / leave +**************************************************************************/ + +/* maybe make this an option ? */ +static const lzo_uint block_size = BLOCK_SIZE; + +lzo_bool lzo_enter(const header_t *h) +{ + int r; + lzo_uint32 wrk_len; + +#if defined(WITH_THREADS) + if (opt_num_threads > 1) + return lzo_threaded_enter(h); +#endif + + if (h != NULL) + { + r = 1; + if ((h->flags & F_ADLER32_C) && !(h->flags & F_ADLER32_D)) + { r = 0; assert(h->flags & F_ADLER32_D); } + if ((h->flags & F_CRC32_C) && !(h->flags & F_CRC32_D)) + { r = 0; assert(h->flags & F_CRC32_D); } + return r; + } + +#if 0 + fprintf(stderr,"%lu %lu %u\n", BLOCK_SIZE, MAX_BLOCK_SIZE, ALIGN_SIZE); +#endif + assert(block_size <= BLOCK_SIZE); + assert(block_size <= MAX_BLOCK_SIZE); + assert(block_size >= 16*1024); + + if (opt_method == M_LZO1X_1) + wrk_len = LZO1X_1_MEM_COMPRESS; + else if (opt_method == M_LZO1X_1_15) + wrk_len = LZO1X_1_15_MEM_COMPRESS; + else if (opt_method == M_LZO1X_999) + wrk_len = LZO1X_999_MEM_COMPRESS; + else + wrk_len = 0; + assert(wrk_len <= WRK_LEN); + + if (opt_method == M_LZO1X_999) + { + if (opt_checksum < 1) + opt_checksum = 1; /* always compute a checksum */ + if (opt_cmd == CMD_COMPRESS) + opt_optimize = 1; + } + + switch (opt_cmd) + { + case CMD_COMPRESS: + r = alloc_mem(block_size, MAX_COMPRESSED_SIZE(block_size), wrk_len); + break; + case CMD_DECOMPRESS: + case CMD_TEST: + r = alloc_mem(0, MAX_COMPRESSED_SIZE(block_size), 0); + break; + case CMD_LIST: + case CMD_LS: + case CMD_INFO: + r = alloc_mem(0, block_size, 0); + break; + default: + r = alloc_mem(0, 0, 0); + break; + } + + return r; +} + + +void lzo_leave(const header_t *h) +{ +#if defined(WITH_THREADS) + if (opt_num_threads > 1) { + lzo_threaded_leave(h); + return; + } +#endif + if (h == NULL) + free_mem(); +} + + +/************************************************************************* +// compress a file +**************************************************************************/ + +lzo_bool lzo_compress(file_t *fip, file_t *fop, const header_t *h) +{ + int r = LZO_E_OK; + lzo_bytep const b1 = blocks[0].mb_mem; + lzo_bytep const b2 = blocks[1].mb_mem; + lzo_uint32 src_len = 0; + lzo_uint dst_len = 0; + lzo_uint32 c_adler32 = ADLER32_INIT_VALUE, d_adler32 = ADLER32_INIT_VALUE; + lzo_uint32 c_crc32 = CRC32_INIT_VALUE, d_crc32 = CRC32_INIT_VALUE; + lzo_int l; + lzo_bool ok = 1; + +#if defined(WITH_THREADS) + if (opt_num_threads > 1) + return lzo_threaded_compress(fip, fop, h, skip); +#endif + + for (;;) + { + /* read a block */ + l = read_buf(fip, b1, block_size); + src_len = (l > 0 ? l : 0); + + /* write uncompressed block size */ + write32(fop,src_len); + + /* exit if last block */ + if (src_len == 0) + break; + + /* compute checksum of uncompressed block */ + if (h->flags & F_ADLER32_D) + d_adler32 = lzo_adler32(ADLER32_INIT_VALUE,b1,src_len); + if (h->flags & F_CRC32_D) + d_crc32 = lzo_crc32(CRC32_INIT_VALUE,b1,src_len); + + x_filter(b1,src_len,h); + + /* compress */ + if (h->method == M_LZO1X_1) + r = lzo1x_1_compress(b1, src_len, b2, &dst_len, wrkmem.mb_mem); +#if defined(USE_LZO1X_1_15) + else if (h->method == M_LZO1X_1_15) + r = lzo1x_1_15_compress(b1, src_len, + b2, &dst_len, wrkmem.mb_mem); +#endif +#if defined(USE_LZO1X_999) + else if (h->method == M_LZO1X_999) + r = lzo1x_999_compress_level(b1, src_len, + b2, &dst_len, wrkmem.mb_mem, + NULL, 0, 0, h->level); +#endif + else + fatal(fip,"Internal error"); + +#if 0 + fprintf(stderr, "%ld %ld %ld\n", (long)src_len, (long)dst_len, (long)block2.size); +#endif + assert(dst_len <= blocks[1].mb_size); + if (r != LZO_E_OK) + fatal(fip,"Internal error - compression failed"); + + /* optimize */ + if (opt_optimize && dst_len < src_len) + { + lzo_uint new_len = src_len; + r = lzo1x_optimize(b2, dst_len, b1, &new_len, NULL); + if (r != LZO_E_OK || new_len != src_len) + fatal(fip,"Internal error - optimization failed"); + } + + /* write compressed block size */ + if (dst_len < src_len) + write32(fop,dst_len); + else + write32(fop,src_len); + + /* write checksum of uncompressed block */ + if (h->flags & F_ADLER32_D) + write32(fop,d_adler32); + if (h->flags & F_CRC32_D) + write32(fop,d_crc32); + + /* write checksum of compressed block */ + if (dst_len < src_len && (h->flags & F_ADLER32_C)) + { + c_adler32 = lzo_adler32(ADLER32_INIT_VALUE,b2,dst_len); + write32(fop,c_adler32); + } + if (dst_len < src_len && (h->flags & F_CRC32_C)) + { + c_crc32 = lzo_crc32(CRC32_INIT_VALUE,b2,dst_len); + write32(fop,c_crc32); + } + + /* write compressed block data */ + if (dst_len < src_len) + write_buf(fop,b2,dst_len); + else + write_buf(fop,b1,src_len); + } + + return ok; +} + + +/************************************************************************* +// decompress a file +**************************************************************************/ + +lzo_bool lzo_decompress(file_t *fip, file_t *fop, + const header_t *h, lzo_bool skip) +{ + int r; + lzo_uint32 src_len, dst_len; + lzo_uint32 c_adler32 = ADLER32_INIT_VALUE, d_adler32 = ADLER32_INIT_VALUE; + lzo_uint32 c_crc32 = CRC32_INIT_VALUE, d_crc32 = CRC32_INIT_VALUE; + lzo_bool ok = 1; + lzo_bool use_seek; + mblock_t * const block = &blocks[1]; + lzo_bytep b1; + lzo_bytep const b2 = block->mb_mem; + +#if defined(WITH_THREADS) + if (opt_num_threads > 1) + return lzo_threaded_decompress(fip, fop, h, skip); +#endif + + use_seek = skip || opt_cmd == CMD_LIST || opt_cmd == CMD_LS || + opt_cmd == CMD_INFO; + + for (;;) + { + lzo_bytep dst; + + /* read uncompressed block size */ + read32(fip,&dst_len); + + /* exit if last block */ + if (dst_len == 0) + break; + + /* error if split file */ + if (dst_len == 0xffffffffUL) + { + /* should not happen - not yet implemented */ + error(fip,"this file is a split " PACKAGE " file"); + ok = 0; break; + } + + if (dst_len > MAX_BLOCK_SIZE) + { + error(fip, PACKAGE " file corrupted"); + ok = 0; break; + } + + /* read compressed block size */ + read32(fip,&src_len); + if (src_len <= 0 || src_len > dst_len) + { + error(fip, PACKAGE " file corrupted"); + ok = 0; break; + } + + if (dst_len > BLOCK_SIZE) + { + fatal(fip,"block size too small -- recompile " PACKAGE); + ok = 0; break; + } + if (dst_len > block_size) + { + /* should not happen - not yet implemented */ + fatal(fip,"block size too small -- use option '--blocksize'"); + ok = 0; break; + } + assert(block->mb_size >= src_len); + + /* read checksum of uncompressed block */ + if (h->flags & F_ADLER32_D) + read32(fip,&d_adler32); + if (h->flags & F_CRC32_D) + read32(fip,&d_crc32); + + /* read checksum of compressed block */ + if (h->flags & F_ADLER32_C) + { + if (src_len < dst_len) + read32(fip,&c_adler32); + else + { + assert(h->flags & F_ADLER32_D); + c_adler32 = d_adler32; + } + } + if (h->flags & F_CRC32_C) + { + if (src_len < dst_len) + read32(fip,&c_crc32); + else + { + assert(h->flags & F_CRC32_D); + c_crc32 = d_crc32; + } + } + + /* read the block */ + b1 = block->mb_mem + block->mb_size - src_len; + if (use_seek && fip->fd != STDIN_FILENO) + { + if (lseek(fip->fd, src_len, SEEK_CUR) == -1) + read_error(fip); + } + else + { + if (read_buf(fip, b1, src_len) != (lzo_int) src_len) + read_error(fip); + } + + fip->bytes_processed += src_len; + if (use_seek) + { + fop->bytes_processed += dst_len; + continue; + } + assert(block->mb_size >= MAX_COMPRESSED_SIZE(dst_len)); + + /* verify checksum of compressed block */ + if (opt_checksum && (h->flags & F_ADLER32_C)) + { + lzo_uint32 c; + c = lzo_adler32(ADLER32_INIT_VALUE,b1,src_len); + if (c != c_adler32) + { + error(fip,"Checksum error (" PACKAGE " file corrupted)"); + ok = 0; break; + } + } + if (opt_checksum && (h->flags & F_CRC32_C)) + { + lzo_uint32 c; + c = lzo_crc32(CRC32_INIT_VALUE,b1,src_len); + if (c != c_crc32) + { + error(fip,"Checksum error (" PACKAGE " file corrupted)"); + ok = 0; break; + } + } + + if (src_len < dst_len) + { + lzo_uint d = dst_len; + + /* decompress */ + if (opt_decompress_safe) + r = lzo1x_decompress_safe(b1,src_len,b2,&d,NULL); + else + r = lzo1x_decompress(b1,src_len,b2,&d,NULL); + + if (r != LZO_E_OK || dst_len != d) + { + error(fip,"Compressed data violation"); +#if 0 + fprintf(stderr,"%d %ld %ld\n", r, (long)dst_len, (long)d); +#endif + ok = 0; break; + } + dst = b2; + } + else + { + assert(dst_len == src_len); + dst = b1; + } + + x_filter(dst,dst_len,h); + + /* verify checksum of uncompressed block */ + if (opt_checksum && (h->flags & F_ADLER32_D)) + { + lzo_uint32 c; + c = lzo_adler32(ADLER32_INIT_VALUE,dst,dst_len); + if (c != d_adler32) + { + error(fip,"Checksum error"); + ok = 0; break; + } + } + if (opt_checksum && (h->flags & F_CRC32_D)) + { + lzo_uint32 c; + c = lzo_crc32(CRC32_INIT_VALUE,dst,dst_len); + if (c != d_crc32) + { + error(fip,"Checksum error"); + ok = 0; break; + } + } + + /* write uncompressed block data */ + write_buf(fop,dst,dst_len); + fop->bytes_processed += dst_len; + } + + return ok; +} + + +#endif /* WITH_LZO */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/s_curses.c b/src/s_curses.c new file mode 100644 index 0000000..0809b8a --- /dev/null +++ b/src/s_curses.c @@ -0,0 +1,412 @@ +/* s_curses.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(USE_SCREEN) && defined(USE_SCREEN_CURSES) + +#include "screen.h" + +#define this local_this + +#define mask_fg 0x0f +#define mask_bg 0xf0 + + +/************************************************************************* +// direct screen access +**************************************************************************/ + +#include <termios.h> +#include <ncurses.h> +#undef refresh +#undef clear + + +struct screen_data_t +{ + WINDOW *w; + int mode; + int page; + int cols; + int rows; + int cursor_x; + int cursor_y; + unsigned char attr; + unsigned char init_attr; + chtype empty_cell; +}; + + + +static void s_refresh(screen_t *this) +{ + wrefresh(this->data->w); +} + + +static __inline__ +chtype make_cell(screen_t *this, int ch, int attr) +{ + int fg = attr & mask_fg; + chtype c = ch & 0xff; + if (fg < 8) + c |= COLOR_PAIR((fg + 0)); + else + c |= COLOR_PAIR(((fg & 7) + 0)) | A_BOLD; + return c; +} + + +static int getMode(const screen_t *this) +{ + return this->data->mode; +} + + +static int getPage(const screen_t *this) +{ + return this->data->page; +} + + +static int getRows(const screen_t *this) +{ + return this->data->rows; +} + + +static int getCols(const screen_t *this) +{ + return this->data->cols; +} + + +static int getFg(const screen_t *this) +{ + return this->data->attr & mask_fg; +} + + +static int getBg(const screen_t *this) +{ + return this->data->attr & mask_bg; +} + + +static void setFg(screen_t *this, int fg) +{ + this->data->attr = (this->data->attr & mask_bg) | (fg & mask_fg); +} + + +static void setBg(screen_t *this, int bg) +{ + this->data->attr = (this->data->attr & mask_fg) | (bg & mask_bg); +} + + +/* private */ +static __inline__ int gotoxy(screen_t *this, int x, int y) +{ + if (wmove(this->data->w, this->data->w->_begy+y, + this->data->w->_begx+x) != ERR) + return 0; + return -1; +} + + +static void setCursor(screen_t *this, int x, int y) +{ + if (gotoxy(this,x,y) == 0) + { + this->data->cursor_x = x; + this->data->cursor_y = y; + } +} + + +static void getCursor(const screen_t *this, int *x, int *y) +{ + if (x) + *x = this->data->cursor_x; + if (y) + *y = this->data->cursor_y; +} + + +static void putCharAttr(screen_t *this, int ch, int attr, int x, int y) +{ + if (gotoxy(this,x,y) == 0) + waddch(this->data->w,make_cell(this,ch,attr)); +} + + +static void putChar(screen_t *this, int ch, int x, int y) +{ + putCharAttr(this,ch,this->data->attr,x,y); +} + + +static void putStringAttr(screen_t *this, const char *s, int attr, int x, int y) +{ + while (*s) + putCharAttr(this,*s++,attr,x++,y); +} + + +static void putString(screen_t *this, const char *s, int x, int y) +{ + putStringAttr(this,s,this->data->attr,x,y); +} + + +static int init(screen_t *this, int fd) +{ + int fg, bg; + + if (!this || !this->data) + return -1; + + this->data->mode = -1; + this->data->page = 0; + + if (fd < 0 || !acc_isatty(fd)) + return -1; + + this->data->w = initscr(); + if (!this->data->w) + return -1; + (void) noecho(); + + this->data->cols = this->data->w->_maxx - this->data->w->_begx + 1; + this->data->rows = this->data->w->_maxy - this->data->w->_begy + 1; + this->data->cursor_x = this->data->w->_curx; + this->data->cursor_y = this->data->w->_cury; + + this->data->empty_cell = ' '; + + if (has_colors()) + start_color(); + fg = (this->data->w->_attrs); + bg = (this->data->w->_bkgd); + fg = PAIR_NUMBER(this->data->w->_attrs); + bg = PAIR_NUMBER(this->data->w->_bkgd); + if (has_colors() && COLORS >= 8 && COLOR_PAIRS >= 8) + this->data->mode = 3; + else + this->data->mode = 7; + + if (this->data->mode == 3) + { + int i = 0; + init_pair(i++, COLOR_BLACK, bg); + init_pair(i++, COLOR_BLUE, bg); + init_pair(i++, COLOR_GREEN, bg); + init_pair(i++, COLOR_CYAN, bg); + init_pair(i++, COLOR_RED, bg); + init_pair(i++, COLOR_MAGENTA, bg); + init_pair(i++, COLOR_YELLOW, bg); + init_pair(i++, COLOR_WHITE, bg); + } + + this->data->attr = (bg << 4) | fg; + this->data->attr = 0x07; + + return 0; +} + + +static void finalize(screen_t *this) +{ +#if 0 + if (this->data->w) + (void) endwin(); +#endif + UNUSED(this); +} + + +static void updateLineN(screen_t *this, const void *line, int y, int len) +{ + if (len > 0 && len <= 2*this->data->cols) + { + int x; + const unsigned char *l = line; + + for (x = 0; x < len / 2; x++, l += 2) + { +#if 1 + if ((l[1] & mask_bg) != BG_BLACK) + putCharAttr(this,'#',l[1] >> 4,x,y); + else + putCharAttr(this,l[0],l[1],x,y); +#else + putCharAttr(this,l[0],l[1],x,y); +#endif + } + } +} + + +static void clearLine(screen_t *this, int y) +{ + int x; + + for (x = 0; x < this->data->cols; x++) + if (gotoxy(this,x,y) == 0) + waddch(this->data->w,this->data->empty_cell); +} + + +static void s_clear(screen_t *this) +{ + int y; + + for (y = 0; y < this->data->rows; y++) + clearLine(this,y); +} + + +static int scrollUp(screen_t *this, int lines) +{ + if (lines <= 0) + return 0; + if (lines >= this->data->rows) + s_clear(this); + else + wscrl(this->data->w,lines); + return lines; +} + + +static int getCursorShape(const screen_t *this) +{ + UNUSED(this); + return 0; +} + + +static void setCursorShape(screen_t *this, int shape) +{ + UNUSED(this); + UNUSED(shape); +} + + +static int kbhit(screen_t *this) +{ + const int fd = STDIN_FILENO; + const unsigned long usec = 0; + struct timeval tv; + fd_set fds; + + UNUSED(this); + FD_ZERO(&fds); + FD_SET(fd, &fds); + tv.tv_sec = usec / 1000000; + tv.tv_usec = usec % 1000000; + return (select(fd + 1, &fds, NULL, NULL, &tv) > 0); +} + + +static int intro(screen_t *this, void (*show_frames)(screen_t *) ) +{ + int shape; + struct termios term_old, term_new; + int term_r; + + term_r = tcgetattr(STDIN_FILENO, &term_old); + if (term_r == 0) + { + term_new = term_old; + term_new.c_lflag &= ~(ISIG | ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &term_new); + } + + shape = getCursorShape(this); + setCursorShape(this,0x2000); + show_frames(this); + if (this->data->rows > 24) + setCursor(this,this->data->cursor_x,this->data->cursor_y+1); + setCursorShape(this,shape); + s_refresh(this); + + if (term_r == 0) + tcsetattr(STDIN_FILENO, TCSANOW, &term_old); + + return 1; +} + + +static const screen_t driver = +{ + sobject_destroy, + finalize, + init, + s_refresh, + getMode, + getPage, + getRows, + getCols, + getFg, + getBg, + getCursor, + getCursorShape, + setFg, + setBg, + setCursor, + setCursorShape, + putChar, + putCharAttr, + putString, + putStringAttr, + s_clear, + clearLine, + updateLineN, + scrollUp, + kbhit, + intro, + (struct screen_data_t *) 0 +}; + + +/* public constructor */ +screen_t *screen_curses_construct(void) +{ + return sobject_construct(&driver,sizeof(*driver.data)); +} + + +#endif /* defined(USE_SCREEN) && defined(USE_SCREEN_CURSES) */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/s_djgpp2.c b/src/s_djgpp2.c new file mode 100644 index 0000000..328d7d7 --- /dev/null +++ b/src/s_djgpp2.c @@ -0,0 +1,378 @@ +/* s_djgpp2.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(USE_SCREEN) && defined(__DJGPP__) + +#include "screen.h" + +#define this local_this + +#define mask_fg 0x0f +#define mask_bg 0xf0 + + +/************************************************************************* +// direct screen access +**************************************************************************/ + +#include <dos.h> +#if 0 +#include <conio.h> +#endif +#include <dpmi.h> +#include <go32.h> +#include <sys/exceptn.h> +#include <sys/farptr.h> +#include <sys/movedata.h> +#define dossel _go32_info_block.selector_for_linear_memory +#define co80 _go32_info_block.linear_address_of_primary_screen +#undef kbhit + + +struct screen_data_t +{ + int cols; + int rows; + int cursor_x; + int cursor_y; + unsigned char attr; + unsigned char init_attr; + unsigned char empty_attr; + unsigned short empty_cell; +}; + + + +static void refresh(screen_t *this) +{ + UNUSED(this); +} + + +static __inline__ +unsigned short make_cell(screen_t *this, int ch, int attr) +{ + UNUSED(this); + return ((attr & 0xff) << 8) | (ch & 0xff); +} + + +static int getMode(const screen_t *this) +{ + UNUSED(this); + return ScreenMode(); +} + + +static int getPage(const screen_t *this) +{ + UNUSED(this); + return _farpeekb(dossel, 0x462); +} + + +static int getRows(const screen_t *this) +{ + return this->data->rows; +} + + +static int getCols(const screen_t *this) +{ + return this->data->cols; +} + + +static int getFg(const screen_t *this) +{ + return this->data->attr & mask_fg; +} + + +static int getBg(const screen_t *this) +{ + return this->data->attr & mask_bg; +} + + +static void setFg(screen_t *this, int fg) +{ + this->data->attr = (this->data->attr & mask_bg) | (fg & mask_fg); +} + + +static void setBg(screen_t *this, int bg) +{ + this->data->attr = (this->data->attr & mask_fg) | (bg & mask_bg); +} + + +static void setCursor(screen_t *this, int x, int y) +{ + if (x >= 0 && y >= 0 && x < this->data->cols && y < this->data->rows) + { + ScreenSetCursor(y,x); + this->data->cursor_x = x; + this->data->cursor_y = y; + } +} + + +static void getCursor(const screen_t *this, int *x, int *y) +{ + if (x) + *x = this->data->cursor_x; + if (y) + *y = this->data->cursor_y; +} + + +static void putCharAttr(screen_t *this, int ch, int attr, int x, int y) +{ + UNUSED(this); + ScreenPutChar(ch,attr,x,y); +} + + +static void putChar(screen_t *this, int ch, int x, int y) +{ + ScreenPutChar(ch,this->data->attr,x,y); +} + + +static void putStringAttr(screen_t *this, const char *s, int attr, int x, int y) +{ + UNUSED(this); + ScreenPutString(s,attr,x,y); +} + + +static void putString(screen_t *this, const char *s, int x, int y) +{ + ScreenPutString(s,this->data->attr,x,y); +} + + +/* private */ +static void getChar(screen_t *this, int *ch, int *attr, int x, int y) +{ + UNUSED(this); + ScreenGetChar(ch,attr,x,y); +} + + +static int init(screen_t *this, int fd) +{ + int mode; + int attr; + +#if 0 + /* force linkage of conio.o */ + (void) _conio_kbhit(); +#endif + + if (!this || !this->data) + return -1; + if (fd < 0 || !acc_isatty(fd)) + return -1; + + mode = getMode(this); + if (mode != 2 && mode != 3 && mode != 7) + return -1; + if (getPage(this) != 0) + return -1; + this->data->rows = ScreenRows(); + this->data->cols = ScreenCols(); + ScreenGetCursor(&this->data->cursor_y,&this->data->cursor_x); + getChar(this,NULL,&attr,this->data->cursor_x,this->data->cursor_y); + this->data->init_attr = attr; + if (mode == 2 || mode == 3) + { + /* Does it normally blink when bg has its 3rd bit set? */ + int b_mask = (_farpeekb(dossel, 0x465) & 0x20) ? 0x70 : 0xf0; + attr = attr & (0x0f | b_mask); + } + this->data->attr = attr; + this->data->empty_attr = attr; + this->data->empty_cell = make_cell(this,' ',attr); + + return 0; +} + + +static void updateLineN(screen_t *this, const void *line, int y, int len) +{ + if (y >= 0 && y < this->data->rows && len > 0 && len <= 2*this->data->cols) + movedata(_my_ds(),(unsigned)line,dossel,co80+y*this->data->cols*2,len); +} + + +static void clearLine(screen_t *this, int y) +{ + if (y >= 0 && y < this->data->rows) + { + unsigned sp = co80 + y * this->data->cols * 2; + unsigned short a = this->data->empty_cell; + int i = this->data->cols; + + _farsetsel(dossel); + do { + _farnspokew(sp, a); + sp += 2; + } while (--i); + } +} + + +static void clear(screen_t *this) +{ + unsigned char attr = ScreenAttrib; + ScreenAttrib = this->data->empty_attr; + ScreenClear(); + ScreenAttrib = attr; +} + + +static int scrollUp(screen_t *this, int lines) +{ + int sr = this->data->rows; + int sc = this->data->cols; + int y; + + if (lines <= 0) + return 0; + if (lines >= sr) + clear(this); + else + { + movedata(dossel,co80+lines*sc*2,dossel,co80,(sr-lines)*sc*2); + for (y = sr - lines; y < sr; y++) + clearLine(this,y); + } + return lines; +} + + +static int getCursorShape(const screen_t *this) +{ + UNUSED(this); + return _farpeekw(dossel, 0x460); +} + + +static void setCursorShape(screen_t *this, int shape) +{ + __dpmi_regs r; + + r.h.ah = 0x01; + r.h.al = getMode(this); + r.x.cx = shape & 0x7f1f; + __dpmi_int(0x10, &r); +} + + +static int s_kbhit(screen_t *this) +{ + UNUSED(this); + return kbhit(); +} + + +static int intro(screen_t *this, void (*show_frames)(screen_t *) ) +{ + int shape; + unsigned short old_flags = __djgpp_hwint_flags; + + if ((this->data->init_attr & mask_bg) != BG_BLACK) + return 0; + + __djgpp_hwint_flags |= 3; + while (kbhit()) + (void) getkey(); + + shape = getCursorShape(this); + setCursorShape(this,0x2000); + show_frames(this); + setCursorShape(this,shape); + + while (kbhit()) + (void) getkey(); + __djgpp_hwint_flags = old_flags; + + return 1; +} + + +static const screen_t driver = +{ + sobject_destroy, + 0, /* finalize, */ + init, + refresh, + getMode, + getPage, + getRows, + getCols, + getFg, + getBg, + getCursor, + getCursorShape, + setFg, + setBg, + setCursor, + setCursorShape, + putChar, + putCharAttr, + putString, + putStringAttr, + clear, + clearLine, + updateLineN, + scrollUp, + s_kbhit, + intro, + (struct screen_data_t *) 0 +}; + + +/* public constructor */ +screen_t *screen_djgpp2_construct(void) +{ + return sobject_construct(&driver,sizeof(*driver.data)); +} + + +#endif /* defined(USE_SCREEN) && defined(__DJGPP__) */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/s_object.c b/src/s_object.c new file mode 100644 index 0000000..4970cf0 --- /dev/null +++ b/src/s_object.c @@ -0,0 +1,87 @@ +/* s_object.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(USE_SCREEN) + +#define this local_this + +#include "screen.h" + + +/************************************************************************* +// +**************************************************************************/ + +void sobject_destroy(screen_t *this) +{ + if (!this) + return; + if (this->data) + { + if (this->finalize) + this->finalize(this); + free(this->data); + this->data = NULL; + } + free(this); +} + + +screen_t *sobject_construct(const screen_t *c, size_t data_size) +{ + screen_t *this; + + /* allocate object */ + this = (screen_t *) malloc(sizeof(*this)); + if (!this) + return NULL; + + /* copy function table */ + *this = *c; + + /* initialize instance variables */ + this->data = (struct screen_data_t *) malloc(data_size); + if (!this->data) + { + free(this); + return NULL; + } + memset(this->data,0,data_size); + + return this; +} + +#endif /* defined(USE_SCREEN) */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/s_vcsa.c b/src/s_vcsa.c new file mode 100644 index 0000000..b04dfe1 --- /dev/null +++ b/src/s_vcsa.c @@ -0,0 +1,488 @@ +/* s_vcsa.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + +#if defined(USE_SCREEN) && defined(USE_SCREEN_VCSA) + +#include "screen.h" + +#define this local_this + +#define mask_fg 0x0f +#define mask_bg 0xf0 + + +/************************************************************************* +// direct screen access ( /dev/vcsaNN ) +**************************************************************************/ + +#include <sys/ioctl.h> +#include <termios.h> +#if defined(__linux__) +# include <linux/kd.h> +# include <linux/kdev_t.h> +# include <linux/major.h> +#endif + + +struct screen_data_t +{ + int fd; + int mode; + int page; + int cols; + int rows; + int cursor_x; + int cursor_y; + unsigned char attr; + unsigned char init_attr; + unsigned char map[256]; + unsigned short empty_line[256]; +}; + + + +static void refresh(screen_t *this) +{ + UNUSED(this); +} + + +static __inline__ +unsigned short make_cell(screen_t *this, int ch, int attr) +{ + return ((attr & 0xff) << 8) | (this->data->map[ch & 0xff] & 0xff); +} + + +static int getMode(const screen_t *this) +{ + return this->data->mode; +} + + +static int getPage(const screen_t *this) +{ + return this->data->page; +} + + +static int getRows(const screen_t *this) +{ + return this->data->rows; +} + + +static int getCols(const screen_t *this) +{ + return this->data->cols; +} + + +static int getFg(const screen_t *this) +{ + return this->data->attr & mask_fg; +} + + +static int getBg(const screen_t *this) +{ + return this->data->attr & mask_bg; +} + + +static void setFg(screen_t *this, int fg) +{ + this->data->attr = (this->data->attr & mask_bg) | (fg & mask_fg); +} + + +static void setBg(screen_t *this, int bg) +{ + this->data->attr = (this->data->attr & mask_fg) | (bg & mask_bg); +} + + +/* private */ +static int gotoxy(screen_t *this, int x, int y) +{ + if (x >= 0 && y >= 0 && x < this->data->cols && y < this->data->rows) + { + if (lseek(this->data->fd, 4 + (x + y * this->data->cols) * 2, SEEK_SET) != -1) + { + return 0; + } + } + return -1; +} + + +static void setCursor(screen_t *this, int x, int y) +{ + if (gotoxy(this,x,y) == 0) + { + unsigned char b[2] = { x, y }; + if (lseek(this->data->fd, 2, SEEK_SET) != -1) + write(this->data->fd, b, 2); + this->data->cursor_x = x; + this->data->cursor_y = y; + } +} + + +static void getCursor(const screen_t *this, int *x, int *y) +{ + if (x) + *x = this->data->cursor_x; + if (y) + *y = this->data->cursor_y; +} + + +static void putCharAttr(screen_t *this, int ch, int attr, int x, int y) +{ + unsigned short a = make_cell(this,ch,attr); + + if (gotoxy(this,x,y) == 0) + write(this->data->fd, &a, 2); +} + + +static void putChar(screen_t *this, int ch, int x, int y) +{ + putCharAttr(this,ch,this->data->attr,x,y); +} + + +static void putStringAttr(screen_t *this, const char *s, int attr, int x, int y) +{ + while (*s) + putCharAttr(this,*s++,attr,x++,y); +} + + +static void putString(screen_t *this, const char *s, int x, int y) +{ + putStringAttr(this,s,this->data->attr,x,y); +} + + +/* private */ +static void getChar(screen_t *this, int *ch, int *attr, int x, int y) +{ + unsigned short a; + + if (gotoxy(this,x,y) == 0 && read(this->data->fd, &a, 2) == 2) + { + if (ch) + *ch = a & 0xff; + if (attr) + *attr = (a >> 8) & 0xff; + } +} + + +/* private */ +static int init_scrnmap(screen_t *this, int fd) +{ + int scrnmap_done = 0; + int i; + +#if 1 && defined(GIO_UNISCRNMAP) && defined(E_TABSZ) + if (!scrnmap_done) + { + unsigned short scrnmap[E_TABSZ]; + if (ioctl(fd, GIO_UNISCRNMAP, scrnmap) == 0) + { + for (i = 0; i < E_TABSZ; i++) + this->data->map[scrnmap[i] & 0xff] = i; + scrnmap_done = 1; + } + } +#endif +#if 1 && defined(GIO_SCRNMAP) && defined(E_TABSZ) + if (!scrnmap_done) + { + unsigned char scrnmap[E_TABSZ]; + if (ioctl(fd, GIO_SCRNMAP, scrnmap) == 0) + { + for (i = 0; i < E_TABSZ; i++) + this->data->map[scrnmap[i] & 0xff] = i; + scrnmap_done = 1; + } + } +#endif + + return scrnmap_done; +} + + +static int init(screen_t *this, int fd) +{ + struct stat st; + + if (!this || !this->data) + return -1; + + this->data->fd = -1; + this->data->mode = -1; + this->data->page = 0; + + if (fd < 0 || !acc_isatty(fd)) + return -1; + if (fstat(fd,&st) != 0) + return -1; + + /* check if we are running in a virtual console */ +#if defined(MINOR) && defined(MAJOR) && defined(TTY_MAJOR) + if (MAJOR(st.st_rdev) == TTY_MAJOR) + { + char vc_name[64]; + unsigned char vc_data[4]; + int i; + int attr; + unsigned short a; + + snprintf(vc_name, sizeof(vc_name), "/dev/vcsa%d", (int) MINOR(st.st_rdev)); + this->data->fd = open(vc_name, O_RDWR); + if (this->data->fd != -1) + { + if (read(this->data->fd, vc_data, 4) == 4) + { + this->data->mode = 3; + this->data->rows = vc_data[0]; + this->data->cols = vc_data[1]; + this->data->cursor_x = vc_data[2]; + this->data->cursor_y = vc_data[3]; + + for (i = 0; i < 256; i++) + this->data->map[i] = i; + i = init_scrnmap(this,this->data->fd) || + init_scrnmap(this,STDIN_FILENO); + + getChar(this,NULL,&attr,this->data->cursor_x,this->data->cursor_y); + this->data->init_attr = attr; + this->data->attr = attr; + a = make_cell(this,' ',attr); + for (i = 0; i < 256; i++) + this->data->empty_line[i] = a; + } + else + { + close(this->data->fd); + this->data->fd = -1; + } + } + } +#endif + + if (this->data->mode < 0) + return -1; + + return 0; +} + + +static void finalize(screen_t *this) +{ + if (this->data->fd != -1) + (void) close(this->data->fd); +} + + +static void updateLineN(screen_t *this, const void *line, int y, int len) +{ + if (len > 0 && len <= 2*this->data->cols && gotoxy(this,0,y) == 0) + { + int i; + unsigned char new_line[len]; + unsigned char *l1 = new_line; + const unsigned char *l2 = (const unsigned char *) line; + + for (i = 0; i < len; i += 2) + { + *l1++ = *l2++; + *l1++ = this->data->map[*l2++]; + } + write(this->data->fd, new_line, len); + } +} + + +static void clearLine(screen_t *this, int y) +{ + if (gotoxy(this,0,y) == 0) + write(this->data->fd, this->data->empty_line, 2*this->data->cols); +} + + +static void clear(screen_t *this) +{ + int y; + + for (y = 0; y < this->data->rows; y++) + clearLine(this,y); +} + + +static int scrollUp(screen_t *this, int lines) +{ + int sr = this->data->rows; + int sc = this->data->cols; + int y; + + if (lines <= 0) + return 0; + if (lines >= sr) + clear(this); + else + { + unsigned short buf[ (sr-lines)*sc ]; + + gotoxy(this,0,lines); + read(this->data->fd, buf, sizeof(buf)); + gotoxy(this,0,0); + write(this->data->fd, buf, sizeof(buf)); + + for (y = sr - lines; y < sr; y++) + clearLine(this,y); + } + return lines; +} + + +static int getCursorShape(const screen_t *this) +{ + UNUSED(this); + return 0; +} + + +static void setCursorShape(screen_t *this, int shape) +{ + UNUSED(this); + UNUSED(shape); +} + + +static int kbhit(screen_t *this) +{ + const int fd = STDIN_FILENO; + const unsigned long usec = 0; + struct timeval tv; + fd_set fds; + + UNUSED(this); + FD_ZERO(&fds); + FD_SET(fd, &fds); + tv.tv_sec = usec / 1000000; + tv.tv_usec = usec % 1000000; + return (select(fd + 1, &fds, NULL, NULL, &tv) > 0); +} + + +static int intro(screen_t *this, void (*show_frames)(screen_t *) ) +{ + int shape; + struct termios term_old, term_new; + int term_r; + + if ((this->data->init_attr & mask_bg) != BG_BLACK) + return 0; + + term_r = tcgetattr(STDIN_FILENO, &term_old); + if (term_r == 0) + { + term_new = term_old; + term_new.c_lflag &= ~(ISIG | ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &term_new); + } + + shape = getCursorShape(this); + setCursorShape(this,0x2000); + show_frames(this); + if (this->data->rows > 24) + setCursor(this,this->data->cursor_x,this->data->cursor_y+1); + setCursorShape(this,shape); + + while (kbhit(this)) + (void) getchar(); + if (term_r == 0) + tcsetattr(STDIN_FILENO, TCSANOW, &term_old); + + return 1; +} + + +static const screen_t driver = +{ + sobject_destroy, + finalize, + init, + refresh, + getMode, + getPage, + getRows, + getCols, + getFg, + getBg, + getCursor, + getCursorShape, + setFg, + setBg, + setCursor, + setCursorShape, + putChar, + putCharAttr, + putString, + putStringAttr, + clear, + clearLine, + updateLineN, + scrollUp, + kbhit, + intro, + (struct screen_data_t *) 0 +}; + + +/* public constructor */ +screen_t *screen_vcsa_construct(void) +{ + return sobject_construct(&driver,sizeof(*driver.data)); +} + + +#endif /* defined(USE_SCREEN) && defined(USE_SCREEN_VCSA) */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/screen.h b/src/screen.h new file mode 100644 index 0000000..3813c5a --- /dev/null +++ b/src/screen.h @@ -0,0 +1,106 @@ +/* screen.h -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#ifndef __SCREEN_H +#define __SCREEN_H 1 + +#if defined(USE_SCREEN) + + +/************************************************************************* +// +**************************************************************************/ + +struct screen_data_t; +struct screen_t; +typedef struct screen_t screen_t; + +struct screen_t +{ +/* public: */ + void (*destroy)(screen_t *s); + void (*finalize)(screen_t *s); + + int (*init)(screen_t *s, int fd); + + void (*refresh)(screen_t *s); + + int (*getMode)(const screen_t *s); + int (*getPage)(const screen_t *s); + int (*getRows)(const screen_t *s); + int (*getCols)(const screen_t *s); + + int (*getFg)(const screen_t *s); + int (*getBg)(const screen_t *s); + void (*getCursor)(const screen_t *s, int *x, int *y); + int (*getCursorShape)(const screen_t *s); + + void (*setFg)(screen_t *s, int); + void (*setBg)(screen_t *s, int); + void (*setCursor)(screen_t *s, int x, int y); + void (*setCursorShape)(screen_t *s, int shape); + + void (*putChar)(screen_t *s, int c, int x, int y); + void (*putCharAttr)(screen_t *s, int c, int attr, int x, int y); + void (*putString)(screen_t *s, const char *, int x, int y); + void (*putStringAttr)(screen_t *s, const char *, int attr, int x, int y); + + void (*clear)(screen_t *s); + void (*clearLine)(screen_t *s, int); + void (*updateLineN)(screen_t *s, const void *, int y, int len); + + int (*scrollUp)(screen_t *s, int); + + int (*kbhit)(screen_t *s); + + int (*intro)(screen_t *s, void (*)(screen_t*) ); + +/* private: */ + struct screen_data_t *data; +}; + + +screen_t *sobject_construct(const screen_t *c, size_t data_size); +void sobject_destroy(screen_t *); + +screen_t *screen_curses_construct(void); +screen_t *screen_djgpp2_construct(void); +screen_t *screen_vcsa_construct(void); + +void screen_show_frames(screen_t *); + + +#endif + +#endif /* already included */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..db50f56 --- /dev/null +++ b/src/util.c @@ -0,0 +1,681 @@ +/* util.c -- + + This file is part of the lzop file compressor. + + Copyright (C) 1996-2010 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + lzop and the LZO library are free software; you can redistribute them + and/or modify them 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. + + This program 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 this program; 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> + http://www.oberhumer.com/opensource/lzop/ + */ + + +#include "conf.h" + + +/************************************************************************* +// filename util +**************************************************************************/ + +static const char dir_sep[] = DIR_SEP; + +#define fn_is_sep(c) (strchr(dir_sep,c) != NULL) + +#if defined(DOSISH) +#define fn_is_drive(n) (n[0] && n[1] == ':') +#define fn_skip_drive(n) (fn_is_drive(n) ? (n) + 2 : (n)) +#else +#define fn_is_drive(n) (0) +#define fn_skip_drive(n) (n) +#endif + + +unsigned fn_baseindex(const char *name) +{ + const char *n, *nn; + + n = fn_skip_drive(name); + for (nn = n; *nn; nn++) + if (fn_is_sep(*nn)) + n = nn + 1; + return (unsigned) (n - name); +} + + +const char *fn_basename(const char *name) +{ + return name + fn_baseindex(name); +} + + +void fn_addslash(char *name, lzo_bool slash) +{ + char *p; + + name = fn_skip_drive(name); + p = name + strlen(name); + while (p > name && fn_is_sep(p[-1])) + *p-- = 0; + if (p > name) + { + if (slash) + *p++ = dir_sep[0]; + *p = 0; + } +} + + +char *fn_strlwr(char *n) +{ + char *p; + for (p = n; *p; p++) + *p = (char) fn_tolower(*p); + return n; +} + + +int fn_strcmp(const char *n1, const char *n2) +{ + for (;;) + { + if (*n1 != *n2) + { + int c = fn_tolower(*n1) - fn_tolower(*n2); + if (c) + return c; + } + if (*n1 == 0) + return 0; + n1++; n2++; + } +} + + +lzo_bool fn_is_same_file(const char *n1, const char *n2) +{ + /* very simple... */ + if (fn_strcmp(n1,n2) == 0) + return 1; + return 0; +} + + +int fn_has_suffix(const char *name) +{ + size_t l; + size_t s; + + name = fn_skip_drive(name); + l = strlen(name); + if (l > 4 && name[l-4] == '.') + { + if (strcasecmp(&name[l-3],"lzo") == 0) + return SUFF_LZO; + if (strcasecmp(&name[l-3],"nrv") == 0) + return SUFF_NRV; + if (strcasecmp(&name[l-3],"tar") == 0) + return SUFF_TAR; + if (strcasecmp(&name[l-3],"tnv") == 0) + return SUFF_TNV; + if (strcasecmp(&name[l-3],"tzo") == 0) + return SUFF_TZO; + } + + if (l > 5 && name[l-5] == '.') + { + if (strcasecmp(&name[l-4],"lzop") == 0) + return SUFF_LZOP; + } + + s = strlen(opt_suffix); + if (s > 0 && l > s) + { + if (strcasecmp(&name[l-s],opt_suffix) == 0) + return SUFF_USER; + } + + return SUFF_NONE; +} + + +int fn_cleanpath(const char *name, char *newname, size_t size, int flags) +{ + size_t l = 0; + size_t n = 0; + int slashes = 0; +#define add(x) if (l >= size) return -1; else newname[l++] = (x) + + name = fn_skip_drive(name); + while (*name && fn_is_sep(*name)) + name++; + while (name[n]) + { + size_t last_n; + assert(!fn_is_sep(name[n])); + last_n = n++; + while (name[n] && !fn_is_sep(name[n])) + n++; + if (n - last_n == 2 && name[n-2] == '.' && name[n-1] == '.') + { + if (flags & 1) + return -2; + while (l > 0) { + if (newname[--l] == '/') + { + --slashes; + break; + } + } + /* newname[l] = 0; printf("del %s\n", newname); */ + } + else if (n - last_n == 1 && name[n-1] == '.') + { + if (flags & 2) + return -3; + } + else + { + if (l > 0) + { ++slashes; add('/'); } + while (last_n < n) + { add(name[last_n++]); } + /* newname[l] = 0; printf("add %s\n", newname); */ + } + while (name[n] && fn_is_sep(name[n])) + n++; + } + add('\0'); + return slashes; +#undef add +} + + +/************************************************************************* +// time util +**************************************************************************/ + +time_t fix_time(time_t t) +{ + if (t == (time_t) -1) + t = 0; + return t; +} + +time_t get_mtime(const header_t *h) +{ + lzop_ulong_t t; + t = h->mtime_high; + t <<= 16; t <<= 16; + t |= h->mtime_low; + return t == (lzop_ulong_t)(time_t)t ? (time_t)t : (time_t)0; +} + + +#if defined(HAVE_LOCALTIME) +void tm2str(char *s, size_t size, const struct tm *tmp) +{ + assert(size >= 18); +#if defined(HAVE_SNPRINTF) + snprintf(s, size, "%04d-%02d-%02d %02d:%02d:%02d", +#else + sprintf(s, "%04d-%02d-%02d %02d:%02d:%02d", +#endif + (int) tmp->tm_year + 1900, (int) tmp->tm_mon + 1, + (int) tmp->tm_mday, + (int) tmp->tm_hour, (int) tmp->tm_min, (int) tmp->tm_sec); +} +#endif + + +void time2str(char *s, size_t size, const time_t *t) +{ +#if defined(HAVE_LOCALTIME) + tm2str(s, size, localtime(t)); +#elif defined(HAVE_CTIME) + const char *p = ctime(t); + assert(size >= 18); + memset(s, ' ', 16); + memcpy(s + 2, p + 4, 6); + memcpy(s + 11, p + 11, 5); + s[16] = 0; +#else + s[0] = 0; + UNUSED(size); +#endif +} + + +void time2ls(char *s, size_t size, const time_t *t) +{ +#if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME) + const char *fmt = "%b %e %Y"; +#if defined(HAVE_DIFFTIME) +# if (ACC_OS_DOS16) + /* do not introduce any floating point dependencies */ + long d = (long)current_time - (long)*t; +# else + const double d = difftime(current_time, *t); +# endif + if (d <= 6 * 30 * 24 * 3600L && d >= -3600L) + fmt = "%b %e %H:%M"; +#endif + assert(size >= 13); + if (strftime(s, 13, fmt, localtime(t)) == 13) + s[0] = 0; +#else + s[0] = 0; + UNUSED(size); + UNUSED(t); +#endif +} + + +/************************************************************************* +// +**************************************************************************/ + +lzo_bool file_exists(const char *name) +{ + int fd, r; + struct stat st; + + /* return true if we can open it */ + fd = open(name, O_RDONLY, 0); + if (fd >= 0) + { + (void) close(fd); + return 1; + } + + /* return true if we can stat it */ + r = stat(name, &st); + if (r != -1) + return 1; + + /* return true if we can lstat it */ +#if defined(HAVE_LSTAT) + r = lstat(name, &st); + if (r != -1) + return 1; +#endif + + return 0; +} + + +/************************************************************************* +// Some systems have very exotic mode values. +// Convert them to standard values for portable use in our header. +**************************************************************************/ + +lzo_uint32 fix_mode_for_header(lzo_uint32 mode) +{ + lzo_uint32 m = mode; + + if (mode == 0) + return 0; + + /* This function can only deal with S_ISREG and S_ISDIR modes. */ + assert(S_ISREG(mode) || S_ISDIR(mode)); + +#if defined(ACC_OS_TOS) && defined(__PUREC__) + m = 0444; + if (mode & S_IWRITE) + m |= 0200; + if (mode & S_IEXEC) + m |= 0111; + if (S_ISREG(mode)) + m |= 0100000 | 0400; + else if (S_ISDIR(mode)) + m |= 0040000 | 0700; +#elif defined(DOSISH) + m &= 0777; + if (S_ISREG(mode)) + m |= 0100000 | 0400; + else if (S_ISDIR(mode)) + m |= 0040000 | 0700; +#else + m &= 07777; + if (S_ISREG(mode)) + m |= 0100000; + else if (S_ISDIR(mode)) + m |= 0040000 | 0700; +#endif + + if ((m & 0777) == 0) + m |= (0644 & ~u_mask); + return m; +} + + +MODE_T fix_mode_for_chmod(lzo_uint32 mode) +{ + MODE_T m = (MODE_T) (mode & 07777); + if ((m & 0777) == 0) + m |= (MODE_T) (0644 & ~u_mask); + return m; +} + + +MODE_T fix_mode_for_ls(lzo_uint32 mode) +{ + MODE_T m = (MODE_T) mode; + if ((m & 0777) == 0) + m |= (MODE_T) (0644 & ~u_mask); + return m; +} + + +MODE_T fix_mode_for_open(MODE_T mode) +{ + MODE_T m = (MODE_T) (mode & 0666); +#if defined(ACC_OS_TOS) && defined(__PUREC__) + m = S_IWRITE | S_IREAD; +#else + if ((m & 0777) == 0) + m |= (MODE_T) (0644 & ~u_mask); + m |= 0600; +#endif + return m; +} + + +/************************************************************************* +// ls util - adapted from GNU fileutils 3.16 +**************************************************************************/ + +/* Return a character indicating the type of file described by + file mode BITS: + 'd' for directories + 'b' for block special files + 'c' for character special files + 'm' for multiplexor files + 'l' for symbolic links + 's' for sockets + 'p' for fifos + '-' for regular files + '?' for any other file type. */ + +static char ftypelet(unsigned mode) +{ + if (S_ISREG(mode)) return '-'; + if (S_ISDIR(mode)) return 'd'; +#ifdef S_ISBLK + if (S_ISBLK(mode)) return 'b'; +#endif +#ifdef S_ISCHR + if (S_ISCHR(mode)) return 'c'; +#endif +#ifdef S_ISFIFO + if (S_ISFIFO(mode)) return 'p'; +#endif +#ifdef S_ISLNK + if (S_ISLNK(mode)) return 'l'; +#endif +#ifdef S_ISSOCK + if (S_ISSOCK(mode)) return 's'; +#endif +#ifdef S_ISMPC + if (S_ISMPC(mode)) return 'm'; +#endif +#ifdef S_ISNWK + if (S_ISNWK(mode)) return 'n'; +#endif +#ifdef S_ISOFD + if (S_ISOFD(mode)) return 'M'; /* Cray migrated dmf file. */ +#endif +#ifdef S_ISOFL + if (S_ISOFL(mode)) return 'M'; /* Cray migrated dmf file. */ +#endif + return '?'; +} + + +/* Set the read, write, and execute flags. */ +static void set_rwx(unsigned mode, char *str) +{ + str[0] = (char) ((mode & 4) ? 'r' : '-'); + str[1] = (char) ((mode & 2) ? 'w' : '-'); + str[2] = (char) ((mode & 1) ? 'x' : '-'); +} + + +/* Set the 's' and 't' flags in file attributes string. */ +static void set_st(unsigned mode, char *str) +{ +#ifdef S_ISUID + if (mode & S_ISUID) + str[3] = (char) (str[3] == 'x' ? 's' : 'S'); +#endif +#ifdef S_ISGID + if (mode & S_ISGID) + str[6] = (char) (str[6] == 'x' ? 's' : 'S'); +#endif +#ifdef S_ISVTX + if (mode & S_ISVTX) + str[9] = (char) (str[9] == 'x' ? 't' : 'T'); +#endif + UNUSED(mode); + UNUSED(str); +} + + +void mode_string(MODE_T m, char *str) +{ + unsigned mode = (unsigned) m; + str[0] = ftypelet(mode); + set_rwx((mode & 0700) >> 6, &str[1]); + set_rwx((mode & 0070) >> 3, &str[4]); + set_rwx((mode & 0007) >> 0, &str[7]); + set_st(mode, str); +} + + +/************************************************************************* +// adapted from the djgpp port of cpio 2.4.2 by Eli Zaretskii +**************************************************************************/ + +#if defined(DOSISH) + +/* If the original file name includes characters illegal for MS-DOS and + MS-Windows, massage it to make it suitable and return a pointer to + static storage with a new name. If the original name is legit, + return it instead. Return NULL if the rename failed (shouldn't happen). + + The file name changes are: (1) any name that is reserved by a DOS + device driver (such as 'prn.txt' or 'aux.c') is prepended with a '_'; + and (2) illegal characters are replaced with '_' or '-' (well, almost; + look at the code below for details). */ + +#define is_slash(x) fn_is_sep(x) + +char *maybe_rename_file(const char *original_name) +{ + static char dosified_name[PATH_MAX+1]; + static const char illegal_chars_dos[] = ".+, ;=[]|<>\":?*"; + const char *illegal_chars = illegal_chars_dos; + int idx, dot_idx; + const char *s = original_name; + char *d = dosified_name; + + /* Support for Win32 VFAT systems, when available. */ +#if defined(__DJGPP__) + if (_use_lfn(original_name)) + illegal_chars = illegal_chars_dos + 8; +#elif (ACC_OS_WIN32 || ACC_OS_WIN64 || ACC_OS_CYGWIN) + illegal_chars = illegal_chars_dos + 8; +#endif + + /* Get past the drive letter, if any. */ + if (fn_is_drive(s)) + { + *d++ = *s++; + *d++ = *s++; + } + + for (idx = 0, dot_idx = -1; *s; s++, d++) + { + if (strchr(illegal_chars, *s)) + { + /* Dots are special on DOS: it doesn't allow them as the leading + character, and a file name cannot have more than a single dot. + We leave the first non-leading dot alone, unless it comes too + close to the beginning of the name: we want sh.lex.c to become + sh_lex.c, not sh.lex-c. */ + if (*s == '.') + { + if (idx == 0 + && (is_slash(s[1]) || s[1] == '\0' + || (s[1] == '.' && (is_slash(s[2]) || s[2] == '\0')))) + { + /* Copy "./" and "../" verbatim. */ + *d++ = *s++; + if (*s == '.') + *d++ = *s++; + *d = *s; + } + else if (idx == 0) + *d = '_'; + else if (dot_idx >= 0) + { + if (dot_idx < 5) /* 5 is merely a heuristic ad-hoc'ery */ + { + d[dot_idx - idx] = '_'; /* replace previous dot */ + *d = '.'; + } + else + *d = '-'; + } + else + *d = '.'; + + if (*s == '.') + dot_idx = idx; + } + else if (*s == '+' && s[1] == '+') + { + if (idx - 2 == dot_idx) /* .c++, .h++ etc. */ + { + *d++ = 'x'; + *d = 'x'; + } + else + { + /* libg++ etc. */ + memcpy (d, "plus", 4); + d += 3; + } + s++; + idx++; + } + else + *d = '_'; + } + else + *d = *s; + if (is_slash(*s)) + { + idx = 0; + dot_idx = -1; + } + else + idx++; + } + + *d = '\0'; + +#if defined(S_ISCHR) + /* We could have a file in an archive whose name is reserved + on MS-DOS by a device driver. Trying to extract such a + file would fail at best and wedge us at worst. We need to + rename such files. */ + + if (idx > 0) + { + struct stat st_buf; + char *base = d - idx; + int i = 0; + + /* The list of character devices is not constant: it depends on + what device drivers did they install in their CONFIG.SYS. + 'stat' will tell us if the basename of the file name is a + characer device. */ + while (stat(base, &st_buf) == 0 && S_ISCHR(st_buf.st_mode)) + { + size_t blen = strlen(base); + + /* I don't believe any DOS character device names begin with a + '_'. But in case they invent such a device, let us try twice. */ + if (++i > 2) + return (char *)0; + + /* Prepend a '_'. */ + memmove(base + 1, base, blen + 1); + base[0] = '_'; + } + } +#endif + + return dosified_name; +} + +#endif /* DOSISH */ + + +/************************************************************************* +// +**************************************************************************/ + +#if (ACC_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1200)) + /* avoid '-W4' warnings in <windows.h> */ +# pragma warning(disable: 4201 4214 4514) +#endif +#if (ACC_CC_MSC && (_MSC_VER >= 1300)) + /* avoid '-Wall' warnings in <windows.h> */ +# pragma warning(disable: 4255) +#endif + +#define ACC_WANT_ACC_INCI_H 1 +#define ACC_WANT_ACCLIB_GETOPT 1 +#define ACC_WANT_ACCLIB_HALLOC 1 +#define ACC_WANT_ACCLIB_HMEMCPY 1 +#define ACC_WANT_ACCLIB_HSREAD 1 +#define ACC_WANT_ACCLIB_MISC 1 +#define ACC_WANT_ACCLIB_WILDARGV 1 +#if (ACC_HAVE_MM_HUGE_PTR) +# define ACC_WANT_ACCLIB_HREAD 1 +#endif +#include "miniacc.h" +#undef ACC_WANT_ACC_INCI_H +#undef ACC_WANT_ACCLIB_HALLOC +#undef ACC_WANT_ACCLIB_MISC +#undef ACC_WANT_ACCLIB_WILDARGV +#undef ACC_WANT_ACCLIB_HREAD + +#if (__ACCLIB_REQUIRE_HMEMCPY_CH) && !defined(__ACCLIB_HMEMCPY_CH_INCLUDED) +# define ACC_WANT_ACCLIB_HMEMCPY 1 +# include "acc/acclib/hmemcpy.ch" +# undef ACC_WANT_ACCLIB_HMEMCPY +#endif + + +/* +vi:ts=4:et +*/ + diff --git a/src/version.h b/src/version.h new file mode 100644 index 0000000..d8457b0 --- /dev/null +++ b/src/version.h @@ -0,0 +1,3 @@ +#define LZOP_VERSION 0x1030 +#define LZOP_VERSION_STRING "1.03" +#define LZOP_VERSION_DATE "Nov 1st 2010" |