summaryrefslogtreecommitdiff
path: root/Build/source/utils/lzma-utils/src/lzma
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-01-06 16:16:41 +0000
committerNorbert Preining <preining@logic.at>2008-01-06 16:16:41 +0000
commit6c31deb575708d803d45bd824f6e947d69ff7b34 (patch)
treecae988d97939a193eaae9b776f4e8849823261be /Build/source/utils/lzma-utils/src/lzma
parent671de1e35391acc8a31f65bae5fb6f0bba7e3260 (diff)
add new lzma-utils 4.32.4
git-svn-id: svn://tug.org/texlive/trunk@6053 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/lzma-utils/src/lzma')
-rw-r--r--Build/source/utils/lzma-utils/src/lzma/Exception.h45
-rw-r--r--Build/source/utils/lzma-utils/src/lzma/Makefile.am54
-rw-r--r--Build/source/utils/lzma-utils/src/lzma/Makefile.in692
-rw-r--r--Build/source/utils/lzma-utils/src/lzma/getopt.c1191
-rw-r--r--Build/source/utils/lzma-utils/src/lzma/getopt1.c171
-rw-r--r--Build/source/utils/lzma-utils/src/lzma/getopt_.h226
-rw-r--r--Build/source/utils/lzma-utils/src/lzma/getopt_int.h131
-rw-r--r--Build/source/utils/lzma-utils/src/lzma/gettext.h240
-rw-r--r--Build/source/utils/lzma-utils/src/lzma/lzma.1228
-rw-r--r--Build/source/utils/lzma-utils/src/lzma/lzmp.cpp983
10 files changed, 3961 insertions, 0 deletions
diff --git a/Build/source/utils/lzma-utils/src/lzma/Exception.h b/Build/source/utils/lzma-utils/src/lzma/Exception.h
new file mode 100644
index 00000000000..6bae26f8b90
--- /dev/null
+++ b/Build/source/utils/lzma-utils/src/lzma/Exception.h
@@ -0,0 +1,45 @@
+/* A couple of exceptions for lzmp.
+ *
+ * Copyright (C) 2005 Ville Koskinen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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.
+ */
+
+#ifndef _EXCEPTION_H_
+#define _EXCEPTION_H_
+
+#include <string>
+using std::string;
+
+class Exception
+{
+private:
+ string message;
+public:
+ Exception(char *what): message(what) { }
+ Exception(string what): message(what) { }
+
+ ~Exception() { }
+
+ string what(void) { return message; }
+};
+
+class ArgumentException: public Exception
+{
+public:
+ ArgumentException(char *what): Exception(what) { }
+ ArgumentException(string what): Exception(what) { }
+
+ ~ArgumentException() { }
+};
+
+#endif
+
diff --git a/Build/source/utils/lzma-utils/src/lzma/Makefile.am b/Build/source/utils/lzma-utils/src/lzma/Makefile.am
new file mode 100644
index 00000000000..52bc68ffb6a
--- /dev/null
+++ b/Build/source/utils/lzma-utils/src/lzma/Makefile.am
@@ -0,0 +1,54 @@
+AM_CPPFLAGS = @SDK_CXXFLAGS@ -I@top_srcdir@/src/sdk -I@top_srcdir@/src/sdk/7zip
+
+# Avoid dependency on libstdc++:
+#AM_LDFLAGS = -lsupc++ -static-libgcc
+
+bin_PROGRAMS = lzma
+
+lzma_SOURCES = lzmp.cpp Exception.h \
+ @top_srcdir@/src/sdk/Common/C_FileIO.cpp \
+ @top_srcdir@/src/sdk/Common/CRC.cpp \
+ @top_srcdir@/src/sdk/Common/Alloc.cpp \
+ @top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp \
+ @top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp \
+ @top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp
+
+lzma_LDADD = @top_builddir@/src/sdk/7zip/Compress/LZMA/libLZMA.a \
+ @top_builddir@/src/sdk/7zip/Compress/LZ/libLZ.a \
+ @top_builddir@/src/sdk/7zip/Common/libCommon.a \
+ @top_builddir@/src/sdk/7zip/Compress/RangeCoder/libRangeCoder.a
+
+dist_man_MANS = lzma.1
+
+# Create symlinks for unlzma and lzcat:
+install-exec-hook:
+ cd $(DESTDIR)$(bindir) && \
+ rm -f unlzma lzcat && \
+ $(LN_S) lzma unlzma && \
+ $(LN_S) lzma lzcat
+
+install-data-hook:
+ cd $(DESTDIR)$(mandir)/man1 && \
+ rm -f unlzma.1 lzcat.1 && \
+ $(LN_S) lzma.1 unlzma.1 && \
+ $(LN_S) lzma.1 lzcat.1
+
+uninstall-hook:
+ cd $(DESTDIR)$(bindir) && \
+ rm -f unlzma lzcat
+ cd $(DESTDIR)$(mandir)/man1 && \
+ rm -f unlzma.1 lzcat.1
+
+# For getopt_long() replacement:
+lzma_DEPENDENCIES = $(LIBOBJS)
+lzma_LDADD += $(LIBOBJS)
+
+EXTRA_DIST = gettext.h getopt_.h getopt.c getopt1.c getopt_int.h
+BUILT_SOURCES = $(GETOPT_H)
+MOSTLYCLEANFILES = getopt.h getopt.h-t
+
+getopt.h: getopt_.h
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/getopt_.h; \
+ } > $@-t
+ mv -f $@-t $@
diff --git a/Build/source/utils/lzma-utils/src/lzma/Makefile.in b/Build/source/utils/lzma-utils/src/lzma/Makefile.in
new file mode 100644
index 00000000000..cc8c83ea277
--- /dev/null
+++ b/Build/source/utils/lzma-utils/src/lzma/Makefile.in
@@ -0,0 +1,692 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006 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@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@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@
+bin_PROGRAMS = lzma$(EXEEXT)
+subdir = src/lzma
+DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in getopt.c getopt1.c
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/getopt.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_lzma_OBJECTS = lzmp.$(OBJEXT) C_FileIO.$(OBJEXT) CRC.$(OBJEXT) \
+ Alloc.$(OBJEXT) FileStreams.$(OBJEXT) InBuffer.$(OBJEXT) \
+ OutBuffer.$(OBJEXT)
+lzma_OBJECTS = $(am_lzma_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(lzma_SOURCES)
+DIST_SOURCES = $(lzma_SOURCES)
+man1dir = $(mandir)/man1
+NROFF = nroff
+MANS = $(dist_man_MANS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GETOPT_H = @GETOPT_H@
+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@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+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_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SDK_CFLAGS = @SDK_CFLAGS@
+SDK_CXXFLAGS = @SDK_CXXFLAGS@
+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@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+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@
+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_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = @SDK_CXXFLAGS@ -I@top_srcdir@/src/sdk -I@top_srcdir@/src/sdk/7zip
+lzma_SOURCES = lzmp.cpp Exception.h \
+ @top_srcdir@/src/sdk/Common/C_FileIO.cpp \
+ @top_srcdir@/src/sdk/Common/CRC.cpp \
+ @top_srcdir@/src/sdk/Common/Alloc.cpp \
+ @top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp \
+ @top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp \
+ @top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp
+
+lzma_LDADD = @top_builddir@/src/sdk/7zip/Compress/LZMA/libLZMA.a \
+ @top_builddir@/src/sdk/7zip/Compress/LZ/libLZ.a \
+ @top_builddir@/src/sdk/7zip/Common/libCommon.a \
+ @top_builddir@/src/sdk/7zip/Compress/RangeCoder/libRangeCoder.a \
+ $(LIBOBJS)
+dist_man_MANS = lzma.1
+
+# For getopt_long() replacement:
+lzma_DEPENDENCIES = $(LIBOBJS)
+EXTRA_DIST = gettext.h getopt_.h getopt.c getopt1.c getopt_int.h
+BUILT_SOURCES = $(GETOPT_H)
+MOSTLYCLEANFILES = getopt.h getopt.h-t
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/lzma/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/lzma/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: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+lzma$(EXEEXT): $(lzma_OBJECTS) $(lzma_DEPENDENCIES)
+ @rm -f lzma$(EXEEXT)
+ $(CXXLINK) $(lzma_OBJECTS) $(lzma_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Alloc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CRC.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/C_FileIO.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileStreams.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InBuffer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OutBuffer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzmp.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+C_FileIO.o: @top_srcdir@/src/sdk/Common/C_FileIO.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT C_FileIO.o -MD -MP -MF $(DEPDIR)/C_FileIO.Tpo -c -o C_FileIO.o `test -f '@top_srcdir@/src/sdk/Common/C_FileIO.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/Common/C_FileIO.cpp
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/C_FileIO.Tpo $(DEPDIR)/C_FileIO.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/Common/C_FileIO.cpp' object='C_FileIO.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o C_FileIO.o `test -f '@top_srcdir@/src/sdk/Common/C_FileIO.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/Common/C_FileIO.cpp
+
+C_FileIO.obj: @top_srcdir@/src/sdk/Common/C_FileIO.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT C_FileIO.obj -MD -MP -MF $(DEPDIR)/C_FileIO.Tpo -c -o C_FileIO.obj `if test -f '@top_srcdir@/src/sdk/Common/C_FileIO.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/Common/C_FileIO.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/Common/C_FileIO.cpp'; fi`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/C_FileIO.Tpo $(DEPDIR)/C_FileIO.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/Common/C_FileIO.cpp' object='C_FileIO.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o C_FileIO.obj `if test -f '@top_srcdir@/src/sdk/Common/C_FileIO.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/Common/C_FileIO.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/Common/C_FileIO.cpp'; fi`
+
+CRC.o: @top_srcdir@/src/sdk/Common/CRC.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CRC.o -MD -MP -MF $(DEPDIR)/CRC.Tpo -c -o CRC.o `test -f '@top_srcdir@/src/sdk/Common/CRC.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/Common/CRC.cpp
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/CRC.Tpo $(DEPDIR)/CRC.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/Common/CRC.cpp' object='CRC.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CRC.o `test -f '@top_srcdir@/src/sdk/Common/CRC.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/Common/CRC.cpp
+
+CRC.obj: @top_srcdir@/src/sdk/Common/CRC.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CRC.obj -MD -MP -MF $(DEPDIR)/CRC.Tpo -c -o CRC.obj `if test -f '@top_srcdir@/src/sdk/Common/CRC.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/Common/CRC.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/Common/CRC.cpp'; fi`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/CRC.Tpo $(DEPDIR)/CRC.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/Common/CRC.cpp' object='CRC.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CRC.obj `if test -f '@top_srcdir@/src/sdk/Common/CRC.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/Common/CRC.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/Common/CRC.cpp'; fi`
+
+Alloc.o: @top_srcdir@/src/sdk/Common/Alloc.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Alloc.o -MD -MP -MF $(DEPDIR)/Alloc.Tpo -c -o Alloc.o `test -f '@top_srcdir@/src/sdk/Common/Alloc.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/Common/Alloc.cpp
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/Alloc.Tpo $(DEPDIR)/Alloc.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/Common/Alloc.cpp' object='Alloc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Alloc.o `test -f '@top_srcdir@/src/sdk/Common/Alloc.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/Common/Alloc.cpp
+
+Alloc.obj: @top_srcdir@/src/sdk/Common/Alloc.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Alloc.obj -MD -MP -MF $(DEPDIR)/Alloc.Tpo -c -o Alloc.obj `if test -f '@top_srcdir@/src/sdk/Common/Alloc.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/Common/Alloc.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/Common/Alloc.cpp'; fi`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/Alloc.Tpo $(DEPDIR)/Alloc.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/Common/Alloc.cpp' object='Alloc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Alloc.obj `if test -f '@top_srcdir@/src/sdk/Common/Alloc.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/Common/Alloc.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/Common/Alloc.cpp'; fi`
+
+FileStreams.o: @top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT FileStreams.o -MD -MP -MF $(DEPDIR)/FileStreams.Tpo -c -o FileStreams.o `test -f '@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/FileStreams.Tpo $(DEPDIR)/FileStreams.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp' object='FileStreams.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o FileStreams.o `test -f '@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp
+
+FileStreams.obj: @top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT FileStreams.obj -MD -MP -MF $(DEPDIR)/FileStreams.Tpo -c -o FileStreams.obj `if test -f '@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp'; fi`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/FileStreams.Tpo $(DEPDIR)/FileStreams.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp' object='FileStreams.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o FileStreams.obj `if test -f '@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/7zip/Common/FileStreams.cpp'; fi`
+
+InBuffer.o: @top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT InBuffer.o -MD -MP -MF $(DEPDIR)/InBuffer.Tpo -c -o InBuffer.o `test -f '@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/InBuffer.Tpo $(DEPDIR)/InBuffer.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp' object='InBuffer.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o InBuffer.o `test -f '@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp
+
+InBuffer.obj: @top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT InBuffer.obj -MD -MP -MF $(DEPDIR)/InBuffer.Tpo -c -o InBuffer.obj `if test -f '@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp'; fi`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/InBuffer.Tpo $(DEPDIR)/InBuffer.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp' object='InBuffer.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o InBuffer.obj `if test -f '@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/7zip/Common/InBuffer.cpp'; fi`
+
+OutBuffer.o: @top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT OutBuffer.o -MD -MP -MF $(DEPDIR)/OutBuffer.Tpo -c -o OutBuffer.o `test -f '@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/OutBuffer.Tpo $(DEPDIR)/OutBuffer.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp' object='OutBuffer.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o OutBuffer.o `test -f '@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp' || echo '$(srcdir)/'`@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp
+
+OutBuffer.obj: @top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT OutBuffer.obj -MD -MP -MF $(DEPDIR)/OutBuffer.Tpo -c -o OutBuffer.obj `if test -f '@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp'; fi`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/OutBuffer.Tpo $(DEPDIR)/OutBuffer.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp' object='OutBuffer.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o OutBuffer.obj `if test -f '@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp'; then $(CYGPATH_W) '@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp'; else $(CYGPATH_W) '$(srcdir)/@top_srcdir@/src/sdk/7zip/Common/OutBuffer.cpp'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-man1: $(man1_MANS) $(man_MANS)
+ @$(NORMAL_INSTALL)
+ test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+ @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
+ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+ for i in $$l2; do \
+ case "$$i" in \
+ *.1*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
+ else file=$$i; fi; \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ case "$$ext" in \
+ 1*) ;; \
+ *) ext='1' ;; \
+ esac; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed -e 's/^.*\///'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
+ done
+uninstall-man1:
+ @$(NORMAL_UNINSTALL)
+ @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
+ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+ for i in $$l2; do \
+ case "$$i" in \
+ *.1*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ case "$$ext" in \
+ 1*) ;; \
+ *) ext='1' ;; \
+ esac; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed -e 's/^.*\///'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
+ rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ 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 $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(PROGRAMS) $(MANS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) 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:
+ -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf $(DEPDIR) ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+ @$(NORMAL_INSTALL)
+ $(MAKE) $(AM_MAKEFLAGS) install-data-hook
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+ @$(NORMAL_INSTALL)
+ $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man: install-man1
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf $(DEPDIR) ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-man
+ @$(NORMAL_INSTALL)
+ $(MAKE) $(AM_MAKEFLAGS) uninstall-hook
+
+uninstall-man: uninstall-man1
+
+.MAKE: install-am install-data-am install-exec-am install-strip \
+ uninstall-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-binPROGRAMS install-data install-data-am \
+ install-data-hook install-dvi install-dvi-am install-exec \
+ install-exec-am install-exec-hook install-html install-html-am \
+ install-info install-info-am install-man install-man1 \
+ 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 mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-binPROGRAMS uninstall-hook uninstall-man \
+ uninstall-man1
+
+
+# Create symlinks for unlzma and lzcat:
+install-exec-hook:
+ cd $(DESTDIR)$(bindir) && \
+ rm -f unlzma lzcat && \
+ $(LN_S) lzma unlzma && \
+ $(LN_S) lzma lzcat
+
+install-data-hook:
+ cd $(DESTDIR)$(mandir)/man1 && \
+ rm -f unlzma.1 lzcat.1 && \
+ $(LN_S) lzma.1 unlzma.1 && \
+ $(LN_S) lzma.1 lzcat.1
+
+uninstall-hook:
+ cd $(DESTDIR)$(bindir) && \
+ rm -f unlzma lzcat
+ cd $(DESTDIR)$(mandir)/man1 && \
+ rm -f unlzma.1 lzcat.1
+
+getopt.h: getopt_.h
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/getopt_.h; \
+ } > $@-t
+ mv -f $@-t $@
+# 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/Build/source/utils/lzma-utils/src/lzma/getopt.c b/Build/source/utils/lzma-utils/src/lzma/getopt.c
new file mode 100644
index 00000000000..3580ad825c6
--- /dev/null
+++ b/Build/source/utils/lzma-utils/src/lzma/getopt.c
@@ -0,0 +1,1191 @@
+/* Getopt for GNU.
+ NOTE: getopt is now part of the C library, so if you don't know what
+ "Keep this file name-space clean" means, talk to drepper@gnu.org
+ before changing it!
+ Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+#include "getopt.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef __VMS
+# include <unixlib.h>
+#endif
+
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "gettext.h"
+# define _(msgid) gettext (msgid)
+#endif
+
+#if defined _LIBC && defined USE_IN_LIBIO
+# include <wchar.h>
+#endif
+
+#ifndef attribute_hidden
+# define attribute_hidden
+#endif
+
+/* Unlike standard Unix `getopt', functions like `getopt_long'
+ let the user intersperse the options with the other arguments.
+
+ As `getopt_long' works, it permutes the elements of ARGV so that,
+ when it is done, all the options precede everything else. Thus
+ all application programs are extended to handle flexible argument order.
+
+ Using `getopt' or setting the environment variable POSIXLY_CORRECT
+ disables permutation.
+ Then the application's behavior is completely standard.
+
+ GNU application programs can use a third alternative mode in which
+ they can distinguish the relative order of options and other arguments. */
+
+#include "getopt_int.h"
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+/* 1003.2 says this must be 1 before any call. */
+int optind = 1;
+
+/* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+ This must be initialized on some systems to avoid linking in the
+ system's own getopt implementation. */
+
+int optopt = '?';
+
+/* Keep a global copy of all internal members of getopt_data. */
+
+static struct _getopt_data getopt_data;
+
+
+#if defined HAVE_DECL_GETENV && !HAVE_DECL_GETENV
+extern char *getenv ();
+#endif
+
+#ifdef _LIBC
+/* Stored original parameters.
+ XXX This is no good solution. We should rather copy the args so
+ that we can compare them later. But we must not use malloc(3). */
+extern int __libc_argc;
+extern char **__libc_argv;
+
+/* Bash 2.0 gives us an environment variable containing flags
+ indicating ARGV elements that should not be considered arguments. */
+
+# ifdef USE_NONOPTION_FLAGS
+/* Defined in getopt_init.c */
+extern char *__getopt_nonoption_flags;
+# endif
+
+# ifdef USE_NONOPTION_FLAGS
+# define SWAP_FLAGS(ch1, ch2) \
+ if (d->__nonoption_flags_len > 0) \
+ { \
+ char __tmp = __getopt_nonoption_flags[ch1]; \
+ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
+ __getopt_nonoption_flags[ch2] = __tmp; \
+ }
+# else
+# define SWAP_FLAGS(ch1, ch2)
+# endif
+#else /* !_LIBC */
+# define SWAP_FLAGS(ch1, ch2)
+#endif /* _LIBC */
+
+/* Exchange two adjacent subsequences of ARGV.
+ One subsequence is elements [first_nonopt,last_nonopt)
+ which contains all the non-options that have been skipped so far.
+ The other is elements [last_nonopt,optind), which contains all
+ the options processed since those non-options were skipped.
+
+ `first_nonopt' and `last_nonopt' are relocated so that they describe
+ the new indices of the non-options in ARGV after they are moved. */
+
+static void
+exchange (char **argv, struct _getopt_data *d)
+{
+ int bottom = d->__first_nonopt;
+ int middle = d->__last_nonopt;
+ int top = d->optind;
+ char *tem;
+
+ /* Exchange the shorter segment with the far end of the longer segment.
+ That puts the shorter segment into the right place.
+ It leaves the longer segment in the right place overall,
+ but it consists of two parts that need to be swapped next. */
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+ /* First make sure the handling of the `__getopt_nonoption_flags'
+ string can work normally. Our top argument must be in the range
+ of the string. */
+ if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
+ {
+ /* We must extend the array. The user plays games with us and
+ presents new arguments. */
+ char *new_str = malloc (top + 1);
+ if (new_str == NULL)
+ d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
+ else
+ {
+ memset (__mempcpy (new_str, __getopt_nonoption_flags,
+ d->__nonoption_flags_max_len),
+ '\0', top + 1 - d->__nonoption_flags_max_len);
+ d->__nonoption_flags_max_len = top + 1;
+ __getopt_nonoption_flags = new_str;
+ }
+ }
+#endif
+
+ while (top > middle && middle > bottom)
+ {
+ if (top - middle > middle - bottom)
+ {
+ /* Bottom segment is the short one. */
+ int len = middle - bottom;
+ register int i;
+
+ /* Swap it with the top part of the top segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[top - (middle - bottom) + i];
+ argv[top - (middle - bottom) + i] = tem;
+ SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
+ }
+ /* Exclude the moved bottom segment from further swapping. */
+ top -= len;
+ }
+ else
+ {
+ /* Top segment is the short one. */
+ int len = top - middle;
+ register int i;
+
+ /* Swap it with the bottom part of the bottom segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ SWAP_FLAGS (bottom + i, middle + i);
+ }
+ /* Exclude the moved top segment from further swapping. */
+ bottom += len;
+ }
+ }
+
+ /* Update records for the slots the non-options now occupy. */
+
+ d->__first_nonopt += (d->optind - d->__last_nonopt);
+ d->__last_nonopt = d->optind;
+}
+
+/* Initialize the internal data when the first call is made. */
+
+static const char *
+_getopt_initialize (int argc, char **argv, const char *optstring,
+ int posixly_correct, struct _getopt_data *d)
+{
+ /* Start processing options with ARGV-element 1 (since ARGV-element 0
+ is the program name); the sequence of previously skipped
+ non-option ARGV-elements is empty. */
+
+ d->__first_nonopt = d->__last_nonopt = d->optind;
+
+ d->__nextchar = NULL;
+
+ d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT");
+
+ /* Determine how to handle the ordering of options and nonoptions. */
+
+ if (optstring[0] == '-')
+ {
+ d->__ordering = RETURN_IN_ORDER;
+ ++optstring;
+ }
+ else if (optstring[0] == '+')
+ {
+ d->__ordering = REQUIRE_ORDER;
+ ++optstring;
+ }
+ else if (d->__posixly_correct)
+ d->__ordering = REQUIRE_ORDER;
+ else
+ d->__ordering = PERMUTE;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+ if (!d->__posixly_correct
+ && argc == __libc_argc && argv == __libc_argv)
+ {
+ if (d->__nonoption_flags_max_len == 0)
+ {
+ if (__getopt_nonoption_flags == NULL
+ || __getopt_nonoption_flags[0] == '\0')
+ d->__nonoption_flags_max_len = -1;
+ else
+ {
+ const char *orig_str = __getopt_nonoption_flags;
+ int len = d->__nonoption_flags_max_len = strlen (orig_str);
+ if (d->__nonoption_flags_max_len < argc)
+ d->__nonoption_flags_max_len = argc;
+ __getopt_nonoption_flags =
+ (char *) malloc (d->__nonoption_flags_max_len);
+ if (__getopt_nonoption_flags == NULL)
+ d->__nonoption_flags_max_len = -1;
+ else
+ memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
+ '\0', d->__nonoption_flags_max_len - len);
+ }
+ }
+ d->__nonoption_flags_len = d->__nonoption_flags_max_len;
+ }
+ else
+ d->__nonoption_flags_len = 0;
+#endif
+
+ return optstring;
+}
+
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+ given in OPTSTRING.
+
+ If an element of ARGV starts with '-', and is not exactly "-" or "--",
+ then it is an option element. The characters of this element
+ (aside from the initial '-') are option characters. If `getopt'
+ is called repeatedly, it returns successively each of the option characters
+ from each of the option elements.
+
+ If `getopt' finds another option character, it returns that character,
+ updating `optind' and `nextchar' so that the next call to `getopt' can
+ resume the scan with the following option character or ARGV-element.
+
+ If there are no more option characters, `getopt' returns -1.
+ Then `optind' is the index in ARGV of the first ARGV-element
+ that is not an option. (The ARGV-elements have been permuted
+ so that those that are not options now come last.)
+
+ OPTSTRING is a string containing the legitimate option characters.
+ If an option character is seen that is not listed in OPTSTRING,
+ return '?' after printing an error message. If you set `opterr' to
+ zero, the error message is suppressed but we still return '?'.
+
+ If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+ so the following text in the same ARGV-element, or the text of the following
+ ARGV-element, is returned in `optarg'. Two colons mean an option that
+ wants an optional arg; if there is text in the current ARGV-element,
+ it is returned in `optarg', otherwise `optarg' is set to zero.
+
+ If OPTSTRING starts with `-' or `+', it requests different methods of
+ handling the non-option ARGV-elements.
+ See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
+ Long-named options begin with `--' instead of `-'.
+ Their names may be abbreviated as long as the abbreviation is unique
+ or is an exact match for some defined option. If they have an
+ argument, it follows the option name in the same ARGV-element, separated
+ from the option name by a `=', or else the in next ARGV-element.
+ When `getopt' finds a long-named option, it returns 0 if that option's
+ `flag' field is nonzero, the value of the option's `val' field
+ if the `flag' field is zero.
+
+ LONGOPTS is a vector of `struct option' terminated by an
+ element containing a name which is zero.
+
+ LONGIND returns the index in LONGOPT of the long-named option found.
+ It is only valid when a long-named option has been found by the most
+ recent call.
+
+ If LONG_ONLY is nonzero, '-' as well as '--' can introduce
+ long-named options.
+
+ If POSIXLY_CORRECT is nonzero, behave as if the POSIXLY_CORRECT
+ environment variable were set. */
+
+int
+_getopt_internal_r (int argc, char **argv, const char *optstring,
+ const struct option *longopts, int *longind,
+ int long_only, int posixly_correct, struct _getopt_data *d)
+{
+ int print_errors = d->opterr;
+ if (optstring[0] == ':')
+ print_errors = 0;
+
+ if (argc < 1)
+ return -1;
+
+ d->optarg = NULL;
+
+ if (d->optind == 0 || !d->__initialized)
+ {
+ if (d->optind == 0)
+ d->optind = 1; /* Don't scan ARGV[0], the program name. */
+ optstring = _getopt_initialize (argc, argv, optstring,
+ posixly_correct, d);
+ d->__initialized = 1;
+ }
+
+ /* Test whether ARGV[optind] points to a non-option argument.
+ Either it does not have option syntax, or there is an environment flag
+ from the shell indicating it is not an option. The later information
+ is only used when the used in the GNU libc. */
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \
+ || (d->optind < d->__nonoption_flags_len \
+ && __getopt_nonoption_flags[d->optind] == '1'))
+#else
+# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
+#endif
+
+ if (d->__nextchar == NULL || *d->__nextchar == '\0')
+ {
+ /* Advance to the next ARGV-element. */
+
+ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+ moved back by the user (who may also have changed the arguments). */
+ if (d->__last_nonopt > d->optind)
+ d->__last_nonopt = d->optind;
+ if (d->__first_nonopt > d->optind)
+ d->__first_nonopt = d->optind;
+
+ if (d->__ordering == PERMUTE)
+ {
+ /* If we have just processed some options following some non-options,
+ exchange them so that the options come first. */
+
+ if (d->__first_nonopt != d->__last_nonopt
+ && d->__last_nonopt != d->optind)
+ exchange ((char **) argv, d);
+ else if (d->__last_nonopt != d->optind)
+ d->__first_nonopt = d->optind;
+
+ /* Skip any additional non-options
+ and extend the range of non-options previously skipped. */
+
+ while (d->optind < argc && NONOPTION_P)
+ d->optind++;
+ d->__last_nonopt = d->optind;
+ }
+
+ /* The special ARGV-element `--' means premature end of options.
+ Skip it like a null option,
+ then exchange with previous non-options as if it were an option,
+ then skip everything else like a non-option. */
+
+ if (d->optind != argc && !strcmp (argv[d->optind], "--"))
+ {
+ d->optind++;
+
+ if (d->__first_nonopt != d->__last_nonopt
+ && d->__last_nonopt != d->optind)
+ exchange ((char **) argv, d);
+ else if (d->__first_nonopt == d->__last_nonopt)
+ d->__first_nonopt = d->optind;
+ d->__last_nonopt = argc;
+
+ d->optind = argc;
+ }
+
+ /* If we have done all the ARGV-elements, stop the scan
+ and back over any non-options that we skipped and permuted. */
+
+ if (d->optind == argc)
+ {
+ /* Set the next-arg-index to point at the non-options
+ that we previously skipped, so the caller will digest them. */
+ if (d->__first_nonopt != d->__last_nonopt)
+ d->optind = d->__first_nonopt;
+ return -1;
+ }
+
+ /* If we have come to a non-option and did not permute it,
+ either stop the scan or describe it to the caller and pass it by. */
+
+ if (NONOPTION_P)
+ {
+ if (d->__ordering == REQUIRE_ORDER)
+ return -1;
+ d->optarg = argv[d->optind++];
+ return 1;
+ }
+
+ /* We have found another option-ARGV-element.
+ Skip the initial punctuation. */
+
+ d->__nextchar = (argv[d->optind] + 1
+ + (longopts != NULL && argv[d->optind][1] == '-'));
+ }
+
+ /* Decode the current option-ARGV-element. */
+
+ /* Check whether the ARGV-element is a long option.
+
+ If long_only and the ARGV-element has the form "-f", where f is
+ a valid short option, don't consider it an abbreviated form of
+ a long option that starts with f. Otherwise there would be no
+ way to give the -f short option.
+
+ On the other hand, if there's a long option "fubar" and
+ the ARGV-element is "-fu", do consider that an abbreviation of
+ the long option, just like "--fu", and not "-f" with arg "u".
+
+ This distinction seems to be the most useful approach. */
+
+ if (longopts != NULL
+ && (argv[d->optind][1] == '-'
+ || (long_only && (argv[d->optind][2]
+ || !strchr (optstring, argv[d->optind][1])))))
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = -1;
+ int option_index;
+
+ for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
+ /* Do nothing. */ ;
+
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
+ {
+ if ((unsigned int) (nameend - d->__nextchar)
+ == (unsigned int) strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else if (long_only
+ || pfound->has_arg != p->has_arg
+ || pfound->flag != p->flag
+ || pfound->val != p->val)
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+
+ if (ambig && !exact)
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[d->optind]) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[d->optind]);
+#endif
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ d->optind++;
+ d->optopt = 0;
+ return '?';
+ }
+
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ d->optind++;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ d->optarg = nameend + 1;
+ else
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+ int n;
+#endif
+
+ if (argv[d->optind - 1][1] == '-')
+ {
+ /* --option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("\
+%s: option `--%s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+#else
+ fprintf (stderr, _("\
+%s: option `--%s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+#endif
+ }
+ else
+ {
+ /* +option or -option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("\
+%s: option `%c%s' doesn't allow an argument\n"),
+ argv[0], argv[d->optind - 1][0],
+ pfound->name);
+#else
+ fprintf (stderr, _("\
+%s: option `%c%s' doesn't allow an argument\n"),
+ argv[0], argv[d->optind - 1][0],
+ pfound->name);
+#endif
+ }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ if (n >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2
+ |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#endif
+ }
+
+ d->__nextchar += strlen (d->__nextchar);
+
+ d->optopt = pfound->val;
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (d->optind < argc)
+ d->optarg = argv[d->optind++];
+ else
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("\
+%s: option `%s' requires an argument\n"),
+ argv[0], argv[d->optind - 1]) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2
+ |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[d->optind - 1]);
+#endif
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ d->optopt = pfound->val;
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+
+ /* Can't find it as a long option. If this is not getopt_long_only,
+ or the option starts with '--' or is not a valid short
+ option, then it's an error.
+ Otherwise interpret it as a short option. */
+ if (!long_only || argv[d->optind][1] == '-'
+ || strchr (optstring, *d->__nextchar) == NULL)
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+ int n;
+#endif
+
+ if (argv[d->optind][1] == '-')
+ {
+ /* --option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
+ argv[0], d->__nextchar);
+#else
+ fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
+ argv[0], d->__nextchar);
+#endif
+ }
+ else
+ {
+ /* +option or -option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
+ argv[0], argv[d->optind][0], d->__nextchar);
+#else
+ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
+ argv[0], argv[d->optind][0], d->__nextchar);
+#endif
+ }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ if (n >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#endif
+ }
+ d->__nextchar = (char *) "";
+ d->optind++;
+ d->optopt = 0;
+ return '?';
+ }
+ }
+
+ /* Look at and handle the next short option-character. */
+
+ {
+ char c = *d->__nextchar++;
+ char *temp = strchr (optstring, c);
+
+ /* Increment `optind' when we start to process its last character. */
+ if (*d->__nextchar == '\0')
+ ++d->optind;
+
+ if (temp == NULL || c == ':')
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+ int n;
+#endif
+
+ if (d->__posixly_correct)
+ {
+ /* 1003.2 specifies the format of this message. */
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
+ argv[0], c);
+#else
+ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
+#endif
+ }
+ else
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("%s: invalid option -- %c\n"),
+ argv[0], c);
+#else
+ fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
+#endif
+ }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ if (n >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#endif
+ }
+ d->optopt = c;
+ return '?';
+ }
+ /* Convenience. Treat POSIX -W foo same as long option --foo */
+ if (temp[0] == 'W' && temp[1] == ';')
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = 0;
+ int option_index;
+
+ /* This is an option that requires an argument. */
+ if (*d->__nextchar != '\0')
+ {
+ d->optarg = d->__nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ d->optind++;
+ }
+ else if (d->optind == argc)
+ {
+ if (print_errors)
+ {
+ /* 1003.2 specifies the format of this message. */
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf,
+ _("%s: option requires an argument -- %c\n"),
+ argv[0], c) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr, _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+#endif
+ }
+ d->optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ return c;
+ }
+ else
+ /* We already incremented `d->optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ d->optarg = argv[d->optind++];
+
+ /* optarg is now the argument, see if it's in the
+ table of longopts. */
+
+ for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '=';
+ nameend++)
+ /* Do nothing. */ ;
+
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
+ {
+ if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+ if (ambig && !exact)
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[d->optind]) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[d->optind]);
+#endif
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ d->optind++;
+ return '?';
+ }
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ d->optarg = nameend + 1;
+ else
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+ argv[0], pfound->name) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2
+ |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+#endif
+ }
+
+ d->__nextchar += strlen (d->__nextchar);
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (d->optind < argc)
+ d->optarg = argv[d->optind++];
+ else
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("\
+%s: option `%s' requires an argument\n"),
+ argv[0], argv[d->optind - 1]) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2
+ |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[d->optind - 1]);
+#endif
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+ d->__nextchar = NULL;
+ return 'W'; /* Let the application handle it. */
+ }
+ if (temp[1] == ':')
+ {
+ if (temp[2] == ':')
+ {
+ /* This is an option that accepts an argument optionally. */
+ if (*d->__nextchar != '\0')
+ {
+ d->optarg = d->__nextchar;
+ d->optind++;
+ }
+ else
+ d->optarg = NULL;
+ d->__nextchar = NULL;
+ }
+ else
+ {
+ /* This is an option that requires an argument. */
+ if (*d->__nextchar != '\0')
+ {
+ d->optarg = d->__nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ d->optind++;
+ }
+ else if (d->optind == argc)
+ {
+ if (print_errors)
+ {
+ /* 1003.2 specifies the format of this message. */
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("\
+%s: option requires an argument -- %c\n"),
+ argv[0], c) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr,
+ _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+#endif
+ }
+ d->optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ }
+ else
+ /* We already incremented `optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ d->optarg = argv[d->optind++];
+ d->__nextchar = NULL;
+ }
+ }
+ return c;
+ }
+}
+
+int
+_getopt_internal (int argc, char **argv, const char *optstring,
+ const struct option *longopts, int *longind,
+ int long_only, int posixly_correct)
+{
+ int result;
+
+ getopt_data.optind = optind;
+ getopt_data.opterr = opterr;
+
+ result = _getopt_internal_r (argc, argv, optstring, longopts, longind,
+ long_only, posixly_correct, &getopt_data);
+
+ optind = getopt_data.optind;
+ optarg = getopt_data.optarg;
+ optopt = getopt_data.optopt;
+
+ return result;
+}
+
+/* glibc gets a LSB-compliant getopt.
+ Standalone applications get a POSIX-compliant getopt. */
+#if _LIBC
+enum { POSIXLY_CORRECT = 0 };
+#else
+enum { POSIXLY_CORRECT = 1 };
+#endif
+
+int
+getopt (int argc, char *const *argv, const char *optstring)
+{
+ return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0,
+ POSIXLY_CORRECT);
+}
+
+
+#ifdef TEST
+
+/* Compile with -DTEST to make an executable for use in testing
+ the above definition of `getopt'. */
+
+int
+main (int argc, char **argv)
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+
+ c = getopt (argc, argv, "abc:d:0123456789");
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
diff --git a/Build/source/utils/lzma-utils/src/lzma/getopt1.c b/Build/source/utils/lzma-utils/src/lzma/getopt1.c
new file mode 100644
index 00000000000..cc0746ea43c
--- /dev/null
+++ b/Build/source/utils/lzma-utils/src/lzma/getopt1.c
@@ -0,0 +1,171 @@
+/* getopt_long and getopt_long_only entry points for GNU getopt.
+ Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifdef _LIBC
+# include <getopt.h>
+#else
+# include <config.h>
+# include "getopt.h"
+#endif
+#include "getopt_int.h"
+
+#include <stdio.h>
+
+/* This needs to come after some library #include
+ to get __GNU_LIBRARY__ defined. */
+#ifdef __GNU_LIBRARY__
+#include <stdlib.h>
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+int
+getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
+ const struct option *long_options, int *opt_index)
+{
+ return _getopt_internal (argc, (char **) argv, options, long_options,
+ opt_index, 0, 0);
+}
+
+int
+_getopt_long_r (int argc, char **argv, const char *options,
+ const struct option *long_options, int *opt_index,
+ struct _getopt_data *d)
+{
+ return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+ 0, 0, d);
+}
+
+/* Like getopt_long, but '-' as well as '--' can indicate a long option.
+ If an option that starts with '-' (not '--') doesn't match a long option,
+ but does match a short option, it is parsed as a short option
+ instead. */
+
+int
+getopt_long_only (int argc, char *__getopt_argv_const *argv,
+ const char *options,
+ const struct option *long_options, int *opt_index)
+{
+ return _getopt_internal (argc, (char **) argv, options, long_options,
+ opt_index, 1, 0);
+}
+
+int
+_getopt_long_only_r (int argc, char **argv, const char *options,
+ const struct option *long_options, int *opt_index,
+ struct _getopt_data *d)
+{
+ return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+ 1, 0, d);
+}
+
+
+#ifdef TEST
+
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+ int option_index = 0;
+ static struct option long_options[] =
+ {
+ {"add", 1, 0, 0},
+ {"append", 0, 0, 0},
+ {"delete", 1, 0, 0},
+ {"verbose", 0, 0, 0},
+ {"create", 0, 0, 0},
+ {"file", 1, 0, 0},
+ {0, 0, 0, 0}
+ };
+
+ c = getopt_long (argc, argv, "abc:d:0123456789",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case 0:
+ printf ("option %s", long_options[option_index].name);
+ if (optarg)
+ printf (" with arg %s", optarg);
+ printf ("\n");
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case 'd':
+ printf ("option d with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
diff --git a/Build/source/utils/lzma-utils/src/lzma/getopt_.h b/Build/source/utils/lzma-utils/src/lzma/getopt_.h
new file mode 100644
index 00000000000..615ef9a3b6f
--- /dev/null
+++ b/Build/source/utils/lzma-utils/src/lzma/getopt_.h
@@ -0,0 +1,226 @@
+/* Declarations for getopt.
+ Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _GETOPT_H
+
+#ifndef __need_getopt
+# define _GETOPT_H 1
+#endif
+
+/* Standalone applications should #define __GETOPT_PREFIX to an
+ identifier that prefixes the external functions and variables
+ defined in this header. When this happens, include the
+ headers that might declare getopt so that they will not cause
+ confusion if included after this file. Then systematically rename
+ identifiers so that they do not collide with the system functions
+ and variables. Renaming avoids problems with some compilers and
+ linkers. */
+#if defined __GETOPT_PREFIX && !defined __need_getopt
+# include <stdlib.h>
+# include <stdio.h>
+# include <unistd.h>
+# undef __need_getopt
+# undef getopt
+# undef getopt_long
+# undef getopt_long_only
+# undef optarg
+# undef opterr
+# undef optind
+# undef optopt
+# define __GETOPT_CONCAT(x, y) x ## y
+# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
+# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
+# define getopt __GETOPT_ID (getopt)
+# define getopt_long __GETOPT_ID (getopt_long)
+# define getopt_long_only __GETOPT_ID (getopt_long_only)
+# define optarg __GETOPT_ID (optarg)
+# define opterr __GETOPT_ID (opterr)
+# define optind __GETOPT_ID (optind)
+# define optopt __GETOPT_ID (optopt)
+#endif
+
+/* Standalone applications get correct prototypes for getopt_long and
+ getopt_long_only; they declare "char **argv". libc uses prototypes
+ with "char *const *argv" that are incorrect because getopt_long and
+ getopt_long_only can permute argv; this is required for backward
+ compatibility (e.g., for LSB 2.0.1).
+
+ This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
+ but it caused redefinition warnings if both unistd.h and getopt.h were
+ included, since unistd.h includes getopt.h having previously defined
+ __need_getopt.
+
+ The only place where __getopt_argv_const is used is in definitions
+ of getopt_long and getopt_long_only below, but these are visible
+ only if __need_getopt is not defined, so it is quite safe to rewrite
+ the conditional as follows:
+*/
+#if !defined __need_getopt
+# if defined __GETOPT_PREFIX
+# define __getopt_argv_const /* empty */
+# else
+# define __getopt_argv_const const
+# endif
+#endif
+
+/* If __GNU_LIBRARY__ is not already defined, either we are being used
+ standalone, or this is the first header included in the source file.
+ If we are being used with glibc, we need to include <features.h>, but
+ that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
+ not defined, include <ctype.h>, which will pull in <features.h> for us
+ if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
+ doesn't flood the namespace with stuff the way some other headers do.) */
+#if !defined __GNU_LIBRARY__
+# include <ctype.h>
+#endif
+
+#ifndef __THROW
+# ifndef __GNUC_PREREQ
+# define __GNUC_PREREQ(maj, min) (0)
+# endif
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# define __THROW throw ()
+# else
+# define __THROW
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+ for unrecognized options. */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized. */
+
+extern int optopt;
+
+#ifndef __need_getopt
+/* Describe the long-named options requested by the application.
+ The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+ of `struct option' terminated by an element containing a name which is
+ zero.
+
+ The field `has_arg' is:
+ no_argument (or 0) if the option does not take an argument,
+ required_argument (or 1) if the option requires an argument,
+ optional_argument (or 2) if the option takes an optional argument.
+
+ If the field `flag' is not NULL, it points to a variable that is set
+ to the value given in the field `val' when the option is found, but
+ left unchanged if the option is not found.
+
+ To have a long-named option do something other than set an `int' to
+ a compiled-in constant, such as set a value from `optarg', set the
+ option's `flag' field to zero and its `val' field to a nonzero
+ value (the equivalent single-letter option character, if there is
+ one). For long options that have a zero `flag' field, `getopt'
+ returns the contents of the `val' field. */
+
+struct option
+{
+ const char *name;
+ /* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'. */
+
+# define no_argument 0
+# define required_argument 1
+# define optional_argument 2
+#endif /* need getopt */
+
+
+/* Get definitions and prototypes for functions to process the
+ arguments in ARGV (ARGC of them, minus the program name) for
+ options given in OPTS.
+
+ Return the option character from OPTS just read. Return -1 when
+ there are no more options. For unrecognized options, or options
+ missing arguments, `optopt' is set to the option letter, and '?' is
+ returned.
+
+ The OPTS string is a list of characters which are recognized option
+ letters, optionally followed by colons, specifying that that letter
+ takes an argument, to be placed in `optarg'.
+
+ If a letter in OPTS is followed by two colons, its argument is
+ optional. This behavior is specific to the GNU `getopt'.
+
+ The argument `--' causes premature termination of argument
+ scanning, explicitly telling `getopt' that there are no more
+ options.
+
+ If OPTS begins with `-', then non-option arguments are treated as
+ arguments to the option '\1'. This behavior is specific to the GNU
+ `getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in
+ the environment, then do not permute arguments. */
+
+extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
+ __THROW;
+
+#ifndef __need_getopt
+extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind)
+ __THROW;
+extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind)
+ __THROW;
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Make sure we later can get all the definitions and declarations. */
+#undef __need_getopt
+
+#endif /* getopt.h */
diff --git a/Build/source/utils/lzma-utils/src/lzma/getopt_int.h b/Build/source/utils/lzma-utils/src/lzma/getopt_int.h
new file mode 100644
index 00000000000..401579fd289
--- /dev/null
+++ b/Build/source/utils/lzma-utils/src/lzma/getopt_int.h
@@ -0,0 +1,131 @@
+/* Internal declarations for getopt.
+ Copyright (C) 1989-1994,1996-1999,2001,2003,2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _GETOPT_INT_H
+#define _GETOPT_INT_H 1
+
+extern int _getopt_internal (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ int __long_only, int __posixly_correct);
+
+
+/* Reentrant versions which can handle parsing multiple argument
+ vectors at the same time. */
+
+/* Data type for reentrant functions. */
+struct _getopt_data
+{
+ /* These have exactly the same meaning as the corresponding global
+ variables, except that they are used for the reentrant
+ versions of getopt. */
+ int optind;
+ int opterr;
+ int optopt;
+ char *optarg;
+
+ /* Internal members. */
+
+ /* True if the internal members have been initialized. */
+ int __initialized;
+
+ /* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+ char *__nextchar;
+
+ /* Describe how to deal with options that follow non-option ARGV-elements.
+
+ If the caller did not specify anything,
+ the default is REQUIRE_ORDER if the environment variable
+ POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+ REQUIRE_ORDER means don't recognize them as options;
+ stop option processing when the first non-option is seen.
+ This is what Unix does.
+ This mode of operation is selected by either setting the environment
+ variable POSIXLY_CORRECT, or using `+' as the first character
+ of the list of option characters, or by calling getopt.
+
+ PERMUTE is the default. We permute the contents of ARGV as we
+ scan, so that eventually all the non-options are at the end.
+ This allows options to be given in any order, even with programs
+ that were not written to expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were
+ written to expect options and other ARGV-elements in any order
+ and that care about the ordering of the two. We describe each
+ non-option ARGV-element as if it were the argument of an option
+ with character code 1. Using `-' as the first character of the
+ list of option characters selects this mode of operation.
+
+ The special argument `--' forces an end of option-scanning regardless
+ of the value of `ordering'. In the case of RETURN_IN_ORDER, only
+ `--' can cause `getopt' to return -1 with `optind' != ARGC. */
+
+ enum
+ {
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+ } __ordering;
+
+ /* If the POSIXLY_CORRECT environment variable is set
+ or getopt was called. */
+ int __posixly_correct;
+
+
+ /* Handle permutation of arguments. */
+
+ /* Describe the part of ARGV that contains non-options that have
+ been skipped. `first_nonopt' is the index in ARGV of the first
+ of them; `last_nonopt' is the index after the last of them. */
+
+ int __first_nonopt;
+ int __last_nonopt;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+ int __nonoption_flags_max_len;
+ int __nonoption_flags_len;
+# endif
+};
+
+/* The initializer is necessary to set OPTIND and OPTERR to their
+ default values and to clear the initialization flag. */
+#define _GETOPT_DATA_INITIALIZER { 1, 1 }
+
+extern int _getopt_internal_r (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ int __long_only, int __posixly_correct,
+ struct _getopt_data *__data);
+
+extern int _getopt_long_r (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ struct _getopt_data *__data);
+
+extern int _getopt_long_only_r (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts,
+ int *__longind,
+ struct _getopt_data *__data);
+
+#endif /* getopt_int.h */
diff --git a/Build/source/utils/lzma-utils/src/lzma/gettext.h b/Build/source/utils/lzma-utils/src/lzma/gettext.h
new file mode 100644
index 00000000000..b6282e54c8a
--- /dev/null
+++ b/Build/source/utils/lzma-utils/src/lzma/gettext.h
@@ -0,0 +1,240 @@
+/* Convenience header for conditional use of GNU <libintl.h>.
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option.
+ *
+ * Extra hack in LZMA Utils: if DISABLE_NLS is defined, NLS is disabled
+ * even if ENABLE_NLS is true. See Makefile.am for more information.
+ */
+#if ENABLE_NLS && !defined(DISABLE_NLS)
+
+/* Get declarations of GNU message catalog functions. */
+# include <libintl.h>
+
+/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
+ the gettext() and ngettext() macros. This is an alternative to calling
+ textdomain(), and is useful for libraries. */
+# ifdef DEFAULT_TEXT_DOMAIN
+# undef gettext
+# define gettext(Msgid) \
+ dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+ dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
+# endif
+
+#else
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+ chokes if dcgettext is defined as a macro. So include it now, to make
+ later inclusions of <locale.h> a NOP. We don't include <libintl.h>
+ as well because people using "gettext.h" will not include <libintl.h>,
+ and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+ is OK. */
+#if defined(__sun)
+# include <locale.h>
+#endif
+
+/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
+ <libintl.h>, which chokes if dcgettext is defined as a macro. So include
+ it now, to make later inclusions of <libintl.h> a NOP. */
+#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
+# include <cstdlib>
+# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
+# include <libintl.h>
+# endif
+#endif
+
+/* Disabled NLS.
+ The casts to 'const char *' serve the purpose of producing warnings
+ for invalid uses of the value returned from these functions.
+ On pre-ANSI systems without 'const', the config.h file is supposed to
+ contain "#define const". */
+# define gettext(Msgid) ((const char *) (Msgid))
+# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
+# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
+# define ngettext(Msgid1, Msgid2, N) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define textdomain(Domainname) ((const char *) (Domainname))
+# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
+# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
+
+#endif
+
+/* A pseudo function call that serves as a marker for the automated
+ extraction of messages, but does not call gettext(). The run-time
+ translation is done at a different place in the code.
+ The argument, String, should be a literal string. Concatenated strings
+ and other string expressions won't work.
+ The macro's expansion is not parenthesized, so that it is suitable as
+ initializer for static 'char[]' or 'const char[]' variables. */
+#define gettext_noop(String) String
+
+/* The separator between msgctxt and msgid in a .mo file. */
+#define GETTEXT_CONTEXT_GLUE "\004"
+
+/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
+ MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
+ short and rarely need to change.
+ The letter 'p' stands for 'particular' or 'special'. */
+#ifdef DEFAULT_TEXT_DOMAIN
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#else
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#endif
+#define dpgettext(Domainname, Msgctxt, Msgid) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
+#ifdef DEFAULT_TEXT_DOMAIN
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#else
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#endif
+#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
+
+static inline const char *
+pgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ int category)
+{
+ const char *translation = dcgettext (domain, msg_ctxt_id, category);
+ if (translation == msg_ctxt_id)
+ return msgid;
+ else
+ return translation;
+}
+
+static inline const char *
+npgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ const char *translation =
+ dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+ if (translation == msg_ctxt_id || translation == msgid_plural)
+ return (n == 1 ? msgid : msgid_plural);
+ else
+ return translation;
+}
+
+/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
+ can be arbitrary expressions. But for string literals these macros are
+ less efficient than those above. */
+
+#include <string.h>
+
+#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
+
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+#include <stdlib.h>
+#endif
+
+#define pgettext_expr(Msgctxt, Msgid) \
+ dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+ dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+
+static inline const char *
+dcpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcgettext (domain, msg_ctxt_id, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (translation != msg_ctxt_id)
+ return translation;
+ }
+ return msgid;
+}
+
+#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+
+static inline const char *
+dcnpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (!(translation == msg_ctxt_id || translation == msgid_plural))
+ return translation;
+ }
+ return (n == 1 ? msgid : msgid_plural);
+}
+
+#endif /* _LIBGETTEXT_H */
diff --git a/Build/source/utils/lzma-utils/src/lzma/lzma.1 b/Build/source/utils/lzma-utils/src/lzma/lzma.1
new file mode 100644
index 00000000000..dfcbac329b7
--- /dev/null
+++ b/Build/source/utils/lzma-utils/src/lzma/lzma.1
@@ -0,0 +1,228 @@
+.TH LZMA 1 "23 Dec 2005" "LZMA utils"
+
+.SH NAME
+lzma, unlzma, lzcat \- LZMA compression and decompression tool
+
+.SH SYNOPSIS
+.B lzma
+.RB [ \-123456789cdefhkLqtvV "] [" \-S
+.IR suffix "] [" "filenames ..." ]
+.br
+.B unlzma
+.RB [ \-cfhkLqtvV "] [" \-S
+.IR suffix "] [" "filenames ..." ]
+.br
+.B lzcat
+.RB [ \-fhLqV ]
+.RI [ "filenames ..." ]
+
+.SH DESCRIPTION
+LZMA (Lempel-Ziv-Markov chain-Algorithm) is an improved version of
+famous LZ77 compression algorithm. It was improved in way of maximum
+increasing of compression ratio, keeping high decompression speed and
+low memory requirements for decompressing.
+.PP
+.B lzma
+command line tool has a similar interface to
+.BR gzip (1)
+and
+.BR bzip2 (1)
+and is intended to make use of LZMA compression easy for the users who
+are already familiar with gzip and bzip2.
+.PP
+In this manual
+.B lzma
+is compared mostly to bzip2 because that is currently one of the most
+widely used free software to compress tar files made for distribution.
+Comparing lzma to gzip is not practical because neither lzma nor bzip2
+can compete with gzip in compression speed. On the other hand the
+compression ratio of gzip is worse than of lzma and bzip2.
+.PP
+.B lzma
+provides notably better compression ratio than bzip2 especially with
+files having other than plain text content. The other advantage of
+.B lzma
+is fast decompression which is many times quicker than bzip2. The major
+disadvantage is that achieving the highest compression ratios requires
+extensive amount of system resources, both CPU time and RAM. Also
+software to handle LZMA compressed files is not installed by default on
+most distributions.
+.PP
+When compressing or decompressing with
+.BR lzma ,
+the new file will have the same ownership information, permissions and
+timestamps as the original file. However the this information is not
+stored into the compressed file like gzip does.
+
+.SH STREAMED VS. NON-STREAMED
+LZMA files can be either streamed or non-streamed. Non-streamed files
+are created only when the size of the file being compressed is known. In
+practice this means that the source file must be a regular file. In
+other words, if compressing from the standard input or from a named pipe
+(fifo) the compressed file will always be streamed.
+.PP
+Both streamed and non-streamed files are compressed identically; the
+only differences are found from the beginnings and ends of LZMA
+compressed files: Non-streamed files contain the uncompressed size of
+the file in the LZMA file header; streamed files have uncompressed size
+marked as unknown. To know where to stop decoding, streamed files have a
+special End Of Stream marker at the end of the LZMA file. The EOS marker
+makes streamed files five or six bytes bigger than non-streamed.
+.PP
+So in practice creating non-streamed files has two advantages: 1) the
+compressed file is a few bytes smaller and 2) the uncompressed size of
+the file can be checked without decompressing the file. To view the data
+stored in the LZMA header use
+.BR lzmainfo (1).
+
+.SH OPTIONS
+Short options can be grouped like
+.BR \-cd.
+.TP
+.B \-c \-\-stdout \-\-to\-stdout
+The output is written to the standard output. The original files are kept
+unchanged. When compressing to the standard output there can be only one
+input file. This option is implied when input is read from the standard
+input or the script is invoked as
+.BR lzcat .
+.TP
+.B \-d \-\-decompress \-\-uncompress
+Force decompression regardless of the invocation name. This the default
+when called as
+.B unlzma
+or
+.BR lzcat .
+.TP
+.B \-f \-\-force
+Force compression or decompression even if source file is a symlink,
+target exists, or target is a terminal. In contrast to gzip and bzip2,
+if input data is not in LZMA format, \-\-force does not make lzma
+behave like
+.BR cat .
+.B lzma
+never prompts if target file should be overwritten; existing files are
+skipped or, in case of
+.BR \-\-force ,
+overwritten.
+.TP
+.B \-h \-\-help
+Show a summary of supported options and quit.
+.TP
+.B \-k \-\-keep
+Do not delete the input files after compression or decompression.
+.TP
+.B \-L \-\-license
+Show licensing information of
+.BR lzma .
+.TP
+.B \-q \-\-quiet
+Suppress all warnings. You can still check the exit status to detect if
+a warning had been shown.
+.TP
+.BI "\-S \-\-suffix " .suf
+Use
+.I .suf
+instead of the default
+.BR .lzma .
+A null suffix forces unlzma to decompress all the given files
+regardless of the filename suffix.
+.TP
+.B \-t \-\-test
+Check the integrity of the compressed file(s). Without
+.B \-\-verbose
+no output is produced if no errors are found.
+.TP
+.B \-v \-\-verbose
+Show the filename and percentage reduction of each processes file.
+.TP
+.B \-V \-\-version
+Show the version number of
+.BR lzma .
+.TP
+.B \-z \-\-compress
+Force compression regardless of the invocation name.
+.TP
+.BR \-1 " .. " \-9
+Set the compression ratio. See the next chapter for detailed
+information. These options have no effect when decompressing.
+.TP
+.B \-\-fast
+Alias to
+.BR \-1 .
+.TP
+.B \-\-best
+Alias to
+.BR \-9 .
+
+.SH COMPRESSION OPTIONS AND MEMORY USAGE
+The compression options of
+.B lzma
+are divided to two groups. The first two
+.RB ( \-1 " and " \-2 )
+are designed for fast compression speed.
+.BR \-3 " .. " \-9
+provide good to excellent compression ratio but require more CPU time
+and system memory.
+.PP
+For relatively fast compression with medium compression ratio
+.B \-1
+is the recommended setting. It's faster than 'bzip2 \-\-fast' and
+usually creates smaller files than 'bzip2 \-\-best'.
+.B \-2
+makes somewhat smaller files but doubles the compression time close to
+what 'bzip2 \-\-best' takes.
+.PP
+Generally for excellent compression ratio, acceptable compression time
+and memory requirements (about 83 MB for compression, 9 MB for
+decompression) you should use
+.B \-7
+which is also the default.
+.B \-8
+and
+.B \-9
+will give some gain especially with bigger files (>=tens of megabytes)
+but also increase the CPU and memory requirements dramatically. See the
+table below for memory requirements of different compression settings.
+.PP
+ Flag Compress usage Decompress usage
+ -1 2 MB 1 MB
+ -2 12 MB 2 MB
+ -3 12 MB 1 MB
+ -4 16 MB 2 MB
+ -5 26 MB 3 MB
+ -6 45 MB 5 MB
+ -7 83 MB 9 MB
+ -8 159 MB 17 MB
+ -9 311 MB 33 MB
+
+.SH DIAGNOSTICS
+Exit status:
+.br
+.B 0
+\- Everything OK.
+.br
+.B 1
+\- An error occurred.
+.br
+.B 2
+\- Something worth a warning happened but no errors.
+
+.SH AUTHORS
+The LZMA algorithm and the implementation used in LZMA utils was
+developed by Igor Pavlov. The original code is available in LZMA SDK
+which can be found from http://7-zip.org/sdk.html .
+.PP
+.B lzma
+command line tool was written by Ville Koskinen.
+http://tukaani.org/lzma/
+.PP
+This manual page is inspired by manual pages of
+.B gzip
+and
+.BR bzip2 .
+
+.SH SEE ALSO
+.BR lzmadec (1),
+.BR lzmainfo (1),
+.BR gzip (1),
+.BR bzip2 (1)
diff --git a/Build/source/utils/lzma-utils/src/lzma/lzmp.cpp b/Build/source/utils/lzma-utils/src/lzma/lzmp.cpp
new file mode 100644
index 00000000000..7fd0d9e7c2b
--- /dev/null
+++ b/Build/source/utils/lzma-utils/src/lzma/lzmp.cpp
@@ -0,0 +1,983 @@
+/*
+ * LZMA command line tool similar to gzip to encode and decode LZMA files.
+ *
+ * Copyright (C) 2005 Ville Koskinen
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+
+#include "../sdk/Common/MyInitGuid.h"
+#include "../sdk/Common/MyWindows.h"
+
+#include <iostream>
+using std::cout;
+using std::cerr;
+using std::endl;
+
+#include <cstdio>
+#include <cstring>
+#include <climits>
+
+#include <string>
+using std::string;
+#include <vector>
+using std::vector;
+typedef vector<string> stringVector;
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "getopt.h"
+#include <signal.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <utime.h>
+#include <sys/time.h> // futimes()
+
+// Solaris has futimesat() instead of futimes() and some systems
+// don't have anything appropriate.
+#ifndef HAVE_FUTIMES
+# ifdef HAVE_FUTIMESAT
+# define futimes(fd, tv) futimesat(fd, NULL, tv)
+# else
+# define futimes(fd, tv) 0
+# endif
+#endif
+
+#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
+#include <fcntl.h>
+#include <io.h>
+#define MY_SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY)
+#else
+#define MY_SET_BINARY_MODE(file)
+#endif
+
+#include "../sdk/7zip/Common/FileStreams.h"
+
+#include "../sdk/Common/Types.h"
+
+#include "../sdk/7zip/Compress/LZMA/LZMADecoder.h"
+#include "../sdk/7zip/Compress/LZMA/LZMAEncoder.h"
+
+#include "Exception.h"
+
+#include "../lzma_version.h"
+
+namespace lzma {
+
+const char *PROGRAM_VERSION = PACKAGE_VERSION;
+const char *PROGRAM_COPYRIGHT = "Copyright (C) 2005 Ville Koskinen";
+
+/* LZMA_Alone switches:
+ -a{N}: set compression mode - [0, 2], default: 2 (max)
+ -d{N}: set dictionary - [0,28], default: 23 (8MB)
+ -fb{N}: set number of fast bytes - [5, 255], default: 128
+ -lc{N}: set number of literal context bits - [0, 8], default: 3
+ -lp{N}: set number of literal pos bits - [0, 4], default: 0
+ -pb{N}: set number of pos bits - [0, 4], default: 2
+ -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, bt4b, pat2r, pat2,
+ pat2h, pat3h, pat4h, hc3, hc4], default: bt4
+*/
+
+struct lzma_option {
+ short compression_mode; // -a
+ short dictionary; // -d
+ short fast_bytes; // -fb
+ wchar_t *match_finder; // -mf
+ short literal_context_bits; // -lc
+ short literal_pos_bits; // -lp
+ short pos_bits; // -pb
+};
+
+/* The following is a mapping from gzip/bzip2 style -1 .. -9 compression modes
+ * to the corresponding LZMA compression modes. Thanks, Larhzu, for coining
+ * these. */
+const lzma_option option_mapping[] = {
+ { 0, 0, 0, NULL, 0, 0, 0}, // -0 (needed for indexing)
+ { 0, 16, 64, L"hc3", 3, 0, 2}, // -1
+ { 0, 20, 64, L"hc4", 3, 0, 2}, // -2
+ { 1, 19, 64, L"bt4", 3, 0, 2}, // -3
+ { 2, 20, 64, L"bt4", 3, 0, 2}, // -4
+ { 2, 21, 128, L"bt4", 3, 0, 2}, // -5
+ { 2, 22, 128, L"bt4", 3, 0, 2}, // -6
+ { 2, 23, 128, L"bt4", 3, 0, 2}, // -7
+ { 2, 24, 255, L"bt4", 3, 0, 2}, // -8
+ { 2, 25, 255, L"bt4", 3, 0, 2}, // -9
+};
+
+struct extension_pair {
+ char *from;
+ char *to;
+};
+
+const extension_pair known_extensions[] = {
+ { ".lzma", "" },
+ { ".tlz", ".tar" },
+ { NULL, NULL }
+};
+
+/* Sorry, I just happen to like enumerations. */
+enum PROGRAM_MODE {
+ PM_COMPRESS = 0,
+ PM_DECOMPRESS,
+ PM_TEST,
+ PM_HELP,
+ PM_LICENSE,
+ PM_VERSION
+};
+
+enum {
+ STATUS_OK = 0,
+ STATUS_ERROR = 1,
+ STATUS_WARNING = 2
+};
+
+/* getopt options. */
+enum {
+ OPT_FORMAT = INT_MIN
+};
+/* struct option { name, has_arg, flag, val } */
+const struct option long_options[] = {
+ { "stdout", 0, 0, 'c' },
+ { "decompress", 0, 0, 'd' },
+ { "compress", 0, 0, 'z' },
+ { "keep", 0, 0, 'k' },
+ { "force", 0, 0, 'f' },
+ { "test", 0, 0, 't' },
+ { "suffix", 1, 0, 'S' },
+ { "quiet", 0, 0, 'q' },
+ { "verbose", 0, 0, 'v' },
+ { "help", 0, 0, 'h' },
+ { "license", 0, 0, 'L' },
+ { "version", 0, 0, 'V' },
+ { "fast", 0, 0, '1' },
+ { "best", 0, 0, '9' },
+ { "format", 1, 0, OPT_FORMAT },
+ { 0, 0, 0, 0 }
+};
+
+/* getopt option string (for the above options). */
+const char option_string[] = "cdzkftS:qvhLV123456789A:D:F:";
+
+/* Defaults. */
+PROGRAM_MODE program_mode = PM_COMPRESS;
+int verbosity = 0;
+bool stdinput = false;
+bool stdoutput = false;
+bool keep = false;
+bool force = false;
+int compression_mode = 7;
+//char *suffix = strdup(".lzma");
+char *suffix = strdup(known_extensions[0].from);
+lzma_option advanced_options = { -1, -1, -1, NULL, -1, -1, -1 };
+
+void print_help(const char *const argv0)
+{
+ // Help goes to stdout while other messages go to stderr.
+ cout << "\nlzma " << PROGRAM_VERSION
+ << " " << PROGRAM_COPYRIGHT << "\n"
+ "Based on LZMA SDK " << LZMA_SDK_VERSION_STRING << " "
+ << LZMA_SDK_COPYRIGHT_STRING
+ << "\n\nUsage: " << argv0
+ << " [flags and input files in any order]\n"
+" -c --stdout output to standard output\n"
+" -d --decompress force decompression\n"
+" -z --compress force compression\n"
+" -k --keep keep (don't delete) input files\n"
+" -f --force force overwrite of output file and compress links\n"
+" -t --test test compressed file integrity\n"
+" -S .suf --suffix .suf use suffix .suf on compressed files\n"
+" -q --quiet suppress error messages\n"
+" -v --verbose be verbose\n"
+" -h --help print this message\n"
+" -L --license display the license information\n"
+" -V --version display version numbers of LZMA SDK and lzma\n"
+" -1 .. -2 fast compression\n"
+" -3 .. -9 good to excellent compression. -7 is the default.\n"
+" --fast alias for -1\n"
+" --best alias for -9 (usually *not* what you want)\n\n"
+" Memory usage depends a lot on the chosen compression mode -1 .. -9.\n"
+" See the man page lzma(1) for details.\n\n";
+}
+
+void print_license(void)
+{
+ cout << "\n LZMA command line tool " << PROGRAM_VERSION << " - "
+ << PROGRAM_COPYRIGHT
+ << "\n LZMA SDK " << LZMA_SDK_VERSION_STRING << " - "
+ << LZMA_SDK_COPYRIGHT_STRING
+ << "\n This program is a part of the LZMA utils package.\n"
+ " http://tukaani.org/lzma/\n\n"
+" This program is free software; you can redistribute it and/or\n"
+" modify it under the terms of the GNU General Public License\n"
+" as published by the Free Software Foundation; either version 2\n"
+" of 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";
+}
+
+void print_version(void)
+{
+ cout << "LZMA command line tool " << PROGRAM_VERSION << "\n"
+ << "LZMA SDK " << LZMA_SDK_VERSION_STRING << "\n";
+}
+
+short str2int (const char *str, const int &min, const int &max)
+{
+ int value = -1;
+ char *endptr = NULL;
+ if (str == NULL || str[0] == '\0')
+ throw ArgumentException("Invalid integer option");
+ value = strtol (str, &endptr, 10);
+ if (*endptr != '\0' || value < min || value > max)
+ throw ArgumentException("Invalid integer option");
+ return value;
+}
+
+void parse_options(int argc, char **argv, stringVector &filenames)
+{
+ /* Snatched from getopt(3). */
+ int c;
+
+ /* Check how we were called */
+ {
+ char *p = strrchr (argv[0], '/'); // Remove path prefix, if any
+ if (p++ == NULL)
+ p = argv[0];
+ if (strstr (p, "un") != NULL) {
+ program_mode = PM_DECOMPRESS;
+ } else if (strstr (p, "cat") != NULL) {
+ program_mode = PM_DECOMPRESS;
+ stdoutput = true;
+ }
+ }
+
+ while (-1 != (c = getopt_long(argc, argv, option_string,
+ long_options, NULL))) {
+ switch (c) {
+ // stdout
+ case 'c':
+ stdoutput = true;
+ break;
+
+ // decompress
+ case 'd':
+ program_mode = PM_DECOMPRESS;
+ break;
+
+ // compress
+ case 'z':
+ program_mode = PM_COMPRESS;
+ break;
+
+ // keep
+ case 'k':
+ keep = true;
+ break;
+
+ // force
+ case 'f':
+ force = true;
+ break;
+
+ // test
+ case 't':
+ program_mode = PM_TEST;
+ break;
+
+ // suffix
+ case 'S':
+ if (optarg) {
+ free(suffix);
+ suffix = strdup(optarg);
+ }
+ break;
+
+ // quiet
+ case 'q':
+ verbosity = 0;
+ break;
+
+ // verbose
+ case 'v':
+ verbosity++;
+ break;
+
+ // help
+ case 'h':
+ program_mode = PM_HELP;
+ break;
+
+ // license
+ case 'L':
+ program_mode = PM_LICENSE;
+ break;
+
+ // version
+ case 'V':
+ program_mode = PM_VERSION;
+ break;
+
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ compression_mode = c - '0';
+ break;
+
+ // Advanced options //
+ // Unfortunately, these won't be compatible with
+ // the new command line tool. These options will
+ // be set differently there.
+
+ // Compression mode
+ case 'A':
+ advanced_options.compression_mode =
+ str2int (optarg, 0, 2);
+ break;
+
+ // Dictionary size
+ case 'D':
+ advanced_options.dictionary =
+ str2int (optarg, 0, 28);
+ break;
+
+ // Fast bytes
+ case 'F':
+ advanced_options.fast_bytes =
+ str2int (optarg, 0, 273);
+ break;
+
+ case OPT_FORMAT:
+ // Forward compatibility with new command line tool.
+ if (strcmp(optarg, "alone") != 0) {
+ cerr << argv[0] << ": Only --format=alone is supported\n";
+ exit(STATUS_ERROR);
+ }
+ break;
+
+ default:
+ throw ArgumentException("");
+ break;
+ } // switch(c)
+ } // while(1)
+
+ for (int i = optind; i < argc; i++) {
+ if (strcmp("-", argv[i]) == 0)
+ continue;
+ filenames.push_back(argv[i]);
+ }
+} // parse_options
+
+void set_encoder_properties(NCompress::NLZMA::CEncoder *encoder,
+ lzma_option &opt)
+{
+ /* Almost verbatim from LzmaAlone.cpp. */
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kDictionarySize,
+ NCoderPropID::kPosStateBits,
+ NCoderPropID::kLitContextBits,
+ NCoderPropID::kLitPosBits,
+ NCoderPropID::kAlgorithm,
+ NCoderPropID::kNumFastBytes,
+ NCoderPropID::kMatchFinder,
+ NCoderPropID::kEndMarker
+ };
+ const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
+#define VALUE(x) (advanced_options.x >= 0 ? advanced_options.x : opt.x)
+ PROPVARIANT properties[kNumProps];
+ for (int p = 0; p < 6; p++)
+ properties[p].vt = VT_UI4;
+ properties[0].ulVal = UInt32(1 << VALUE (dictionary));
+ properties[1].ulVal = UInt32(VALUE (pos_bits));
+ properties[2].ulVal = UInt32(VALUE (literal_context_bits));
+ properties[3].ulVal = UInt32(VALUE (literal_pos_bits));
+ properties[4].ulVal = UInt32(VALUE (compression_mode));
+ properties[5].ulVal = UInt32(VALUE (fast_bytes));
+#undef VALUE
+
+ properties[6].vt = VT_BSTR;
+ properties[6].bstrVal = (BSTR)opt.match_finder;
+
+ properties[7].vt = VT_BOOL;
+ properties[7].boolVal = stdinput ? VARIANT_TRUE : VARIANT_FALSE;
+
+ if (encoder->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
+ throw Exception("SetCoderProperties() error");
+}
+
+void encode(NCompress::NLZMA::CEncoder *encoderSpec,
+ CMyComPtr<ISequentialInStream> inStream,
+ CMyComPtr<ISequentialOutStream> outStream,
+ lzma_option encoder_options,
+ UInt64 fileSize)
+{
+ set_encoder_properties(encoderSpec, encoder_options);
+
+ encoderSpec->WriteCoderProperties(outStream);
+
+ for (int i = 0; i < 8; i++)
+ {
+ Byte b = Byte(fileSize >> (8 * i));
+ if (outStream->Write(&b, sizeof(b), 0) != S_OK)
+ throw Exception("Write error while encoding");
+ }
+
+ HRESULT result = encoderSpec->Code(inStream, outStream, 0, 0, 0);
+
+ if (result == E_OUTOFMEMORY)
+ throw Exception("Cannot allocate memory");
+ else if (result != S_OK) {
+ char buffer[33];
+ snprintf(buffer, 33, "%d", (unsigned int)result);
+ throw Exception(string("Encoder error: ") + buffer);
+ }
+}
+
+void decode(NCompress::NLZMA::CDecoder *decoderSpec,
+ CMyComPtr<ISequentialInStream> inStream,
+ CMyComPtr<ISequentialOutStream> outStream)
+{
+ const UInt32 kPropertiesSize = 5;
+ Byte properties[kPropertiesSize];
+ UInt32 processedSize;
+ UInt64 fileSize = 0;
+
+ if (inStream->Read(properties, kPropertiesSize, &processedSize) != S_OK)
+ throw Exception("Read error");
+ if (processedSize != kPropertiesSize)
+ throw Exception("Read error");
+
+ // This tests only the first five bytes although the new format has
+ // six-byte magic. It was lazier to implement this way.
+ if (memcmp(properties, "\xFFLZMA", kPropertiesSize) == 0)
+ throw Exception("New .lzma format detected. Newer LZMA Utils needed to decode.");
+
+ if (decoderSpec->SetDecoderProperties2(properties, kPropertiesSize) != S_OK)
+ throw Exception("SetDecoderProperties() error");
+
+ for (int i = 0; i < 8; i++)
+ {
+ Byte b;
+
+ if (inStream->Read(&b, sizeof(b), &processedSize) != S_OK)
+ throw Exception("Read error");
+ if (processedSize != 1)
+ throw Exception("Read error");
+
+ fileSize |= ((UInt64)b) << (8 * i);
+ }
+
+ if (decoderSpec->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
+ throw Exception("Decoder error");
+}
+
+int open_instream(const string infile,
+ CMyComPtr<ISequentialInStream> &inStream,
+ UInt64 &fileSize)
+{
+ CInFileStream *inStreamSpec = new CInFileStream;
+ inStream = inStreamSpec;
+ if (!inStreamSpec->Open(infile.c_str()))
+ throw Exception("Cannot open input file " + infile);
+
+ inStreamSpec->File.GetLength(fileSize);
+
+ return inStreamSpec->File.GetHandle();
+}
+
+int open_outstream(const string outfile,
+ CMyComPtr<ISequentialOutStream> &outStream)
+{
+ COutFileStream *outStreamSpec = new COutFileStream;
+ outStream = outStreamSpec;
+
+ bool open_by_force = (program_mode == PM_TEST) | force;
+
+ if (!outStreamSpec->Create(outfile.c_str(), open_by_force))
+ throw Exception("Cannot open output file " + outfile);
+
+ return outStreamSpec->File.GetHandle();
+}
+
+double get_ratio(int inhandle, int outhandle)
+{
+ struct stat in_stats, out_stats;
+ fstat(inhandle, &in_stats);
+ fstat(outhandle, &out_stats);
+
+ return (double)out_stats.st_size / (double)in_stats.st_size;
+}
+
+mode_t get_file_mode(string filename)
+{
+ struct stat in_stat;
+ lstat(filename.c_str(), &in_stat);
+
+ return in_stat.st_mode;
+}
+
+bool string_ends_with(string str, string ending)
+{
+ return equal(ending.rbegin(), ending.rend(), str.rbegin());
+}
+
+bool extension_is_known(string filename)
+{
+ bool known_format = false;
+ extension_pair extension; int i = 1;
+
+ extension = known_extensions[0];
+ while (extension.from != NULL) {
+ if (string_ends_with(filename, extension.from)) {
+ known_format = true;
+ break;
+ }
+ extension = known_extensions[i];
+ i++;
+ }
+
+ if (!known_format) {
+ if (!string_ends_with(filename, suffix)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+string replace_extension(string filename)
+{
+ int suffix_starts_at = filename.length() - strlen (suffix);
+ string from_suffix = filename.substr(suffix_starts_at, strlen (suffix));
+ string ret = filename.substr(0, suffix_starts_at);
+ extension_pair extension; int i = 1;
+
+ bool found_replacement = false;
+ extension = known_extensions[0];
+ while (extension.from != NULL) {
+ if (from_suffix.compare(extension.from) == 0) {
+ ret += extension.to;
+ found_replacement = true;
+ break;
+ }
+
+ extension = known_extensions[i];
+ i++;
+ }
+
+ return ret;
+}
+
+string pretty_print_status(string filename, string output_filename,
+ string ratio)
+{
+ string ret = "";
+
+ ret += filename;
+ ret += ":\t ";
+
+ if (program_mode == PM_TEST) {
+ ret += "decoded succesfully";
+
+ return ret;
+ }
+
+ if (!stdinput && !stdoutput) {
+ ret += ratio;
+ ret += " -- ";
+ }
+
+ if (program_mode == PM_COMPRESS) {
+ if (keep) {
+ ret += "encoded succesfully";
+
+ return ret;
+ }
+
+ ret += "replaced with ";
+ ret += output_filename;
+
+ return ret;
+ }
+
+ if (program_mode == PM_DECOMPRESS) {
+ if (keep) {
+ ret += "decoded succesfully";
+
+ return ret;
+ }
+
+ ret += "replaced with ";
+ ret += output_filename;
+
+ return ret;
+ }
+
+ return ret;
+}
+
+static string archive_name; // I know, it is crude, but I haven't found any other
+ // way then making a global variable to transfer filename to handler
+
+void signal_handler (int signum)
+{
+ unlink (archive_name.c_str()); // deleting
+ signal (signum, SIG_DFL); // we return the default function to used signal
+ kill (getpid(), signum); // and then send this signal to the process again
+}
+
+static void
+open_stdxxx(int status)
+{
+ for (int i = 0; i <= 2; ++i) {
+ // We use fcntl() to check if the file descriptor is open.
+ if (fcntl(i, F_GETFD) == -1 && errno == EBADF) {
+ const int fd = open("/dev/null", O_NOCTTY
+ | (i == 0 ? O_WRONLY : O_RDONLY));
+ if (fd != i) {
+ (void)close(fd);
+ exit(status);
+ }
+ }
+ }
+
+ return;
+}
+
+} // namespace lzma
+
+
+int main(int argc, char **argv)
+{
+ using namespace lzma;
+ using std::cerr;
+
+ open_stdxxx(STATUS_ERROR);
+
+ stringVector filenames;
+
+ signal (SIGTERM,signal_handler);
+ signal (SIGHUP,signal_handler);
+ signal (SIGINT,signal_handler);
+
+ try {
+ parse_options(argc, argv, filenames);
+ }
+ catch (...) {
+ return STATUS_ERROR;
+ }
+
+ if (program_mode == PM_HELP) {
+ print_help(argv[0]);
+ return STATUS_OK;
+ }
+ else if (program_mode == PM_LICENSE) {
+ print_license();
+ return STATUS_OK;
+ }
+ else if (program_mode == PM_VERSION) {
+ print_version();
+ return STATUS_OK;
+ }
+
+ if (filenames.empty()) {
+ stdinput = true;
+ stdoutput = true;
+
+ /* FIXME: get rid of this */
+ filenames.push_back("-");
+ }
+
+ /* Protection: always create new files with 0600 in order to prevent
+ * outsiders from reading incomplete data. */
+ umask(0077);
+
+ bool warning = false;
+
+ for (int i = 0; i < filenames.size(); i++) {
+ CMyComPtr<ISequentialInStream> inStream;
+ CMyComPtr<ISequentialOutStream> outStream;
+ UInt64 fileSize = 0;
+ int inhandle = 0, outhandle = 0;
+ string output_filename;
+
+ if (stdinput) {
+ inStream = new CStdInFileStream;
+ MY_SET_BINARY_MODE(stdin);
+ fileSize = (UInt64)(Int64)-1;
+
+ inhandle = STDIN_FILENO;
+
+ outStream = new CStdOutFileStream;
+ MY_SET_BINARY_MODE(stdout);
+
+ outhandle = STDOUT_FILENO;
+ }
+ else {
+ mode_t infile_mode = get_file_mode(filenames[i]);
+ if (!S_ISREG(infile_mode)) {
+ if (S_ISDIR(infile_mode)) {
+ warning = true;
+ cerr << argv[0] << ": " << filenames[i] << ": "
+ << "cowardly refusing to work on directory"
+ << endl;
+
+ continue;
+ }
+ else if (S_ISLNK(infile_mode)) {
+ if (!stdoutput && !force) {
+ warning = true;
+
+ cerr << argv[0] << ": " << filenames[i] << ": "
+ << "cowardly refusing to work on symbolic link "
+ << "(use --force to force encoding or decoding)"
+ << endl;
+
+ continue;
+ }
+ }
+ else {
+ warning = true;
+
+ cerr << argv[0] << ": " << filenames[i] << ": "
+ << "doesn't exist or is not a regular file"
+ << endl;
+
+ continue;
+ }
+ }
+
+ // Test if the file already ends with *suffix.
+ if (!stdoutput && program_mode == PM_COMPRESS && !force
+ && string_ends_with(filenames[i],
+ suffix)) {
+ warning = true;
+
+ cerr << filenames[i] << " already has "
+ << suffix << " suffix -- unchanged\n";
+
+ continue;
+ }
+
+ // Test if the file extension is known.
+ if (!stdoutput && program_mode == PM_DECOMPRESS
+ && !extension_is_known(filenames[i])) {
+ warning = true;
+
+ cerr << filenames[i] << ": "
+ << " unknown suffix -- unchanged"
+ << endl;
+
+ continue;
+ }
+
+ try {
+ inhandle = open_instream(filenames[i], inStream, fileSize);
+ }
+ catch (Exception e) {
+ cerr << argv[0] << ": " << e.what() << endl;
+ return STATUS_ERROR;
+ }
+
+ if (stdoutput) {
+ outStream = new CStdOutFileStream;
+ MY_SET_BINARY_MODE(stdout);
+
+ outhandle = STDOUT_FILENO;
+ }
+ else {
+ /* Testing mode is nothing else but decoding
+ * and throwing away the result. */
+ if (program_mode == PM_TEST)
+ output_filename = "/dev/null";
+ else if (program_mode == PM_DECOMPRESS)
+ output_filename = replace_extension(filenames[i]);
+ else
+ output_filename = filenames[i]
+ + suffix;
+ archive_name = output_filename;
+
+ try {
+ outhandle = open_outstream(output_filename, outStream);
+ }
+ catch (Exception e) {
+ cerr << argv[0] << ": " << e.what() << endl;
+ return STATUS_ERROR;
+ }
+ }
+
+ }
+
+ // Unless --force is specified, do not read/write compressed
+ // data from/to a terminal.
+ if (!force) {
+ if (program_mode == PM_COMPRESS && isatty(outhandle)) {
+ cerr << argv[0] << ": compressed data not "
+ "written to a terminal. Use "
+ "-f to force compression.\n"
+ << argv[0] << ": For help, type: "
+ << argv[0] << " -h\n";
+ return STATUS_ERROR;
+ } else if (program_mode == PM_DECOMPRESS
+ && isatty(inhandle)) {
+ cerr << argv[0] << ": compressed data not "
+ "read from a terminal. Use "
+ "-f to force decompression.\n"
+ << argv[0] << ": For help, type: "
+ << argv[0] << " -h\n";
+ return STATUS_ERROR;
+ }
+ }
+
+ if (program_mode == PM_COMPRESS) {
+ NCompress::NLZMA::CEncoder *encoderSpec =
+ new NCompress::NLZMA::CEncoder;
+
+ lzma_option options = option_mapping[compression_mode];
+
+ try {
+ encode(encoderSpec, inStream, outStream, options, fileSize);
+ }
+ catch (Exception e) {
+ cerr << argv[0] << ": " << e.what() << endl;
+ unlink(output_filename.c_str());
+ delete(encoderSpec);
+
+ return STATUS_ERROR;
+ }
+
+ delete(encoderSpec);
+ }
+ else { // PM_DECOMPRESS | PM_TEST
+ NCompress::NLZMA::CDecoder *decoderSpec =
+ new NCompress::NLZMA::CDecoder;
+
+ try {
+ decode(decoderSpec, inStream, outStream);
+ }
+ catch (Exception e) {
+ cerr << argv[0] << ": " << e.what() << endl;
+ unlink(output_filename.c_str());
+ delete(decoderSpec);
+
+ return STATUS_ERROR;
+ }
+
+ delete(decoderSpec);
+ }
+
+ /* Set permissions and owners. */
+ if ( (program_mode == PM_COMPRESS || program_mode == PM_DECOMPRESS )
+ && (!stdinput && !stdoutput) ) {
+
+ struct stat file_stats;
+ if (!fstat(inhandle, &file_stats)) {
+ (void)fchown(outhandle, file_stats.st_uid, -1);
+
+ mode_t mode;
+ if (fchown(outhandle, -1, file_stats.st_gid)) {
+ // Setting the GID of the file failed.
+ // We can still safely copy some
+ // permissions: `group' must be at
+ // least as strict as `other' and
+ // also vice versa.
+ //
+ // NOTE: After this, the owner of the
+ // source file may get additional
+ // permissions. This shouldn't be too
+ // bad, because the owner would have
+ // had permission to chmod the
+ // original file anyway.
+ mode = ((file_stats.st_mode & 0070) >> 3)
+ & (file_stats.st_mode & 0007);
+ mode = (file_stats.st_mode & 0700) | (mode << 3) | mode;
+ } else {
+ mode = file_stats.st_mode & 0777;
+ }
+
+ (void)fchmod(outhandle, mode);
+
+ struct timeval file_times[2];
+ // Access time
+ file_times[0].tv_sec = file_stats.st_atime;
+ file_times[0].tv_usec = 0;
+ // Modification time
+ file_times[1].tv_sec = file_stats.st_mtime;
+ file_times[1].tv_usec = 0;
+
+ (void)futimes(outhandle, file_times);
+ }
+
+ // Check that closing the output stream succeeds.
+ // Note that this is no-op for stdout; we don't
+ // need to handle it separately here.
+ if (outStream->Close()) {
+ unlink(output_filename.c_str());
+ cerr << output_filename << ": write error\n";
+ continue;
+ }
+
+ // Output closed successfully. Now we can remove the input
+ // file unless --keep was specified.
+ if (!keep)
+ unlink(filenames[i].c_str());
+ }
+
+ if (verbosity > 0) {
+ if (stdoutput) {
+ cerr << filenames[i] << ":\t ";
+ cerr << "decoded succesfully"
+ << endl;
+ }
+
+ else {
+ char buf[10] = { 0 };
+
+ if (program_mode == PM_DECOMPRESS)
+ snprintf(buf, 10, "%.2f%%",
+ (1 - get_ratio(outhandle, inhandle)) * 100);
+ if (program_mode == PM_COMPRESS)
+ snprintf(buf, 10, "%.2f%%",
+ (1 - get_ratio(inhandle, outhandle)) * 100);
+
+ string ratio = buf;
+ cerr << pretty_print_status(filenames[i], output_filename,
+ ratio)
+ << endl;
+ }
+ }
+ }
+
+ cout.flush();
+ if (!cout.good() || close(STDOUT_FILENO)) {
+ cerr << "Error writing to stdout\n";
+ return STATUS_ERROR;
+ }
+
+ cerr.flush();
+ if (!cerr.good() || close(STDERR_FILENO))
+ return STATUS_ERROR;
+
+ if (warning)
+ return STATUS_WARNING;
+
+ return STATUS_OK;
+}