summaryrefslogtreecommitdiff
path: root/tailor.h
diff options
context:
space:
mode:
Diffstat (limited to 'tailor.h')
-rw-r--r--tailor.h459
1 files changed, 433 insertions, 26 deletions
diff --git a/tailor.h b/tailor.h
index 38afdcd..272f979 100644
--- a/tailor.h
+++ b/tailor.h
@@ -1,11 +1,41 @@
/*
- Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
+ tailor.h - Zip 3
- See the accompanying file LICENSE, version 2004-May-22 or later
+ Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
+
+ See the accompanying file LICENSE, version 2007-Mar-4 or later
(the contents of which are also included in zip.h) for terms of use.
- If, for some reason, both of these files are missing, the Info-ZIP license
+ If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
+
+/* Some compiler distributions for Win32/i386 systems try to emulate
+ * a Unix (POSIX-compatible) environment.
+ */
+#if (defined(WIN32) && defined(UNIX))
+ /* Zip does not support merging both ports in a single executable. */
+# if (defined(FORCE_WIN32_OVER_UNIX) && defined(FORCE_UNIX_OVER_WIN32))
+ /* conflicting choice requests -> we prefer the Win32 environment */
+# undef FORCE_UNIX_OVER_WIN32
+# endif
+# ifdef FORCE_WIN32_OVER_UNIX
+ /* native Win32 support was explicitely requested... */
+# undef UNIX
+# else
+ /* use the POSIX (Unix) emulation features by default... */
+# undef WIN32
+# endif
+#endif
+
+
+/* UNICODE */
+#ifdef NO_UNICODE_SUPPORT
+# ifdef UNICODE_SUPPORT
+# undef UNICODE_SUPPORT
+# endif
+#endif
+
+
#ifdef AMIGA
#include "amiga/osdep.h"
#endif
@@ -18,14 +48,14 @@
#include "atari/osdep.h"
#endif
-#ifdef __BEOS__
-#include "beos/osdep.h"
-#endif
-
#ifdef __ATHEOS__
#include "atheos/osdep.h"
#endif
+#ifdef __BEOS__
+#include "beos/osdep.h"
+#endif
+
#ifdef DOS
#include "msdos/osdep.h"
#endif
@@ -38,6 +68,10 @@
#include "macos/osdep.h"
#endif
+#ifdef NLM
+#include "novell/osdep.h"
+#endif
+
#ifdef OS2
#include "os2/osdep.h"
#endif
@@ -79,6 +113,53 @@
#include "theos/osdep.h"
#endif
+
+/* generic LARGE_FILE_SUPPORT defines
+ These get used if not defined above.
+ 7/21/2004 EG
+*/
+/* If a port hasn't defined ZOFF_T_FORMAT_SIZE_PREFIX
+ then probably need to define all of these. */
+#ifndef ZOFF_T_FORMAT_SIZE_PREFIX
+
+# ifdef LARGE_FILE_SUPPORT
+ /* Probably passed in from command line instead of in above
+ includes if get here. Assume large file support and hope. 8/14/04 EG */
+
+ /* Set the Large File Summit (LFS) defines to turn on large file support
+ in case it helps. */
+
+# define _LARGEFILE_SOURCE /* some OSes need this for fseeko */
+# define _LARGEFILE64_SOURCE
+# define _FILE_OFFSET_BITS 64 /* select default interface as 64 bit */
+# define _LARGE_FILES /* some OSes need this for 64-bit off_t */
+
+ typedef off_t zoff_t;
+ typedef unsigned long long uzoff_t; /* unsigned zoff_t (12/29/04 EG) */
+
+ /* go with common prefix */
+# define ZOFF_T_FORMAT_SIZE_PREFIX "ll"
+
+# else
+ /* Default type for offsets and file sizes was ulg but reports
+ of using ulg to create files from 2 GB to 4 GB suggest
+ it doesn't work well. Now just switch to Zip64 or not
+ support over 2 GB. 7/24/04 EG */
+ /* Now use uzoff_t for unsigned things. 12/29/04 EG */
+ typedef long zoff_t;
+ typedef unsigned long uzoff_t;
+
+# define ZOFF_T_FORMAT_SIZE_PREFIX "l"
+
+# endif
+
+ typedef struct stat z_stat;
+
+ /* flag that we are defaulting */
+# define USING_DEFAULT_LARGE_FILE_SUPPORT
+#endif
+
+
#if (defined(USE_ZLIB) && defined(ASM_CRC))
# undef ASM_CRC
#endif
@@ -95,8 +176,10 @@
/* Used to remove arguments in function prototypes for non-ANSI C */
#ifndef NO_PROTO
# define OF(a) a
+# define OFT(a) a
#else /* NO_PROTO */
# define OF(a) ()
+# define OFT(a)
#endif /* ?NO_PROTO */
/* If the compiler can't handle const define ZCONST in osdep.h */
@@ -111,6 +194,16 @@
#endif
/*
+ * Some compiler environments may require additional attributes attached
+ * to declarations of runtime libary functions (e.g. to prepare for
+ * linking against a "shared dll" version of the RTL). Here, we provide
+ * the "empty" default for these attributes.
+ */
+#ifndef IZ_IMP
+# define IZ_IMP
+#endif
+
+/*
* case mapping functions. case_map is used to ignore case in comparisons,
* to_up is used to force upper case even on Unix (for dosify option).
*/
@@ -171,28 +264,27 @@
* not supply C runtime library prototypes.
*/
#ifdef NO_PROTO
-char *strcpy();
-char *strcat();
-char *strrchr();
+IZ_IMP char *strcpy();
+IZ_IMP char *strcat();
+IZ_IMP char *strrchr();
/* XXX use !defined(ZMEM) && !defined(__hpux__) ? */
#if !defined(ZMEM) && defined(NO_STRING_H)
-char *memset();
-char *memcpy();
+IZ_IMP char *memset();
+IZ_IMP char *memcpy();
#endif /* !ZMEM && NO_STRING_H */
/* XXX use !defined(__hpux__) ? */
#ifdef NO_STDLIB_H
-char *calloc();
-char *malloc();
-char *getenv();
-long atol();
+IZ_IMP char *calloc();
+IZ_IMP char *malloc();
+IZ_IMP char *getenv();
+IZ_IMP long atol();
#endif /* NO_STDLIB_H */
#ifndef NO_MKTEMP
-char *mktemp();
+IZ_IMP char *mktemp();
#endif /* !NO_MKTEMP */
-/* moved to include mktemp - Cosmin 2/18/05 */
#endif /* NO_PROTO */
/*
@@ -217,6 +309,8 @@ char *mktemp();
#ifdef NO_SIZE_T
typedef unsigned int extent;
+ /* define size_t 3/17/05 EG */
+ typedef unsigned int size_t;
#else
typedef size_t extent;
#endif
@@ -229,6 +323,20 @@ char *mktemp();
* by Yoshioka Tsuneo (QWF00133@nifty.ne.jp,tsuneo-y@is.aist-nara.ac.jp)
* This code is public domain! Date: 1998/12/20
*/
+
+/* 2007-07-29 SMS.
+ * Include <locale.h> here if it will be needed later for Unicode.
+ * Otherwise, SETLOCALE may be defined here, and then defined again
+ * (differently) when <locale.h> is read later.
+ */
+#ifdef UNICODE_SUPPORT
+# if defined( UNIX) || defined( VMS)
+# include <locale.h>
+# endif /* defined( UNIX) || defined( VMS) */
+# include <wchar.h>
+# include <wctype.h>
+#endif /* def UNICODE_SUPPORT */
+
#ifdef _MBCS
# include <locale.h>
@@ -236,13 +344,15 @@ char *mktemp();
extern char *___tmp_ptr;
unsigned char *zmbschr OF((ZCONST unsigned char *, unsigned int));
unsigned char *zmbsrchr OF((ZCONST unsigned char *, unsigned int));
-# define CLEN(ptr) mblen(ptr, MB_CUR_MAX)
+# define CLEN(ptr) mblen((ZCONST char *)ptr, MB_CUR_MAX)
# define PREINCSTR(ptr) (ptr += CLEN(ptr))
# define POSTINCSTR(ptr) (___tmp_ptr=(char *)ptr,ptr += CLEN(ptr),___tmp_ptr)
int lastchar OF((ZCONST char *ptr));
# define MBSCHR(str,c) (char *)zmbschr((ZCONST unsigned char *)(str), c)
# define MBSRCHR(str,c) (char *)zmbsrchr((ZCONST unsigned char *)(str), (c))
-# define SETLOCALE(category, locale) setlocale(category, locale)
+# ifndef SETLOCALE
+# define SETLOCALE(category, locale) setlocale(category, locale)
+# endif /* ndef SETLOCALE */
#else /* !_MBCS */
# define CLEN(ptr) 1
# define PREINCSTR(ptr) (++(ptr))
@@ -250,7 +360,9 @@ char *mktemp();
# define lastchar(ptr) ((*(ptr)=='\0') ? '\0' : ptr[strlen(ptr)-1])
# define MBSCHR(str, c) strchr(str, c)
# define MBSRCHR(str, c) strrchr(str, c)
-# define SETLOCALE(category, locale)
+# ifndef SETLOCALE
+# define SETLOCALE(category, locale)
+# endif /* ndef SETLOCALE */
#endif /* ?_MBCS */
#define INCSTR(ptr) PREINCSTR(ptr)
@@ -269,10 +381,33 @@ typedef struct ztimbuf {
#endif
/* Some systems define S_IFLNK but do not support symbolic links */
-#if defined (S_IFLNK) && defined(NO_SYMLINK)
+#if defined (S_IFLNK) && defined(NO_SYMLINKS)
# undef S_IFLNK
#endif
+#ifndef Z_UINT4_DEFINED
+# if !defined(NO_LIMITS_H)
+# if (defined(UINT_MAX) && (UINT_MAX == 0xffffffffUL))
+ typedef unsigned int z_uint4;
+# define Z_UINT4_DEFINED
+# else
+# if (defined(ULONG_MAX) && (ULONG_MAX == 0xffffffffUL))
+ typedef unsigned long z_uint4;
+# define Z_UINT4_DEFINED
+# else
+# if (defined(USHRT_MAX) && (USHRT_MAX == 0xffffffffUL))
+ typedef unsigned short z_uint4;
+# define Z_UINT4_DEFINED
+# endif
+# endif
+# endif
+# endif /* !defined(NO_LIMITS_H) */
+#endif /* ndef Z_UINT4_DEFINED */
+#ifndef Z_UINT4_DEFINED
+ typedef ulg z_uint4;
+# define Z_UINT4_DEFINED
+#endif
+
#ifndef FOPR /* fallback default definitions for FOPR, FOPM, FOPW: */
# define FOPR "r"
# define FOPM "r+"
@@ -368,17 +503,288 @@ typedef struct ztimbuf {
# define DYN_ALLOC
#endif
-#ifndef SSTAT
-# define SSTAT stat
+
+/* LARGE_FILE_SUPPORT
+ *
+ * Types are in osdep.h for each port
+ *
+ * LARGE_FILE_SUPPORT and ZIP64_SUPPORT are automatically
+ * set in osdep.h (for some ports) based on the port and compiler.
+ *
+ * Function prototypes are below as OF is defined earlier in this file
+ * but after osdep.h is included. In the future ANSI prototype
+ * support may be required and the OF define may then go away allowing
+ * the function defines to be in the port osdep.h.
+ *
+ * E. Gordon 9/21/2003
+ * Updated 7/24/04 EG
+ */
+#ifdef LARGE_FILE_SUPPORT
+ /* 64-bit Large File Support */
+
+ /* Arguments for all functions are assumed to match the actual
+ arguments of the various port calls. As such only the
+ function names are mapped below. */
+
+/* ---------------------------- */
+# ifdef UNIX
+
+ /* Assume 64-bit file environment is defined. The below should all
+ be set to their 64-bit versions automatically. Neat. 7/20/2004 EG */
+
+ /* 64-bit stat functions */
+# define zstat stat
+# define zfstat fstat
+# define zlstat lstat
+
+# if defined(__alpha) && defined(__osf__) /* support for osf4.0f */
+ /* 64-bit fseek */
+# define zfseeko fseek
+
+ /* 64-bit ftell */
+# define zftello ftell
+
+# else
+ /* 64-bit fseeko */
+# define zfseeko fseeko
+
+ /* 64-bit ftello */
+# define zftello ftello
+# endif /* __alpha && __osf__ */
+
+ /* 64-bit fopen */
+# define zfopen fopen
+# define zfdopen fdopen
+
+# endif /* UNIX */
+
+/* ---------------------------- */
+# ifdef VMS
+
+ /* 64-bit stat functions */
+# define zstat stat
+# define zfstat fstat
+# define zlstat lstat
+
+ /* 64-bit fseeko */
+# define zfseeko fseeko
+
+ /* 64-bit ftello */
+# define zftello ftello
+
+ /* 64-bit fopen */
+# define zfopen fopen
+# define zfdopen fdopen
+
+# endif /* def VMS */
+
+/* ---------------------------- */
+# ifdef WIN32
+
+# if defined(__MINGW32__)
+ /* GNU C, linked against "msvcrt.dll" */
+
+ /* 64-bit stat functions */
+# define zstat _stati64
+# ifdef UNICODE_SUPPORT
+# define zwfstat _fstati64
+# define zwstat _wstati64
+# define zw_stat struct _stati64
+# endif
+# define zfstat _fstati64
+# define zlstat lstat
+
+ /* 64-bit fseeko */
+ /* function in win32.c */
+ int zfseeko OF((FILE *, zoff_t, int));
+
+ /* 64-bit ftello */
+ /* function in win32.c */
+ zoff_t zftello OF((FILE *));
+
+ /* 64-bit fopen */
+# define zfopen fopen
+# define zfdopen fdopen
+
+# endif
+
+# if defined(__CYGWIN__)
+ /* GNU C, CygWin with its own POSIX compatible runtime library */
+
+ /* 64-bit stat functions */
+# define zstat stat
+# define zfstat fstat
+# define zlstat lstat
+
+ /* 64-bit fseeko */
+# define zfseeko fseeko
+
+ /* 64-bit ftello */
+# define zftello ftello
+
+ /* 64-bit fopen */
+# define zfopen fopen
+# define zfdopen fdopen
+
+# endif
+
+# ifdef __WATCOMC__
+ /* WATCOM C */
+
+ /* 64-bit stat functions */
+# define zstat _stati64
+# ifdef UNICODE_SUPPORT
+# define zwfstat _fstati64
+# define zwstat _wstati64
+# define zw_stat struct _stati64
+# endif
+# define zfstat _fstati64
+# define zlstat lstat
+
+ /* 64-bit fseeko */
+ /* function in win32.c */
+ int zfseeko OF((FILE *, zoff_t, int));
+
+ /* 64-bit ftello */
+ /* function in win32.c */
+ zoff_t zftello OF((FILE *));
+
+ /* 64-bit fopen */
+# define zfopen fopen
+# define zfdopen fdopen
+
+# endif
+
+# ifdef _MSC_VER
+ /* MS C and VC */
+
+ /* 64-bit stat functions */
+# define zstat _stati64
+# ifdef UNICODE_SUPPORT
+# define zwfstat _fstati64
+# define zwstat _wstati64
+# define zw_stat struct _stati64
+# endif
+# define zfstat _fstati64
+# define zlstat lstat
+
+ /* 64-bit fseeko */
+ /* function in win32.c */
+ int zfseeko OF((FILE *, zoff_t, int));
+
+ /* 64-bit ftello */
+ /* function in win32.c */
+ zoff_t zftello OF((FILE *));
+
+ /* 64-bit fopen */
+# define zfopen fopen
+# define zfdopen fdopen
+
+# endif
+
+# ifdef __IBMC__
+ /* IBM C */
+
+ /* 64-bit stat functions */
+
+ /* 64-bit fseeko */
+ /* function in win32.c */
+ int zfseeko OF((FILE *, zoff_t, int));
+
+ /* 64-bit ftello */
+ /* function in win32.c */
+ zoff_t zftello OF((FILE *));
+
+ /* 64-bit fopen */
+
+# endif
+
+# endif /* WIN32 */
+
+#else
+ /* No Large File Support or default for 64-bit environment */
+
+# define zstat stat
+# define zfstat fstat
+# define zlstat lstat
+# define zfseeko fseek
+# define zftello ftell
+# define zfopen fopen
+# define zfdopen fdopen
+# ifdef UNICODE_SUPPORT
+# define zwfstat _fstat
+# define zwstat _wstat
+# define zw_stat struct _stat
+# endif
+
#endif
-#ifdef S_IFLNK
+
+#ifdef LARGE_FILE_SUPPORT /* E. Gordon 9/12/2003 */
+
+# ifndef SSTAT
+# define SSTAT zstat
+# ifdef UNICODE_SUPPORT
+# define SSTATW zwstat
+# endif
+# endif
+# ifdef S_IFLNK
+# define LSTAT zlstat
+# define LSSTAT(n, s) (linkput ? zlstat((n), (s)) : SSTAT((n), (s)))
+# else
+# define LSTAT SSTAT
+# define LSSTAT SSTAT
+# ifdef UNICODE_SUPPORT
+# define LSSTATW SSTATW
+# endif
+# endif
+
+#else /* no LARGE_FILE_SUPPORT */
+
+# ifndef SSTAT
+# define SSTAT stat
+# endif
+# ifdef S_IFLNK
# define LSTAT lstat
# define LSSTAT(n, s) (linkput ? lstat((n), (s)) : SSTAT((n), (s)))
-#else
+# else
# define LSTAT SSTAT
# define LSSTAT SSTAT
+# ifdef UNICODE_SUPPORT
+# define LSSTATW SSTATW
+# endif
+# endif
+
#endif
+
+/*---------------------------------------------------------------------*/
+
+
+/* 2004-12-01 SMS.
+ * Added fancy zofft() macros, et c.
+ */
+
+/* Default fzofft() format selection.
+ * Modified 2004-12-27 EG
+ */
+
+#ifndef FZOFFT_FMT
+# define FZOFFT_FMT ZOFF_T_FORMAT_SIZE_PREFIX /* printf for zoff_t values */
+
+# ifdef LARGE_FILE_SUPPORT
+# define FZOFFT_HEX_WID_VALUE "16" /* width of 64-bit hex values */
+# else
+# define FZOFFT_HEX_WID_VALUE "8" /* digits in 32-bit hex values */
+# endif
+
+#endif /* ndef FZOFFT_FMT */
+
+#define FZOFFT_HEX_WID ((char *) -1)
+#define FZOFFT_HEX_DOT_WID ((char *) -2)
+
+
+
+
/* The following default definition of the second input for the crypthead()
* random seed computation can be used on most systems (all those that
* supply a UNIX compatible getpid() function).
@@ -438,6 +844,7 @@ typedef struct ztimbuf {
#ifdef THEOS
# define OS_CODE 0x1200
#endif
+/* Yes, there is a gap here. */
#ifdef __ATHEOS__
# define OS_CODE 0x1E00
#endif