| 1 |
/* |
| 2 |
Copyright (c) 1990-1999 Info-ZIP. All rights reserved. |
| 3 |
|
| 4 |
See the accompanying file LICENSE, version 1999-Oct-05 or later |
| 5 |
(the contents of which are also included in zip.h) for terms of use. |
| 6 |
If, for some reason, both of these files are missing, the Info-ZIP license |
| 7 |
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html |
| 8 |
*/ |
| 9 |
#if defined(__OS2__) && !defined(OS2) |
| 10 |
# define OS2 |
| 11 |
#endif |
| 12 |
|
| 13 |
/* Automatic setting of the common Microsoft C idenfifier MSC. |
| 14 |
* NOTE: Watcom also defines M_I*86 ! |
| 15 |
*/ |
| 16 |
#if defined(_MSC_VER) || (defined(M_I86) && !defined(__WATCOMC__)) |
| 17 |
# ifndef MSC |
| 18 |
# define MSC /* This should work for older MSC, too! */ |
| 19 |
# endif |
| 20 |
#endif |
| 21 |
|
| 22 |
#if defined(__WATCOMC__) && defined(__386__) |
| 23 |
# define WATCOMC_386 |
| 24 |
#endif |
| 25 |
|
| 26 |
#if defined(__EMX__) || defined(WATCOMC_386) || defined(__BORLANDC__) |
| 27 |
# if (defined(OS2) && !defined(__32BIT__)) |
| 28 |
# define __32BIT__ |
| 29 |
# endif |
| 30 |
#endif |
| 31 |
|
| 32 |
#if defined(OS2) && !defined(__32BIT__) |
| 33 |
# define MEMORY16 |
| 34 |
#endif |
| 35 |
|
| 36 |
#ifndef NO_ASM |
| 37 |
# define ASMV |
| 38 |
/* # define ASM_CRC */ |
| 39 |
#endif |
| 40 |
|
| 41 |
/* enable creation of UTC time fields unless explicitely suppressed */ |
| 42 |
#if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME)) |
| 43 |
# define USE_EF_UT_TIME |
| 44 |
#endif |
| 45 |
|
| 46 |
/* check that TZ environment variable is defined before using UTC times */ |
| 47 |
#if (!defined(NO_IZ_CHECK_TZ) && !defined(IZ_CHECK_TZ)) |
| 48 |
# define IZ_CHECK_TZ |
| 49 |
#endif |
| 50 |
|
| 51 |
#ifndef ZP_NEED_MEMCOMPR |
| 52 |
# define ZP_NEED_MEMCOMPR |
| 53 |
#endif |
| 54 |
|
| 55 |
#ifdef MEMORY16 |
| 56 |
# ifdef __TURBOC__ |
| 57 |
# include <alloc.h> |
| 58 |
# if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__) |
| 59 |
# if defined(DYNAMIC_CRC_TABLE) && defined(DYNALLOC_CRCTAB) |
| 60 |
error: No dynamic CRC table allocation with Borland C far data models. |
| 61 |
# endif /* DYNAMIC_CRC_TABLE */ |
| 62 |
# endif /* Turbo/Borland C far data memory models */ |
| 63 |
# define nearmalloc malloc |
| 64 |
# define nearfree free |
| 65 |
# define DYN_ALLOC |
| 66 |
# else /* !__TURBOC__ */ |
| 67 |
# include <malloc.h> |
| 68 |
# define nearmalloc _nmalloc |
| 69 |
# define nearfree _nfree |
| 70 |
# define farmalloc _fmalloc |
| 71 |
# define farfree _ffree |
| 72 |
# endif /* ?__TURBOC__ */ |
| 73 |
# define MY_ZCALLOC 1 |
| 74 |
#endif /* MEMORY16 */ |
| 75 |
|
| 76 |
|
| 77 |
/* The symbol MSDOS is consistently used in the generic source files |
| 78 |
* to identify code to support for MSDOS (and MSDOS related) stuff. |
| 79 |
* e.g: FAT or (FAT like) file systems, |
| 80 |
* '\\' as directory separator in paths, |
| 81 |
* "\r\n" as record (line) terminator in text files, ... |
| 82 |
* |
| 83 |
* MSDOS is defined anyway with MS C 16-bit. So the block above works. |
| 84 |
* For the 32-bit compilers, MSDOS must not be defined in the block above. |
| 85 |
*/ |
| 86 |
#if (defined(OS2) && !defined(MSDOS)) |
| 87 |
# define MSDOS |
| 88 |
/* inherit MS-DOS file system etc. stuff */ |
| 89 |
#endif |
| 90 |
|
| 91 |
#define USE_CASE_MAP |
| 92 |
#define PROCNAME(n) (action == ADD || action == UPDATE ? wild(n) : \ |
| 93 |
procname(n, 1)) |
| 94 |
|
| 95 |
/* time stamp resolution of file system is 2 seconds */ |
| 96 |
#define ROUNDED_TIME(time) ((time_t)(((unsigned long)(time) + 1) & (~1))) |
| 97 |
|
| 98 |
#define FOPR "rb" |
| 99 |
#define FOPM "r+b" |
| 100 |
#define FOPW "wb" |
| 101 |
|
| 102 |
#ifdef __32BIT__ |
| 103 |
# define CBSZ 0x40000 |
| 104 |
# define ZBSZ 0x40000 |
| 105 |
#else |
| 106 |
# define CBSZ 0xE000 |
| 107 |
# define ZBSZ 0x7F00 /* Some libraries do not allow a buffer size > 32K */ |
| 108 |
#endif |
| 109 |
|
| 110 |
#include <sys/types.h> |
| 111 |
#include <sys/stat.h> |
| 112 |
#include <io.h> |
| 113 |
|
| 114 |
#ifdef ZCRYPT_INTERNAL |
| 115 |
# ifndef __GO32__ |
| 116 |
# include <process.h> /* getpid() declaration for srand seed */ |
| 117 |
# endif |
| 118 |
#endif |
| 119 |
|
| 120 |
/* for some (all ?) versions of IBM C Set/2 and IBM C Set++ */ |
| 121 |
#ifndef S_IFMT |
| 122 |
# define S_IFMT 0xF000 |
| 123 |
#endif /* !S_IFMT */ |
| 124 |
|
| 125 |
#ifdef MSC |
| 126 |
# define NO_UNISTD_H |
| 127 |
#endif |
| 128 |
|
| 129 |
#ifdef __WATCOMC__ |
| 130 |
# define NO_MKTEMP |
| 131 |
/* Get asm routines to link properly without using "__cdecl": */ |
| 132 |
# ifdef __386__ |
| 133 |
# ifdef ASMV |
| 134 |
# pragma aux window "*"; |
| 135 |
# pragma aux prev "*"; |
| 136 |
# pragma aux prev_length "*"; |
| 137 |
# pragma aux strstart "*"; |
| 138 |
# pragma aux match_start "*"; |
| 139 |
# pragma aux max_chain_length "*"; |
| 140 |
# pragma aux good_match "*"; |
| 141 |
# pragma aux nice_match "*"; |
| 142 |
# pragma aux match_init "*"; |
| 143 |
# pragma aux longest_match "*"; |
| 144 |
# endif |
| 145 |
# ifndef USE_ZLIB |
| 146 |
# pragma aux crc32 "_*" parm caller [] value [eax] modify [eax] |
| 147 |
# pragma aux get_crc_table "_*" parm caller [] value [eax] \ |
| 148 |
modify [eax ecx edx] |
| 149 |
# endif /* !USE_ZLIB */ |
| 150 |
# else /* !__386__ */ |
| 151 |
# if defined(ASMV) || defined(ASM_CRC) |
| 152 |
/*# error 16 bit assembly modules currently DO NOT WORK with Watcom C. */ |
| 153 |
# endif |
| 154 |
# ifdef ASMV |
| 155 |
# pragma aux match_init "_*" parm caller [] loadds modify [ax bx] |
| 156 |
# pragma aux longest_match "_*" parm caller [] loadds value [ax] \ |
| 157 |
modify [ax bx cx dx es] |
| 158 |
# endif |
| 159 |
# ifndef USE_ZLIB |
| 160 |
# pragma aux crc32 "_*" parm caller [] value [ax dx] \ |
| 161 |
modify [ax bx cx dx es] |
| 162 |
# pragma aux get_crc_table "_*" parm caller [] value [ax] \ |
| 163 |
modify [ax bx cx dx] |
| 164 |
# endif /* !USE_ZLIB */ |
| 165 |
# endif /* ?__386__ */ |
| 166 |
#endif |
| 167 |
|
| 168 |
#ifdef __IBMC__ |
| 169 |
# define NO_UNISTD_H |
| 170 |
# define NO_MKTEMP |
| 171 |
# define timezone _timezone /* (underscore names work with */ |
| 172 |
# define tzset _tzset /* all versions of C Set) */ |
| 173 |
#endif |