1/*
2  Copyright (c) 1990-2005 Info-ZIP.  All rights reserved.
3
4  See the accompanying file LICENSE, version 2004-May-22 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.info-zip.org/pub/infozip/license.html
8*/
9
10/* Some compiler distributions for Win32/i386 systems try to emulate
11 * a Unix (POSIX-compatible) environment.
12 */
13#if (defined(WIN32) && defined(UNIX))
14   /* Zip does not support merging both ports in a single executable. */
15#  if (defined(FORCE_WIN32_OVER_UNIX) && defined(FORCE_UNIX_OVER_WIN32))
16     /* conflicting choice requests -> we prefer the Win32 environment */
17#    undef FORCE_UNIX_OVER_WIN32
18#  endif
19#  ifdef FORCE_WIN32_OVER_UNIX
20     /* native Win32 support was explicitely requested... */
21#    undef UNIX
22#  else
23     /* use the POSIX (Unix) emulation features by default... */
24#    undef WIN32
25#  endif
26#endif
27
28#ifdef AMIGA
29#include "amiga/osdep.h"
30#endif
31
32#ifdef AOSVS
33#include "aosvs/osdep.h"
34#endif
35
36#ifdef ATARI
37#include "atari/osdep.h"
38#endif
39
40#if (defined(__BEOS__) || defined(__HAIKU__))
41#include "beos/osdep.h"
42#endif
43
44#ifdef __ATHEOS__
45#include "atheos/osdep.h"
46#endif
47
48#ifdef DOS
49#include "msdos/osdep.h"
50#endif
51
52#ifdef __human68k__
53#include "human68k/osdep.h"
54#endif
55
56#if ((defined(__MWERKS__) && defined(macintosh)) || defined(MACOS))
57#include "macos/osdep.h"
58#endif
59
60#ifdef OS2
61#include "os2/osdep.h"
62#endif
63
64#ifdef __riscos
65#include "acorn/osdep.h"
66#endif
67
68#ifdef QDOS
69#include "qdos/osdep.h"
70#endif
71
72#ifdef __TANDEM
73#include "tandem.h"
74#include "tanzip.h"
75#endif
76
77#ifdef UNIX
78#include "unix/osdep.h"
79#endif
80
81#if defined(__COMPILER_KCC__) || defined(TOPS20)
82#include "tops20/osdep.h"
83#endif
84
85#if defined(VMS) || defined(__VMS)
86#include "vms/osdep.h"
87#endif
88
89#if defined(__VM__) || defined(VM_CMS) || defined(MVS)
90#include "cmsmvs.h"
91#endif
92
93#ifdef WIN32
94#include "win32/osdep.h"
95#endif
96
97#ifdef THEOS
98#include "theos/osdep.h"
99#endif
100
101#if (defined(USE_ZLIB) && defined(ASM_CRC))
102#  undef ASM_CRC
103#endif
104
105#if (defined(USE_ZLIB) && defined(ASMV))
106#  undef ASMV
107#endif
108
109/* When "void" is an alias for "int", prototypes cannot be used. */
110#if (defined(NO_VOID) && !defined(NO_PROTO))
111#  define NO_PROTO
112#endif
113
114/* Used to remove arguments in function prototypes for non-ANSI C */
115#ifndef NO_PROTO
116#  define OF(a) a
117#else /* NO_PROTO */
118#  define OF(a) ()
119#endif /* ?NO_PROTO */
120
121/* If the compiler can't handle const define ZCONST in osdep.h */
122/* Define const itself in case the system include files are bonkers */
123#ifndef ZCONST
124#  ifdef NO_CONST
125#    define ZCONST
126#    define const
127#  else
128#    define ZCONST const
129#  endif
130#endif
131
132/*
133 * case mapping functions. case_map is used to ignore case in comparisons,
134 * to_up is used to force upper case even on Unix (for dosify option).
135 */
136#ifdef USE_CASE_MAP
137#  define case_map(c) upper[(c) & 0xff]
138#  define to_up(c)    upper[(c) & 0xff]
139#else
140#  define case_map(c) (c)
141#  define to_up(c)    ((c) >= 'a' && (c) <= 'z' ? (c)-'a'+'A' : (c))
142#endif /* USE_CASE_MAP */
143
144/* Define void, zvoid, and extent (size_t) */
145#include <stdio.h>
146
147#ifndef NO_STDDEF_H
148#  include <stddef.h>
149#endif /* !NO_STDDEF_H */
150
151#ifndef NO_STDLIB_H
152#  include <stdlib.h>
153#endif /* !NO_STDLIB_H */
154
155#ifndef NO_UNISTD_H
156#  include <unistd.h> /* usually defines _POSIX_VERSION */
157#endif /* !NO_UNISTD_H */
158
159#ifndef NO_FCNTL_H
160#  include <fcntl.h>
161#endif /* !NO_FNCTL_H */
162
163#ifndef NO_STRING_H
164#  include <string.h>
165#else
166#  include <strings.h>
167#endif /* NO_STRING_H */
168
169#ifdef NO_VOID
170#  define void int
171   typedef char zvoid;
172#else /* !NO_VOID */
173# ifdef NO_TYPEDEF_VOID
174#  define zvoid void
175# else
176   typedef void zvoid;
177# endif
178#endif /* ?NO_VOID */
179
180#ifdef NO_STRRCHR
181#  define strrchr rindex
182#endif
183
184#ifdef NO_STRCHR
185#  define strchr index
186#endif
187
188/*
189 * A couple of forward declarations that are needed on systems that do
190 * not supply C runtime library prototypes.
191 */
192#ifdef NO_PROTO
193char *strcpy();
194char *strcat();
195char *strrchr();
196/* XXX use !defined(ZMEM) && !defined(__hpux__) ? */
197#if !defined(ZMEM) && defined(NO_STRING_H)
198char *memset();
199char *memcpy();
200#endif /* !ZMEM && NO_STRING_H */
201
202/* XXX use !defined(__hpux__) ? */
203#ifdef NO_STDLIB_H
204char *calloc();
205char *malloc();
206char *getenv();
207long atol();
208#endif /* NO_STDLIB_H */
209
210#ifndef NO_MKTEMP
211char *mktemp();
212#endif /* !NO_MKTEMP */
213
214/* moved to include mktemp - Cosmin 2/18/05 */
215#endif /* NO_PROTO */
216
217/*
218 * SEEK_* macros, should be defined in stdio.h
219 */
220/* Define fseek() commands */
221#ifndef SEEK_SET
222#  define SEEK_SET 0
223#endif /* !SEEK_SET */
224
225#ifndef SEEK_CUR
226#  define SEEK_CUR 1
227#endif /* !SEEK_CUR */
228
229#ifndef FALSE
230#  define FALSE 0
231#endif
232
233#ifndef TRUE
234#  define TRUE 1
235#endif
236
237#ifdef NO_SIZE_T
238   typedef unsigned int extent;
239#else
240   typedef size_t extent;
241#endif
242
243#ifdef NO_TIME_T
244   typedef long time_t;
245#endif
246
247/* DBCS support for Info-ZIP's zip  (mainly for japanese (-: )
248 * by Yoshioka Tsuneo (QWF00133@nifty.ne.jp,tsuneo-y@is.aist-nara.ac.jp)
249 * This code is public domain!   Date: 1998/12/20
250 */
251#ifdef _MBCS
252#   include <locale.h>
253
254    /* Multi Byte Character Set */
255    extern char *___tmp_ptr;
256    unsigned char *zmbschr OF((ZCONST unsigned char *, unsigned int));
257    unsigned char *zmbsrchr OF((ZCONST unsigned char *, unsigned int));
258#   define CLEN(ptr) mblen(ptr, MB_CUR_MAX)
259#   define PREINCSTR(ptr) (ptr += CLEN(ptr))
260#   define POSTINCSTR(ptr) (___tmp_ptr=(char *)ptr,ptr += CLEN(ptr),___tmp_ptr)
261    int lastchar OF((ZCONST char *ptr));
262#   define MBSCHR(str,c) (char *)zmbschr((ZCONST unsigned char *)(str), c)
263#   define MBSRCHR(str,c) (char *)zmbsrchr((ZCONST unsigned char *)(str), (c))
264#   define SETLOCALE(category, locale) setlocale(category, locale)
265#else /* !_MBCS */
266#   define CLEN(ptr) 1
267#   define PREINCSTR(ptr) (++(ptr))
268#   define POSTINCSTR(ptr) ((ptr)++)
269#   define lastchar(ptr) ((*(ptr)=='\0') ? '\0' : ptr[strlen(ptr)-1])
270#   define MBSCHR(str, c) strchr(str, c)
271#   define MBSRCHR(str, c) strrchr(str, c)
272#   define SETLOCALE(category, locale)
273#endif /* ?_MBCS */
274#define INCSTR(ptr) PREINCSTR(ptr)
275
276
277/* System independent replacement for "struct utimbuf", which is missing
278 * in many older OS environments.
279 */
280typedef struct ztimbuf {
281    time_t actime;              /* new access time */
282    time_t modtime;             /* new modification time */
283} ztimbuf;
284
285/* This macro round a time_t value to the OS specific resolution */
286#ifndef ROUNDED_TIME
287#  define ROUNDED_TIME(time)   (time)
288#endif
289
290/* Some systems define S_IFLNK but do not support symbolic links */
291#if defined (S_IFLNK) && defined(NO_SYMLINK)
292#  undef S_IFLNK
293#endif
294
295#ifndef FOPR    /* fallback default definitions for FOPR, FOPM, FOPW: */
296#  define FOPR "r"
297#  define FOPM "r+"
298#  define FOPW "w"
299#endif /* fallback definition */
300
301#ifndef FOPW_TMP    /* fallback default for opening writable temp files */
302#  define FOPW_TMP FOPW
303#endif
304
305/* Open the old zip file in exclusive mode if possible (to avoid adding
306 * zip file to itself).
307 */
308#ifdef OS2
309#  define FOPR_EX FOPM
310#else
311#  define FOPR_EX FOPR
312#endif
313
314
315/* MSDOS file or directory attributes */
316#define MSDOS_HIDDEN_ATTR 0x02
317#define MSDOS_DIR_ATTR 0x10
318
319
320/* Define this symbol if your target allows access to unaligned data.
321 * This is not mandatory, just a speed optimization. The compressed
322 * output is strictly identical.
323 */
324#if (defined(MSDOS) && !defined(WIN32)) || defined(i386)
325#    define UNALIGNED_OK
326#endif
327#if defined(mc68020) || defined(vax)
328#    define UNALIGNED_OK
329#endif
330
331#if (defined(SMALL_MEM) && !defined(CBSZ))
332#   define CBSZ 2048 /* buffer size for copying files */
333#   define ZBSZ 2048 /* buffer size for temporary zip file */
334#endif
335
336#if (defined(MEDIUM_MEM) && !defined(CBSZ))
337#  define CBSZ 8192
338#  define ZBSZ 8192
339#endif
340
341#ifndef CBSZ
342#  define CBSZ 16384
343#  define ZBSZ 16384
344#endif
345
346#ifndef SBSZ
347#  define SBSZ CBSZ     /* copy buf size for STORED entries, see zipup() */
348#endif
349
350#ifndef MEMORY16
351#  ifdef __WATCOMC__
352#    undef huge
353#    undef far
354#    undef near
355#  endif
356#  ifdef THEOS
357#    undef far
358#    undef near
359#  endif
360#  if (!defined(__IBMC__) || !defined(OS2))
361#    ifndef huge
362#      define huge
363#    endif
364#    ifndef far
365#      define far
366#    endif
367#    ifndef near
368#      define near
369#    endif
370#  endif
371#  define nearmalloc malloc
372#  define nearfree free
373#  define farmalloc malloc
374#  define farfree free
375#endif /* !MEMORY16 */
376
377#ifndef Far
378#  define Far far
379#endif
380
381/* MMAP and BIG_MEM cannot be used together -> let MMAP take precedence */
382#if (defined(MMAP) && defined(BIG_MEM))
383#  undef BIG_MEM
384#endif
385
386#if (defined(BIG_MEM) || defined(MMAP)) && !defined(DYN_ALLOC)
387#   define DYN_ALLOC
388#endif
389
390#ifndef SSTAT
391#  define SSTAT      stat
392#endif
393#ifdef S_IFLNK
394#  define LSTAT      lstat
395#  define LSSTAT(n, s)  (linkput ? lstat((n), (s)) : SSTAT((n), (s)))
396#else
397#  define LSTAT      SSTAT
398#  define LSSTAT     SSTAT
399#endif
400
401/* The following default definition of the second input for the crypthead()
402 * random seed computation can be used on most systems (all those that
403 * supply a UNIX compatible getpid() function).
404 */
405#ifdef ZCRYPT_INTERNAL
406#  ifndef ZCR_SEED2
407#    define ZCR_SEED2     (unsigned) getpid()   /* use PID as seed pattern */
408#  endif
409#endif /* ZCRYPT_INTERNAL */
410
411/* The following OS codes are defined in pkzip appnote.txt */
412#ifdef AMIGA
413#  define OS_CODE  0x100
414#endif
415#ifdef VMS
416#  define OS_CODE  0x200
417#endif
418/* unix    3 */
419#ifdef VM_CMS
420#  define OS_CODE  0x400
421#endif
422#ifdef ATARI
423#  define OS_CODE  0x500
424#endif
425#ifdef OS2
426#  define OS_CODE  0x600
427#endif
428#ifdef MACOS
429#  define OS_CODE  0x700
430#endif
431/* z system 8 */
432/* cp/m     9 */
433#ifdef TOPS20
434#  define OS_CODE  0xa00
435#endif
436#ifdef WIN32
437#  define OS_CODE  0xb00
438#endif
439#ifdef QDOS
440#  define OS_CODE  0xc00
441#endif
442#ifdef RISCOS
443#  define OS_CODE  0xd00
444#endif
445#ifdef VFAT
446#  define OS_CODE  0xe00
447#endif
448#ifdef MVS
449#  define OS_CODE  0xf00
450#endif
451#if (defined(__BEOS__) || defined(__HAIKU__))
452#  define OS_CODE  0x1000
453#endif
454#ifdef TANDEM
455#  define OS_CODE  0x1100
456#endif
457#ifdef THEOS
458#  define OS_CODE  0x1200
459#endif
460#ifdef __ATHEOS__
461#  define OS_CODE  0x1E00
462#endif
463
464#define NUM_HOSTS 31
465/* Number of operating systems. Should be updated when new ports are made */
466
467#if defined(DOS) && !defined(OS_CODE)
468#  define OS_CODE  0x000
469#endif
470
471#ifndef OS_CODE
472#  define OS_CODE  0x300  /* assume Unix */
473#endif
474
475/* can't use "return 0" from main() on VMS */
476#ifndef EXIT
477#  define EXIT  exit
478#endif
479#ifndef RETURN
480#  define RETURN return
481#endif
482
483#ifndef ZIPERR
484#  define ZIPERR ziperr
485#endif
486
487#if (defined(USE_ZLIB) && defined(MY_ZCALLOC))
488   /* special zcalloc function is not needed when linked against zlib */
489#  undef MY_ZCALLOC
490#endif
491
492#if (!defined(USE_ZLIB) && !defined(MY_ZCALLOC))
493   /* Any system without a special calloc function */
494#  define zcalloc(items,size) \
495          (zvoid far *)calloc((unsigned)(items), (unsigned)(size))
496#  define zcfree    free
497#endif /* !USE_ZLIB && !MY_ZCALLOC */
498
499/* end of tailor.h */
500