/*
* ratz -- read a tar gzip archive from the standard input
*
* coded for portability
* _SEAR_* macros for win32 self extracting archives -- see sear(1).
*/
static char id[] = "\n@(#)$Id: ratz (Jean-loup Gailly, Mark Adler, Glenn Fowler) 1.2.3 2010-10-10 $\0\n";
#if _PACKAGE_ast
#include <ast.h>
#include <error.h>
static const char usage[] =
"[-?\n@(#)$Id: ratz (Jean-loup Gailly, Mark Adler, Glenn Fowler) 1.2.3 2010-10-10 $\n]"
"[-author?Jean-loup Gailly]"
"[-author?Mark Adler]"
"[-author?Glenn Fowler <gsf@research.att.com>]"
"[-copyright?Copyright (c) 1995-2005 Jean-loup Gailly and Mark Adler]"
"[-license?http://www.opensource.org/licenses/zlib-license]"
"[+NAME?ratz - read a tar gzip archive]"
"[+DESCRIPTION?\bratz\b extracts files and directories from a tar gzip"
" archive on the standard input. It is a standalone program for systems"
" that do not have \bpax\b(1), \btar\b(1) or \bgunzip\b(1). Only regular"
" files and directories are extracted; all other file types are ignored.]"
"[+?\b.exe\b files generated by \bsear\b(1) are fully functional \bratz\b"
" executables, so any \bratz\b option may be used on a \bsear\b file."
" This allows \bsear\b file contents to be examined and extracted without"
" executing any embedded installation scripts.]"
"[c:cat|uncompress?Uncompress the standard input and copy it to the standard"
" output.]"
#if defined(_SEAR_EXEC) || defined(_SEAR_SEEK)
"[i!:install?Execute the sear installation script.]"
"[k:keep?Keep the installation temporary directory.]"
#endif
"[l:local?Reject files that traverse outside the current directory.]"
"[m:meter?Display a one line text meter showing archive read progress.]"
"[n!:convert?In ebcdic environments convert text archive members from ascii"
" to the native ebcdic.]"
"[t:list?List each file path on the standard output but do not extract.]"
"[v:verbose?List each file path on the standard output as it is extracted.]"
"[V?Print the program version and exit.]"
"[+SEE ALSO?\bgunzip\b(1), \bpackage\b(1), \bpax\b(1), \bsear\b(1), \btar\b(1)]"
;
#else
#define NiL ((char*)0)
#endif
#ifndef _GUNZIP_H
/*
* stripped down zlib containing public gzfopen()+gzread() in one file
* USE THE REAL ZLIB AFTER BOOTSTRAP
*/
#include <stdio.h>
#else
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
#if _PACKAGE_ast
#ifndef setmode
#define setmode(d,m)
#endif
#else
#endif
#include <direct.h>
#include <io.h>
#include <fcntl.h>
#include <windows.h>
#else
#include <unistd.h>
#include <errno.h>
#ifndef setmode
#define setmode(d,m)
#endif
#endif
#if defined(__STDC__)
#include <stdlib.h>
#include <string.h>
#endif
#endif
#ifndef _ZLIB_H
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.3, July 18th, 2005
Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
The data format used by the zlib library is described by RFCs (Request for
Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
*/
#ifndef _ZCONF_H
#if _PACKAGE_ast
#include <ast_std.h> /* for { _WINIX __IMPORT__ __EXPORT__ } */
#if _typ_int64_t
#endif
#else
#endif
#endif
#if _BLD_z && defined(__EXPORT__)
#define ZEXPORT
#endif
# define MSDOS
#endif
# define OS2
#endif
# define WINDOWS
#endif
# ifndef WIN32
# define WIN32
# endif
#endif
# ifndef SYS16BIT
# define SYS16BIT
# endif
# endif
#endif
/*
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
* than 64k bytes at a time (needed on systems with 16-bit int).
*/
#ifdef SYS16BIT
# define MAXSEG_64K
#endif
#ifdef MSDOS
# define UNALIGNED_OK
#endif
#ifdef __STDC_VERSION__
# ifndef STDC
# define STDC
# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
# define STDC
#endif
# define STDC
#endif
# define STDC
#endif
# define STDC
#endif
# define STDC
#endif
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
/* Some Mac compilers merge all .h files incorrectly: */
# define NO_DUMMY_DECL
#endif
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K
# else
# endif
#endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS
#endif
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus a few kilobytes
for small objects.
*/
/* Type declarations */
#ifndef OF /* function prototypes */
# ifdef STDC
# else
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#ifdef SYS16BIT
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# else
# endif
# endif
# if (defined(__SMALL__) || defined(__MEDIUM__))
/* Turbo C small or medium model */
# define SMALL_MEDIUM
# ifdef __BORLANDC__
# else
# endif
# endif
#endif
/* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase.
*/
# ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL
# else
# endif
# endif
# endif /* ZLIB_DLL */
* define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/
# ifdef ZLIB_WINAPI
# ifdef FAR
# endif
# include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
# ifdef WIN32
# else
# endif
# endif
#endif
#if defined (__BEOS__)
# ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL
# else
# endif
# endif
#endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
#ifndef ZEXPORT
# define ZEXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA
#endif
#ifndef FAR
# define FAR
#endif
#if !defined(__MACTYPES__)
#endif
#ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
#else
#endif
#ifdef STDC
typedef void const *voidpc;
typedef void *voidp;
#else
#endif
#if HAVE_UNISTD_H
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
#endif
#ifndef SEEK_SET
#endif
#ifndef z_off_t
# define z_off_t long
#endif
#if defined(__OS400__)
# define NO_vsnprintf
#endif
#if defined(__MVS__)
# define NO_vsnprintf
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
#endif
#endif /* _ZCONF_H */
/*
The 'zlib' compression library provides in-memory compression and
decompression functions, including integrity checks of the uncompressed
data. This version of the library supports only one compression method
(deflation) but other algorithms will be added later and will have the same
stream interface.
Compression can be done in a single step if the buffers are large
enough (for example if an input file is mmap'ed), or can be done by
repeated calls of the compression function. In the latter case, the
(providing more output space) before each call.
The compressed data format used by default by the in-memory functions is
the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
around a deflate stream, which is itself documented in RFC 1951.
The library also supports reading and writing files in gzip (.gz) format
with an interface similar to that of stdio using the functions that start
with "gz". The gzip format is different from the zlib format. gzip is a
gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
This library can optionally read and write gzip streams in memory as well.
The zlib format was designed to be compact and fast for use in memory
and on communications channels. The gzip format was designed for single-
file compression on file systems, has a larger header than zlib to maintain
directory information, and uses a different, slower check method than zlib.
The library does not install any signal handler. The decoder checks
the consistency of the compressed data, so the library should never
crash even in case of corrupted input.
*/
struct internal_state;
typedef struct z_stream_s {
} z_stream;
/* constants */
#define Z_NO_FLUSH 0
/* Allowed flush values; see deflate() and inflate() below for details */
#define Z_OK 0
/* Return codes for the compression/decompression functions. Negative
* values are errors, positive values are used for special but normal events.
*/
#define Z_NO_COMPRESSION 0
/* compression levels */
#define Z_DEFAULT_STRATEGY 0
/* compression strategy; see deflateInit2() below for details */
#define Z_BINARY 0
/* Possible values of the data_type field (though see inflate()) */
/* The deflate compression method (the only one supported in this version) */
#endif /* _ZLIB_H */
#ifndef _ZUTIL_H
#if !_PACKAGE_ast && !defined(STDC)
#if defined(__STDC__)
# include <stddef.h>
#endif
# include <string.h>
# include <stdlib.h>
#endif
#ifndef local
# define local static
#endif
/* compile with -Dlocal if your debugger can't find static symbols */
typedef unsigned char uch;
typedef unsigned short ush;
typedef unsigned long ulg;
/* common constants */
#ifndef DEF_WBITS
#endif
/* default windowBits for decompression. MAX_WBITS is for compression only */
#if MAX_MEM_LEVEL >= 8
#else
#endif
/* default memLevel */
#define STORED_BLOCK 0
/* The three kinds of block type */
/* The minimum and maximum match lengths */
/* target dependencies */
# if defined(__TURBOC__) || defined(__BORLANDC__)
/* Allow compilation with ANSI keywords only enabled */
# else
# include <alloc.h>
# endif
# else /* MSC or DJGPP */
# include <malloc.h>
# endif
#endif
#ifdef AMIGA
#endif
#endif
#endif
#ifdef OS2
# ifdef M_I86
#include <malloc.h>
# endif
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
# include <unix.h> /* for fdopen */
# else
# ifndef fdopen
# endif
# endif
#endif
#ifdef TOPS20
#endif
#ifdef WIN32
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
# endif
#endif
#ifdef __50SERIES /* Prime/PRIMOS */
#endif
#endif
# if defined(_WIN32_WCE)
# ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t;
# define _PTRDIFF_T_DEFINED
# endif
# else
# endif
#endif
/* common defaults */
#ifndef OS_CODE
#endif
#ifndef F_OPEN
#endif
/* functions */
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#if defined(__CYGWIN__)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#ifndef HAVE_VSNPRINTF
# ifdef MSDOS
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
but for now we just assume it doesn't. */
# define NO_vsnprintf
# endif
# ifdef __TURBOC__
# define NO_vsnprintf
# endif
# ifdef WIN32
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
# endif
# endif
# ifdef __SASC
# define NO_vsnprintf
# endif
#endif
#ifdef VMS
# define NO_vsnprintf
#endif
#if defined(pyr)
# define NO_MEMCPY
#endif
/* Use our own functions for small and medium model with MSC <= 5.0.
* You may have to use the same strategy for Borland C (untested).
* The __SC__ check is for Symantec.
*/
# define NO_MEMCPY
#endif
# define HAVE_MEMCPY
#endif
#ifdef HAVE_MEMCPY
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
# else
# endif
#else
#endif
/* Diagnostic functions */
#ifdef Z_DEBUG
# include <stdio.h>
extern int z_verbose;
#else
# define Trace(x)
# define Tracev(x)
# define Tracevv(x)
# define Tracec(c,x)
# define Tracecv(c,x)
#endif
#endif /* _ZUTIL_H */
#ifndef _ZUTIL_C
#define _ZUTIL_C
#if 0 && !_PACKAGE_ast && !defined(STDC)
#endif
#ifndef HAVE_MEMCPY
{
if (len == 0) return;
do {
} while (--len != 0);
}
{
uInt j;
for (j = 0; j < len; j++) {
}
return 0;
}
{
if (len == 0) return;
do {
*dest++ = 0; /* ??? to be unrolled */
} while (--len != 0);
}
#endif
#ifdef SYS16BIT
#ifdef __TURBOC__
/* Turbo C in 16-bit mode */
# define MY_ZCALLOC
/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
* and farmalloc(64K) returns a pointer with an offset of 8, so we
* must fix the pointer. Warning: the pointer must be put back to its
* original form in order to free it, use zcfree().
*/
/* 10*64K = 640K */
typedef struct ptr_table_s {
} ptr_table;
/* This table is used to remember the original form of pointers
* to large buffers (64K). Such pointers are normalized with a zero offset.
* Since MSDOS is not a preemptive multitasking OS, this table is not
* protected from concurrent access. This hack doesn't work anyway on
* a protected system like OS/2. Use Microsoft C instead.
*/
{
/* If we allocate less than 65520 bytes, we assume that farmalloc
* will return a usable pointer which doesn't have to be normalized.
*/
if (bsize < 65520L) {
} else {
}
/* Normalize the pointer to seg:0 */
return buf;
}
{
int n;
return;
}
/* Find the original pointer */
for (n = 0; n < next_ptr; n++) {
while (++n < next_ptr) {
}
next_ptr--;
return;
}
Assert(0, "zcfree: ptr not found");
}
#endif /* __TURBOC__ */
#ifdef M_I86
/* Microsoft C in 16-bit mode */
# define MY_ZCALLOC
#endif
{
}
{
}
#endif /* M_I86 */
#endif /* SYS16BIT */
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
#if 0 && !_PACKAGE_ast
#ifndef STDC
#endif
#endif
unsigned items;
unsigned size;
{
}
{
if (opaque) return; /* make compiler happy */
}
#endif /* MY_ZCALLOC */
#endif /* _ZUTIL_C */
#ifndef _CRC32_H
/* crc32.h -- tables for rapid CRC calculation
* Generated automatically by crc32.c
*/
#ifndef TBLS
#endif
{
{
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
0x2d02ef8d
},
};
#endif /* _CRC32_H */
#ifndef _CRC32_C
/* ========================================================================= */
/* ========================================================================= */
unsigned long crc;
unsigned len;
{
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
#endif /* DYNAMIC_CRC_TABLE */
#ifdef BYFOUR
if (sizeof(void *) == sizeof(ptrdiff_t)) {
endian = 1;
if (*((unsigned char *)(&endian)))
else
}
#endif /* BYFOUR */
while (len >= 8) {
DO8;
len -= 8;
}
if (len) do {
DO1;
} while (--len);
return crc ^ 0xffffffff;
}
#endif /* _CRC32_C */
#ifndef _ADLER32_C
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
/* use NO_DIVIDE if your processor does not do division in hardware */
#ifdef NO_DIVIDE
# define MOD(a) \
do { \
} while (0)
# define MOD4(a) \
do { \
} while (0)
#else
#endif
/* ========================================================================= */
{
unsigned long sum2;
unsigned n;
/* split Adler-32 into component sums */
adler &= 0xffff;
/* in case user likes doing a byte at a time, keep it fast */
if (len == 1) {
}
/* initial Adler-32 value (deferred check for len == 1 speed) */
return 1L;
/* in case short lengths are provided, keep it somewhat fast */
if (len < 16) {
while (len--) {
}
}
/* do length NMAX blocks -- requires just one modulo operation */
do {
buf += 16;
} while (--n);
}
/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
while (len >= 16) {
len -= 16;
buf += 16;
}
while (len--) {
}
}
/* return recombined sums */
}
#endif /* _ADLER32_C */
#ifndef _DEFLATE_H
/* ===========================================================================
* Internal compression state.
*/
/* number of length codes, not counting the special END_BLOCK code */
/* number of literal bytes 0..255 */
/* number of Literal or Length codes, including the END_BLOCK code */
/* number of distance codes */
/* number of codes used to transfer the bit lengths */
/* maximum heap size */
/* All codes must not exceed MAX_BITS bits */
/* Stream status */
/* Data structure describing a single value and its code string. */
typedef struct ct_data_s {
union {
} fc;
union {
} dl;
typedef struct tree_desc_s {
typedef unsigned IPos;
/* A Pos is an index in the character window. We use short instead of int to
* save space in the various tables. IPos is used only for parameter passing.
*/
typedef struct internal_state {
/* used by deflate.c: */
/* Sliding window. Input bytes are read into the second half of the window,
* and move to the first half later to keep a dictionary of at least wSize
* bytes. With this organization, matches are limited to a distance of
* wSize-MAX_MATCH bytes, but this ensures that IO is always
* performed with a length multiple of the block size. Also, it limits
* the window size to 64K, which is quite useful on MSDOS.
* To do: use the user input buffer as sliding window.
*/
/* Actual size of window: 2*wSize, except when the user input buffer
* is directly used as sliding window.
*/
/* Link to older string with same hash index. To limit the size of this
* array to 64K, this link is maintained only for the last 32K strings.
* An index in this array is thus a window index modulo 32K.
*/
/* Number of bits by which ins_h must be shifted at each input
* step. It must be such that after MIN_MATCH steps, the oldest
* byte no longer takes part in the hash key, that is:
* hash_shift * MIN_MATCH >= hash_bits
*/
long block_start;
/* Window position at the beginning of the current output block. Gets
* negative when the window is moved backwards.
*/
/* Length of the best match at previous step. Matches not greater than this
* are discarded. This is used in the lazy match evaluation.
*/
/* To speed up deflation, hash chains are never searched beyond this
* length. A higher limit improves compression ratio but degrades the
* speed.
*/
/* Attempt to find a better match only when the current match is strictly
* smaller than this value. This mechanism is used only for compression
* levels >= 4.
*/
/* Insert new strings in the hash table only if the match length is not
* greater than this length. This saves time but degrades compression.
* max_insert_length is used only for compression levels <= 3.
*/
/* Use a faster search when the previous match is longer than this */
/* used by trees.c: */
/* Didn't use ct_data typedef below to supress compiler warning */
/* number of codes at each bit length for an optimal tree */
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
* The same heap array is used to build all trees.
*/
/* Depth of each subtree used as tie breaker for trees of equal frequency
*/
* limiting lit_bufsize to 64K:
* - frequencies can be kept in 16 bit counters
* - if compression is not successful for the first block, all input
* data is still in the window so we can still emit a stored block even
* when input comes from standard input. (This can also be done for
* all blocks if lit_bufsize is not greater than 32K.)
* - if compression is not successful for a file smaller than 64K, we can
* even emit a stored file instead of a stored block (saving 5 bytes).
* This is applicable only for zip (not gzip or zlib).
* - creating new Huffman trees less frequently may not provide fast
* adaptation to changes in the input data statistics. (Take for
* example a binary file with poorly compressible code followed by
* a highly compressible string table.) Smaller buffer sizes give
* fast adaptation but have of course the overhead of transmitting
* trees more frequently.
* - I can't count above 4
*/
/* Buffer for distances. To simplify the code, d_buf and l_buf have
* the same number of elements. To use different lengths, an extra flag
* array would be necessary.
*/
#ifdef Z_DEBUG
#endif
/* Output buffer. bits are inserted starting at the bottom (least
* significant bits).
*/
int bi_valid;
/* Number of valid bits in bi_buf. All bits above the last valid bit
* are always zero.
*/
/* Output a byte on the stream.
* IN assertion: there is enough room in pending_buf.
*/
/* Minimum amount of lookahead, except at the end of the input file.
* See deflate.c for comments about the MIN_MATCH+1.
*/
/* In order to simplify the code, particularly on 16 bit machines, match
* distances are limited to MAX_DIST instead of WSIZE.
*/
/* in trees.c */
int eof));
int eof));
/* Mapping from a distance to a distance code. dist is the distance - 1 and
* must not have side effects. _dist_code[256] and _dist_code[257] are never
* used.
*/
#ifndef Z_DEBUG
/* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC)
extern uch _length_code[];
extern uch _dist_code[];
#else
extern const uch _length_code[];
extern const uch _dist_code[];
#endif
}
dist--; \
}
#else
#endif
#endif /* _DEFLATE_H */
#ifndef _INFTREES_H
typedef struct {
} code;
/* op values as set by inflate_table():
00000000 - literal
0000tttt - table link, tttt != 0 is the number of table index bits
0001eeee - length or distance, eeee is the number of extra bits
01100000 - end of block
01000000 - invalid code
*/
/* Maximum size of dynamic tree. The maximum found in a long but non-
and 592 for distances, the latter actually the result of an
exhaustive search). The true maximum is not known, but the value
below is more than safe. */
/* Type of code to build for inftable() */
typedef enum {
LENS,
} codetype;
#endif /* _INFTREES_H */
#ifndef _INFLATE_H
/* Possible inflate modes between inflate() calls */
typedef enum {
} inflate_mode;
/*
State transitions between above modes -
(most modes can go to the BAD or MEM mode -- not shown for clarity)
Process header:
HEAD -> (gzip) or (zlib)
(gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
NAME -> COMMENT -> HCRC -> TYPE
(zlib) -> DICTID or TYPE
DICTID -> DICT -> TYPE
Read deflate blocks:
TYPE -> STORED or TABLE or LEN or CHECK
STORED -> COPY -> TYPE
TABLE -> LENLENS -> CODELENS -> LEN
Read deflate codes:
LEN -> LENEXT or LIT or TYPE
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
LIT -> LEN
Process trailer:
CHECK -> LENGTH -> DONE
*/
/* state maintained between inflate() calls. Approximately 7K bytes. */
struct inflate_state {
/* sliding window */
/* bit accumulator */
/* for string and stored block copying */
/* for table and code decoding */
/* fixed and dynamic code tables */
/* dynamic table building */
};
#endif /* _INFLATE_H */
#ifndef _INFTREES_C
const char inflate_copyright[] =
" inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
include such an acknowledgment, I would appreciate that you keep this
copyright string in the executable of your product.
*/
/*
Build a set of tables to decode the provided canonical Huffman code.
The code lengths are lens[0..codes-1]. The result starts at *table,
whose indices are 0..2^bits-1. work is a writable array of at least
lens shorts, which is used as a work area. type is the type of code
to be generated, CODES, LENS, or DISTS. On return, zero is success,
-1 is an invalid code, and +1 means that ENOUGH isn't enough. table
on return points to the next available entry's address. bits is the
requested root table index bits, and on return it is the actual root
table index bits. It will differ if the request is greater than the
longest code or if it is less than the shortest code.
*/
unsigned codes;
{
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577, 0, 0};
16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
28, 28, 29, 29, 64, 64};
/*
Process a set of code lengths to create a canonical Huffman code. The
code lengths are lens[0..codes-1]. Each length corresponds to the
symbols 0..codes-1. The Huffman code is generated by first sorting the
symbols by length from short to long, and retaining the symbol order
for codes with equal lengths. Then the code starts with all zero bits
for the first code of the shortest length, and the codes are integer
increments for the same length, and zeros are appended as the length
increases. For the deflate format, these bits are stored backwards
from their more natural integer increment ordering, and so when the
decoding tables are built in the large loop below, the integer codes
are incremented backwards.
This routine assumes, but does not check, that all of the entries in
lens[] are in the range 0..MAXBITS. The caller must assure this.
1..MAXBITS is interpreted as that code length. zero means that that
symbol does not occur in this code.
The codes are sorted by computing a count of codes for each length,
creating from that a table of starting indices for each length in the
sorted table, and then entering the symbols in order in the sorted
table. The sorted table is work[], with that space being provided by
the caller.
The length counts are used for other purposes as well, i.e. finding
the minimum and maximum length codes, determining if there are any
codes at all, checking for a valid set of lengths, and looking ahead
at length counts to determine sub-table sizes when building the
decoding tables.
*/
/* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
/* bound code lengths, force root to be within code lengths */
if (max == 0) { /* no symbols to code at all */
*bits = 1;
return 0; /* no symbols, but wait for decoding to report error */
}
/* check for an over-subscribed or incomplete set of lengths */
left = 1;
left <<= 1;
}
return -1; /* incomplete set */
/* generate offsets into symbol table for each length for sorting */
offs[1] = 0;
/* sort symbols by length, by symbol order within each length */
/*
Create and fill in decoding tables. In this loop, the table being
filled is at next and has curr index bits. The code being used is huff
with length len. That code is converted to an index by dropping drop
bits off of the bottom. For codes where len is less than drop + curr,
those top drop + curr - len bits are incremented through all values to
fill the table with replicated entries.
root is the number of index bits for the root table. When len exceeds
root, sub-tables are created pointed to by the root entry with an index
of the low root bits of huff. This is saved in low to check for when a
new sub-table should be started. drop is zero when the root table is
being filled, and drop is root when sub-tables are being filled.
When a new sub-table is needed, it is necessary to look ahead in the
code lengths to determine what size sub-table is needed. The length
counts are used for this, and so count[] is decremented as codes are
entered in the tables.
used keeps track of how many table entries have been allocated from the
provided *table space. It is checked when a LENS table is being made
against the space in *table, ENOUGH, minus the maximum space needed by
the worst case distance code, MAXD. This should never happen, but the
sufficiency of ENOUGH has not been proven exhaustively, hence the check.
This assumes that when type == LENS, bits == 9.
sym increments through all symbols, and the loop terminates when
all codes of length max, i.e. all codes, have been processed. This
routine permits incomplete codes, so another loop after this one fills
in the rest of the decoding tables with invalid code markers.
*/
/* set up for code type */
switch (type) {
case CODES:
end = 19;
break;
case LENS:
base -= 257;
extra -= 257;
end = 256;
break;
default: /* DISTS */
end = -1;
}
/* initialize state for loop */
huff = 0; /* starting code */
sym = 0; /* starting code symbol */
drop = 0; /* current bits to drop from code for index */
/* check available table space */
return 1;
/* process all codes and make table entries */
for (;;) {
/* create table entry */
}
}
else {
}
/* replicate for those indices with low len bits equal to huff */
do {
} while (fill != 0);
/* backwards increment the len-bit code huff */
incr >>= 1;
if (incr != 0) {
}
else
huff = 0;
/* go to next symbol, update count, len */
sym++;
}
/* create new sub-table if needed */
/* if first time, transition to sub-tables */
if (drop == 0)
/* increment past last table */
/* determine length of next table */
if (left <= 0) break;
curr++;
left <<= 1;
}
/* check for enough space */
return 1;
/* point entry in root table to sub-table */
}
}
/*
Fill in rest of table for incomplete codes. This loop is similar to the
loop above in incrementing huff for table indices. It is assumed that
len is equal to curr + drop, so there is no loop needed to increment
through high index bits. When the current sub-table is filled, the loop
drops back to the root table to fill in any remaining entries there.
*/
while (huff != 0) {
/* when done with sub-table, drop back to root table */
drop = 0;
}
/* put invalid code marker in table */
/* backwards increment the len-bit code huff */
incr >>= 1;
if (incr != 0) {
}
else
huff = 0;
}
/* set return parameters */
return 0;
}
#endif /* _INFTREES_C */
#ifndef _INFFAST_C
/* Allow machine dependent optimization for post-increment or pre-increment.
Based on testing to date,
Pre-increment preferred for:
- PowerPC G3 (Adler)
- MIPS R5000 (Randers-Pehrson)
Post-increment preferred for:
- none
No measurable difference:
- Pentium III (Anderson)
- M68060 (Nikl)
*/
#ifdef POSTINC
# define OFF 0
# define PUP(a) *(a)++
#else
# define PUP(a) *++(a)
#endif
/*
Decode literal, length, and distance codes and write out the resulting
literal and match bytes until either not enough input or output is
available, an end-of-block is encountered, or a data error is encountered.
When large enough input and output buffers are supplied to inflate(), for
example, a 16K input buffer and a 64K output buffer, more than 95% of the
inflate execution time is spent in this routine.
Entry assumptions:
state->mode == LEN
strm->avail_in >= 6
strm->avail_out >= 258
start >= strm->avail_out
state->bits < 8
On return, state->mode is one of:
LEN -- ran out of enough output space or enough available input
TYPE -- reached end of block code, inflate() to interpret next block
BAD -- error in block data
Notes:
length code, 5 bits for the length extra, 15 bits for the distance code,
and 13 bits for the distance extra. This totals 48 bits, or six bytes.
Therefore if strm->avail_in >= 6, then there is enough input to avoid
checking for available input while decoding.
bytes, which is the maximum length that can be coded. inflate_fast()
requires strm->avail_out >= 258 for each loop to avoid checking for
output space.
*/
unsigned start; /* inflate()'s starting value for strm->avail_out */
{
#ifdef INFLATE_STRICT
#endif
/* window position, window bytes to copy */
/* copy state to local variables */
#ifdef INFLATE_STRICT
#endif
input data or output space */
do {
if (bits < 15) {
bits += 8;
bits += 8;
}
if (op == 0) { /* literal */
"inflate: literal '%c'\n" :
}
if (op) {
bits += 8;
}
}
if (bits < 15) {
bits += 8;
bits += 8;
}
bits += 8;
bits += 8;
}
}
#ifdef INFLATE_STRICT
break;
}
#endif
break;
}
if (write == 0) { /* very common case */
do {
} while (--op);
}
}
do {
} while (--op);
do {
} while (--op);
}
}
}
else { /* contiguous in window */
do {
} while (--op);
}
}
while (len > 2) {
len -= 3;
}
if (len) {
if (len > 1)
}
}
else {
do { /* minimum length is three */
len -= 3;
} while (len > 2);
if (len) {
if (len > 1)
}
}
}
goto dodist;
}
else {
break;
}
}
goto dolen;
}
break;
}
else {
break;
}
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
/* update state and return */
return;
}
/*
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- Using bit fields for code structure
- Different op definition to avoid & for extra bits (do & for table bits)
- Three separate decoding do-loops for direct, window, and write == 0
- Special case for distance > 1 copies to do overlapped load and store copy
- Explicit branch predictions (based on measured branch probabilities)
- Deferring match copy and interspersed it with decoding subsequent codes
- Larger unrolled copy loops (three is about right)
- Moving len -= 3 statement into middle of loop
*/
#endif /* _INFFAST_C */
#ifndef _INFLATE_C
/* function prototypes */
#ifdef BUILDFIXED
#endif
unsigned len));
{
return Z_OK;
}
int bits;
int value;
{
return Z_OK;
}
int windowBits;
const char *version;
int stream_size;
{
stream_size != (int)(sizeof(z_stream)))
return Z_VERSION_ERROR;
}
if (windowBits < 0) {
windowBits = -windowBits;
}
else {
#ifdef GUNZIP
#endif
}
return Z_STREAM_ERROR;
}
return inflateReset(strm);
}
const char *version;
int stream_size;
{
}
/*
Return state with length and distance decoding tables and index sizes set to
fixed code decoding. Normally this returns fixed tables from inffixed.h.
If BUILDFIXED is defined, then instead this routine builds the tables the
first time it's called, and returns those tables the first time and
thereafter. This reduces the size of the code by about 2K bytes, in
exchange for a little execution time. However, BUILDFIXED should not be
used for threaded applications, since the rewriting of the tables and virgin
may not be thread-safe.
*/
{
#ifndef _INFFIXED_H
{96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
{0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
{0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
{0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
{0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
{21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
{0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
{0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
{18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
{0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
{0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
{0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
{20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
{0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
{0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
{16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
{0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
{0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
{0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
{0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
{0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
{0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
{0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
{17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
{0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
{0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
{0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
{19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
{0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
{0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
{16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
{0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
{0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
{0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
{0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
{20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
{0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
{0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
{17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
{0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
{0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
{0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
{20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
{0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
{0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
{0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
{16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
{0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
{0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
{0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
{0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
{0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
{0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
{0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
{16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
{0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
{0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
{0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
{19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
{0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
{0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
{16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
{0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
{0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
{0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
{0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
{64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
{0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
{0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
{18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
{0,9,255}
};
{16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
{21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
{18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
{19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
{16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
{22,5,193},{64,5,0}
};
#endif /* _INFFIXED_H */
}
/*
Update the window with the last wsize (normally 32K) bytes written before
returning. If window does not exist yet, create it. This is only called
when a window is already in use, or when output has been written during this
inflate call, but the end of the deflate stream has not been reached yet.
It is also called to create a window for dictionary data when a dictionary
is loaded.
Providing output buffers larger than 32K to inflate() should provide a speed
advantage, since only the last 32K of output is copied to the sliding window
upon return from inflate(), and since all distances after the first 32K of
output will fall in the output data, making match copies simpler and faster.
The advantage may be dependent on the size of the processor's data caches.
*/
unsigned out;
{
/* if it hasn't been done already, allocate space for the window */
sizeof(unsigned char));
}
/* if window not in use yet, initialize */
}
/* copy state->wsize or less output bytes into the circular window */
}
else {
if (copy) {
}
else {
}
}
return 0;
}
/* Macros for inflate(): */
/* check function to use adler32() for zlib or crc32() for gzip */
#ifdef GUNZIP
#else
#endif
/* check macros for header crc */
#ifdef GUNZIP
do { \
} while (0)
do { \
} while (0)
#endif
/* Load registers with state in inflate() for speed */
#define LOAD() \
do { \
} while (0)
/* Restore state from registers in inflate() */
#define RESTORE() \
do { \
} while (0)
/* Clear the input bit accumulator */
#define INITBITS() \
do { \
hold = 0; \
bits = 0; \
} while (0)
/* Get a byte of input into the bit accumulator, or return from inflate()
if there is no input available. */
#define PULLBYTE() \
do { \
have--; \
bits += 8; \
} while (0)
/* Assure that there are at least n bits in the bit accumulator. If there is
not enough available input to do that, then return from inflate(). */
#define NEEDBITS(n) \
do { \
while (bits < (unsigned)(n)) \
PULLBYTE(); \
} while (0)
/* Return the low n bits of the bit accumulator (n < 16) */
#define BITS(n) \
/* Remove n bits from the bit accumulator */
#define DROPBITS(n) \
do { \
hold >>= (n); \
bits -= (unsigned)(n); \
} while (0)
/* Remove zero to seven bits as needed to go to a byte boundary */
#define BYTEBITS() \
do { \
} while (0)
/* Reverse the bytes in a 32-bit value */
#define REVERSE(q) \
((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
/*
inflate() uses a state machine to process as much input data and generate as
much output data as possible before returning. The state machine is
structured roughly as follows:
for (;;) switch (state) {
...
case STATEn:
if (not enough input data or output space to make progress)
return;
... make progress ...
state = STATEm;
break;
...
}
so when inflate() is called again, the same case is attempted again, and
if the appropriate resources are provided, the machine proceeds to the
next state. The NEEDBITS() macro is usually the way the state evaluates
whether it can proceed or should return. NEEDBITS() does the return if
the requested bits are not available. The typical use of the BITS macros
is:
NEEDBITS(n);
... do something with BITS(n) ...
DROPBITS(n);
where NEEDBITS(n) either returns from inflate() if there isn't enough
input left to load n bits into the accumulator, or it continues. BITS(n)
gives the low n bits in the accumulator. When done, DROPBITS(n) drops
the low n bits off the accumulator. INITBITS() clears the accumulator
and sets the number of available bits to zero. BYTEBITS() discards just
enough bits to put the accumulator on a byte boundary. After BYTEBITS()
and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
if there is no input available. The decoding of variable length codes uses
PULLBYTE() directly in order to pull just enough bytes to decode the next
code, and no more.
Some states loop until they get enough input, making sure that enough
state information is maintained to continue the loop where it left off
if NEEDBITS() returns in the loop. For example, want, need, and keep
would all have to actually be part of the saved state in case NEEDBITS()
returns:
case STATEw:
while (want < need) {
NEEDBITS(n);
keep[want++] = BITS(n);
DROPBITS(n);
}
state = STATEx;
case STATEx:
As shown above, if the next state is also the next case, then the break
is omitted.
A state may also return if there is not enough output space available to
complete that state. Those states are copying stored data, writing a
literal byte, and copying a matching string.
When returning, a "goto inf_leave" is used to update the total counters,
update the check value, and determine whether any progress has been made
during that inflate() call in order to return the proper return code.
Progress is defined as a change in either strm->avail_in or strm->avail_out.
When there is a window, goto inf_leave will update the window with the last
output written. If a goto inf_leave occurs in the middle of decompression
and there is no window currently, goto inf_leave will create one and copy
output to the window for the next call of inflate().
In this implementation, the flush parameter of inflate() only affects the
return code (per zlib.h). inflate() always writes as much as possible to
strm->next_out, given the space available and the provided input--the effect
documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
the allocation of and copying into a sliding window until necessary, which
provides the effect documented in zlib.h for Z_FINISH when the entire input
stream available. So the only thing the flush parameter actually does is:
when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
will return Z_BUF_ERROR if it has not reached the end of the stream.
*/
int flush;
{
#ifdef GUNZIP
#endif
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
return Z_STREAM_ERROR;
LOAD();
for (;;)
case HEAD:
break;
}
NEEDBITS(16);
#ifdef GUNZIP
INITBITS();
break;
}
#else
if (
#endif
break;
}
break;
}
DROPBITS(4);
break;
}
INITBITS();
break;
#ifdef GUNZIP
case FLAGS:
NEEDBITS(16);
break;
}
break;
}
INITBITS();
case TIME:
NEEDBITS(32);
INITBITS();
case OS:
NEEDBITS(16);
}
INITBITS();
case EXLEN:
NEEDBITS(16);
INITBITS();
}
case EXTRA:
if (copy) {
}
}
}
case NAME:
copy = 0;
do {
}
case COMMENT:
copy = 0;
do {
}
case HCRC:
NEEDBITS(16);
break;
}
INITBITS();
}
}
break;
#endif
case DICTID:
NEEDBITS(32);
INITBITS();
case DICT:
RESTORE();
return Z_NEED_DICT;
}
case TYPE:
case TYPEDO:
BYTEBITS();
break;
}
NEEDBITS(3);
DROPBITS(1);
switch (BITS(2)) {
case 0: /* stored block */
break;
case 1: /* fixed block */
break;
case 2: /* dynamic block */
break;
case 3:
}
DROPBITS(2);
break;
case STORED:
BYTEBITS(); /* go to byte boundary */
NEEDBITS(32);
break;
}
INITBITS();
case COPY:
if (copy) {
break;
}
break;
case TABLE:
NEEDBITS(14);
DROPBITS(5);
DROPBITS(5);
DROPBITS(4);
#ifndef PKZIP_BUG_WORKAROUND
break;
}
#endif
case LENLENS:
NEEDBITS(3);
DROPBITS(3);
}
if (ret) {
break;
}
case CODELENS:
for (;;) {
PULLBYTE();
}
}
else {
break;
}
DROPBITS(2);
}
len = 0;
DROPBITS(3);
}
else {
len = 0;
DROPBITS(7);
}
break;
}
while (copy--)
}
}
/* handle error breaks in while */
/* build code tables */
if (ret) {
break;
}
if (ret) {
break;
}
case LEN:
RESTORE();
LOAD();
break;
}
for (;;) {
PULLBYTE();
}
for (;;) {
PULLBYTE();
}
}
"inflate: literal '%c'\n" :
break;
}
break;
}
break;
}
case LENEXT:
}
case DIST:
for (;;) {
PULLBYTE();
}
for (;;) {
PULLBYTE();
}
}
break;
}
case DISTEXT:
}
#ifdef INFLATE_STRICT
break;
}
#endif
break;
}
case MATCH:
}
else
}
else { /* copy from output */
}
do {
} while (--copy);
break;
case LIT:
left--;
break;
case CHECK:
NEEDBITS(32);
if (out)
if ((
#ifdef GUNZIP
#endif
break;
}
INITBITS();
}
#ifdef GUNZIP
case LENGTH:
NEEDBITS(32);
break;
}
INITBITS();
}
#endif
case DONE:
ret = Z_STREAM_END;
goto inf_leave;
case BAD:
ret = Z_DATA_ERROR;
goto inf_leave;
case MEM:
return Z_MEM_ERROR;
case SYNC:
default:
return Z_STREAM_ERROR;
}
/*
Return from inflate(), updating the total counts and the check value.
If there was no progress during the inflate() call, return a buffer
Note: a memory error from inflate() is non-recoverable.
*/
RESTORE();
return Z_MEM_ERROR;
}
ret = Z_BUF_ERROR;
return ret;
}
{
return Z_STREAM_ERROR;
return Z_OK;
}
const Bytef *dictionary;
{
unsigned long id;
/* check state */
return Z_STREAM_ERROR;
/* check for correct dictionary id */
return Z_DATA_ERROR;
}
/* copy dictionary to window */
return Z_MEM_ERROR;
}
}
else {
}
return Z_OK;
}
{
/* check state */
/* save header structure */
#ifdef GUNZIP
#endif
return Z_OK;
}
/*
Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
or when out of input. When called, *have is the number of pattern bytes
found in order so far, in 0..3. On return *have is updated to the new
state. If on return *have equals four, then the pattern was found and the
return value is how many bytes were read including the last byte of the
pattern. If *have is less than four, then the pattern has not been found
yet and the return value is len. In the latter case, syncsearch() can be
called again with more data and the *have state. *have is initialized to
zero for the first call.
*/
unsigned len;
{
unsigned got;
unsigned next;
next = 0;
got++;
got = 0;
else
next++;
}
return next;
}
{
unsigned len; /* number of bytes to look at or looked at */
/* check parameters */
/* if first time, start search in bit buffer */
len = 0;
}
}
/* search available input */
/* return no joy or set up to restart inflate() on a new block */
return Z_OK;
}
/*
Returns true if inflate is currently at the end of a block generated by
Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
implementation to provide an additional safety check. PPP uses
Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
block. When decompressing, PPP checks that at the end of input packet,
inflate is waiting for these length bytes.
*/
{
}
{
unsigned wsize;
/* check input */
return Z_STREAM_ERROR;
/* allocate space */
return Z_MEM_ERROR;
}
}
/* copy state */
}
}
return Z_OK;
}
#endif /* _INFLATE_C */
#ifndef _GZIO_C
#ifndef Z_BUFSIZE
# ifdef MAXSEG_64K
# else
# endif
#endif
#ifndef Z_PRINTF_BUFSIZE
#endif
#ifdef __MVS__
#endif
#if 0 && !_PACKAGE_ast
#ifndef STDC
#endif
#endif
/* gzip flag byte */
typedef struct gz_stream {
int z_err; /* error code for last stream operation */
int z_eof; /* set if end of input file */
char *msg; /* error message */
char *path; /* path name for debugging only */
int transparent; /* 1 if input file is not a .gz file */
#if _PACKAGE_ast
int fatal; /* fatal stream error => all other ops fail */
int nocrc; /* 1 to skip 'r' crc checks */
int noclose; /* 1 to skip destroy fclose */
int verified;/* 2-byte magic read and verified ('v') */
#endif
char mode; /* 'w' or 'r' */
int back; /* one character push-back */
int last; /* true if push-back is last character */
} gz_stream;
/* ===========================================================================
Opens a gzip (.gz) file for reading or writing. The mode parameter
is as in fopen ("rb" or "wb"). The file is given either by FILE pointer
or path name (if fp == 0).
gz_open returns NULL if the file could not be opened or if there was
insufficient memory to allocate the (de)compression state; errno
can be checked to distinguish the two cases (if errno is zero, the
zlib error is Z_MEM_ERROR).
*/
const char *path;
const char *mode;
{
int err;
char *p = (char*)mode;
gz_stream *s;
char *m = fmode;
if (!s) return Z_NULL;
s->z_eof = 0;
s->in = 0;
s->out = 0;
#if _PACKAGE_ast
s->fatal = 0;
s->nocrc = 0;
s->verified = 0;
#endif
s->transparent = 0;
}
s->mode = '\0';
do {
if (*p >= '0' && *p <= '9') {
level = *p - '0';
} else if (*p == 'f') {
} else if (*p == 'h') {
} else if (*p == 'R') {
#if _PACKAGE_ast
} else if (*p == 'n') {
s->nocrc = 1;
} else if (*p == 'o') {
s->noclose = 1;
} else if (*p == 'v') {
s->verified = 1;
#endif
} else {
*m++ = *p; /* copy the mode */
}
if (s->mode == 'w') {
#ifdef NO_GZCOMPRESS
#else
#if _PACKAGE_ast
s->nocrc = 0;
#endif
/* windowBits is passed < 0 to suppress zlib header */
#endif
}
} else {
/* windowBits is passed < 0 to tell that there is no zlib header.
* Note that in this case inflate *requires* an extra "dummy" byte
* after the compressed stream in order to complete decompression and
* return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
* present after the compressed stream.
*/
}
}
errno = 0;
}
if (s->mode == 'w') {
/* Write a very simple .gz header:
*/
s->start = 10L;
/* We use 10L instead of ftell(s->file) to because ftell causes an
* fflush on some systems. This version of the library doesn't use
* start anyway in write mode, so this initialization is not
* necessary.
*/
} else {
#if _PACKAGE_ast
#endif
check_header(s); /* skip the .gz header */
}
return (gzFile)s;
}
/* ===========================================================================
Associate a gzFile with the stdio stream fp.
*/
const char *mode;
{
char name[20];
if (!sp)
}
/* ===========================================================================
Read a byte from a gz_stream; update next_in and avail_in. Return EOF
for end of file.
IN assertion: the stream s has been sucessfully opened for reading.
*/
gz_stream *s;
{
errno = 0;
s->z_eof = 1;
return EOF;
}
}
}
/* ===========================================================================
Check the gzip header of a gz_stream opened for reading. Set the stream
mode to transparent if the gzip magic header is not present; set s->err
to Z_DATA_ERROR if the magic header is present but the rest of the header
is incorrect.
IN assertion: the stream s has already been created sucessfully;
s->stream.avail_in is zero for the first time, but may be non-zero
for concatenated .gz files.
*/
local void check_header(s)
gz_stream *s;
{
int method; /* method byte */
int flags; /* flags byte */
int c;
#if _PACKAGE_ast
if (!s->verified)
c = get_byte(s);
if (c != EOF) {
s->transparent = 1;
}
return;
}
}
#else
/* Assure two bytes in the buffer so we can peek ahead -- handle case
where first byte of header is at the end of the buffer after the last
gzip segment */
if (len < 2) {
errno = 0;
return;
}
}
/* Peek ahead to check the gzip magic header */
s->transparent = 1;
return;
}
#endif
/* Check the rest of the gzip header */
s->z_err = Z_DATA_ERROR;
return;
}
/* Discard time, xflags and OS code: */
/* len is garbage if EOF but the loop below will quit anyway */
}
}
}
}
}
/* ===========================================================================
* Cleanup then free the given gz_stream. Return a zlib error code.
Try freeing in the reverse order of allocations.
*/
gz_stream *s;
{
if (!s) return Z_STREAM_ERROR;
if (s->mode == 'w') {
#ifdef NO_GZCOMPRESS
#else
#endif
} else if (s->mode == 'r') {
}
}
#if _PACKAGE_ast
#else
#endif
#ifdef ESPIPE
#endif
}
TRYFREE(s);
return err;
}
/* ===========================================================================
Reads the given number of uncompressed bytes from the compressed file.
gzread returns the number of bytes actually read (0 for end of file).
*/
unsigned len;
{
s->out++;
start++;
if (s->last) {
s->z_err = Z_STREAM_END;
return 1;
}
}
if (s->transparent) {
/* Copy first the lookahead bytes: */
if (n > 0) {
next_out += n;
}
}
return (int)len;
}
errno = 0;
s->z_eof = 1;
break;
}
}
}
if (s->z_err == Z_STREAM_END) {
/* Check CRC and original size */
#if _PACKAGE_ast
if (!s->nocrc)
#endif
#if _PACKAGE_ast
#else
#endif
s->z_err = Z_DATA_ERROR;
} else {
(void)getLong(s);
/* The uncompressed length returned by above getlong() may be
* different from s->out in case of concatenated .gz files.
* Check for such files:
*/
check_header(s);
inflateReset(&(s->stream));
#if _PACKAGE_ast
if (!s->nocrc)
#endif
#if _PACKAGE_ast
else
s->z_err = Z_STREAM_END;
#endif
}
}
}
}
#if _PACKAGE_ast
if (!s->nocrc)
#endif
return -1;
}
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets z_err in case
of error.
*/
gz_stream *s;
{
int c;
c = get_byte(s);
x += ((uLong)c)<<24;
return x;
}
#endif /* _GZIO_C */
#endif /* _GUNZIP_H */
#ifndef _RATZ_C
#ifndef S_IRUSR
#endif
#ifndef S_IWUSR
#endif
#ifndef S_IXUSR
#endif
#ifndef S_IRGRP
#endif
#ifndef S_IWGRP
#endif
#ifndef S_IXGRP
#endif
#ifndef S_IROTH
#endif
#ifndef S_IWOTH
#endif
#ifndef S_IXOTH
#endif
/*
* Standard Archive Format
* USTAR - Uniform Standard Tape ARchive
*/
/*
* values used in typeflag field
*/
/*
* bits used in mode field
*/
/*
* file permissions
*/
typedef struct
{
char typeflag;
} Header_t;
static struct
{
char* id;
unsigned long blocks;
unsigned long files;
} state;
#if !_PACKAGE_ast
static void
usage()
{
#if defined(_SEAR_EXEC) || defined(_SEAR_SEEK)
#else
#endif
exit(2);
}
#endif
/*
*/
static const unsigned char a2e[] =
{
0000,0001,0002,0003,0067,0055,0056,0057,
0026,0005,0045,0013,0014,0015,0016,0017,
0020,0021,0022,0023,0074,0075,0062,0046,
0030,0031,0077,0047,0034,0035,0036,0037,
0100,0132,0177,0173,0133,0154,0120,0175,
0115,0135,0134,0116,0153,0140,0113,0141,
0360,0361,0362,0363,0364,0365,0366,0367,
0370,0371,0172,0136,0114,0176,0156,0157,
0174,0301,0302,0303,0304,0305,0306,0307,
0310,0311,0321,0322,0323,0324,0325,0326,
0327,0330,0331,0342,0343,0344,0345,0346,
0347,0350,0351,0255,0340,0275,0232,0155,
0171,0201,0202,0203,0204,0205,0206,0207,
0210,0211,0221,0222,0223,0224,0225,0226,
0227,0230,0231,0242,0243,0244,0245,0246,
0247,0250,0251,0300,0117,0320,0137,0007,
0040,0041,0042,0043,0044,0025,0006,0027,
0050,0051,0052,0053,0054,0011,0012,0033,
0060,0061,0032,0063,0064,0065,0066,0010,
0070,0071,0072,0073,0004,0024,0076,0341,
0101,0102,0103,0104,0105,0106,0107,0110,
0111,0121,0122,0123,0124,0125,0126,0127,
0130,0131,0142,0143,0144,0145,0146,0147,
0150,0151,0160,0161,0162,0163,0164,0165,
0166,0167,0170,0200,0212,0213,0214,0215,
0216,0217,0220,0152,0233,0234,0235,0236,
0237,0240,0252,0253,0254,0112,0256,0257,
0260,0261,0262,0263,0264,0265,0266,0267,
0270,0271,0272,0273,0274,0241,0276,0277,
0312,0313,0314,0315,0316,0317,0332,0333,
0334,0335,0336,0337,0352,0353,0354,0355,
0356,0357,0372,0373,0374,0375,0376,0377,
};
/*
*/
static const unsigned char a2i[] =
{
0000,0001,0002,0003,0067,0055,0056,0057,
0026,0005,0045,0013,0014,0015,0016,0017,
0020,0021,0022,0023,0074,0075,0062,0046,
0030,0031,0077,0047,0034,0035,0036,0037,
0100,0132,0177,0173,0133,0154,0120,0175,
0115,0135,0134,0116,0153,0140,0113,0141,
0360,0361,0362,0363,0364,0365,0366,0367,
0370,0371,0172,0136,0114,0176,0156,0157,
0174,0301,0302,0303,0304,0305,0306,0307,
0310,0311,0321,0322,0323,0324,0325,0326,
0327,0330,0331,0342,0343,0344,0345,0346,
0347,0350,0351,0255,0340,0275,0137,0155,
0171,0201,0202,0203,0204,0205,0206,0207,
0210,0211,0221,0222,0223,0224,0225,0226,
0227,0230,0231,0242,0243,0244,0245,0246,
0247,0250,0251,0300,0117,0320,0241,0007,
0040,0041,0042,0043,0044,0025,0006,0027,
0050,0051,0052,0053,0054,0011,0012,0033,
0060,0061,0032,0063,0064,0065,0066,0010,
0070,0071,0072,0073,0004,0024,0076,0341,
0101,0102,0103,0104,0105,0106,0107,0110,
0111,0121,0122,0123,0124,0125,0126,0127,
0130,0131,0142,0143,0144,0145,0146,0147,
0150,0151,0160,0161,0162,0163,0164,0165,
0166,0167,0170,0200,0212,0213,0214,0215,
0216,0217,0220,0232,0233,0234,0235,0236,
0237,0240,0252,0253,0254,0255,0256,0257,
0260,0261,0262,0263,0264,0265,0266,0267,
0270,0271,0272,0273,0274,0275,0276,0277,
0312,0313,0314,0315,0316,0317,0332,0333,
0334,0335,0336,0337,0352,0353,0354,0355,
0356,0357,0372,0373,0374,0375,0376,0377,
};
/*
* the mvs OpenEdition EBCDIC table
*/
static const unsigned char a2o[] =
{
0000,0001,0002,0003,0067,0055,0056,0057,
0026,0005,0025,0013,0014,0015,0016,0017,
0020,0021,0022,0023,0074,0075,0062,0046,
0030,0031,0077,0047,0034,0035,0036,0037,
0100,0132,0177,0173,0133,0154,0120,0175,
0115,0135,0134,0116,0153,0140,0113,0141,
0360,0361,0362,0363,0364,0365,0366,0367,
0370,0371,0172,0136,0114,0176,0156,0157,
0174,0301,0302,0303,0304,0305,0306,0307,
0310,0311,0321,0322,0323,0324,0325,0326,
0327,0330,0331,0342,0343,0344,0345,0346,
0347,0350,0351,0255,0340,0275,0137,0155,
0171,0201,0202,0203,0204,0205,0206,0207,
0210,0211,0221,0222,0223,0224,0225,0226,
0227,0230,0231,0242,0243,0244,0245,0246,
0247,0250,0251,0300,0117,0320,0241,0007,
0040,0041,0042,0043,0044,0045,0006,0027,
0050,0051,0052,0053,0054,0011,0012,0033,
0060,0061,0032,0063,0064,0065,0066,0010,
0070,0071,0072,0073,0004,0024,0076,0377,
0101,0252,0112,0261,0237,0262,0152,0265,
0273,0264,0232,0212,0260,0312,0257,0274,
0220,0217,0352,0372,0276,0240,0266,0263,
0235,0332,0233,0213,0267,0270,0271,0253,
0144,0145,0142,0146,0143,0147,0236,0150,
0164,0161,0162,0163,0170,0165,0166,0167,
0254,0151,0355,0356,0353,0357,0354,0277,
0200,0375,0376,0373,0374,0272,0256,0131,
0104,0105,0102,0106,0103,0107,0234,0110,
0124,0121,0122,0123,0130,0125,0126,0127,
0214,0111,0315,0316,0313,0317,0314,0341,
0160,0335,0336,0333,0334,0215,0216,0337,
};
/*
* ascii text vs. control
*/
static const unsigned char ascii_text[] =
{
0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
static int
char* buf;
{
int r;
if (gz)
else
if (r)
return r;
}
static int
char* buf;
unsigned long n;
{
while (n > 0)
{
{
return 1;
}
if (n <= sizeof(Header_t))
break;
n -= sizeof(Header_t);
}
return 0;
}
static unsigned long
number(s)
register char* s;
{
unsigned long n = 0;
while (*s == ' ')
s++;
while (*s >= '0' && *s <= '7')
n = (n << 3) + (*s++ - '0');
return n;
}
#if defined(_SEAR_EXEC) || defined(_SEAR_SEEK)
#ifndef PATH_MAX
#endif
static int sear_stdin;
static char* sear_tmp;
static int
{
int n;
sear_stdin = dup(0);
close(0);
{
return -1;
}
if (tmp)
{
{
return -1;
}
{
return -1;
}
if (!DeleteFile(sear_tmp))
{
return -1;
}
{
return -1;
}
if (!SetCurrentDirectory(sear_tmp))
{
return -1;
}
}
return 0;
}
/*
* remove dir and its subdirs
*/
static void
{
if (!SetCurrentDirectory(dir))
return;
{
do
{
{
}
else if (info.cFileName[0] != '.' || info.cFileName[1] != 0 && (info.cFileName[1] != '.' || info.cFileName[2] != 0))
}
if (SetCurrentDirectory(".."))
}
/*
* system(3) without PATH search that should work on all windows variants
*/
static int
{
char* cp;
int n = *command == '"';
n = n ? '"' : ' ';
if (*cp == n)
break;
*cp = 0;
if (nowindow)
else
{
n = 1;
}
return n;
}
/*
* copy t to f but no farther than e
* next t returned
*/
static char*
copy(char* t, const char* f, char* e)
{
while (t < e && *f)
*t++ = *f++;
return t;
}
/*
* execute cmd, chdir .., and remove sear_tmp
*/
static int
{
const char* a;
char* b;
char* e;
int r;
int sh;
int nowindow;
char buf[1024];
if (sear_tmp)
{
close(0);
nowindow = 0;
if (cmd)
{
if (arg)
for (r = 0; arg[r]; r++)
{
nowindow = 1;
break;
}
sh = 0;
for (a = cmd; *a && *a != ' '; a++)
if (a[0] == '.' && a[1] == 's' && a[2] == 'h' && (!a[3] || a[3] == ' '))
{
sh = 1;
break;
}
b = buf;
{
if (sh)
{
b = copy(b, "ksh.exe ", e);
b = copy(b, "./", e);
}
while (a = *arg++)
{
if ((e - b) < 3)
break;
b = copy(b, " \"", e);
b = copy(b, a, e);
b = copy(b, "\"", e);
}
}
if (operands)
{
if (b == buf)
b = copy(b, " -- ", e);
}
if (b > buf)
{
*b = 0;
}
}
else
r = code;
if (code >= 0)
}
else
return r;
}
#else
#define EXIT(n) return(n)
#endif
int
int argc;
char** argv;
{
register int c;
register char* s;
register char* t;
register char* e;
unsigned long n;
unsigned long m;
const unsigned char* a2x;
int clear;
int list;
int local;
int meter;
int unzip;
int verbose;
unsigned int mode;
unsigned long total;
unsigned char num[4];
#if defined(_SEAR_OPTS)
char* opts[4];
#endif
#if defined(_SEAR_EXEC) || defined(_SEAR_SEEK)
int install = 1;
#endif
clear = 0;
list = 0;
local = 0;
meter = 0;
unzip = 0;
verbose = 0;
if (s = *argv)
{
t = s;
while (*s)
if (*s++ == '/')
t = s;
if (!strcmp(t, "gunzip"))
unzip = 1;
}
else
switch ('~')
{
case 0241:
switch ('\n')
{
case 0025:
break;
default:
break;
}
break;
case 0137:
break;
default:
a2x = 0;
break;
}
#if defined(_SEAR_OPTS)
opts[3] = 0;
#endif
#if _PACKAGE_ast
for (;;)
{
{
case 'c':
unzip = 1;
continue;
#if defined(_SEAR_EXEC) || defined(_SEAR_SEEK)
case 'i':
install = 0;
continue;
case 'k':
install = -1;
continue;
#endif
case 'l':
local = 1;
continue;
case 'm':
meter = 1;
continue;
case 'n':
a2x = 0;
continue;
case 't':
list = 1;
continue;
case 'v':
verbose = 1;
continue;
case 'V':
return 0;
case '?':
continue;
case ':':
continue;
}
break;
}
if (error_info.errors)
#else
{
if (*(s + 1) == '-')
{
if (!*(s + 2))
{
argv++;
break;
}
usage();
break;
}
for (;;)
{
switch (c = *++s)
{
case 0:
break;
case 'c':
unzip = 1;
continue;
#if defined(_SEAR_EXEC) || defined(_SEAR_SEEK)
case 'i':
install = 0;
continue;
case 'k':
install = -1;
continue;
#endif
case 'l':
local = 1;
continue;
case 'm':
meter = 1;
continue;
case 'n':
a2x = 0;
continue;
case 't':
list = 1;
continue;
case 'v':
verbose = 1;
continue;
case 'V':
return 0;
default:
/*FALLTHROUGH*/
case '?':
usage();
break;
}
break;
}
}
#endif
#if defined(_SEAR_SEEK)
{
return 1;
}
#endif
/*
* commit on the first gzip magic char
*/
EXIT(0);
if (c != gz_magic[0])
gz = 0;
{
EXIT(1);
}
if (unzip)
{
if (!gz)
{
EXIT(1);
}
{
EXIT(1);
}
if (c < 0)
{
EXIT(1);
}
{
EXIT(1);
}
EXIT(0);
}
if (meter)
{
meter = 0;
else
{
meter = 0;
else if (!(total = ((num[0]|(num[1]<<8)|(num[2]<<16)|(num[3]<<24)) + sizeof(Header_t) - 1) / sizeof(Header_t)))
total = 1;
}
}
/*
* loop on all the header blocks
*/
{
/*
* last 2 blocks are NUL
*/
break;
/*
* verify the checksum
*/
if (a2x)
{
for (; s < e; s++)
*s = a2x[*(unsigned char*)s];
}
n = number(s) & TAR_SUMASK;
while (s < e)
*s++ = 040;
m = 0;
s = (char*)&header;
while (s < e)
m += *(unsigned char*)s++;
m &= TAR_SUMASK;
if (m != n)
{
else
EXIT(1);
}
/*
* convert to the native charset
*/
if (a2x)
*s = a2x[*(unsigned char*)s];
/*
* get the pathname, type and size
*/
t = path;
{
while (s < e && (c = *s++))
*t++ = c;
*t++ = '/';
}
while (s < e && (c = *s++))
*t++ = c;
*t = 0;
/*
* verify the dir prefix
*/
t = 0;
s = path;
while (*s)
if (*s++ == '/')
t = s;
if (t)
{
*--t = 0;
{
s = path;
do
{
if (!(c = *s) || c == '/')
{
*s = 0;
{
EXIT(1);
}
*s = c;
}
} while (*s++);
}
if (*(t + 1))
*t = '/';
else
}
/*
* check for non-local paths
*/
{
while (n > 0)
{
{
EXIT(1);
}
if (n <= sizeof(header))
break;
n -= sizeof(header);
}
continue;
}
/*
* create and grab the data
*/
mode = 0;
if (n & TUREAD)
if (n & TUWRITE)
if (n & TUEXEC)
if (n & TGREAD)
if (n & TGWRITE)
if (n & TGEXEC)
if (n & TOREAD)
if (n & TOWRITE)
if (n & TOEXEC)
{
if (meter)
{
int i;
int j;
int k;
int n;
int p;
for (s = path; *s; s++)
if (s[0] == ' ' && s[1] == '-' && s[2] == '-' && s[3] == ' ')
break;
if (*s)
{
if (clear)
{
clear = 0;
}
}
else
{
{
}
j = n + METER_parts + 2;
if (!clear)
clear = j + 5;
if ((k = clear - j - 5) < 0)
k = 0;
i = sizeof(bar) - 1;
n = 0;
while (n < i)
bar[n++] = '*';
while (n < sizeof(bar) - 1)
bar[n++] = ' ';
bar[n] = 0;
}
}
else
{
if (verbose)
{
{
case REGTYPE:
case AREGTYPE:
c = '-';
break;
case DIRTYPE:
c = 'd';
break;
case LNKTYPE:
c = 'h';
break;
case SYMTYPE:
c = 'l';
break;
default:
c = '?';
break;
}
printf("%c", c);
m = 0400;
while (m)
{
m >>= 1;
m >>= 1;
m >>= 1;
}
}
{
case LNKTYPE:
break;
case SYMTYPE:
break;
default:
break;
}
}
if (list)
{
EXIT(1);
continue;
}
}
else if (verbose)
{
case REGTYPE:
case AREGTYPE:
{
break;
}
c = a2x ? 0 : -1;
while (n > 0)
{
{
EXIT(1);
}
switch (c)
{
case 0:
if ((m = n) < 4)
{
for (e = (s = buf) + m; s < e; s++)
if (a2x[*(unsigned char*)s] != '\n')
break;
}
else
{
if (m > 256)
m = 256;
for (e = (s = buf) + m; s < e; s++)
if (!ascii_text[*(unsigned char*)s])
break;
}
if (s < e)
{
c = -1;
break;
}
c = 1;
/*FALLTHROUGH*/
case 1:
*s = a2x[*(unsigned char*)s];
break;
}
{
EXIT(1);
}
if (n <= sizeof(header))
break;
n -= sizeof(header);
}
{
EXIT(1);
}
break;
case DIRTYPE:
{
EXIT(1);
}
break;
case SYMTYPE:
{
EXIT(1);
}
continue;
#endif
case LNKTYPE:
{
EXIT(1);
}
continue;
#endif
default:
EXIT(1);
continue;
}
}
if (clear)
else if (verbose)
fprintf(stderr, "%lu file%s, %lu block%s\n", state.files, state.files == 1 ? "" : "s", state.blocks, state.blocks == 1 ? "" : "s");
#if defined(_SEAR_EXEC)
#if !defined(_SEAR_ARGS)
#define _SEAR_ARGS 0
#endif
{
return 1;
}
#endif
return 0;
}
#endif /* _RATZ_C */