tailor.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  1. /*
  2. tailor.h - Zip 3
  3. Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
  4. See the accompanying file LICENSE, version 2007-Mar-4 or later
  5. (the contents of which are also included in zip.h) for terms of use.
  6. If, for some reason, all 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. /* Some compiler distributions for Win32/i386 systems try to emulate
  10. * a Unix (POSIX-compatible) environment.
  11. */
  12. #if (defined(WIN32) && defined(UNIX))
  13. /* Zip does not support merging both ports in a single executable. */
  14. # if (defined(FORCE_WIN32_OVER_UNIX) && defined(FORCE_UNIX_OVER_WIN32))
  15. /* conflicting choice requests -> we prefer the Win32 environment */
  16. # undef FORCE_UNIX_OVER_WIN32
  17. # endif
  18. # ifdef FORCE_WIN32_OVER_UNIX
  19. /* native Win32 support was explicitely requested... */
  20. # undef UNIX
  21. # else
  22. /* use the POSIX (Unix) emulation features by default... */
  23. # undef WIN32
  24. # endif
  25. #endif
  26. /* UNICODE */
  27. #ifdef NO_UNICODE_SUPPORT
  28. # ifdef UNICODE_SUPPORT
  29. # undef UNICODE_SUPPORT
  30. # endif
  31. #endif
  32. #ifdef AMIGA
  33. #include "amiga/osdep.h"
  34. #endif
  35. #ifdef AOSVS
  36. #include "aosvs/osdep.h"
  37. #endif
  38. #ifdef ATARI
  39. #include "atari/osdep.h"
  40. #endif
  41. #ifdef __ATHEOS__
  42. #include "atheos/osdep.h"
  43. #endif
  44. #ifdef __BEOS__
  45. #include "beos/osdep.h"
  46. #endif
  47. #ifdef DOS
  48. #include "msdos/osdep.h"
  49. #endif
  50. #ifdef __human68k__
  51. #include "human68k/osdep.h"
  52. #endif
  53. #if ((defined(__MWERKS__) && defined(macintosh)) || defined(MACOS))
  54. #include "macos/osdep.h"
  55. #endif
  56. #ifdef NLM
  57. #include "novell/osdep.h"
  58. #endif
  59. #ifdef OS2
  60. #include "os2/osdep.h"
  61. #endif
  62. #ifdef __riscos
  63. #include "acorn/osdep.h"
  64. #endif
  65. #ifdef QDOS
  66. #include "qdos/osdep.h"
  67. #endif
  68. #ifdef __TANDEM
  69. #include "tandem.h"
  70. #include "tanzip.h"
  71. #endif
  72. #ifdef UNIX
  73. #include "unix/osdep.h"
  74. #endif
  75. #if defined(__COMPILER_KCC__) || defined(TOPS20)
  76. #include "tops20/osdep.h"
  77. #endif
  78. #if defined(VMS) || defined(__VMS)
  79. #include "vms/osdep.h"
  80. #endif
  81. #if defined(__VM__) || defined(VM_CMS) || defined(MVS)
  82. #include "cmsmvs.h"
  83. #endif
  84. #ifdef WIN32
  85. #include "win32/osdep.h"
  86. #endif
  87. #ifdef THEOS
  88. #include "theos/osdep.h"
  89. #endif
  90. /* generic LARGE_FILE_SUPPORT defines
  91. These get used if not defined above.
  92. 7/21/2004 EG
  93. */
  94. /* If a port hasn't defined ZOFF_T_FORMAT_SIZE_PREFIX
  95. then probably need to define all of these. */
  96. #ifndef ZOFF_T_FORMAT_SIZE_PREFIX
  97. # ifdef LARGE_FILE_SUPPORT
  98. /* Probably passed in from command line instead of in above
  99. includes if get here. Assume large file support and hope. 8/14/04 EG */
  100. /* Set the Large File Summit (LFS) defines to turn on large file support
  101. in case it helps. */
  102. # define _LARGEFILE_SOURCE /* some OSes need this for fseeko */
  103. # define _LARGEFILE64_SOURCE
  104. # define _FILE_OFFSET_BITS 64 /* select default interface as 64 bit */
  105. # define _LARGE_FILES /* some OSes need this for 64-bit off_t */
  106. typedef off_t zoff_t;
  107. typedef unsigned long long uzoff_t; /* unsigned zoff_t (12/29/04 EG) */
  108. /* go with common prefix */
  109. # define ZOFF_T_FORMAT_SIZE_PREFIX "ll"
  110. # else
  111. /* Default type for offsets and file sizes was ulg but reports
  112. of using ulg to create files from 2 GB to 4 GB suggest
  113. it doesn't work well. Now just switch to Zip64 or not
  114. support over 2 GB. 7/24/04 EG */
  115. /* Now use uzoff_t for unsigned things. 12/29/04 EG */
  116. typedef long zoff_t;
  117. typedef unsigned long uzoff_t;
  118. # define ZOFF_T_FORMAT_SIZE_PREFIX "l"
  119. # endif
  120. typedef struct stat z_stat;
  121. /* flag that we are defaulting */
  122. # define USING_DEFAULT_LARGE_FILE_SUPPORT
  123. #endif
  124. #if (defined(USE_ZLIB) && defined(ASM_CRC))
  125. # undef ASM_CRC
  126. #endif
  127. #if (defined(USE_ZLIB) && defined(ASMV))
  128. # undef ASMV
  129. #endif
  130. /* When "void" is an alias for "int", prototypes cannot be used. */
  131. #if (defined(NO_VOID) && !defined(NO_PROTO))
  132. # define NO_PROTO
  133. #endif
  134. /* Used to remove arguments in function prototypes for non-ANSI C */
  135. #ifndef NO_PROTO
  136. # define OF(a) a
  137. # define OFT(a) a
  138. #else /* NO_PROTO */
  139. # define OF(a) ()
  140. # define OFT(a)
  141. #endif /* ?NO_PROTO */
  142. /* If the compiler can't handle const define ZCONST in osdep.h */
  143. /* Define const itself in case the system include files are bonkers */
  144. #ifndef ZCONST
  145. # ifdef NO_CONST
  146. # define ZCONST
  147. # define const
  148. # else
  149. # define ZCONST const
  150. # endif
  151. #endif
  152. /*
  153. * Some compiler environments may require additional attributes attached
  154. * to declarations of runtime libary functions (e.g. to prepare for
  155. * linking against a "shared dll" version of the RTL). Here, we provide
  156. * the "empty" default for these attributes.
  157. */
  158. #ifndef IZ_IMP
  159. # define IZ_IMP
  160. #endif
  161. /*
  162. * case mapping functions. case_map is used to ignore case in comparisons,
  163. * to_up is used to force upper case even on Unix (for dosify option).
  164. */
  165. #ifdef USE_CASE_MAP
  166. # define case_map(c) upper[(c) & 0xff]
  167. # define to_up(c) upper[(c) & 0xff]
  168. #else
  169. # define case_map(c) (c)
  170. # define to_up(c) ((c) >= 'a' && (c) <= 'z' ? (c)-'a'+'A' : (c))
  171. #endif /* USE_CASE_MAP */
  172. /* Define void, zvoid, and extent (size_t) */
  173. #include <stdio.h>
  174. #ifndef NO_STDDEF_H
  175. # include <stddef.h>
  176. #endif /* !NO_STDDEF_H */
  177. #ifndef NO_STDLIB_H
  178. # include <stdlib.h>
  179. #endif /* !NO_STDLIB_H */
  180. #ifndef NO_UNISTD_H
  181. # include <unistd.h> /* usually defines _POSIX_VERSION */
  182. #endif /* !NO_UNISTD_H */
  183. #ifndef NO_FCNTL_H
  184. # include <fcntl.h>
  185. #endif /* !NO_FNCTL_H */
  186. #ifndef NO_STRING_H
  187. # include <string.h>
  188. #else
  189. # include <strings.h>
  190. #endif /* NO_STRING_H */
  191. #ifdef NO_VOID
  192. # define void int
  193. typedef char zvoid;
  194. #else /* !NO_VOID */
  195. # ifdef NO_TYPEDEF_VOID
  196. # define zvoid void
  197. # else
  198. typedef void zvoid;
  199. # endif
  200. #endif /* ?NO_VOID */
  201. #ifdef NO_STRRCHR
  202. # define strrchr rindex
  203. #endif
  204. #ifdef NO_STRCHR
  205. # define strchr index
  206. #endif
  207. /*
  208. * A couple of forward declarations that are needed on systems that do
  209. * not supply C runtime library prototypes.
  210. */
  211. #ifdef NO_PROTO
  212. IZ_IMP char *strcpy();
  213. IZ_IMP char *strcat();
  214. IZ_IMP char *strrchr();
  215. /* XXX use !defined(ZMEM) && !defined(__hpux__) ? */
  216. #if !defined(ZMEM) && defined(NO_STRING_H)
  217. IZ_IMP char *memset();
  218. IZ_IMP char *memcpy();
  219. #endif /* !ZMEM && NO_STRING_H */
  220. /* XXX use !defined(__hpux__) ? */
  221. #ifdef NO_STDLIB_H
  222. IZ_IMP char *calloc();
  223. IZ_IMP char *malloc();
  224. IZ_IMP char *getenv();
  225. IZ_IMP long atol();
  226. #endif /* NO_STDLIB_H */
  227. #ifndef NO_MKTEMP
  228. IZ_IMP char *mktemp();
  229. #endif /* !NO_MKTEMP */
  230. #endif /* NO_PROTO */
  231. /*
  232. * SEEK_* macros, should be defined in stdio.h
  233. */
  234. /* Define fseek() commands */
  235. #ifndef SEEK_SET
  236. # define SEEK_SET 0
  237. #endif /* !SEEK_SET */
  238. #ifndef SEEK_CUR
  239. # define SEEK_CUR 1
  240. #endif /* !SEEK_CUR */
  241. #ifndef FALSE
  242. # define FALSE 0
  243. #endif
  244. #ifndef TRUE
  245. # define TRUE 1
  246. #endif
  247. #ifdef NO_SIZE_T
  248. typedef unsigned int extent;
  249. /* define size_t 3/17/05 EG */
  250. typedef unsigned int size_t;
  251. #else
  252. typedef size_t extent;
  253. #endif
  254. #ifdef NO_TIME_T
  255. typedef long time_t;
  256. #endif
  257. /* DBCS support for Info-ZIP's zip (mainly for japanese (-: )
  258. * by Yoshioka Tsuneo (QWF00133@nifty.ne.jp,tsuneo-y@is.aist-nara.ac.jp)
  259. * This code is public domain! Date: 1998/12/20
  260. */
  261. /* 2007-07-29 SMS.
  262. * Include <locale.h> here if it will be needed later for Unicode.
  263. * Otherwise, SETLOCALE may be defined here, and then defined again
  264. * (differently) when <locale.h> is read later.
  265. */
  266. #ifdef UNICODE_SUPPORT
  267. # if defined( UNIX) || defined( VMS)
  268. # include <locale.h>
  269. # endif /* defined( UNIX) || defined( VMS) */
  270. # include <wchar.h>
  271. # include <wctype.h>
  272. #endif /* def UNICODE_SUPPORT */
  273. #ifdef _MBCS
  274. # include <locale.h>
  275. /* Multi Byte Character Set */
  276. extern char *___tmp_ptr;
  277. unsigned char *zmbschr OF((ZCONST unsigned char *, unsigned int));
  278. unsigned char *zmbsrchr OF((ZCONST unsigned char *, unsigned int));
  279. # define CLEN(ptr) mblen((ZCONST char *)ptr, MB_CUR_MAX)
  280. # define PREINCSTR(ptr) (ptr += CLEN(ptr))
  281. # define POSTINCSTR(ptr) (___tmp_ptr=(char *)ptr,ptr += CLEN(ptr),___tmp_ptr)
  282. int lastchar OF((ZCONST char *ptr));
  283. # define MBSCHR(str,c) (char *)zmbschr((ZCONST unsigned char *)(str), c)
  284. # define MBSRCHR(str,c) (char *)zmbsrchr((ZCONST unsigned char *)(str), (c))
  285. # ifndef SETLOCALE
  286. # define SETLOCALE(category, locale) setlocale(category, locale)
  287. # endif /* ndef SETLOCALE */
  288. #else /* !_MBCS */
  289. # define CLEN(ptr) 1
  290. # define PREINCSTR(ptr) (++(ptr))
  291. # define POSTINCSTR(ptr) ((ptr)++)
  292. # define lastchar(ptr) ((*(ptr)=='\0') ? '\0' : ptr[strlen(ptr)-1])
  293. # define MBSCHR(str, c) strchr(str, c)
  294. # define MBSRCHR(str, c) strrchr(str, c)
  295. # ifndef SETLOCALE
  296. # define SETLOCALE(category, locale)
  297. # endif /* ndef SETLOCALE */
  298. #endif /* ?_MBCS */
  299. #define INCSTR(ptr) PREINCSTR(ptr)
  300. /* System independent replacement for "struct utimbuf", which is missing
  301. * in many older OS environments.
  302. */
  303. typedef struct ztimbuf {
  304. time_t actime; /* new access time */
  305. time_t modtime; /* new modification time */
  306. } ztimbuf;
  307. /* This macro round a time_t value to the OS specific resolution */
  308. #ifndef ROUNDED_TIME
  309. # define ROUNDED_TIME(time) (time)
  310. #endif
  311. /* Some systems define S_IFLNK but do not support symbolic links */
  312. #if defined (S_IFLNK) && defined(NO_SYMLINKS)
  313. # undef S_IFLNK
  314. #endif
  315. #ifndef Z_UINT4_DEFINED
  316. # if !defined(NO_LIMITS_H)
  317. # if (defined(UINT_MAX) && (UINT_MAX == 0xffffffffUL))
  318. typedef unsigned int z_uint4;
  319. # define Z_UINT4_DEFINED
  320. # else
  321. # if (defined(ULONG_MAX) && (ULONG_MAX == 0xffffffffUL))
  322. typedef unsigned long z_uint4;
  323. # define Z_UINT4_DEFINED
  324. # else
  325. # if (defined(USHRT_MAX) && (USHRT_MAX == 0xffffffffUL))
  326. typedef unsigned short z_uint4;
  327. # define Z_UINT4_DEFINED
  328. # endif
  329. # endif
  330. # endif
  331. # endif /* !defined(NO_LIMITS_H) */
  332. #endif /* ndef Z_UINT4_DEFINED */
  333. #ifndef Z_UINT4_DEFINED
  334. typedef ulg z_uint4;
  335. # define Z_UINT4_DEFINED
  336. #endif
  337. #ifndef FOPR /* fallback default definitions for FOPR, FOPM, FOPW: */
  338. # define FOPR "r"
  339. # define FOPM "r+"
  340. # define FOPW "w"
  341. #endif /* fallback definition */
  342. #ifndef FOPW_TMP /* fallback default for opening writable temp files */
  343. # define FOPW_TMP FOPW
  344. #endif
  345. /* Open the old zip file in exclusive mode if possible (to avoid adding
  346. * zip file to itself).
  347. */
  348. #ifdef OS2
  349. # define FOPR_EX FOPM
  350. #else
  351. # define FOPR_EX FOPR
  352. #endif
  353. /* MSDOS file or directory attributes */
  354. #define MSDOS_HIDDEN_ATTR 0x02
  355. #define MSDOS_DIR_ATTR 0x10
  356. /* Define this symbol if your target allows access to unaligned data.
  357. * This is not mandatory, just a speed optimization. The compressed
  358. * output is strictly identical.
  359. */
  360. #if (defined(MSDOS) && !defined(WIN32)) || defined(i386)
  361. # define UNALIGNED_OK
  362. #endif
  363. #if defined(mc68020) || defined(vax)
  364. # define UNALIGNED_OK
  365. #endif
  366. #if (defined(SMALL_MEM) && !defined(CBSZ))
  367. # define CBSZ 2048 /* buffer size for copying files */
  368. # define ZBSZ 2048 /* buffer size for temporary zip file */
  369. #endif
  370. #if (defined(MEDIUM_MEM) && !defined(CBSZ))
  371. # define CBSZ 8192
  372. # define ZBSZ 8192
  373. #endif
  374. #ifndef CBSZ
  375. # define CBSZ 16384
  376. # define ZBSZ 16384
  377. #endif
  378. #ifndef SBSZ
  379. # define SBSZ CBSZ /* copy buf size for STORED entries, see zipup() */
  380. #endif
  381. #ifndef MEMORY16
  382. # ifdef __WATCOMC__
  383. # undef huge
  384. # undef far
  385. # undef near
  386. # endif
  387. # ifdef THEOS
  388. # undef far
  389. # undef near
  390. # endif
  391. # if (!defined(__IBMC__) || !defined(OS2))
  392. # ifndef huge
  393. # define huge
  394. # endif
  395. # ifndef far
  396. # define far
  397. # endif
  398. # ifndef near
  399. # define near
  400. # endif
  401. # endif
  402. # define nearmalloc malloc
  403. # define nearfree free
  404. # define farmalloc malloc
  405. # define farfree free
  406. #endif /* !MEMORY16 */
  407. #ifndef Far
  408. # define Far far
  409. #endif
  410. /* MMAP and BIG_MEM cannot be used together -> let MMAP take precedence */
  411. #if (defined(MMAP) && defined(BIG_MEM))
  412. # undef BIG_MEM
  413. #endif
  414. #if (defined(BIG_MEM) || defined(MMAP)) && !defined(DYN_ALLOC)
  415. # define DYN_ALLOC
  416. #endif
  417. /* LARGE_FILE_SUPPORT
  418. *
  419. * Types are in osdep.h for each port
  420. *
  421. * LARGE_FILE_SUPPORT and ZIP64_SUPPORT are automatically
  422. * set in osdep.h (for some ports) based on the port and compiler.
  423. *
  424. * Function prototypes are below as OF is defined earlier in this file
  425. * but after osdep.h is included. In the future ANSI prototype
  426. * support may be required and the OF define may then go away allowing
  427. * the function defines to be in the port osdep.h.
  428. *
  429. * E. Gordon 9/21/2003
  430. * Updated 7/24/04 EG
  431. */
  432. #ifdef LARGE_FILE_SUPPORT
  433. /* 64-bit Large File Support */
  434. /* Arguments for all functions are assumed to match the actual
  435. arguments of the various port calls. As such only the
  436. function names are mapped below. */
  437. /* ---------------------------- */
  438. # ifdef UNIX
  439. /* Assume 64-bit file environment is defined. The below should all
  440. be set to their 64-bit versions automatically. Neat. 7/20/2004 EG */
  441. /* 64-bit stat functions */
  442. # define zstat stat
  443. # define zfstat fstat
  444. # define zlstat lstat
  445. # if defined(__alpha) && defined(__osf__) /* support for osf4.0f */
  446. /* 64-bit fseek */
  447. # define zfseeko fseek
  448. /* 64-bit ftell */
  449. # define zftello ftell
  450. # else
  451. /* 64-bit fseeko */
  452. # define zfseeko fseeko
  453. /* 64-bit ftello */
  454. # define zftello ftello
  455. # endif /* __alpha && __osf__ */
  456. /* 64-bit fopen */
  457. # define zfopen fopen
  458. # define zfdopen fdopen
  459. # endif /* UNIX */
  460. /* ---------------------------- */
  461. # ifdef VMS
  462. /* 64-bit stat functions */
  463. # define zstat stat
  464. # define zfstat fstat
  465. # define zlstat lstat
  466. /* 64-bit fseeko */
  467. # define zfseeko fseeko
  468. /* 64-bit ftello */
  469. # define zftello ftello
  470. /* 64-bit fopen */
  471. # define zfopen fopen
  472. # define zfdopen fdopen
  473. # endif /* def VMS */
  474. /* ---------------------------- */
  475. # ifdef WIN32
  476. # if defined(__MINGW32__)
  477. /* GNU C, linked against "msvcrt.dll" */
  478. /* 64-bit stat functions */
  479. # define zstat _stati64
  480. # ifdef UNICODE_SUPPORT
  481. # define zwfstat _fstati64
  482. # define zwstat _wstati64
  483. # define zw_stat struct _stati64
  484. # endif
  485. # define zfstat _fstati64
  486. # define zlstat lstat
  487. /* 64-bit fseeko */
  488. /* function in win32.c */
  489. int zfseeko OF((FILE *, zoff_t, int));
  490. /* 64-bit ftello */
  491. /* function in win32.c */
  492. zoff_t zftello OF((FILE *));
  493. /* 64-bit fopen */
  494. # define zfopen fopen
  495. # define zfdopen fdopen
  496. # endif
  497. # if defined(__CYGWIN__)
  498. /* GNU C, CygWin with its own POSIX compatible runtime library */
  499. /* 64-bit stat functions */
  500. # define zstat stat
  501. # define zfstat fstat
  502. # define zlstat lstat
  503. /* 64-bit fseeko */
  504. # define zfseeko fseeko
  505. /* 64-bit ftello */
  506. # define zftello ftello
  507. /* 64-bit fopen */
  508. # define zfopen fopen
  509. # define zfdopen fdopen
  510. # endif
  511. # ifdef __WATCOMC__
  512. /* WATCOM C */
  513. /* 64-bit stat functions */
  514. # define zstat _stati64
  515. # ifdef UNICODE_SUPPORT
  516. # define zwfstat _fstati64
  517. # define zwstat _wstati64
  518. # define zw_stat struct _stati64
  519. # endif
  520. # define zfstat _fstati64
  521. # define zlstat lstat
  522. /* 64-bit fseeko */
  523. /* function in win32.c */
  524. int zfseeko OF((FILE *, zoff_t, int));
  525. /* 64-bit ftello */
  526. /* function in win32.c */
  527. zoff_t zftello OF((FILE *));
  528. /* 64-bit fopen */
  529. # define zfopen fopen
  530. # define zfdopen fdopen
  531. # endif
  532. # ifdef _MSC_VER
  533. /* MS C and VC */
  534. /* 64-bit stat functions */
  535. # define zstat _stati64
  536. # ifdef UNICODE_SUPPORT
  537. # define zwfstat _fstati64
  538. # define zwstat _wstati64
  539. # define zw_stat struct _stati64
  540. # endif
  541. # define zfstat _fstati64
  542. # define zlstat lstat
  543. /* 64-bit fseeko */
  544. /* function in win32.c */
  545. int zfseeko OF((FILE *, zoff_t, int));
  546. /* 64-bit ftello */
  547. /* function in win32.c */
  548. zoff_t zftello OF((FILE *));
  549. /* 64-bit fopen */
  550. # define zfopen fopen
  551. # define zfdopen fdopen
  552. # endif
  553. # ifdef __IBMC__
  554. /* IBM C */
  555. /* 64-bit stat functions */
  556. /* 64-bit fseeko */
  557. /* function in win32.c */
  558. int zfseeko OF((FILE *, zoff_t, int));
  559. /* 64-bit ftello */
  560. /* function in win32.c */
  561. zoff_t zftello OF((FILE *));
  562. /* 64-bit fopen */
  563. # endif
  564. # endif /* WIN32 */
  565. #else
  566. /* No Large File Support or default for 64-bit environment */
  567. # define zstat stat
  568. # define zfstat fstat
  569. # define zlstat lstat
  570. # define zfseeko fseek
  571. # define zftello ftell
  572. # define zfopen fopen
  573. # define zfdopen fdopen
  574. # ifdef UNICODE_SUPPORT
  575. # define zwfstat _fstat
  576. # define zwstat _wstat
  577. # define zw_stat struct _stat
  578. # endif
  579. #endif
  580. #ifdef LARGE_FILE_SUPPORT /* E. Gordon 9/12/2003 */
  581. # ifndef SSTAT
  582. # define SSTAT zstat
  583. # ifdef UNICODE_SUPPORT
  584. # define SSTATW zwstat
  585. # endif
  586. # endif
  587. # ifdef S_IFLNK
  588. # define LSTAT zlstat
  589. # define LSSTAT(n, s) (linkput ? zlstat((n), (s)) : SSTAT((n), (s)))
  590. # else
  591. # define LSTAT SSTAT
  592. # define LSSTAT SSTAT
  593. # ifdef UNICODE_SUPPORT
  594. # define LSSTATW SSTATW
  595. # endif
  596. # endif
  597. #else /* no LARGE_FILE_SUPPORT */
  598. # ifndef SSTAT
  599. # define SSTAT stat
  600. # endif
  601. # ifdef S_IFLNK
  602. # define LSTAT lstat
  603. # define LSSTAT(n, s) (linkput ? lstat((n), (s)) : SSTAT((n), (s)))
  604. # else
  605. # define LSTAT SSTAT
  606. # define LSSTAT SSTAT
  607. # ifdef UNICODE_SUPPORT
  608. # define LSSTATW SSTATW
  609. # endif
  610. # endif
  611. #endif
  612. /*---------------------------------------------------------------------*/
  613. /* 2004-12-01 SMS.
  614. * Added fancy zofft() macros, et c.
  615. */
  616. /* Default fzofft() format selection.
  617. * Modified 2004-12-27 EG
  618. */
  619. #ifndef FZOFFT_FMT
  620. # define FZOFFT_FMT ZOFF_T_FORMAT_SIZE_PREFIX /* printf for zoff_t values */
  621. # ifdef LARGE_FILE_SUPPORT
  622. # define FZOFFT_HEX_WID_VALUE "16" /* width of 64-bit hex values */
  623. # else
  624. # define FZOFFT_HEX_WID_VALUE "8" /* digits in 32-bit hex values */
  625. # endif
  626. #endif /* ndef FZOFFT_FMT */
  627. #define FZOFFT_HEX_WID ((char *) -1)
  628. #define FZOFFT_HEX_DOT_WID ((char *) -2)
  629. /* The following default definition of the second input for the crypthead()
  630. * random seed computation can be used on most systems (all those that
  631. * supply a UNIX compatible getpid() function).
  632. */
  633. #ifdef ZCRYPT_INTERNAL
  634. # ifndef ZCR_SEED2
  635. # define ZCR_SEED2 (unsigned) getpid() /* use PID as seed pattern */
  636. # endif
  637. #endif /* ZCRYPT_INTERNAL */
  638. /* The following OS codes are defined in pkzip appnote.txt */
  639. #ifdef AMIGA
  640. # define OS_CODE 0x100
  641. #endif
  642. #ifdef VMS
  643. # define OS_CODE 0x200
  644. #endif
  645. /* unix 3 */
  646. #ifdef VM_CMS
  647. # define OS_CODE 0x400
  648. #endif
  649. #ifdef ATARI
  650. # define OS_CODE 0x500
  651. #endif
  652. #ifdef OS2
  653. # define OS_CODE 0x600
  654. #endif
  655. #ifdef MACOS
  656. # define OS_CODE 0x700
  657. #endif
  658. /* z system 8 */
  659. /* cp/m 9 */
  660. #ifdef TOPS20
  661. # define OS_CODE 0xa00
  662. #endif
  663. #ifdef WIN32
  664. # define OS_CODE 0xb00
  665. #endif
  666. #ifdef QDOS
  667. # define OS_CODE 0xc00
  668. #endif
  669. #ifdef RISCOS
  670. # define OS_CODE 0xd00
  671. #endif
  672. #ifdef VFAT
  673. # define OS_CODE 0xe00
  674. #endif
  675. #ifdef MVS
  676. # define OS_CODE 0xf00
  677. #endif
  678. #ifdef __BEOS__
  679. # define OS_CODE 0x1000
  680. #endif
  681. #ifdef TANDEM
  682. # define OS_CODE 0x1100
  683. #endif
  684. #ifdef THEOS
  685. # define OS_CODE 0x1200
  686. #endif
  687. /* Yes, there is a gap here. */
  688. #ifdef __ATHEOS__
  689. # define OS_CODE 0x1E00
  690. #endif
  691. #define NUM_HOSTS 31
  692. /* Number of operating systems. Should be updated when new ports are made */
  693. #if defined(DOS) && !defined(OS_CODE)
  694. # define OS_CODE 0x000
  695. #endif
  696. #ifndef OS_CODE
  697. # define OS_CODE 0x300 /* assume Unix */
  698. #endif
  699. /* can't use "return 0" from main() on VMS */
  700. #ifndef EXIT
  701. # define EXIT exit
  702. #endif
  703. #ifndef RETURN
  704. # define RETURN return
  705. #endif
  706. #ifndef ZIPERR
  707. # define ZIPERR ziperr
  708. #endif
  709. #if (defined(USE_ZLIB) && defined(MY_ZCALLOC))
  710. /* special zcalloc function is not needed when linked against zlib */
  711. # undef MY_ZCALLOC
  712. #endif
  713. #if (!defined(USE_ZLIB) && !defined(MY_ZCALLOC))
  714. /* Any system without a special calloc function */
  715. # define zcalloc(items,size) \
  716. (zvoid far *)calloc((unsigned)(items), (unsigned)(size))
  717. # define zcfree free
  718. #endif /* !USE_ZLIB && !MY_ZCALLOC */
  719. /* end of tailor.h */