1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
/*---------------------------------------------------------------------------
MS-DOS specific configuration section:
---------------------------------------------------------------------------*/
#ifndef __doscfg_h
#define __doscfg_h
#include <dos.h> /* for REGS macro (TC) or _dos_setftime (MSC) */
#ifdef __TURBOC__ /* includes Power C */
# include <sys/timeb.h> /* for structure ftime */
# ifndef __BORLANDC__ /* there appears to be a bug (?) in Borland's */
# include <mem.h> /* MEM.H related to __STDC__ and far poin- */
# endif /* ters. (dpk) [mem.h included for memcpy] */
#endif
#ifdef WINDLL
# if (defined(MSC) || defined(__WATCOMC__))
# include <sys/utime.h>
# else /* !(MSC || __WATCOMC__) ==> may be BORLANDC, or GNU environment */
# include <utime.h>
# endif /* ?(MSC || __WATCOMC__) */
#endif
#ifdef __WATCOMC__
# undef SSTAT
# define SSTAT stat_bandaid
int stat_bandaid(const char *path, struct stat *buf);
# ifdef __386__
# ifndef WATCOMC_386
# define WATCOMC_386
# endif
# define __32BIT__
# undef far
# define far
# undef near
# define near
/* Get asm routines to link properly without using "__cdecl": */
# ifndef USE_ZLIB
# pragma aux crc32 "_*" parm caller [] value [eax] modify [eax]
# pragma aux get_crc_table "_*" parm caller [] value [eax] \
modify [eax ecx edx]
# endif /* !USE_ZLIB */
# else /* !__386__ */
# ifndef USE_ZLIB
# pragma aux crc32 "_*" parm caller [] value [ax dx] \
modify [ax cx dx bx]
# pragma aux get_crc_table "_*" parm caller [] value [ax] \
modify [ax cx dx bx]
# endif /* !USE_ZLIB */
# endif /* ?__386__ */
# ifndef EPIPE
# define EPIPE -1
# endif
# define PIPE_ERROR (errno == EPIPE)
#endif /* __WATCOMC__ */
#ifdef __EMX__
# ifndef __32BIT__
# define __32BIT__
# endif
# define far
#endif
#if defined(__GO32__) || defined(__DJGPP__) /* MS-DOS compiler, not OS/2 */
# ifndef __32BIT__
# define __32BIT__
# endif
# ifndef __GO32__
# define __GO32__
# endif
# include <sys/timeb.h> /* for structure ftime */
# if (defined(__DJGPP__) && (__DJGPP__ > 1))
# include <unistd.h> /* for prototypes for read/write etc. */
# include <dir.h> /* for FA_LABEL */
# if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ == 0))
# include <libc/dosio.h> /* for _USE_LFN, djgpp 2.0 only */
# endif
# define USE_LFN _USE_LFN /* runtime test: support long filenames? */
# else
int setmode(int, int); /* not in older djgpp's include files */
# endif
#endif
#ifndef __32BIT__
# define __16BIT__
#endif
#if (defined(M_I86CM) || defined(M_I86LM)) || defined(WINDLL)
# define MED_MEM
#endif
#if (defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__))
# define MED_MEM
#endif
#ifdef __16BIT__
# ifndef MED_MEM
# define SMALL_MEM
# endif
#endif
#define EXE_EXTENSION ".exe" /* OS/2 has GetLoadPath() function instead */
#ifdef __16BIT__
# if defined(MSC) || defined(__WATCOMC__)
# include <malloc.h>
# define nearmalloc _nmalloc
# define nearfree _nfree
# endif
# if defined(__TURBOC__) && defined(DYNALLOC_CRCTAB)
# if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
# undef DYNALLOC_CRCTAB
# endif
# endif
# ifndef nearmalloc
# define nearmalloc malloc
# define nearfree free
# endif
# if defined(USE_ZLIB) && !defined(USE_OWN_CRCTAB)
# define USE_OWN_CRCTAB
# endif
#endif
/* another stat()/fopen() bug with some 16-bit compilers on Novell drives;
* very dangerous (silently overwrites executables in other directories)
*/
#define NOVELL_BUG_WORKAROUND
/* enables additional test and message code that directs UnZip to fail safely
* in case the "workaround" enabled above does not work as intended
*/
#define NOVELL_BUG_FAILSAFE
/* the TIMESTAMP feature is now supported on MSDOS, enable it per default */
#if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
# define TIMESTAMP
#endif
/* The optional "long filename" support available with some MSDOS compiler
* environments running under VFAT systems (Win95) is controlled with the
* help of the two preprocessor symbols USE_VFAT and USE_LFN:
* - USE_VFAT is a compile time switch that selects the long filename
* semantics in mapname()
* - USE_LFN is a macro equating to a boolean expression indicating
* whether long filenames are supported. If available, this
* macro should make use of a runtime function checking the
* LFN support.
*
* The code in msdos.c distinguishes three cases:
* 1.) USE_VFAT is not defined:
* No support of LFN is included; filenames are mapped to 8+3 plain FAT
* syntax unconditionally.
* This is achieved by ``#define MAYBE_PLAIN_FAT'' to include the plain
* FAT name mapping code and by ``#undef USE_LFN'' to disable bypassing
* of the FAT mapping at runtime.
* 2.) USE_VFAT is defined:
* Support for LFN is enabled.
* a) USE_LFN is undefined:
* There is no (runtime) check available to distinguish between OS
* environments that support VFAT extensions and those that do not.
* In this case, filenames are mapped to the more liberal VFAT LFN
* syntax unconditionally. The internal switch MAYBE_PLAIN_FAT remains
* undefined to exclude to "map to plain FAT" code parts.
* b) USE_LFN is defined (hopefully to a boolean runtime LFN check function):
* "#define MAYBE_PLAIN_FAT" is applied to include the plain FAT mapping
* code; the programs checks at runtime whether the OS supports LFN and
* uses the appropiate mapping syntax.
*/
/* Some environments, like DJGPP v2, can support long filenames on VFAT
* systems and DOS 8.3 filenames on FAT systems in the same executable. If
* such support is available, USE_LFN should be defined to an expression
* that will return non-zero when long filenames API should be used, zero
* otherwise.
*/
#ifndef USE_VFAT
# ifdef USE_LFN
# undef USE_LFN
# endif
# ifndef MAYBE_PLAIN_FAT
# define MAYBE_PLAIN_FAT
# endif
#endif
#ifdef USE_LFN
# define MAYBE_PLAIN_FAT
#endif
/* handlers for OEM <--> ANSI string conversions */
#ifdef WINDLL
# if 1
/* C RTL's file system support assumes OEM-coded strings */
# ifdef CRTL_CP_IS_ISO
# undef CRTL_CP_IS_ISO
# endif
# ifndef CRTL_CP_IS_OEM
# define CRTL_CP_IS_OEM
# endif
# else
/* C RTL's file system support assumes ISO-coded strings */
# ifndef CRTL_CP_IS_ISO
# define CRTL_CP_IS_ISO
# endif
# ifdef CRTL_CP_IS_OEM
# undef CRTL_CP_IS_OEM
# endif
# endif /* ?(code page of 16bit Windows compilers) */
/* include Win API declarations only in sources where conversion is
* actually used (skip EXTRACT_C, extract.c includes windll.h instead)
*/
# if defined(ENVARGS_C) || defined(UNZIP_C) || defined(ZCRYPT_INTERNAL)
# include <windows.h>
# endif
/* use conversion functions of Windows API */
# ifdef CRTL_CP_IS_ISO
# define ISO_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# define OEM_TO_INTERN(src, dst) OemToAnsi(src, dst)
# define INTERN_TO_ISO(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# define INTERN_TO_OEM(src, dst) AnsiToOem(src, dst)
# endif
# ifdef CRTL_CP_IS_OEM
# define ISO_TO_INTERN(src, dst) AnsiToOem(src, dst)
# define OEM_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# define INTERN_TO_ISO(src, dst) OemToAnsi(src, dst)
# define INTERN_TO_OEM(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# endif
# define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1)
# define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1)
/* UzpPassword supplies ANSI-coded string regardless of C RTL's native CP */
# define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst)
/* dummy defines to disable these functions, they are not needed */
# define STR_TO_ISO
# define STR_TO_OEM
#else
/* use home-brewed conversion functions; internal charset is OEM */
# ifdef CRTL_CP_IS_ISO
# undef CRTL_CP_IS_ISO
# endif
# ifndef CRTL_CP_IS_OEM
# define CRTL_CP_IS_OEM
# endif
#endif
/* SCREENLINES macros for 16-bit and djgpp compilers */
#ifdef __16BIT__
# define SCREENLINES (int)(*((unsigned char far*)0x00400084L) + 1)
# define SCREENWIDTH (int)(*(unsigned short far*)0x0040004AL)
#endif
#if defined(__GO32__) || defined(__DJGPP__) /* djgpp v1.x and v2.x */
# include <pc.h>
# define SCREENLINES ScreenRows()
# define SCREENWIDTH ScreenCols()
#endif
#ifdef __EMX__
# define SCREENLINES screenlines()
# define SCREENWIDTH screencolumns()
int screenlines(void);
int screencolumns(void);
#endif
#endif /* !__doscfg_h */
|