Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6725 | siemargl | 1 | /* |
2 | Copyright (c) 1990-2009 Info-ZIP. All rights reserved. |
||
3 | |||
4 | See the accompanying file LICENSE, version 2009-Jan-02 or later |
||
5 | (the contents of which are also included in unzip.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 | /*--------------------------------------------------------------------------- |
||
10 | |||
11 | unzpriv.h |
||
12 | |||
13 | This header file contains private (internal) macros, typedefs, prototypes |
||
14 | and global-variable declarations used by all of the UnZip source files. |
||
15 | In a prior life it was part of the main unzip.h header, but now it is only |
||
16 | included by that header if UNZIP_INTERNAL is defined. |
||
17 | |||
18 | ---------------------------------------------------------------------------*/ |
||
19 | |||
20 | |||
21 | |||
22 | #ifndef __unzpriv_h /* prevent multiple inclusions */ |
||
23 | #define __unzpriv_h |
||
24 | |||
25 | /* First thing: Signal all following code that we compile UnZip utilities! */ |
||
26 | #ifndef UNZIP |
||
27 | # define UNZIP |
||
28 | #endif |
||
29 | |||
30 | /* GRR 960204: MORE defined here in preparation for removal altogether */ |
||
31 | #ifndef MORE |
||
32 | # ifndef RISCOS |
||
33 | # define MORE |
||
34 | # endif |
||
35 | #endif |
||
36 | |||
37 | /* fUnZip should never need to be reentrant */ |
||
38 | #ifdef FUNZIP |
||
39 | # ifdef REENTRANT |
||
40 | # undef REENTRANT |
||
41 | # endif |
||
42 | # ifdef DLL |
||
43 | # undef DLL |
||
44 | # endif |
||
45 | # ifdef SFX /* fUnZip is NOT the sfx stub! */ |
||
46 | # undef SFX |
||
47 | # endif |
||
48 | # ifdef USE_BZIP2 /* fUnZip does not support bzip2 decompression */ |
||
49 | # undef USE_BZIP2 |
||
50 | # endif |
||
51 | #endif |
||
52 | |||
53 | #if (defined(USE_ZLIB) && !defined(HAVE_ZL_INFLAT64) && !defined(NO_DEFLATE64)) |
||
54 | /* zlib does not (yet?) provide Deflate64(tm) support */ |
||
55 | # define NO_DEFLATE64 |
||
56 | #endif |
||
57 | |||
58 | #ifdef NO_DEFLATE64 |
||
59 | /* disable support for Deflate64(tm) */ |
||
60 | # ifdef USE_DEFLATE64 |
||
61 | # undef USE_DEFLATE64 |
||
62 | # endif |
||
63 | #else |
||
64 | /* enable Deflate64(tm) support unless compiling for SFX stub */ |
||
65 | # if (!defined(USE_DEFLATE64) && !defined(SFX)) |
||
66 | # define USE_DEFLATE64 |
||
67 | # endif |
||
68 | #endif |
||
69 | |||
70 | /* disable bzip2 support for SFX stub, unless explicitly requested */ |
||
71 | #if (defined(SFX) && !defined(BZIP2_SFX) && defined(USE_BZIP2)) |
||
72 | # undef USE_BZIP2 |
||
73 | #endif |
||
74 | |||
75 | #if (defined(NO_VMS_TEXT_CONV) || defined(VMS)) |
||
76 | # ifdef VMS_TEXT_CONV |
||
77 | # undef VMS_TEXT_CONV |
||
78 | # endif |
||
79 | #else |
||
80 | # if (!defined(VMS_TEXT_CONV) && !defined(SFX)) |
||
81 | # define VMS_TEXT_CONV |
||
82 | # endif |
||
83 | #endif |
||
84 | |||
85 | /* Enable -B option per default on specific systems, to allow backing up |
||
86 | * files that would be overwritten. |
||
87 | * (This list of systems must be kept in sync with the list of systems |
||
88 | * that add the B_flag to the UzpOpts structure, see unzip.h.) |
||
89 | */ |
||
90 | #if (!defined(NO_UNIXBACKUP) && !defined(UNIXBACKUP)) |
||
91 | # if defined(UNIX) || defined(OS2) || defined(WIN32) |
||
92 | # define UNIXBACKUP |
||
93 | # endif |
||
94 | #endif |
||
95 | |||
96 | #if (defined(DLL) && !defined(REENTRANT)) |
||
97 | # define REENTRANT |
||
98 | #endif |
||
99 | |||
100 | #if (!defined(DYNAMIC_CRC_TABLE) && !defined(FUNZIP)) |
||
101 | # define DYNAMIC_CRC_TABLE |
||
102 | #endif |
||
103 | |||
104 | #if (defined(DYNAMIC_CRC_TABLE) && !defined(REENTRANT)) |
||
105 | # ifndef DYNALLOC_CRCTAB |
||
106 | # define DYNALLOC_CRCTAB |
||
107 | # endif |
||
108 | #endif |
||
109 | |||
110 | /*--------------------------------------------------------------------------- |
||
111 | OS-dependent configuration for UnZip internals |
||
112 | ---------------------------------------------------------------------------*/ |
||
113 | |||
114 | /* Some compiler distributions for Win32/i386 systems try to emulate |
||
115 | * a Unix (POSIX-compatible) environment. |
||
116 | */ |
||
117 | #if (defined(WIN32) && defined(UNIX)) |
||
118 | /* UnZip does not support merging both ports in a single executable. */ |
||
119 | # if (defined(FORCE_WIN32_OVER_UNIX) && defined(FORCE_UNIX_OVER_WIN32)) |
||
120 | /* conflicting choice requests -> we prefer the Win32 environment */ |
||
121 | # undef FORCE_UNIX_OVER_WIN32 |
||
122 | # endif |
||
123 | # ifdef FORCE_WIN32_OVER_UNIX |
||
124 | /* native Win32 support was explicitly requested... */ |
||
125 | # undef UNIX |
||
126 | # else |
||
127 | /* use the POSIX (Unix) emulation features by default... */ |
||
128 | # undef WIN32 |
||
129 | # endif |
||
130 | #endif |
||
131 | |||
132 | /* bad or (occasionally?) missing stddef.h: */ |
||
133 | #if (defined(M_XENIX) || defined(DNIX)) |
||
134 | # define NO_STDDEF_H |
||
135 | #endif |
||
136 | |||
137 | #if (defined(M_XENIX) && !defined(M_UNIX)) /* SCO Xenix only, not SCO Unix */ |
||
138 | # define SCO_XENIX |
||
139 | # define NO_LIMITS_H /* no limits.h, but MODERN defined */ |
||
140 | # define NO_UID_GID /* no uid_t/gid_t */ |
||
141 | # define size_t int |
||
142 | #endif |
||
143 | |||
144 | #ifdef realix /* Modcomp Real/IX, real-time SysV.3 variant */ |
||
145 | # define SYSV |
||
146 | # define NO_UID_GID /* no uid_t/gid_t */ |
||
147 | #endif |
||
148 | |||
149 | #if (defined(_AIX) && !defined(_ALL_SOURCE)) |
||
150 | # define _ALL_SOURCE |
||
151 | #endif |
||
152 | |||
153 | #if defined(apollo) /* defines __STDC__ */ |
||
154 | # define NO_STDLIB_H |
||
155 | #endif |
||
156 | |||
157 | #ifdef DNIX |
||
158 | # define SYSV |
||
159 | # define SHORT_NAMES /* 14-char limitation on path components */ |
||
160 | /* # define FILENAME_MAX 14 */ |
||
161 | # define FILENAME_MAX NAME_MAX /* GRR: experiment */ |
||
162 | #endif |
||
163 | |||
164 | #if (defined(SYSTEM_FIVE) || defined(__SYSTEM_FIVE)) |
||
165 | # ifndef SYSV |
||
166 | # define SYSV |
||
167 | # endif |
||
168 | #endif /* SYSTEM_FIVE || __SYSTEM_FIVE */ |
||
169 | #if (defined(M_SYSV) || defined(M_SYS5)) |
||
170 | # ifndef SYSV |
||
171 | # define SYSV |
||
172 | # endif |
||
173 | #endif /* M_SYSV || M_SYS5 */ |
||
174 | /* __SVR4 and __svr4__ catch Solaris on at least some combos of compiler+OS */ |
||
175 | #if (defined(__SVR4) || defined(__svr4__) || defined(sgi) || defined(__hpux)) |
||
176 | # ifndef SYSV |
||
177 | # define SYSV |
||
178 | # endif |
||
179 | #endif /* __SVR4 || __svr4__ || sgi || __hpux */ |
||
180 | #if (defined(LINUX) || defined(__QNX__)) |
||
181 | # ifndef SYSV |
||
182 | # define SYSV |
||
183 | # endif |
||
184 | #endif /* LINUX || __QNX__ */ |
||
185 | |||
186 | #if (defined(ultrix) || defined(__ultrix) || defined(bsd4_2)) |
||
187 | # if (!defined(BSD) && !defined(SYSV)) |
||
188 | # define BSD |
||
189 | # endif |
||
190 | #endif /* ultrix || __ultrix || bsd4_2 */ |
||
191 | #if (defined(sun) || defined(pyr) || defined(CONVEX)) |
||
192 | # if (!defined(BSD) && !defined(SYSV)) |
||
193 | # define BSD |
||
194 | # endif |
||
195 | #endif /* sun || pyr || CONVEX */ |
||
196 | |||
197 | #ifdef pyr /* Pyramid: has BSD and AT&T "universes" */ |
||
198 | # ifdef BSD |
||
199 | # define pyr_bsd |
||
200 | # define USE_STRINGS_H /* instead of more common string.h */ |
||
201 | # define ZMEM /* ZMEM now uses bcopy/bzero: not in AT&T universe */ |
||
202 | # endif /* (AT&T memcpy claimed to be very slow, though) */ |
||
203 | # define DECLARE_ERRNO |
||
204 | #endif /* pyr */ |
||
205 | |||
206 | /* stat() bug for Borland, VAX C RTL, and Atari ST MiNT on TOS |
||
207 | * filesystems: returns 0 for wildcards! (returns 0xffffffff on Minix |
||
208 | * filesystem or `U:' drive under Atari MiNT.) Watcom C was previously |
||
209 | * included on this list; it would be good to know what version the problem |
||
210 | * was fixed at, if it did exist. */ |
||
211 | #if (defined(__TURBOC__) && !defined(WIN32)) |
||
212 | /*# define WILD_STAT_BUG*/ |
||
213 | #endif |
||
214 | #if (defined(VMS) || defined(__MINT__)) |
||
215 | # define WILD_STAT_BUG |
||
216 | #endif |
||
217 | |||
218 | /*--------------------------------------------------------------------------- |
||
219 | OS-dependent includes |
||
220 | ---------------------------------------------------------------------------*/ |
||
221 | |||
222 | |||
223 | /*--------------------------------------------------------------------------- |
||
224 | API (DLL) section: |
||
225 | ---------------------------------------------------------------------------*/ |
||
226 | |||
227 | #ifdef DLL |
||
228 | # define MAIN UZ_EXP UzpMain /* was UzpUnzip */ |
||
229 | # ifdef OS2DLL |
||
230 | # undef Info |
||
231 | # define REDIRECTC(c) varputchar(__G__ c) |
||
232 | # define REDIRECTPRINT(buf,size) varmessage(__G__ buf, size) |
||
233 | # define FINISH_REDIRECT() finish_REXX_redirect(__G) |
||
234 | # else |
||
235 | # define REDIRECTC(c) |
||
236 | # define REDIRECTPRINT(buf,size) 0 |
||
237 | # define FINISH_REDIRECT() close_redirect(__G) |
||
238 | # endif |
||
239 | #endif |
||
240 | |||
241 | /*--------------------------------------------------------------------------- |
||
242 | Acorn RISCOS section: |
||
243 | ---------------------------------------------------------------------------*/ |
||
244 | |||
245 | #ifdef RISCOS |
||
246 | # include "acorn/riscos.h" |
||
247 | #endif |
||
248 | |||
249 | /*--------------------------------------------------------------------------- |
||
250 | Amiga section: |
||
251 | ---------------------------------------------------------------------------*/ |
||
252 | |||
253 | #ifdef AMIGA |
||
254 | # include "amiga/amiga.h" |
||
255 | #endif |
||
256 | |||
257 | /*--------------------------------------------------------------------------- |
||
258 | AOS/VS section (somewhat similar to Unix, apparently): |
||
259 | ---------------------------------------------------------------------------*/ |
||
260 | |||
261 | #ifdef AOS_VS |
||
262 | # ifdef __FILEIO_C |
||
263 | # include "aosvs/aosvs.h" |
||
264 | # endif |
||
265 | #endif |
||
266 | |||
267 | /*--------------------------------------------------------------------------- |
||
268 | Atari ST section: |
||
269 | ---------------------------------------------------------------------------*/ |
||
270 | |||
271 | #ifdef ATARI |
||
272 | # include |
||
273 | # include |
||
274 | # include |
||
275 | # include |
||
276 | # define SYMLINKS |
||
277 | # define EXE_EXTENSION ".tos" |
||
278 | # ifndef DATE_FORMAT |
||
279 | # define DATE_FORMAT DF_DMY |
||
280 | # endif |
||
281 | # define DIR_END '/' |
||
282 | # define INT_SPRINTF |
||
283 | # define timezone _timezone |
||
284 | # define lenEOL 2 |
||
285 | # define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);} |
||
286 | # undef SHORT_NAMES |
||
287 | # if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP)) |
||
288 | # define TIMESTAMP |
||
289 | # endif |
||
290 | #endif |
||
291 | |||
292 | /*--------------------------------------------------------------------------- |
||
293 | AtheOS section: |
||
294 | ---------------------------------------------------------------------------*/ |
||
295 | |||
296 | #ifdef __ATHEOS__ |
||
297 | # include "atheos/athcfg.h" |
||
298 | #endif |
||
299 | |||
300 | /*--------------------------------------------------------------------------- |
||
301 | BeOS section: |
||
302 | ---------------------------------------------------------------------------*/ |
||
303 | |||
304 | #ifdef __BEOS__ |
||
305 | # include "beos/beocfg.h" |
||
306 | #endif |
||
307 | |||
308 | /*--------------------------------------------------------------------------- |
||
309 | Human68k/X680x0 section: |
||
310 | ---------------------------------------------------------------------------*/ |
||
311 | |||
312 | #ifdef __human68k__ |
||
313 | /* DO NOT DEFINE DOS_OS2 HERE! If Human68k is so much */ |
||
314 | /* like MS-DOS and/or OS/2, create DOS_H68_OS2 macro. */ |
||
315 | # if (!defined(_MBCS) && !defined(NO_MBCS)) |
||
316 | /* enable MBCS support by default for this system */ |
||
317 | # define _MBCS |
||
318 | # endif |
||
319 | # if (defined(_MBCS) && defined(NO_MBCS)) |
||
320 | /* disable MBCS support when explicitely requested */ |
||
321 | # undef _MBCS |
||
322 | # endif |
||
323 | # include |
||
324 | # include |
||
325 | # include |
||
326 | # include |
||
327 | # include |
||
328 | # ifdef HAVE_MBSTRING_H |
||
329 | # include |
||
330 | # endif |
||
331 | # ifdef HAVE_MBCTYPE_H |
||
332 | # include |
||
333 | # else |
||
334 | # ifndef _ismbblead |
||
335 | # define _ismbblead(c) (0x80 <= (c) && ((c) < 0xa0 || 0xe0 <= (c))) |
||
336 | # endif |
||
337 | # endif |
||
338 | # ifndef DATE_FORMAT |
||
339 | # define DATE_FORMAT DF_YMD /* Japanese standard */ |
||
340 | # endif |
||
341 | # define lenEOL 1 |
||
342 | # define PutNativeEOL *q++ = native(LF); |
||
343 | # define INT_SPRINTF |
||
344 | # define SYMLINKS |
||
345 | # ifdef SFX |
||
346 | # define MAIN main_sfx |
||
347 | # endif |
||
348 | #endif |
||
349 | |||
350 | /*--------------------------------------------------------------------------- |
||
351 | Mac section: |
||
352 | ---------------------------------------------------------------------------*/ |
||
353 | |||
354 | #ifdef MACOS |
||
355 | # include "maccfg.h" |
||
356 | #endif /* MACOS */ |
||
357 | |||
358 | /*--------------------------------------------------------------------------- |
||
359 | MS-DOS, OS/2, FLEXOS section: |
||
360 | ---------------------------------------------------------------------------*/ |
||
361 | |||
362 | #ifdef WINDLL |
||
363 | # ifdef MORE |
||
364 | # undef MORE |
||
365 | # endif |
||
366 | # ifdef OS2_EAS |
||
367 | # undef OS2_EAS |
||
368 | # endif |
||
369 | #endif |
||
370 | |||
371 | #if (defined(_MSC_VER) || (defined(M_I86) && !defined(__WATCOMC__))) |
||
372 | # ifndef MSC |
||
373 | # define MSC /* This should work for older MSC, too! */ |
||
374 | # endif |
||
375 | #endif |
||
376 | |||
377 | #if (defined(MSDOS) || defined(OS2) || defined(FLEXOS)) |
||
378 | # include |
||
379 | # include |
||
380 | # include |
||
381 | # include |
||
382 | # include |
||
383 | |||
384 | # ifdef OS2 /* defined for all OS/2 compilers */ |
||
385 | # include "os2/os2cfg.h" |
||
386 | # else |
||
387 | # ifdef FLEXOS |
||
388 | # include "flexos/flxcfg.h" |
||
389 | # else |
||
390 | # include "msdos/doscfg.h" |
||
391 | # endif |
||
392 | # endif |
||
393 | |||
394 | # if (defined(_MSC_VER) && (_MSC_VER == 700) && !defined(GRR)) |
||
395 | /* |
||
396 | * ARGH. MSC 7.0 libraries think times are based on 1899 Dec 31 00:00, not |
||
397 | * 1970 Jan 1 00:00. So we have to diddle time_t's appropriately: add or |
||
398 | * subtract 70 years' worth of seconds; i.e., number of days times 86400; |
||
399 | * i.e., (70*365 regular days + 17 leap days + 1 1899 day) * 86400 == |
||
400 | * (25550 + 17 + 1) * 86400 == 2209075200 seconds. We know time_t is an |
||
401 | * unsigned long (ulg) on the only system with this bug. |
||
402 | */ |
||
403 | # define TIMET_TO_NATIVE(x) (x) += (ulg)2209075200L; |
||
404 | # define NATIVE_TO_TIMET(x) (x) -= (ulg)2209075200L; |
||
405 | # endif |
||
406 | # if (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0450)) |
||
407 | # define timezone _timezone |
||
408 | # endif |
||
409 | # if (defined(__GO32__) || defined(FLEXOS)) |
||
410 | # define DIR_END '/' |
||
411 | # else |
||
412 | # define DIR_END '\\' /* OS uses '\\' as directory separator */ |
||
413 | # define DIR_END2 '/' /* also check for '/' (RTL may convert) */ |
||
414 | # endif |
||
415 | # ifdef DATE_FORMAT |
||
416 | # undef DATE_FORMAT |
||
417 | # endif |
||
418 | # define DATE_FORMAT dateformat() |
||
419 | # define lenEOL 2 |
||
420 | # define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);} |
||
421 | # if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME)) |
||
422 | # define USE_EF_UT_TIME |
||
423 | # endif |
||
424 | #endif /* MSDOS || OS2 || FLEXOS */ |
||
425 | |||
426 | /*--------------------------------------------------------------------------- |
||
427 | MTS section (piggybacks UNIX, I think): |
||
428 | ---------------------------------------------------------------------------*/ |
||
429 | |||
430 | #ifdef MTS |
||
431 | # include |
||
432 | # include |
||
433 | # include |
||
434 | # include |
||
435 | # include |
||
436 | # include |
||
437 | # define mkdir(s,n) (-1) /* no "make directory" capability */ |
||
438 | # define EBCDIC /* set EBCDIC conversion on */ |
||
439 | # define NO_STRNICMP /* unzip's is as good the one in MTS */ |
||
440 | # define USE_FWRITE |
||
441 | # define close_outfile() fclose(G.outfile) /* can't set time on files */ |
||
442 | # define umask(n) /* don't have umask() on MTS */ |
||
443 | # define FOPWT "w" /* open file for writing in TEXT mode */ |
||
444 | # ifndef DATE_FORMAT |
||
445 | # define DATE_FORMAT DF_MDY |
||
446 | # endif |
||
447 | # define lenEOL 1 |
||
448 | # define PutNativeEOL *q++ = native(LF); |
||
449 | #endif /* MTS */ |
||
450 | |||
451 | /*--------------------------------------------------------------------------- |
||
452 | Novell Netware NLM section |
||
453 | ---------------------------------------------------------------------------*/ |
||
454 | |||
455 | #ifdef NLM |
||
456 | # include "netware/nlmcfg.h" |
||
457 | #endif |
||
458 | |||
459 | /*--------------------------------------------------------------------------- |
||
460 | QDOS section |
||
461 | ---------------------------------------------------------------------------*/ |
||
462 | |||
463 | #ifdef QDOS |
||
464 | # define DIRENT |
||
465 | # include |
||
466 | # include |
||
467 | # include |
||
468 | # include |
||
469 | # include "qdos/izqdos.h" |
||
470 | # ifndef DATE_FORMAT |
||
471 | # define DATE_FORMAT DF_MDY |
||
472 | # endif |
||
473 | # define lenEOL 1 |
||
474 | # define PutNativeEOL *q++ = native(LF); |
||
475 | # define DIR_END '_' |
||
476 | # define RETURN QReturn |
||
477 | # undef PATH_MAX |
||
478 | # define PATH_MAX 36 |
||
479 | # if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP)) |
||
480 | # define TIMESTAMP |
||
481 | # endif |
||
482 | # define SCREENSIZE(ttrows, ttcols) screensize(ttrows, ttcols) |
||
483 | # define SCREENWIDTH 80 |
||
484 | #endif |
||
485 | |||
486 | /*--------------------------------------------------------------------------- |
||
487 | Tandem NSK section: |
||
488 | ---------------------------------------------------------------------------*/ |
||
489 | |||
490 | #ifdef TANDEM |
||
491 | # include "tandem.h" |
||
492 | # include |
||
493 | # ifndef __INT32 |
||
494 | /* We are compiling with non-WIDE memory model, int = 16 bits */ |
||
495 | # ifndef INT_16BIT |
||
496 | # define INT_16BIT /* report "int" size is 16-bit to inflate setup */ |
||
497 | # endif |
||
498 | # ifdef USE_DEFLATE64 |
||
499 | /* Following required for 64k WSIZE of Deflate64 support */ |
||
500 | # define MED_MEM /* else OUTBUFSIZ is 64K and fails in do_string */ |
||
501 | # define INBUFSIZ 8192 /* but larger buffer for real OSes */ |
||
502 | # endif |
||
503 | # endif |
||
504 | /* use a single LF delimiter so that writes to 101 text files work */ |
||
505 | # define PutNativeEOL *q++ = native(LF); |
||
506 | # define lenEOL 1 |
||
507 | # ifndef DATE_FORMAT |
||
508 | # define DATE_FORMAT DF_DMY |
||
509 | # endif |
||
510 | # define SCREENLINES 25 |
||
511 | /* USE_EF_UT_TIME is set in tandem.h */ |
||
512 | # define RESTORE_UIDGID |
||
513 | # define NO_STRNICMP |
||
514 | #endif |
||
515 | |||
516 | /*--------------------------------------------------------------------------- |
||
517 | THEOS section: |
||
518 | ---------------------------------------------------------------------------*/ |
||
519 | |||
520 | #ifdef THEOS |
||
521 | # include "theos/thscfg.h" |
||
522 | #endif |
||
523 | |||
524 | /*--------------------------------------------------------------------------- |
||
525 | TOPS-20 section: |
||
526 | ---------------------------------------------------------------------------*/ |
||
527 | |||
528 | #ifdef TOPS20 |
||
529 | # include |
||
530 | # include |
||
531 | # include |
||
532 | # include |
||
533 | # include |
||
534 | # include |
||
535 | # include |
||
536 | # include |
||
537 | extern int open(), close(), read(); |
||
538 | extern int stat(), unlink(), jsys(), fcntl(); |
||
539 | extern long lseek(), dup(), creat(); |
||
540 | # define strchr index /* GRR: necessary? */ |
||
541 | # define strrchr rindex |
||
542 | # define REALLY_SHORT_SYMS |
||
543 | # define NO_MKDIR |
||
544 | # ifndef HAVE_STRNICMP |
||
545 | # define NO_STRNICMP /* probably not provided by TOPS20 C RTL */ |
||
546 | # endif |
||
547 | # define DIR_BEG '<' |
||
548 | # define DIR_END '>' |
||
549 | # define DIR_EXT ".directory" |
||
550 | # ifndef DATE_FORMAT |
||
551 | # define DATE_FORMAT DF_MDY |
||
552 | # endif |
||
553 | # define EXE_EXTENSION ".exe" /* just a guess... */ |
||
554 | #endif /* TOPS20 */ |
||
555 | |||
556 | /*--------------------------------------------------------------------------- |
||
557 | Unix section: |
||
558 | ---------------------------------------------------------------------------*/ |
||
559 | |||
560 | #ifdef UNIX |
||
561 | # include "unix/unxcfg.h" |
||
562 | #endif /* UNIX */ |
||
563 | |||
564 | /*--------------------------------------------------------------------------- |
||
565 | VM/CMS and MVS section: |
||
566 | ---------------------------------------------------------------------------*/ |
||
567 | |||
568 | #ifdef CMS_MVS |
||
569 | # include "vmmvs.h" |
||
570 | # define CLOSE_INFILE() close_infile(__G) |
||
571 | #endif |
||
572 | |||
573 | /*--------------------------------------------------------------------------- |
||
574 | VMS section: |
||
575 | ---------------------------------------------------------------------------*/ |
||
576 | |||
577 | #ifdef VMS |
||
578 | # include "vms/vmscfg.h" |
||
579 | #endif /* VMS */ |
||
580 | |||
581 | /*--------------------------------------------------------------------------- |
||
582 | KolibriOS section: |
||
583 | ---------------------------------------------------------------------------*/ |
||
584 | |||
585 | #if defined(KOS32) |
||
586 | # include "kolibri/config.h" |
||
587 | # undef WIN32 |
||
588 | #endif |
||
589 | |||
590 | /*--------------------------------------------------------------------------- |
||
591 | Win32 (Windows 95/NT) section: |
||
592 | ---------------------------------------------------------------------------*/ |
||
593 | |||
594 | #if (defined(WIN32) && !defined(POCKET_UNZIP) && !defined(_WIN32_WCE)) |
||
595 | # include "win32/w32cfg.h" |
||
596 | #endif |
||
597 | |||
598 | /*--------------------------------------------------------------------------- |
||
599 | Win32 Windows CE section (also POCKET_UNZIP) |
||
600 | ---------------------------------------------------------------------------*/ |
||
601 | |||
602 | #if (defined(_WIN32_WCE) || defined(POCKET_UNZIP)) |
||
603 | # include "wince/wcecfg.h" |
||
604 | #endif |
||
605 | |||
606 | |||
607 | |||
608 | /* ---------------------------------------------------------------------------- |
||
609 | MUST BE AFTER LARGE FILE INCLUDES |
||
610 | ---------------------------------------------------------------------------- */ |
||
611 | /* This stuff calls in types and messes up large file includes. It needs to |
||
612 | go after large file defines in local includes. |
||
613 | I am guessing that moving them here probably broke some ports, but hey. |
||
614 | 10/31/2004 EG */ |
||
615 | /* ---------------------------------------------------------------------------- |
||
616 | Common includes |
||
617 | ---------------------------------------------------------------------------- */ |
||
618 | |||
619 | /* Some ports apply specific adjustments which must be in effect before |
||
620 | reading the "standard" include headers. |
||
621 | */ |
||
622 | |||
623 | #ifdef EFT |
||
624 | # define Z_OFF_T off_t /* Amdahl UTS nonsense ("extended file types") */ |
||
625 | #else |
||
626 | #if (defined(UNIX) && defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)) |
||
627 | # define Z_OFF_T off_t /* 64bit offsets to support 2GB < zipfile size < 4GB */ |
||
628 | #else |
||
629 | # define Z_OFF_T long |
||
630 | #endif |
||
631 | #endif |
||
632 | |||
633 | #ifndef ZOFF_T_DEFINED |
||
634 | typedef Z_OFF_T zoff_t; |
||
635 | # define ZOFF_T_DEFINED |
||
636 | #endif |
||
637 | #ifndef Z_STAT_DEFINED |
||
638 | typedef struct stat z_stat; |
||
639 | # define Z_STAT_DEFINED |
||
640 | #endif |
||
641 | |||
642 | #ifndef MINIX /* Minix needs it after all the other includes (?) */ |
||
643 | # include |
||
644 | #endif |
||
645 | |||
646 | #include |
||
647 | #include |
||
648 | #ifdef USE_STRINGS_H |
||
649 | # include |
||
650 | #else |
||
651 | # include |
||
652 | #endif |
||
653 | #if (defined(MODERN) && !defined(NO_LIMITS_H)) |
||
654 | # include |
||
655 | #endif |
||
656 | |||
657 | /* this include must be down here for SysV.4, for some reason... */ |
||
658 | #include |
||
659 | |||
660 | |||
661 | #ifdef MODERN |
||
662 | # ifndef NO_STDDEF_H |
||
663 | # include |
||
664 | # endif |
||
665 | # ifndef NO_STDLIB_H |
||
666 | # include |
||
667 | # endif |
||
668 | typedef size_t extent; |
||
669 | #else /* !MODERN */ |
||
670 | # ifndef AOS_VS /* mostly modern? */ |
||
671 | Z_OFF_T lseek(); |
||
672 | # ifdef VAXC /* not fully modern, but has stdlib.h and void */ |
||
673 | # include |
||
674 | # else |
||
675 | char *malloc(); |
||
676 | # endif /* ?VAXC */ |
||
677 | # endif /* !AOS_VS */ |
||
678 | typedef unsigned int extent; |
||
679 | #endif /* ?MODERN */ |
||
680 | |||
681 | |||
682 | |||
683 | |||
684 | /*************/ |
||
685 | /* Defines */ |
||
686 | /*************/ |
||
687 | |||
688 | #define UNZIP_BZ2VERS 46 |
||
689 | #ifdef ZIP64_SUPPORT |
||
690 | # ifdef USE_BZIP2 |
||
691 | # define UNZIP_VERSION UNZIP_BZ2VERS |
||
692 | # else |
||
693 | # define UNZIP_VERSION 45 |
||
694 | # endif |
||
695 | #else |
||
696 | #ifdef USE_DEFLATE64 |
||
697 | # define UNZIP_VERSION 21 /* compatible with PKUNZIP 4.0 */ |
||
698 | #else |
||
699 | # define UNZIP_VERSION 20 /* compatible with PKUNZIP 2.0 */ |
||
700 | #endif |
||
701 | #endif |
||
702 | #define VMS_UNZIP_VERSION 42 /* if OS-needed-to-extract is VMS: can do */ |
||
703 | |||
704 | #if (defined(MSDOS) || defined(OS2)) |
||
705 | # define DOS_OS2 |
||
706 | #endif |
||
707 | |||
708 | #if (defined(OS2) || defined(WIN32)) |
||
709 | # define OS2_W32 |
||
710 | #endif |
||
711 | |||
712 | #if (defined(DOS_OS2) || defined(WIN32)) |
||
713 | # define DOS_OS2_W32 |
||
714 | # define DOS_W32_OS2 /* historical: don't use */ |
||
715 | #endif |
||
716 | |||
717 | #if (defined(DOS_OS2_W32) || defined(__human68k__)) |
||
718 | # define DOS_H68_OS2_W32 |
||
719 | #endif |
||
720 | |||
721 | #if (defined(DOS_OS2) || defined(FLEXOS)) |
||
722 | # define DOS_FLX_OS2 |
||
723 | #endif |
||
724 | |||
725 | #if (defined(DOS_OS2_W32) || defined(FLEXOS)) |
||
726 | # define DOS_FLX_OS2_W32 |
||
727 | #endif |
||
728 | |||
729 | #if (defined(DOS_H68_OS2_W32) || defined(FLEXOS)) |
||
730 | # define DOS_FLX_H68_OS2_W32 |
||
731 | #endif |
||
732 | |||
733 | #if (defined(DOS_FLX_OS2) || defined(NLM)) |
||
734 | # define DOS_FLX_NLM_OS2 |
||
735 | #endif |
||
736 | |||
737 | #if (defined(DOS_FLX_OS2_W32) || defined(NLM)) |
||
738 | # define DOS_FLX_NLM_OS2_W32 |
||
739 | #endif |
||
740 | |||
741 | #if (defined(DOS_FLX_H68_OS2_W32) || defined(NLM)) |
||
742 | # define DOS_FLX_H68_NLM_OS2_W32 |
||
743 | #endif |
||
744 | |||
745 | #if (defined(TOPS20) || defined(VMS)) |
||
746 | # define T20_VMS |
||
747 | #endif |
||
748 | |||
749 | #if (defined(MSDOS) || defined(T20_VMS)) |
||
750 | # define DOS_T20_VMS |
||
751 | #endif |
||
752 | |||
753 | #if (defined(__ATHEOS__) || defined(__BEOS__)) |
||
754 | # define ATH_BEO |
||
755 | #endif |
||
756 | |||
757 | #if (defined(ATH_BEO) || defined(UNIX)) |
||
758 | # define ATH_BEO_UNX |
||
759 | #endif |
||
760 | |||
761 | #if (defined(ATH_BEO_UNX) || defined(THEOS)) |
||
762 | # define ATH_BEO_THS_UNX |
||
763 | #endif |
||
764 | |||
765 | /* clean up with a few defaults */ |
||
766 | #ifndef DIR_END |
||
767 | # define DIR_END '/' /* last char before program name or filename */ |
||
768 | #endif |
||
769 | #ifndef DATE_FORMAT |
||
770 | # ifdef DATEFMT_ISO_DEFAULT |
||
771 | # define DATE_FORMAT DF_YMD /* defaults to invariant ISO-style */ |
||
772 | # else |
||
773 | # define DATE_FORMAT DF_MDY /* defaults to US convention */ |
||
774 | # endif |
||
775 | #endif |
||
776 | #ifndef DATE_SEPCHAR |
||
777 | # define DATE_SEPCHAR '-' |
||
778 | #endif |
||
779 | #ifndef CLOSE_INFILE |
||
780 | # define CLOSE_INFILE() close(G.zipfd) |
||
781 | #endif |
||
782 | #ifndef RETURN |
||
783 | # define RETURN return /* only used in main() */ |
||
784 | #endif |
||
785 | #ifndef EXIT |
||
786 | # define EXIT exit |
||
787 | #endif |
||
788 | #ifndef USAGE |
||
789 | # define USAGE(ret) usage(__G__ (ret)) /* used in unzip.c, zipinfo.c */ |
||
790 | #endif |
||
791 | #ifndef TIMET_TO_NATIVE /* everybody but MSC 7.0 and Macintosh */ |
||
792 | # define TIMET_TO_NATIVE(x) |
||
793 | # define NATIVE_TO_TIMET(x) |
||
794 | #endif |
||
795 | #ifndef STRNICMP |
||
796 | # ifdef NO_STRNICMP |
||
797 | # define STRNICMP zstrnicmp |
||
798 | # else |
||
799 | # define STRNICMP strnicmp |
||
800 | # endif |
||
801 | #endif |
||
802 | |||
803 | |||
804 | #if (defined(DOS_FLX_NLM_OS2_W32) || defined(ATH_BEO_UNX) || defined(RISCOS)) |
||
805 | # ifndef HAVE_UNLINK |
||
806 | # define HAVE_UNLINK |
||
807 | # endif |
||
808 | #endif |
||
809 | #if (defined(AOS_VS) || defined(ATARI)) /* GRR: others? */ |
||
810 | # ifndef HAVE_UNLINK |
||
811 | # define HAVE_UNLINK |
||
812 | # endif |
||
813 | #endif |
||
814 | |||
815 | /* OS-specific exceptions to the "ANSI <--> INT_SPRINTF" rule */ |
||
816 | |||
817 | #if (!defined(PCHAR_SPRINTF) && !defined(INT_SPRINTF)) |
||
818 | # if (defined(SYSV) || defined(CONVEX) || defined(NeXT) || defined(BSD4_4)) |
||
819 | # define INT_SPRINTF /* sprintf() returns int: SysVish/Posix */ |
||
820 | # endif |
||
821 | # if (defined(DOS_FLX_NLM_OS2_W32) || defined(VMS) || defined(AMIGA)) |
||
822 | # define INT_SPRINTF /* sprintf() returns int: ANSI */ |
||
823 | # endif |
||
824 | # if (defined(ultrix) || defined(__ultrix)) /* Ultrix 4.3 and newer */ |
||
825 | # if (defined(POSIX) || defined(__POSIX)) |
||
826 | # define INT_SPRINTF /* sprintf() returns int: ANSI/Posix */ |
||
827 | # endif |
||
828 | # ifdef __GNUC__ |
||
829 | # define PCHAR_SPRINTF /* undetermined actual return value */ |
||
830 | # endif |
||
831 | # endif |
||
832 | # if (defined(__osf__) || defined(_AIX) || defined(CMS_MVS) || defined(THEOS)) |
||
833 | # define INT_SPRINTF /* sprintf() returns int: ANSI/Posix */ |
||
834 | # endif |
||
835 | # if defined(sun) |
||
836 | # define PCHAR_SPRINTF /* sprintf() returns char *: SunOS cc *and* gcc */ |
||
837 | # endif |
||
838 | #endif |
||
839 | |||
840 | /* defaults that we hope will take care of most machines in the future */ |
||
841 | |||
842 | #if (!defined(PCHAR_SPRINTF) && !defined(INT_SPRINTF)) |
||
843 | # ifdef __STDC__ |
||
844 | # define INT_SPRINTF /* sprintf() returns int: ANSI */ |
||
845 | # endif |
||
846 | # ifndef INT_SPRINTF |
||
847 | # define PCHAR_SPRINTF /* sprintf() returns char *: BSDish */ |
||
848 | # endif |
||
849 | #endif |
||
850 | |||
851 | #define MSG_STDERR(f) (f & 1) /* bit 0: 0 = stdout, 1 = stderr */ |
||
852 | #define MSG_INFO(f) ((f & 6) == 0) /* bits 1 and 2: 0 = info */ |
||
853 | #define MSG_WARN(f) ((f & 6) == 2) /* bits 1 and 2: 1 = warning */ |
||
854 | #define MSG_ERROR(f) ((f & 6) == 4) /* bits 1 and 2: 2 = error */ |
||
855 | #define MSG_FATAL(f) ((f & 6) == 6) /* bits 1 and 2: (3 = fatal error) */ |
||
856 | #define MSG_ZFN(f) (f & 0x0008) /* bit 3: 1 = print zipfile name */ |
||
857 | #define MSG_FN(f) (f & 0x0010) /* bit 4: 1 = print filename */ |
||
858 | #define MSG_LNEWLN(f) (f & 0x0020) /* bit 5: 1 = leading newline if !SOL */ |
||
859 | #define MSG_TNEWLN(f) (f & 0x0040) /* bit 6: 1 = trailing newline if !SOL */ |
||
860 | #define MSG_MNEWLN(f) (f & 0x0080) /* bit 7: 1 = trailing NL for prompts */ |
||
861 | /* the following are subject to change */ |
||
862 | #define MSG_NO_WGUI(f) (f & 0x0100) /* bit 8: 1 = skip if Windows GUI */ |
||
863 | #define MSG_NO_AGUI(f) (f & 0x0200) /* bit 9: 1 = skip if Acorn GUI */ |
||
864 | #define MSG_NO_DLL2(f) (f & 0x0400) /* bit 10: 1 = skip if OS/2 DLL */ |
||
865 | #define MSG_NO_NDLL(f) (f & 0x0800) /* bit 11: 1 = skip if WIN32 DLL */ |
||
866 | #define MSG_NO_WDLL(f) (f & 0x1000) /* bit 12: 1 = skip if Windows DLL */ |
||
867 | |||
868 | #if (defined(MORE) && !defined(SCREENLINES)) |
||
869 | # ifdef DOS_FLX_NLM_OS2_W32 |
||
870 | # define SCREENLINES 25 /* can be (should be) a function instead */ |
||
871 | # else |
||
872 | # define SCREENLINES 24 /* VT-100s are assumed to be minimal hardware */ |
||
873 | # endif |
||
874 | #endif |
||
875 | #if (defined(MORE) && !defined(SCREENSIZE)) |
||
876 | # ifndef SCREENWIDTH |
||
877 | # define SCREENSIZE(scrrows, scrcols) { \ |
||
878 | if ((scrrows) != NULL) *(scrrows) = SCREENLINES; } |
||
879 | # else |
||
880 | # define SCREENSIZE(scrrows, scrcols) { \ |
||
881 | if ((scrrows) != NULL) *(scrrows) = SCREENLINES; \ |
||
882 | if ((scrcols) != NULL) *(scrcols) = SCREENWIDTH; } |
||
883 | # endif |
||
884 | #endif |
||
885 | |||
886 | #if (defined(__16BIT__) || defined(MED_MEM) || defined(SMALL_MEM)) |
||
887 | # define DIR_BLKSIZ 64 /* number of directory entries per block |
||
888 | * (should fit in 4096 bytes, usually) */ |
||
889 | #else |
||
890 | # define DIR_BLKSIZ 16384 /* use more memory, to reduce long-range seeks */ |
||
891 | #endif |
||
892 | |||
893 | #ifndef WSIZE |
||
894 | # ifdef USE_DEFLATE64 |
||
895 | # define WSIZE 65536L /* window size--must be a power of two, and */ |
||
896 | # else /* at least 64K for PKZip's deflate64 method */ |
||
897 | # define WSIZE 0x8000 /* window size--must be a power of two, and */ |
||
898 | # endif /* at least 32K for zip's deflate method */ |
||
899 | #endif |
||
900 | |||
901 | #ifdef __16BIT__ |
||
902 | # ifndef INT_16BIT |
||
903 | # define INT_16BIT /* on 16-bit systems int size is 16 bits */ |
||
904 | # endif |
||
905 | #else |
||
906 | # define nearmalloc malloc |
||
907 | # define nearfree free |
||
908 | # if (!defined(__IBMC__) || !defined(OS2)) |
||
909 | # ifndef near |
||
910 | # define near |
||
911 | # endif |
||
912 | # ifndef far |
||
913 | # define far |
||
914 | # endif |
||
915 | # endif |
||
916 | #endif |
||
917 | |||
918 | #if (defined(DYNALLOC_CRCTAB) && !defined(DYNAMIC_CRC_TABLE)) |
||
919 | # undef DYNALLOC_CRCTAB |
||
920 | #endif |
||
921 | |||
922 | #if (defined(DYNALLOC_CRCTAB) && defined(REENTRANT)) |
||
923 | # undef DYNALLOC_CRCTAB /* not safe with reentrant code */ |
||
924 | #endif |
||
925 | |||
926 | #if (defined(USE_ZLIB) && !defined(USE_OWN_CRCTAB)) |
||
927 | # ifdef DYNALLOC_CRCTAB |
||
928 | # undef DYNALLOC_CRCTAB |
||
929 | # endif |
||
930 | #endif |
||
931 | |||
932 | #if (defined(USE_ZLIB) && defined(ASM_CRC)) |
||
933 | # undef ASM_CRC |
||
934 | #endif |
||
935 | |||
936 | #ifdef USE_ZLIB |
||
937 | # ifdef IZ_CRC_BE_OPTIMIZ |
||
938 | # undef IZ_CRC_BE_OPTIMIZ |
||
939 | # endif |
||
940 | # ifdef IZ_CRC_LE_OPTIMIZ |
||
941 | # undef IZ_CRC_LE_OPTIMIZ |
||
942 | # endif |
||
943 | #endif |
||
944 | #if (!defined(IZ_CRC_BE_OPTIMIZ) && !defined(IZ_CRC_LE_OPTIMIZ)) |
||
945 | # ifdef IZ_CRCOPTIM_UNFOLDTBL |
||
946 | # undef IZ_CRCOPTIM_UNFOLDTBL |
||
947 | # endif |
||
948 | #endif |
||
949 | |||
950 | #ifndef INBUFSIZ |
||
951 | # if (defined(MED_MEM) || defined(SMALL_MEM)) |
||
952 | # define INBUFSIZ 2048 /* works for MS-DOS small model */ |
||
953 | # else |
||
954 | # define INBUFSIZ 8192 /* larger buffers for real OSes */ |
||
955 | # endif |
||
956 | #endif |
||
957 | |||
958 | #if (defined(INT_16BIT) && (defined(USE_DEFLATE64) || lenEOL > 1)) |
||
959 | /* For environments using 16-bit integers OUTBUFSIZ must be limited to |
||
960 | * less than 64k (do_string() uses "unsigned" in calculations involving |
||
961 | * OUTBUFSIZ). This is achieved by defining MED_MEM when WSIZE = 64k (aka |
||
962 | * Deflate64 support enabled) or EOL markers contain multiple characters. |
||
963 | * (The rule gets applied AFTER the default rule for INBUFSIZ because it |
||
964 | * is not neccessary to reduce INBUFSIZE in this case.) |
||
965 | */ |
||
966 | # if (!defined(SMALL_MEM) && !defined(MED_MEM)) |
||
967 | # define MED_MEM |
||
968 | # endif |
||
969 | #endif |
||
970 | |||
971 | /* Logic for case of small memory, length of EOL > 1: if OUTBUFSIZ == 2048, |
||
972 | * OUTBUFSIZ>>1 == 1024 and OUTBUFSIZ>>7 == 16; therefore rawbuf is 1008 bytes |
||
973 | * and transbuf 1040 bytes. Have room for 32 extra EOL chars; 1008/32 == 31.5 |
||
974 | * chars/line, smaller than estimated 35-70 characters per line for C source |
||
975 | * and normal text. Hence difference is sufficient for most "average" files. |
||
976 | * (Argument scales for larger OUTBUFSIZ.) |
||
977 | */ |
||
978 | #ifdef SMALL_MEM /* i.e., 16-bit OSes: MS-DOS, OS/2 1.x, etc. */ |
||
979 | # define LoadFarString(x) fLoadFarString(__G__ (x)) |
||
980 | # define LoadFarStringSmall(x) fLoadFarStringSmall(__G__ (x)) |
||
981 | # define LoadFarStringSmall2(x) fLoadFarStringSmall2(__G__ (x)) |
||
982 | # if (defined(_MSC_VER) && (_MSC_VER >= 600)) |
||
983 | # define zfstrcpy(dest, src) _fstrcpy((dest), (src)) |
||
984 | # define zfstrcmp(s1, s2) _fstrcmp((s1), (s2)) |
||
985 | # endif |
||
986 | # if !(defined(SFX) || defined(FUNZIP)) |
||
987 | # if (defined(_MSC_VER)) |
||
988 | # define zfmalloc(sz) _fmalloc((sz)) |
||
989 | # define zffree(x) _ffree(x) |
||
990 | # endif |
||
991 | # if (defined(__TURBOC__)) |
||
992 | # include |
||
993 | # define zfmalloc(sz) farmalloc((unsigned long)(sz)) |
||
994 | # define zffree(x) farfree(x) |
||
995 | # endif |
||
996 | # endif /* !(SFX || FUNZIP) */ |
||
997 | # ifndef Far |
||
998 | # define Far far /* __far only works for MSC 6.00, not 6.0a or Borland */ |
||
999 | # endif |
||
1000 | # define OUTBUFSIZ INBUFSIZ |
||
1001 | # if (lenEOL == 1) |
||
1002 | # define RAWBUFSIZ (OUTBUFSIZ>>1) |
||
1003 | # else |
||
1004 | # define RAWBUFSIZ ((OUTBUFSIZ>>1) - (OUTBUFSIZ>>7)) |
||
1005 | # endif |
||
1006 | # define TRANSBUFSIZ (OUTBUFSIZ-RAWBUFSIZ) |
||
1007 | typedef short shrint; /* short/int or "shrink int" (unshrink) */ |
||
1008 | #else |
||
1009 | # define zfstrcpy(dest, src) strcpy((dest), (src)) |
||
1010 | # define zfstrcmp(s1, s2) strcmp((s1), (s2)) |
||
1011 | # define zfmalloc malloc |
||
1012 | # define zffree(x) free(x) |
||
1013 | # ifdef QDOS |
||
1014 | # define LoadFarString(x) Qstrfix(x) /* fix up _ for '.' */ |
||
1015 | # define LoadFarStringSmall(x) Qstrfix(x) |
||
1016 | # define LoadFarStringSmall2(x) Qstrfix(x) |
||
1017 | # else |
||
1018 | # define LoadFarString(x) (char *)(x) |
||
1019 | # define LoadFarStringSmall(x) (char *)(x) |
||
1020 | # define LoadFarStringSmall2(x) (char *)(x) |
||
1021 | # endif |
||
1022 | # ifdef MED_MEM |
||
1023 | # define OUTBUFSIZ 0xFF80 /* can't malloc arrays of 0xFFE8 or more */ |
||
1024 | # define TRANSBUFSIZ 0xFF80 |
||
1025 | typedef short shrint; |
||
1026 | # else |
||
1027 | # define OUTBUFSIZ (lenEOL*WSIZE) /* more efficient text conversion */ |
||
1028 | # define TRANSBUFSIZ (lenEOL*OUTBUFSIZ) |
||
1029 | # ifdef AMIGA |
||
1030 | typedef short shrint; |
||
1031 | # else |
||
1032 | typedef int shrint; /* for efficiency/speed, we hope... */ |
||
1033 | # endif |
||
1034 | # endif /* ?MED_MEM */ |
||
1035 | # define RAWBUFSIZ OUTBUFSIZ |
||
1036 | #endif /* ?SMALL_MEM */ |
||
1037 | |||
1038 | #ifndef Far |
||
1039 | # define Far |
||
1040 | #endif |
||
1041 | |||
1042 | #ifndef Cdecl |
||
1043 | # define Cdecl |
||
1044 | #endif |
||
1045 | |||
1046 | #ifndef MAIN |
||
1047 | # define MAIN main |
||
1048 | #endif |
||
1049 | |||
1050 | #ifdef SFX /* disable some unused features for SFX executables */ |
||
1051 | # ifndef NO_ZIPINFO |
||
1052 | # define NO_ZIPINFO |
||
1053 | # endif |
||
1054 | # ifdef TIMESTAMP |
||
1055 | # undef TIMESTAMP |
||
1056 | # endif |
||
1057 | #endif |
||
1058 | |||
1059 | #ifdef SFX |
||
1060 | # ifdef CHEAP_SFX_AUTORUN |
||
1061 | # ifndef NO_SFX_EXDIR |
||
1062 | # define NO_SFX_EXDIR |
||
1063 | # endif |
||
1064 | # endif |
||
1065 | # ifndef NO_SFX_EXDIR |
||
1066 | # ifndef SFX_EXDIR |
||
1067 | # define SFX_EXDIR |
||
1068 | # endif |
||
1069 | # else |
||
1070 | # ifdef SFX_EXDIR |
||
1071 | # undef SFX_EXDIR |
||
1072 | # endif |
||
1073 | # endif |
||
1074 | #endif |
||
1075 | |||
1076 | /* user may have defined both by accident... NOTIMESTAMP takes precedence */ |
||
1077 | #if (defined(TIMESTAMP) && defined(NOTIMESTAMP)) |
||
1078 | # undef TIMESTAMP |
||
1079 | #endif |
||
1080 | |||
1081 | #if (!defined(COPYRIGHT_CLEAN) && !defined(USE_SMITH_CODE)) |
||
1082 | # define COPYRIGHT_CLEAN |
||
1083 | #endif |
||
1084 | |||
1085 | /* The LZW patent is expired worldwide since 2004-Jul-07, so USE_UNSHRINK |
||
1086 | * is now enabled by default. See unshrink.c. |
||
1087 | */ |
||
1088 | #if (!defined(LZW_CLEAN) && !defined(USE_UNSHRINK)) |
||
1089 | # define USE_UNSHRINK |
||
1090 | #endif |
||
1091 | |||
1092 | #ifndef O_BINARY |
||
1093 | # define O_BINARY 0 |
||
1094 | #endif |
||
1095 | |||
1096 | #ifndef PIPE_ERROR |
||
1097 | # ifndef EPIPE |
||
1098 | # define EPIPE -1 |
||
1099 | # endif |
||
1100 | # define PIPE_ERROR (errno == EPIPE) |
||
1101 | #endif |
||
1102 | |||
1103 | /* File operations--use "b" for binary if allowed or fixed length 512 on VMS */ |
||
1104 | #ifdef VMS |
||
1105 | # define FOPR "r","ctx=stm" |
||
1106 | # define FOPM "r+","ctx=stm","rfm=fix","mrs=512" |
||
1107 | # define FOPW "w","ctx=stm","rfm=fix","mrs=512" |
||
1108 | # define FOPWR "w+","ctx=stm","rfm=fix","mrs=512" |
||
1109 | #endif /* VMS */ |
||
1110 | |||
1111 | #ifdef CMS_MVS |
||
1112 | /* Binary files must be RECFM=F,LRECL=1 for ftell() to get correct pos */ |
||
1113 | /* ...unless byteseek is used. Let's try that for a while. */ |
||
1114 | # define FOPR "rb,byteseek" |
||
1115 | # define FOPM "r+b,byteseek" |
||
1116 | # ifdef MVS |
||
1117 | # define FOPW "wb,recfm=u,lrecl=32760,byteseek" /* New binary files */ |
||
1118 | # define FOPWE "wb" /* Existing binary files */ |
||
1119 | # define FOPWT "w,lrecl=133" /* New text files */ |
||
1120 | # define FOPWTE "w" /* Existing text files */ |
||
1121 | # else |
||
1122 | # define FOPW "wb,recfm=v,lrecl=32760" |
||
1123 | # define FOPWT "w" |
||
1124 | # endif |
||
1125 | #endif /* CMS_MVS */ |
||
1126 | |||
1127 | #ifdef TOPS20 /* TOPS-20 MODERN? You kidding? */ |
||
1128 | # define FOPW "w8" |
||
1129 | #endif /* TOPS20 */ |
||
1130 | |||
1131 | /* Defaults when nothing special has been defined previously. */ |
||
1132 | #ifdef MODERN |
||
1133 | # ifndef FOPR |
||
1134 | # define FOPR "rb" |
||
1135 | # endif |
||
1136 | # ifndef FOPM |
||
1137 | # define FOPM "r+b" |
||
1138 | # endif |
||
1139 | # ifndef FOPW |
||
1140 | # define FOPW "wb" |
||
1141 | # endif |
||
1142 | # ifndef FOPWT |
||
1143 | # define FOPWT "wt" |
||
1144 | # endif |
||
1145 | # ifndef FOPWR |
||
1146 | # define FOPWR "w+b" |
||
1147 | # endif |
||
1148 | #else /* !MODERN */ |
||
1149 | # ifndef FOPR |
||
1150 | # define FOPR "r" |
||
1151 | # endif |
||
1152 | # ifndef FOPM |
||
1153 | # define FOPM "r+" |
||
1154 | # endif |
||
1155 | # ifndef FOPW |
||
1156 | # define FOPW "w" |
||
1157 | # endif |
||
1158 | # ifndef FOPWT |
||
1159 | # define FOPWT "w" |
||
1160 | # endif |
||
1161 | # ifndef FOPWR |
||
1162 | # define FOPWR "w+" |
||
1163 | # endif |
||
1164 | #endif /* ?MODERN */ |
||
1165 | |||
1166 | /* |
||
1167 | * If |
||
1168 | * define some or all of the following: NAME_MAX, PATH_MAX, _POSIX_NAME_MAX, |
||
1169 | * _POSIX_PATH_MAX. |
||
1170 | */ |
||
1171 | #ifdef DOS_FLX_NLM_OS2_W32 |
||
1172 | # include |
||
1173 | #endif |
||
1174 | |||
1175 | /* 2008-07-22 SMS. |
||
1176 | * Unfortunately, on VMS, |
||
1177 | * (so it's pretty much unavoidable), and it defines PATH_MAX to a fixed |
||
1178 | * short value (256, correct only for older systems without ODS-5 support), |
||
1179 | * rather than one based on the real RMS NAM[L] situation. So, we |
||
1180 | * artificially undefine it here, to allow our better-defined _MAX_PATH |
||
1181 | * (see vms/vmscfg.h) to be used. |
||
1182 | */ |
||
1183 | #ifdef VMS |
||
1184 | # undef PATH_MAX |
||
1185 | #endif |
||
1186 | |||
1187 | #ifndef PATH_MAX |
||
1188 | # ifdef MAXPATHLEN |
||
1189 | # define PATH_MAX MAXPATHLEN /* in |
||
1190 | # else |
||
1191 | # ifdef _MAX_PATH |
||
1192 | # define PATH_MAX _MAX_PATH |
||
1193 | # else |
||
1194 | # if FILENAME_MAX > 255 |
||
1195 | # define PATH_MAX FILENAME_MAX /* used like PATH_MAX on some systems */ |
||
1196 | # else |
||
1197 | # define PATH_MAX 1024 |
||
1198 | # endif |
||
1199 | # endif /* ?_MAX_PATH */ |
||
1200 | # endif /* ?MAXPATHLEN */ |
||
1201 | #endif /* !PATH_MAX */ |
||
1202 | |||
1203 | /* |
||
1204 | * buffer size required to hold the longest legal local filepath |
||
1205 | * (including the trailing '\0') |
||
1206 | */ |
||
1207 | #define FILNAMSIZ PATH_MAX |
||
1208 | |||
1209 | #ifdef UNICODE_SUPPORT |
||
1210 | # if !(defined(UTF8_MAYBE_NATIVE) || defined(UNICODE_WCHAR)) |
||
1211 | # undef UNICODE_SUPPORT |
||
1212 | # endif |
||
1213 | #endif |
||
1214 | /* 2007-09-18 SMS. |
||
1215 | * Include |
||
1216 | * Otherwise, SETLOCALE may be defined here, and then defined again |
||
1217 | * (differently) when |
||
1218 | */ |
||
1219 | #ifdef UNICODE_SUPPORT |
||
1220 | # ifdef UNICODE_WCHAR |
||
1221 | # if !(defined(_WIN32_WCE) || defined(POCKET_UNZIP)) |
||
1222 | # include |
||
1223 | # endif |
||
1224 | # endif |
||
1225 | # ifndef _MBCS /* no need to include |
||
1226 | # include |
||
1227 | # ifndef SETLOCALE |
||
1228 | # define SETLOCALE(category, locale) setlocale(category, locale) |
||
1229 | # endif |
||
1230 | # endif |
||
1231 | #endif /* UNICODE_SUPPORT */ |
||
1232 | |||
1233 | /* DBCS support for Info-ZIP (mainly for japanese (-: ) |
||
1234 | * by Yoshioka Tsuneo (QWF00133@nifty.ne.jp,tsuneo-y@is.aist-nara.ac.jp) |
||
1235 | */ |
||
1236 | #ifdef _MBCS |
||
1237 | # include |
||
1238 | /* Multi Byte Character Set */ |
||
1239 | # define ___MBS_TMP_DEF char *___tmp_ptr; |
||
1240 | # define ___TMP_PTR ___tmp_ptr |
||
1241 | # ifndef CLEN |
||
1242 | # define NEED_UZMBCLEN |
||
1243 | # define CLEN(ptr) (int)uzmbclen((ZCONST unsigned char *)(ptr)) |
||
1244 | # endif |
||
1245 | # ifndef PREINCSTR |
||
1246 | # define PREINCSTR(ptr) (ptr += CLEN(ptr)) |
||
1247 | # endif |
||
1248 | # define POSTINCSTR(ptr) (___TMP_PTR=(char *)(ptr), PREINCSTR(ptr),___TMP_PTR) |
||
1249 | char *plastchar OF((ZCONST char *ptr, extent len)); |
||
1250 | # define lastchar(ptr, len) ((int)(unsigned)*plastchar(ptr, len)) |
||
1251 | # ifndef MBSCHR |
||
1252 | # define NEED_UZMBSCHR |
||
1253 | # define MBSCHR(str,c) (char *)uzmbschr((ZCONST unsigned char *)(str), c) |
||
1254 | # endif |
||
1255 | # ifndef MBSRCHR |
||
1256 | # define NEED_UZMBSRCHR |
||
1257 | # define MBSRCHR(str,c) (char *)uzmbsrchr((ZCONST unsigned char *)(str), c) |
||
1258 | # endif |
||
1259 | # ifndef SETLOCALE |
||
1260 | # define SETLOCALE(category, locale) setlocale(category, locale) |
||
1261 | # endif |
||
1262 | #else /* !_MBCS */ |
||
1263 | # define ___MBS_TMP_DEF |
||
1264 | # define ___TMP_PTR |
||
1265 | # define CLEN(ptr) 1 |
||
1266 | # define PREINCSTR(ptr) (++(ptr)) |
||
1267 | # define POSTINCSTR(ptr) ((ptr)++) |
||
1268 | # define plastchar(ptr, len) (&ptr[(len)-1]) |
||
1269 | # define lastchar(ptr, len) (ptr[(len)-1]) |
||
1270 | # define MBSCHR(str, c) strchr(str, c) |
||
1271 | # define MBSRCHR(str, c) strrchr(str, c) |
||
1272 | # ifndef SETLOCALE |
||
1273 | # define SETLOCALE(category, locale) |
||
1274 | # endif |
||
1275 | #endif /* ?_MBCS */ |
||
1276 | #define INCSTR(ptr) PREINCSTR(ptr) |
||
1277 | |||
1278 | |||
1279 | #if (defined(MALLOC_WORK) && !defined(MY_ZCALLOC)) |
||
1280 | /* Any system without a special calloc function */ |
||
1281 | # ifndef zcalloc |
||
1282 | # define zcalloc(items, size) \ |
||
1283 | (zvoid far *)calloc((unsigned)(items), (unsigned)(size)) |
||
1284 | # endif |
||
1285 | # ifndef zcfree |
||
1286 | # define zcfree free |
||
1287 | # endif |
||
1288 | #endif /* MALLOC_WORK && !MY_ZCALLOC */ |
||
1289 | |||
1290 | #if (defined(CRAY) && defined(ZMEM)) |
||
1291 | # undef ZMEM |
||
1292 | #endif |
||
1293 | |||
1294 | #ifdef ZMEM |
||
1295 | # undef ZMEM |
||
1296 | # define memcmp(b1,b2,len) bcmp(b2,b1,len) |
||
1297 | # define memcpy(dest,src,len) bcopy(src,dest,len) |
||
1298 | # define memzero bzero |
||
1299 | #else |
||
1300 | # define memzero(dest,len) memset(dest,0,len) |
||
1301 | #endif |
||
1302 | |||
1303 | #ifndef TRUE |
||
1304 | # define TRUE 1 /* sort of obvious */ |
||
1305 | #endif |
||
1306 | #ifndef FALSE |
||
1307 | # define FALSE 0 |
||
1308 | #endif |
||
1309 | |||
1310 | #ifndef SEEK_SET |
||
1311 | # define SEEK_SET 0 |
||
1312 | # define SEEK_CUR 1 |
||
1313 | # define SEEK_END 2 |
||
1314 | #endif |
||
1315 | |||
1316 | #if (!defined(S_IEXEC) && defined(S_IXUSR)) |
||
1317 | # define S_IEXEC S_IXUSR |
||
1318 | #endif |
||
1319 | |||
1320 | #if (defined(UNIX) && defined(S_IFLNK) && !defined(MTS)) |
||
1321 | # define SYMLINKS |
||
1322 | # ifndef S_ISLNK |
||
1323 | # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) |
||
1324 | # endif |
||
1325 | #endif /* UNIX && S_IFLNK && !MTS */ |
||
1326 | |||
1327 | #ifndef S_ISDIR |
||
1328 | # ifdef CMS_MVS |
||
1329 | # define S_ISDIR(m) (FALSE) |
||
1330 | # else |
||
1331 | # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) |
||
1332 | # endif |
||
1333 | #endif |
||
1334 | |||
1335 | #ifndef IS_VOLID |
||
1336 | # define IS_VOLID(m) ((m) & 0x08) |
||
1337 | #endif |
||
1338 | |||
1339 | /***********************************/ |
||
1340 | /* LARGE_FILE_SUPPORT */ |
||
1341 | /***********************************/ |
||
1342 | /* This whole section lifted from Zip 3b tailor.h |
||
1343 | |||
1344 | * Types are in OS dependent headers (eg, w32cfg.h) |
||
1345 | * |
||
1346 | * LARGE_FILE_SUPPORT and ZIP64_SUPPORT are automatically |
||
1347 | * set in OS dependent headers (for some ports) based on the port and compiler. |
||
1348 | * |
||
1349 | * Function prototypes are below as OF is defined earlier in this file |
||
1350 | * but after OS dependent header is included. |
||
1351 | * |
||
1352 | * E. Gordon 9/21/2003 |
||
1353 | * Updated 1/28/2004 |
||
1354 | * Lifted and placed here 6/7/2004 - Myles Bennett |
||
1355 | */ |
||
1356 | #ifdef LARGE_FILE_SUPPORT |
||
1357 | /* 64-bit Large File Support */ |
||
1358 | |||
1359 | /* ---------------------------- */ |
||
1360 | |||
1361 | # if defined(UNIX) || defined(VMS) |
||
1362 | |||
1363 | /* 64-bit stat functions */ |
||
1364 | # define zstat stat |
||
1365 | # define zfstat fstat |
||
1366 | |||
1367 | /* 64-bit fseeko */ |
||
1368 | # define zlseek lseek |
||
1369 | # define zfseeko fseeko |
||
1370 | |||
1371 | /* 64-bit ftello */ |
||
1372 | # define zftello ftello |
||
1373 | |||
1374 | /* 64-bit fopen */ |
||
1375 | # define zfopen fopen |
||
1376 | # define zfdopen fdopen |
||
1377 | |||
1378 | # endif /* UNIX || VMS */ |
||
1379 | |||
1380 | /* ---------------------------- */ |
||
1381 | |||
1382 | # ifdef WIN32 |
||
1383 | |||
1384 | # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__LCC__) |
||
1385 | /* MS C (VC), MinGW GCC port and LCC-32 use the MS C Runtime lib */ |
||
1386 | |||
1387 | /* 64-bit stat functions */ |
||
1388 | # define zstat _stati64 |
||
1389 | # define zfstat _fstati64 |
||
1390 | |||
1391 | /* 64-bit lseek */ |
||
1392 | # define zlseek _lseeki64 |
||
1393 | |||
1394 | # if defined(_MSC_VER) && (_MSC_VER >= 1400) |
||
1395 | /* Beginning with VS 8.0 (Visual Studio 2005, MSC 14), the Microsoft |
||
1396 | C rtl publishes its (previously internal) implmentations of |
||
1397 | "fseeko" and "ftello" for 64-bit file offsets. */ |
||
1398 | /* 64-bit fseeko */ |
||
1399 | # define zfseeko _fseeki64 |
||
1400 | /* 64-bit ftello */ |
||
1401 | # define zftello _ftelli64 |
||
1402 | |||
1403 | # else /* not (defined(_MSC_VER) && (_MSC_VER >= 1400)) */ |
||
1404 | |||
1405 | # if defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ >= 0x800) |
||
1406 | /* Up-to-date versions of MinGW define the macro __MSVCRT_VERSION__ |
||
1407 | to denote the version of the MS C rtl dll used for linking. When |
||
1408 | configured to link against the runtime of MS Visual Studio 8 (or |
||
1409 | newer), the built-in 64-bit fseek/ftell functions are available. */ |
||
1410 | /* 64-bit fseeko */ |
||
1411 | # define zfseeko _fseeki64 |
||
1412 | /* 64-bit ftello */ |
||
1413 | # define zftello _ftelli64 |
||
1414 | |||
1415 | # else /* !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__>=0x800)) */ |
||
1416 | /* The version of the C runtime is lower than MSC 14 or unknown. */ |
||
1417 | |||
1418 | /* The newest MinGW port contains built-in extensions to the MSC rtl |
||
1419 | that provide fseeko and ftello, but our implementations will do |
||
1420 | for now. */ |
||
1421 | /* 64-bit fseeko */ |
||
1422 | int zfseeko OF((FILE *, zoff_t, int)); |
||
1423 | |||
1424 | /* 64-bit ftello */ |
||
1425 | zoff_t zftello OF((FILE *)); |
||
1426 | |||
1427 | # endif /* ? (__MSVCRT_VERSION__ >= 0x800) */ |
||
1428 | # endif /* ? (_MSC_VER >= 1400) */ |
||
1429 | |||
1430 | /* 64-bit fopen */ |
||
1431 | # define zfopen fopen |
||
1432 | # define zfdopen fdopen |
||
1433 | |||
1434 | # endif /* _MSC_VER || __MINGW__ || __LCC__ */ |
||
1435 | |||
1436 | # ifdef __CYGWIN__ |
||
1437 | /* CYGWIN GCC Posix emulator on Windows |
||
1438 | (configuration not yet finished/tested) */ |
||
1439 | |||
1440 | /* 64-bit stat functions */ |
||
1441 | # define zstat _stati64 |
||
1442 | # define zfstat _fstati64 |
||
1443 | |||
1444 | /* 64-bit lseek */ |
||
1445 | # define zlseek _lseeki64 |
||
1446 | |||
1447 | /* 64-bit fseeko */ |
||
1448 | # define zfseeko fseeko |
||
1449 | |||
1450 | /* 64-bit ftello */ |
||
1451 | # define zftello ftello |
||
1452 | |||
1453 | /* 64-bit fopen */ |
||
1454 | # define zfopen fopen |
||
1455 | # define zfdopen fdopen |
||
1456 | |||
1457 | # endif |
||
1458 | # if defined(__WATCOMC__) || defined(__BORLANDC__) |
||
1459 | /* WATCOM C and Borland C provide their own C runtime libraries, |
||
1460 | but they are sufficiently compatible with MS CRTL. */ |
||
1461 | |||
1462 | /* 64-bit stat functions */ |
||
1463 | # define zstat _stati64 |
||
1464 | # define zfstat _fstati64 |
||
1465 | |||
1466 | # ifdef __WATCOMC__ |
||
1467 | /* 64-bit lseek */ |
||
1468 | # define zlseek _lseeki64 |
||
1469 | # endif |
||
1470 | |||
1471 | /* 64-bit fseeko */ |
||
1472 | int zfseeko OF((FILE *, zoff_t, int)); |
||
1473 | |||
1474 | /* 64-bit ftello */ |
||
1475 | zoff_t zftello OF((FILE *)); |
||
1476 | |||
1477 | /* 64-bit fopen */ |
||
1478 | # define zfopen fopen |
||
1479 | # define zfdopen fdopen |
||
1480 | |||
1481 | # endif |
||
1482 | # ifdef __IBMC__ |
||
1483 | /* IBM C */ |
||
1484 | |||
1485 | /* 64-bit stat functions */ |
||
1486 | |||
1487 | /* 64-bit fseeko */ |
||
1488 | |||
1489 | /* 64-bit ftello */ |
||
1490 | |||
1491 | /* 64-bit fopen */ |
||
1492 | |||
1493 | # endif |
||
1494 | |||
1495 | # endif /* WIN32 */ |
||
1496 | |||
1497 | #else |
||
1498 | /* No Large File Support */ |
||
1499 | |||
1500 | # ifndef REGULUS /* returns the inode number on success(!)...argh argh argh */ |
||
1501 | # define zstat stat |
||
1502 | # endif |
||
1503 | # define zfstat fstat |
||
1504 | # define zlseek lseek |
||
1505 | # define zfseeko fseek |
||
1506 | # define zftello ftell |
||
1507 | # define zfopen fopen |
||
1508 | # define zfdopen fdopen |
||
1509 | |||
1510 | # if defined(UNIX) || defined(VMS) || defined(WIN32) |
||
1511 | /* For these systems, implement "64bit file vs. 32bit prog" check */ |
||
1512 | # ifndef DO_SAFECHECK_2GB |
||
1513 | # define DO_SAFECHECK_2GB |
||
1514 | # endif |
||
1515 | # endif |
||
1516 | |||
1517 | #endif |
||
1518 | |||
1519 | /* No "64bit file vs. 32bit prog" check for SFX stub, to save space */ |
||
1520 | #if (defined(DO_SAFECHECK_2GB) && defined(SFX)) |
||
1521 | # undef DO_SAFECHECK_2GB |
||
1522 | #endif |
||
1523 | |||
1524 | #ifndef SSTAT |
||
1525 | # ifdef WILD_STAT_BUG |
||
1526 | # define SSTAT(path,pbuf) (iswild(path) || zstat(path,pbuf)) |
||
1527 | # else |
||
1528 | # define SSTAT zstat |
||
1529 | # endif |
||
1530 | #endif |
||
1531 | |||
1532 | |||
1533 | /* Default fzofft() format selection. */ |
||
1534 | |||
1535 | #ifndef FZOFFT_FMT |
||
1536 | |||
1537 | # ifdef LARGE_FILE_SUPPORT |
||
1538 | # define FZOFFT_FMT "ll" |
||
1539 | # define FZOFFT_HEX_WID_VALUE "16" |
||
1540 | # else /* def LARGE_FILE_SUPPORT */ |
||
1541 | # define FZOFFT_FMT "l" |
||
1542 | # define FZOFFT_HEX_WID_VALUE "8" |
||
1543 | # endif /* def LARGE_FILE_SUPPORT */ |
||
1544 | |||
1545 | #endif /* ndef FZOFFT_FMT */ |
||
1546 | |||
1547 | #define FZOFFT_HEX_WID ((char *) -1) |
||
1548 | #define FZOFFT_HEX_DOT_WID ((char *) -2) |
||
1549 | |||
1550 | #define FZOFFT_NUM 4 /* Number of chambers. */ |
||
1551 | #define FZOFFT_LEN 24 /* Number of characters/chamber. */ |
||
1552 | |||
1553 | |||
1554 | #ifdef SHORT_SYMS /* Mark Williams C, ...? */ |
||
1555 | # define extract_or_test_files xtr_or_tst_files |
||
1556 | # define extract_or_test_member xtr_or_tst_member |
||
1557 | #endif |
||
1558 | |||
1559 | #ifdef REALLY_SHORT_SYMS /* TOPS-20 linker: first 6 chars */ |
||
1560 | # define process_cdir_file_hdr XXpcdfh |
||
1561 | # define process_local_file_hdr XXplfh |
||
1562 | # define extract_or_test_files XXxotf /* necessary? */ |
||
1563 | # define extract_or_test_member XXxotm /* necessary? */ |
||
1564 | # define check_for_newer XXcfn |
||
1565 | # define overwrite_all XXoa |
||
1566 | # define process_all_files XXpaf |
||
1567 | # define extra_field XXef |
||
1568 | # define explode_lit8 XXel8 |
||
1569 | # define explode_lit4 XXel4 |
||
1570 | # define explode_nolit8 XXnl8 |
||
1571 | # define explode_nolit4 XXnl4 |
||
1572 | # define cpdist8 XXcpdist8 |
||
1573 | # define inflate_codes XXic |
||
1574 | # define inflate_stored XXis |
||
1575 | # define inflate_fixed XXif |
||
1576 | # define inflate_dynamic XXid |
||
1577 | # define inflate_block XXib |
||
1578 | # define maxcodemax XXmax |
||
1579 | #endif |
||
1580 | |||
1581 | #ifndef S_TIME_T_MAX /* max value of signed (>= 32-bit) time_t */ |
||
1582 | # define S_TIME_T_MAX ((time_t)(ulg)0x7fffffffL) |
||
1583 | #endif |
||
1584 | #ifndef U_TIME_T_MAX /* max value of unsigned (>= 32-bit) time_t */ |
||
1585 | # define U_TIME_T_MAX ((time_t)(ulg)0xffffffffL) |
||
1586 | #endif |
||
1587 | #ifdef DOSTIME_MINIMUM /* min DOSTIME value (1980-01-01) */ |
||
1588 | # undef DOSTIME_MINIMUM |
||
1589 | #endif |
||
1590 | #define DOSTIME_MINIMUM ((ulg)0x00210000L) |
||
1591 | #ifdef DOSTIME_2038_01_18 /* approximate DOSTIME equivalent of */ |
||
1592 | # undef DOSTIME_2038_01_18 /* the signed-32-bit time_t limit */ |
||
1593 | #endif |
||
1594 | #define DOSTIME_2038_01_18 ((ulg)0x74320000L) |
||
1595 | |||
1596 | #ifdef QDOS |
||
1597 | # define ZSUFX "_zip" |
||
1598 | # define ALT_ZSUFX ".zip" |
||
1599 | #else |
||
1600 | # ifdef RISCOS |
||
1601 | # define ZSUFX "/zip" |
||
1602 | # else |
||
1603 | # define ZSUFX ".zip" |
||
1604 | # endif |
||
1605 | # define ALT_ZSUFX ".ZIP" /* Unix-only so far (only case-sensitive fs) */ |
||
1606 | #endif |
||
1607 | |||
1608 | #define CENTRAL_HDR_SIG "\001\002" /* the infamous "PK" signature bytes, */ |
||
1609 | #define LOCAL_HDR_SIG "\003\004" /* w/o "PK" (so unzip executable not */ |
||
1610 | #define END_CENTRAL_SIG "\005\006" /* mistaken for zipfile itself) */ |
||
1611 | #define EXTD_LOCAL_SIG "\007\010" /* [ASCII "\113" == EBCDIC "\080" ??] */ |
||
1612 | |||
1613 | /** internal-only return codes **/ |
||
1614 | #define IZ_DIR 76 /* potential zipfile is a directory */ |
||
1615 | /* special return codes for mapname() */ |
||
1616 | #define MPN_OK 0 /* mapname successful */ |
||
1617 | #define MPN_INF_TRUNC (1<<8) /* caution - filename truncated */ |
||
1618 | #define MPN_INF_SKIP (2<<8) /* info - skipped because nothing to do */ |
||
1619 | #define MPN_ERR_SKIP (3<<8) /* error - entry skipped */ |
||
1620 | #define MPN_ERR_TOOLONG (4<<8) /* error - path too long */ |
||
1621 | #define MPN_NOMEM (10<<8) /* error - out of memory, file skipped */ |
||
1622 | #define MPN_CREATED_DIR (16<<8) /* directory created: set time & permission */ |
||
1623 | #define MPN_VOL_LABEL (17<<8) /* volume label, but can't set on hard disk */ |
||
1624 | #define MPN_INVALID (99<<8) /* internal logic error, should never reach */ |
||
1625 | /* mask for internal mapname&checkdir return codes */ |
||
1626 | #define MPN_MASK 0x7F00 |
||
1627 | /* error code for extracting/testing extra field blocks */ |
||
1628 | #define IZ_EF_TRUNC 79 /* local extra field truncated (PKZIP'd) */ |
||
1629 | |||
1630 | /* choice of activities for do_string() */ |
||
1631 | #define SKIP 0 /* skip header block */ |
||
1632 | #define DISPLAY 1 /* display archive comment (ASCII) */ |
||
1633 | #define DISPL_8 5 /* display file comment (ext. ASCII) */ |
||
1634 | #define DS_FN 2 /* read filename (ext. ASCII, chead) */ |
||
1635 | #define DS_FN_C 2 /* read filename from central header */ |
||
1636 | #define DS_FN_L 6 /* read filename from local header */ |
||
1637 | #define EXTRA_FIELD 3 /* copy extra field into buffer */ |
||
1638 | #define DS_EF 3 |
||
1639 | #ifdef AMIGA |
||
1640 | # define FILENOTE 4 /* convert file comment to filenote */ |
||
1641 | #endif |
||
1642 | #if (defined(SFX) && defined(CHEAP_SFX_AUTORUN)) |
||
1643 | # define CHECK_AUTORUN 7 /* copy command, display remainder */ |
||
1644 | # define CHECK_AUTORUN_Q 8 /* copy command, skip remainder */ |
||
1645 | #endif |
||
1646 | |||
1647 | #define DOES_NOT_EXIST -1 /* return values for check_for_newer() */ |
||
1648 | #define EXISTS_AND_OLDER 0 |
||
1649 | #define EXISTS_AND_NEWER 1 |
||
1650 | |||
1651 | #define OVERWRT_QUERY 0 /* status values for G.overwrite_mode */ |
||
1652 | #define OVERWRT_ALWAYS 1 |
||
1653 | #define OVERWRT_NEVER 2 |
||
1654 | |||
1655 | #define IS_OVERWRT_ALL (G.overwrite_mode == OVERWRT_ALWAYS) |
||
1656 | #define IS_OVERWRT_NONE (G.overwrite_mode == OVERWRT_NEVER) |
||
1657 | |||
1658 | #ifdef VMS |
||
1659 | /* return codes for VMS-specific open_outfile() function */ |
||
1660 | # define OPENOUT_OK 0 /* file openend normally */ |
||
1661 | # define OPENOUT_FAILED 1 /* file open failed */ |
||
1662 | # define OPENOUT_SKIPOK 2 /* file not opened, skip at error level OK */ |
||
1663 | # define OPENOUT_SKIPWARN 3 /* file not opened, skip at error level WARN */ |
||
1664 | #endif /* VMS */ |
||
1665 | |||
1666 | #define ROOT 0 /* checkdir() extract-to path: called once */ |
||
1667 | #define INIT 1 /* allocate buildpath: called once per member */ |
||
1668 | #define APPEND_DIR 2 /* append a dir comp.: many times per member */ |
||
1669 | #define APPEND_NAME 3 /* append actual filename: once per member */ |
||
1670 | #define GETPATH 4 /* retrieve the complete path and free it */ |
||
1671 | #define END 5 /* free root path prior to exiting program */ |
||
1672 | |||
1673 | /* version_made_by codes (central dir): make sure these */ |
||
1674 | /* are not defined on their respective systems!! */ |
||
1675 | #define FS_FAT_ 0 /* filesystem used by MS-DOS, OS/2, Win32 */ |
||
1676 | #define AMIGA_ 1 |
||
1677 | #define VMS_ 2 |
||
1678 | #define UNIX_ 3 |
||
1679 | #define VM_CMS_ 4 |
||
1680 | #define ATARI_ 5 /* what if it's a minix filesystem? [cjh] */ |
||
1681 | #define FS_HPFS_ 6 /* filesystem used by OS/2 (and NT 3.x) */ |
||
1682 | #define MAC_ 7 /* HFS filesystem used by MacOS */ |
||
1683 | #define Z_SYSTEM_ 8 |
||
1684 | #define CPM_ 9 |
||
1685 | #define TOPS20_ 10 |
||
1686 | #define FS_NTFS_ 11 /* filesystem used by Windows NT */ |
||
1687 | #define QDOS_ 12 |
||
1688 | #define ACORN_ 13 /* Archimedes Acorn RISC OS */ |
||
1689 | #define FS_VFAT_ 14 /* filesystem used by Windows 95, NT */ |
||
1690 | #define MVS_ 15 |
||
1691 | #define BEOS_ 16 /* hybrid POSIX/database filesystem */ |
||
1692 | #define TANDEM_ 17 /* Tandem NSK */ |
||
1693 | #define THEOS_ 18 /* THEOS */ |
||
1694 | #define MAC_OSX_ 19 /* Mac OS/X (Darwin) */ |
||
1695 | #define ATHEOS_ 30 /* AtheOS */ |
||
1696 | #define NUM_HOSTS 31 /* index of last system + 1 */ |
||
1697 | /* don't forget to update zipinfo.c appropiately if NUM_HOSTS changes! */ |
||
1698 | |||
1699 | #define STORED 0 /* compression methods */ |
||
1700 | #define SHRUNK 1 |
||
1701 | #define REDUCED1 2 |
||
1702 | #define REDUCED2 3 |
||
1703 | #define REDUCED3 4 |
||
1704 | #define REDUCED4 5 |
||
1705 | #define IMPLODED 6 |
||
1706 | #define TOKENIZED 7 |
||
1707 | #define DEFLATED 8 |
||
1708 | #define ENHDEFLATED 9 |
||
1709 | #define DCLIMPLODED 10 |
||
1710 | #define BZIPPED 12 |
||
1711 | #define LZMAED 14 |
||
1712 | #define IBMTERSED 18 |
||
1713 | #define IBMLZ77ED 19 |
||
1714 | #define WAVPACKED 97 |
||
1715 | #define PPMDED 98 |
||
1716 | #define NUM_METHODS 17 /* number of known method IDs */ |
||
1717 | /* don't forget to update list.c (list_files()), extract.c and zipinfo.c |
||
1718 | * appropriately if NUM_METHODS changes */ |
||
1719 | |||
1720 | /* (the PK-class error codes are public and have been moved into unzip.h) */ |
||
1721 | |||
1722 | #define DF_MDY 0 /* date format 10/26/91 (USA only) */ |
||
1723 | #define DF_DMY 1 /* date format 26/10/91 (most of the world) */ |
||
1724 | #define DF_YMD 2 /* date format 91/10/26 (a few countries) */ |
||
1725 | |||
1726 | /*--------------------------------------------------------------------------- |
||
1727 | Extra-field block ID values and offset info. |
||
1728 | ---------------------------------------------------------------------------*/ |
||
1729 | /* extra-field ID values, all little-endian: */ |
||
1730 | #define EF_PKSZ64 0x0001 /* PKWARE's 64-bit filesize extensions */ |
||
1731 | #define EF_AV 0x0007 /* PKWARE's authenticity verification */ |
||
1732 | #define EF_EFS 0x0008 /* PKWARE's extended language encoding */ |
||
1733 | #define EF_OS2 0x0009 /* OS/2 extended attributes */ |
||
1734 | #define EF_PKW32 0x000a /* PKWARE's Win95/98/WinNT filetimes */ |
||
1735 | #define EF_PKVMS 0x000c /* PKWARE's VMS */ |
||
1736 | #define EF_PKUNIX 0x000d /* PKWARE's Unix */ |
||
1737 | #define EF_PKFORK 0x000e /* PKWARE's future stream/fork descriptors */ |
||
1738 | #define EF_PKPATCH 0x000f /* PKWARE's patch descriptor */ |
||
1739 | #define EF_PKPKCS7 0x0014 /* PKWARE's PKCS#7 store for X.509 Certs */ |
||
1740 | #define EF_PKFX509 0x0015 /* PKWARE's file X.509 Cert&Signature ID */ |
||
1741 | #define EF_PKCX509 0x0016 /* PKWARE's central dir X.509 Cert ID */ |
||
1742 | #define EF_PKENCRHD 0x0017 /* PKWARE's Strong Encryption header */ |
||
1743 | #define EF_PKRMCTL 0x0018 /* PKWARE's Record Management Controls*/ |
||
1744 | #define EF_PKLSTCS7 0x0019 /* PKWARE's PKCS#7 Encr. Recipient Cert List */ |
||
1745 | #define EF_PKIBM 0x0065 /* PKWARE's IBM S/390 & AS/400 attributes */ |
||
1746 | #define EF_PKIBM2 0x0066 /* PKWARE's IBM S/390 & AS/400 compr. attribs */ |
||
1747 | #define EF_IZVMS 0x4d49 /* Info-ZIP's VMS ("IM") */ |
||
1748 | #define EF_IZUNIX 0x5855 /* Info-ZIP's first Unix[1] ("UX") */ |
||
1749 | #define EF_IZUNIX2 0x7855 /* Info-ZIP's second Unix[2] ("Ux") */ |
||
1750 | #define EF_IZUNIX3 0x7875 /* Info-ZIP's newest Unix[3] ("ux") */ |
||
1751 | #define EF_TIME 0x5455 /* universal timestamp ("UT") */ |
||
1752 | #define EF_UNIPATH 0x7075 /* Info-ZIP Unicode Path ("up") */ |
||
1753 | #define EF_UNICOMNT 0x6375 /* Info-ZIP Unicode Comment ("uc") */ |
||
1754 | #define EF_MAC3 0x334d /* Info-ZIP's new Macintosh (= "M3") */ |
||
1755 | #define EF_JLMAC 0x07c8 /* Johnny Lee's old Macintosh (= 1992) */ |
||
1756 | #define EF_ZIPIT 0x2605 /* Thomas Brown's Macintosh (ZipIt) */ |
||
1757 | #define EF_ZIPIT2 0x2705 /* T. Brown's Mac (ZipIt) v 1.3.8 and newer ? */ |
||
1758 | #define EF_SMARTZIP 0x4d63 /* Mac SmartZip by Marco Bambini */ |
||
1759 | #define EF_VMCMS 0x4704 /* Info-ZIP's VM/CMS ("\004G") */ |
||
1760 | #define EF_MVS 0x470f /* Info-ZIP's MVS ("\017G") */ |
||
1761 | #define EF_ACL 0x4c41 /* (OS/2) access control list ("AL") */ |
||
1762 | #define EF_NTSD 0x4453 /* NT security descriptor ("SD") */ |
||
1763 | #define EF_ATHEOS 0x7441 /* AtheOS ("At") */ |
||
1764 | #define EF_BEOS 0x6542 /* BeOS ("Be") */ |
||
1765 | #define EF_QDOS 0xfb4a /* SMS/QDOS ("J\373") */ |
||
1766 | #define EF_AOSVS 0x5356 /* AOS/VS ("VS") */ |
||
1767 | #define EF_SPARK 0x4341 /* David Pilling's Acorn/SparkFS ("AC") */ |
||
1768 | #define EF_TANDEM 0x4154 /* Tandem NSK ("TA") */ |
||
1769 | #define EF_THEOS 0x6854 /* Jean-Michel Dubois' Theos "Th" */ |
||
1770 | #define EF_THEOSO 0x4854 /* old Theos port */ |
||
1771 | #define EF_MD5 0x4b46 /* Fred Kantor's MD5 ("FK") */ |
||
1772 | #define EF_ASIUNIX 0x756e /* ASi's Unix ("nu") */ |
||
1773 | |||
1774 | #define EB_HEADSIZE 4 /* length of extra field block header */ |
||
1775 | #define EB_ID 0 /* offset of block ID in header */ |
||
1776 | #define EB_LEN 2 /* offset of data length field in header */ |
||
1777 | #define EB_UCSIZE_P 0 /* offset of ucsize field in compr. data */ |
||
1778 | #define EB_CMPRHEADLEN 6 /* lenght of compression header */ |
||
1779 | |||
1780 | #define EB_UX_MINLEN 8 /* minimal "UX" field contains atime, mtime */ |
||
1781 | #define EB_UX_FULLSIZE 12 /* full "UX" field (atime, mtime, uid, gid) */ |
||
1782 | #define EB_UX_ATIME 0 /* offset of atime in "UX" extra field data */ |
||
1783 | #define EB_UX_MTIME 4 /* offset of mtime in "UX" extra field data */ |
||
1784 | #define EB_UX_UID 8 /* byte offset of UID in "UX" field data */ |
||
1785 | #define EB_UX_GID 10 /* byte offset of GID in "UX" field data */ |
||
1786 | |||
1787 | #define EB_UX2_MINLEN 4 /* minimal "Ux" field contains UID/GID */ |
||
1788 | #define EB_UX2_UID 0 /* byte offset of UID in "Ux" field data */ |
||
1789 | #define EB_UX2_GID 2 /* byte offset of GID in "Ux" field data */ |
||
1790 | #define EB_UX2_VALID (1 << 8) /* UID/GID present */ |
||
1791 | |||
1792 | #define EB_UX3_MINLEN 7 /* minimal "ux" field size (2-byte UID/GID) */ |
||
1793 | |||
1794 | #define EB_UT_MINLEN 1 /* minimal UT field contains Flags byte */ |
||
1795 | #define EB_UT_FLAGS 0 /* byte offset of Flags field */ |
||
1796 | #define EB_UT_TIME1 1 /* byte offset of 1st time value */ |
||
1797 | #define EB_UT_FL_MTIME (1 << 0) /* mtime present */ |
||
1798 | #define EB_UT_FL_ATIME (1 << 1) /* atime present */ |
||
1799 | #define EB_UT_FL_CTIME (1 << 2) /* ctime present */ |
||
1800 | |||
1801 | #define EB_FLGS_OFFS 4 /* offset of flags area in generic compressed |
||
1802 | extra field blocks (BEOS, MAC, and others) */ |
||
1803 | #define EB_OS2_HLEN 4 /* size of OS2/ACL compressed data header */ |
||
1804 | #define EB_BEOS_HLEN 5 /* length of BeOS&AtheOS e.f attribute header */ |
||
1805 | #define EB_BE_FL_UNCMPR 0x01 /* "BeOS&AtheOS attribs uncompr." bit flag */ |
||
1806 | #define EB_MAC3_HLEN 14 /* length of Mac3 attribute block header */ |
||
1807 | #define EB_SMARTZIP_HLEN 64 /* fixed length of the SmartZip extra field */ |
||
1808 | #define EB_M3_FL_DATFRK 0x01 /* "this entry is data fork" flag */ |
||
1809 | #define EB_M3_FL_UNCMPR 0x04 /* "Mac3 attributes uncompressed" bit flag */ |
||
1810 | #define EB_M3_FL_TIME64 0x08 /* "Mac3 time fields are 64 bit wide" flag */ |
||
1811 | #define EB_M3_FL_NOUTC 0x10 /* "Mac3 timezone offset fields missing" flag */ |
||
1812 | |||
1813 | #define EB_NTSD_C_LEN 4 /* length of central NT security data */ |
||
1814 | #define EB_NTSD_L_LEN 5 /* length of minimal local NT security data */ |
||
1815 | #define EB_NTSD_VERSION 4 /* offset of NTSD version byte */ |
||
1816 | #define EB_NTSD_MAX_VER (0) /* maximum version # we know how to handle */ |
||
1817 | |||
1818 | #define EB_ASI_CRC32 0 /* offset of ASI Unix field's crc32 checksum */ |
||
1819 | #define EB_ASI_MODE 4 /* offset of ASI Unix permission mode field */ |
||
1820 | |||
1821 | #define EB_IZVMS_HLEN 12 /* length of IZVMS attribute block header */ |
||
1822 | #define EB_IZVMS_FLGS 4 /* offset of compression type flag */ |
||
1823 | #define EB_IZVMS_UCSIZ 6 /* offset of ucsize field in IZVMS header */ |
||
1824 | #define EB_IZVMS_BCMASK 07 /* 3 bits for compression type */ |
||
1825 | #define EB_IZVMS_BCSTOR 0 /* Stored */ |
||
1826 | #define EB_IZVMS_BC00 1 /* 0byte -> 0bit compression */ |
||
1827 | #define EB_IZVMS_BCDEFL 2 /* Deflated */ |
||
1828 | |||
1829 | |||
1830 | /*--------------------------------------------------------------------------- |
||
1831 | True sizes of the various headers (excluding their 4-byte signatures), |
||
1832 | as defined by PKWARE--so it is not likely that these will ever change. |
||
1833 | But if they do, make sure both these defines AND the typedefs below get |
||
1834 | updated accordingly. |
||
1835 | |||
1836 | 12/27/2006 |
||
1837 | The Zip64 End Of Central Directory record is variable size and now |
||
1838 | comes in two flavors, version 1 and the new version 2 that supports |
||
1839 | central directory encryption. We only use the old fields at the |
||
1840 | top of the Zip64 EOCDR, and this block is a fixed size still, but |
||
1841 | need to be aware of the stuff following. |
||
1842 | ---------------------------------------------------------------------------*/ |
||
1843 | #define LREC_SIZE 26 /* lengths of local file headers, central */ |
||
1844 | #define CREC_SIZE 42 /* directory headers, end-of-central-dir */ |
||
1845 | #define ECREC_SIZE 18 /* record, zip64 end-of-cent-dir locator */ |
||
1846 | #define ECLOC64_SIZE 16 /* and zip64 end-of-central-dir record, */ |
||
1847 | #define ECREC64_SIZE 52 /* respectively */ |
||
1848 | |||
1849 | #define MAX_BITS 13 /* used in unshrink() */ |
||
1850 | #define HSIZE (1 << MAX_BITS) /* size of global work area */ |
||
1851 | |||
1852 | #define LF 10 /* '\n' on ASCII machines; must be 10 due to EBCDIC */ |
||
1853 | #define CR 13 /* '\r' on ASCII machines; must be 13 due to EBCDIC */ |
||
1854 | #define CTRLZ 26 /* DOS & OS/2 EOF marker (used in fileio.c, vms.c) */ |
||
1855 | |||
1856 | #ifdef EBCDIC |
||
1857 | # define foreign(c) ascii[(uch)(c)] |
||
1858 | # define native(c) ebcdic[(uch)(c)] |
||
1859 | # define NATIVE "EBCDIC" |
||
1860 | # define NOANSIFILT |
||
1861 | #endif |
||
1862 | |||
1863 | #ifdef VMS |
||
1864 | # define ENV_UNZIP "UNZIP_OPTS" /* names of environment variables */ |
||
1865 | # define ENV_ZIPINFO "ZIPINFO_OPTS" |
||
1866 | #endif /* VMS */ |
||
1867 | #ifdef RISCOS |
||
1868 | # define ENV_UNZIP "Unzip$Options" |
||
1869 | # define ENV_ZIPINFO "Zipinfo$Options" |
||
1870 | # define ENV_UNZIPEXTS "Unzip$Exts" |
||
1871 | #endif /* RISCOS */ |
||
1872 | #ifndef ENV_UNZIP |
||
1873 | # define ENV_UNZIP "UNZIP" /* the standard names */ |
||
1874 | # define ENV_ZIPINFO "ZIPINFO" |
||
1875 | #endif |
||
1876 | #define ENV_UNZIP2 "UNZIPOPT" /* alternate names, for zip compat. */ |
||
1877 | #define ENV_ZIPINFO2 "ZIPINFOOPT" |
||
1878 | |||
1879 | #if (!defined(QQ) && !defined(NOQQ)) |
||
1880 | # define QQ |
||
1881 | #endif |
||
1882 | |||
1883 | #ifdef QQ /* Newtware version: no file */ |
||
1884 | # define QCOND (!uO.qflag) /* comments with -vq or -vqq */ |
||
1885 | #else /* Bill Davidsen version: no way to */ |
||
1886 | # define QCOND (longhdr) /* kill file comments when listing */ |
||
1887 | #endif |
||
1888 | |||
1889 | #ifdef OLD_QQ |
||
1890 | # define QCOND2 (uO.qflag < 2) |
||
1891 | #else |
||
1892 | # define QCOND2 (!uO.qflag) |
||
1893 | #endif |
||
1894 | |||
1895 | #ifdef WILD_STOP_AT_DIR |
||
1896 | # define __WDLPRO , int sepc |
||
1897 | # define __WDL , sepc |
||
1898 | # define __WDLDEF int sepc; |
||
1899 | # define WISEP , (uO.W_flag ? '/' : '\0') |
||
1900 | #else |
||
1901 | # define __WDLPRO |
||
1902 | # define __WDL |
||
1903 | # define __WDLDEF |
||
1904 | # define WISEP |
||
1905 | #endif |
||
1906 | |||
1907 | |||
1908 | |||
1909 | |||
1910 | /**************/ |
||
1911 | /* Typedefs */ |
||
1912 | /**************/ |
||
1913 | |||
1914 | #ifdef ZIP64_SUPPORT |
||
1915 | # ifndef Z_UINT8_DEFINED |
||
1916 | # if (defined(__GNUC__) || defined(__hpux) || defined(__SUNPRO_C)) |
||
1917 | typedef unsigned long long z_uint8; |
||
1918 | # else |
||
1919 | typedef unsigned __int64 z_uint8; |
||
1920 | # endif |
||
1921 | # define Z_UINT8_DEFINED |
||
1922 | # endif |
||
1923 | #endif |
||
1924 | #ifndef Z_UINT4_DEFINED |
||
1925 | # if (defined(MODERN) && !defined(NO_LIMITS_H)) |
||
1926 | # if (defined(UINT_MAX) && (UINT_MAX == 0xffffffffUL)) |
||
1927 | typedef unsigned int z_uint4; |
||
1928 | # define Z_UINT4_DEFINED |
||
1929 | # else |
||
1930 | # if (defined(ULONG_MAX) && (ULONG_MAX == 0xffffffffUL)) |
||
1931 | typedef unsigned long z_uint4; |
||
1932 | # define Z_UINT4_DEFINED |
||
1933 | # else |
||
1934 | # if (defined(USHRT_MAX) && (USHRT_MAX == 0xffffffffUL)) |
||
1935 | typedef unsigned short z_uint4; |
||
1936 | # define Z_UINT4_DEFINED |
||
1937 | # endif |
||
1938 | # endif |
||
1939 | # endif |
||
1940 | # endif /* MODERN && !NO_LIMITS_H */ |
||
1941 | #endif /* !Z_UINT4_DEFINED */ |
||
1942 | #ifndef Z_UINT4_DEFINED |
||
1943 | typedef ulg z_uint4; |
||
1944 | # define Z_UINT4_DEFINED |
||
1945 | #endif |
||
1946 | |||
1947 | /* The following three user-defined unsigned integer types are used for |
||
1948 | holding zipfile entities (required widths without / with Zip64 support): |
||
1949 | a) sizes and offset of zipfile entries |
||
1950 | (4 bytes / 8 bytes) |
||
1951 | b) enumeration and counts of zipfile entries |
||
1952 | (2 bytes / 8 bytes) |
||
1953 | Remark: internally, we use 4 bytes for archive member counting in the |
||
1954 | No-Zip64 case, because UnZip supports more than 64k entries for |
||
1955 | classic Zip archives without Zip64 extensions. |
||
1956 | c) enumeration and counts of zipfile volumes of multivolume archives |
||
1957 | (2 bytes / 4 bytes) |
||
1958 | */ |
||
1959 | #ifdef ZIP64_SUPPORT |
||
1960 | typedef z_uint8 zusz_t; /* zipentry sizes & offsets */ |
||
1961 | typedef z_uint8 zucn_t; /* archive entry counts */ |
||
1962 | typedef z_uint4 zuvl_t; /* multivolume numbers */ |
||
1963 | # define MASK_ZUCN64 (~(zucn_t)0) |
||
1964 | /* In case we ever get to support an environment where z_uint8 may be WIDER |
||
1965 | than 64 bit wide, we will have to apply a construct similar to |
||
1966 | #define MASK_ZUCN64 (~(zucn_t)0 & (zucn_t)0xffffffffffffffffULL) |
||
1967 | for the 64-bit mask. |
||
1968 | */ |
||
1969 | #else |
||
1970 | typedef ulg zusz_t; /* zipentry sizes & offsets */ |
||
1971 | typedef unsigned int zucn_t; /* archive entry counts */ |
||
1972 | typedef unsigned short zuvl_t; /* multivolume numbers */ |
||
1973 | # define MASK_ZUCN64 (~(zucn_t)0) |
||
1974 | #endif |
||
1975 | #define MASK_ZUCN16 ((zucn_t)0xFFFF) |
||
1976 | |||
1977 | #ifdef NO_UID_GID |
||
1978 | # ifdef UID_USHORT |
||
1979 | typedef unsigned short uid_t; /* TI SysV.3 */ |
||
1980 | typedef unsigned short gid_t; |
||
1981 | # else |
||
1982 | typedef unsigned int uid_t; /* SCO Xenix */ |
||
1983 | typedef unsigned int gid_t; |
||
1984 | # endif |
||
1985 | #endif |
||
1986 | |||
1987 | #if (defined(GOT_UTIMBUF) || defined(sgi) || defined(ATARI)) |
||
1988 | typedef struct utimbuf ztimbuf; |
||
1989 | #else |
||
1990 | typedef struct ztimbuf { |
||
1991 | time_t actime; /* new access time */ |
||
1992 | time_t modtime; /* new modification time */ |
||
1993 | } ztimbuf; |
||
1994 | #endif |
||
1995 | |||
1996 | typedef struct iztimes { |
||
1997 | time_t atime; /* new access time */ |
||
1998 | time_t mtime; /* new modification time */ |
||
1999 | time_t ctime; /* used for creation time; NOT same as st_ctime */ |
||
2000 | } iztimes; |
||
2001 | |||
2002 | #ifdef SET_DIR_ATTRIB |
||
2003 | typedef struct direntry { /* head of system-specific struct holding */ |
||
2004 | struct direntry *next; /* defered directory attributes info */ |
||
2005 | char *fn; /* filename of directory */ |
||
2006 | char buf[1]; /* start of system-specific internal data */ |
||
2007 | } direntry; |
||
2008 | #endif /* SET_DIR_ATTRIB */ |
||
2009 | |||
2010 | #ifdef SYMLINKS |
||
2011 | typedef struct slinkentry { /* info for deferred symlink creation */ |
||
2012 | struct slinkentry *next; /* pointer to next entry in chain */ |
||
2013 | extent targetlen; /* length of target filespec */ |
||
2014 | extent attriblen; /* length of system-specific attrib data */ |
||
2015 | char *target; /* pointer to target filespec */ |
||
2016 | char *fname; /* pointer to name of link */ |
||
2017 | char buf[1]; /* data/name/link buffer */ |
||
2018 | } slinkentry; |
||
2019 | #endif /* SYMLINKS */ |
||
2020 | |||
2021 | typedef struct min_info { |
||
2022 | zoff_t offset; |
||
2023 | zusz_t compr_size; /* compressed size (needed if extended header) */ |
||
2024 | zusz_t uncompr_size; /* uncompressed size (needed if extended header) */ |
||
2025 | ulg crc; /* crc (needed if extended header) */ |
||
2026 | zuvl_t diskstart; /* no of volume where this entry starts */ |
||
2027 | uch hostver; |
||
2028 | uch hostnum; |
||
2029 | unsigned file_attr; /* local flavor, as used by creat(), chmod()... */ |
||
2030 | unsigned encrypted : 1; /* file encrypted: decrypt before uncompressing */ |
||
2031 | unsigned ExtLocHdr : 1; /* use time instead of CRC for decrypt check */ |
||
2032 | unsigned textfile : 1; /* file is text (according to zip) */ |
||
2033 | unsigned textmode : 1; /* file is to be extracted as text */ |
||
2034 | unsigned lcflag : 1; /* convert filename to lowercase */ |
||
2035 | unsigned vollabel : 1; /* "file" is an MS-DOS volume (disk) label */ |
||
2036 | #ifdef SYMLINKS |
||
2037 | unsigned symlink : 1; /* file is a symbolic link */ |
||
2038 | #endif |
||
2039 | unsigned HasUxAtt : 1; /* crec ext_file_attr has Unix style mode bits */ |
||
2040 | #ifdef UNICODE_SUPPORT |
||
2041 | unsigned GPFIsUTF8: 1; /* crec gen_purpose_flag UTF-8 bit 11 is set */ |
||
2042 | #endif |
||
2043 | #ifndef SFX |
||
2044 | char Far *cfilname; /* central header version of filename */ |
||
2045 | #endif |
||
2046 | } min_info; |
||
2047 | |||
2048 | typedef struct VMStimbuf { |
||
2049 | char *revdate; /* (both roughly correspond to Unix modtime/st_mtime) */ |
||
2050 | char *credate; |
||
2051 | } VMStimbuf; |
||
2052 | |||
2053 | /*--------------------------------------------------------------------------- |
||
2054 | Zipfile work area declarations. |
||
2055 | ---------------------------------------------------------------------------*/ |
||
2056 | |||
2057 | #ifdef MALLOC_WORK |
||
2058 | union work { |
||
2059 | struct { /* unshrink(): */ |
||
2060 | shrint *Parent; /* pointer to (8192 * sizeof(shrint)) */ |
||
2061 | uch *value; /* pointer to 8KB char buffer */ |
||
2062 | uch *Stack; /* pointer to another 8KB char buffer */ |
||
2063 | } shrink; |
||
2064 | uch *Slide; /* explode(), inflate(), unreduce() */ |
||
2065 | }; |
||
2066 | #else /* !MALLOC_WORK */ |
||
2067 | union work { |
||
2068 | struct { /* unshrink(): */ |
||
2069 | shrint Parent[HSIZE]; /* (8192 * sizeof(shrint)) == 16KB minimum */ |
||
2070 | uch value[HSIZE]; /* 8KB */ |
||
2071 | uch Stack[HSIZE]; /* 8KB */ |
||
2072 | } shrink; /* total = 32KB minimum; 80KB on Cray/Alpha */ |
||
2073 | uch Slide[WSIZE]; /* explode(), inflate(), unreduce() */ |
||
2074 | }; |
||
2075 | #endif /* ?MALLOC_WORK */ |
||
2076 | |||
2077 | #define slide G.area.Slide |
||
2078 | |||
2079 | #if (defined(DLL) && !defined(NO_SLIDE_REDIR)) |
||
2080 | # define redirSlide G.redirect_sldptr |
||
2081 | #else |
||
2082 | # define redirSlide G.area.Slide |
||
2083 | #endif |
||
2084 | |||
2085 | /*--------------------------------------------------------------------------- |
||
2086 | Zipfile layout declarations. If these headers ever change, make sure the |
||
2087 | xxREC_SIZE defines (above) change with them! |
||
2088 | ---------------------------------------------------------------------------*/ |
||
2089 | |||
2090 | typedef uch local_byte_hdr[ LREC_SIZE ]; |
||
2091 | # define L_VERSION_NEEDED_TO_EXTRACT_0 0 |
||
2092 | # define L_VERSION_NEEDED_TO_EXTRACT_1 1 |
||
2093 | # define L_GENERAL_PURPOSE_BIT_FLAG 2 |
||
2094 | # define L_COMPRESSION_METHOD 4 |
||
2095 | # define L_LAST_MOD_DOS_DATETIME 6 |
||
2096 | # define L_CRC32 10 |
||
2097 | # define L_COMPRESSED_SIZE 14 |
||
2098 | # define L_UNCOMPRESSED_SIZE 18 |
||
2099 | # define L_FILENAME_LENGTH 22 |
||
2100 | # define L_EXTRA_FIELD_LENGTH 24 |
||
2101 | |||
2102 | typedef uch cdir_byte_hdr[ CREC_SIZE ]; |
||
2103 | # define C_VERSION_MADE_BY_0 0 |
||
2104 | # define C_VERSION_MADE_BY_1 1 |
||
2105 | # define C_VERSION_NEEDED_TO_EXTRACT_0 2 |
||
2106 | # define C_VERSION_NEEDED_TO_EXTRACT_1 3 |
||
2107 | # define C_GENERAL_PURPOSE_BIT_FLAG 4 |
||
2108 | # define C_COMPRESSION_METHOD 6 |
||
2109 | # define C_LAST_MOD_DOS_DATETIME 8 |
||
2110 | # define C_CRC32 12 |
||
2111 | # define C_COMPRESSED_SIZE 16 |
||
2112 | # define C_UNCOMPRESSED_SIZE 20 |
||
2113 | # define C_FILENAME_LENGTH 24 |
||
2114 | # define C_EXTRA_FIELD_LENGTH 26 |
||
2115 | # define C_FILE_COMMENT_LENGTH 28 |
||
2116 | # define C_DISK_NUMBER_START 30 |
||
2117 | # define C_INTERNAL_FILE_ATTRIBUTES 32 |
||
2118 | # define C_EXTERNAL_FILE_ATTRIBUTES 34 |
||
2119 | # define C_RELATIVE_OFFSET_LOCAL_HEADER 38 |
||
2120 | |||
2121 | typedef uch ec_byte_rec[ ECREC_SIZE+4 ]; |
||
2122 | /* define SIGNATURE 0 space-holder only */ |
||
2123 | # define NUMBER_THIS_DISK 4 |
||
2124 | # define NUM_DISK_WITH_START_CEN_DIR 6 |
||
2125 | # define NUM_ENTRIES_CEN_DIR_THS_DISK 8 |
||
2126 | # define TOTAL_ENTRIES_CENTRAL_DIR 10 |
||
2127 | # define SIZE_CENTRAL_DIRECTORY 12 |
||
2128 | # define OFFSET_START_CENTRAL_DIRECTORY 16 |
||
2129 | # define ZIPFILE_COMMENT_LENGTH 20 |
||
2130 | |||
2131 | typedef uch ec_byte_loc64[ ECLOC64_SIZE+4 ]; |
||
2132 | # define NUM_DISK_START_EOCDR64 4 |
||
2133 | # define OFFSET_START_EOCDR64 8 |
||
2134 | # define NUM_THIS_DISK_LOC64 16 |
||
2135 | |||
2136 | typedef uch ec_byte_rec64[ ECREC64_SIZE+4 ]; |
||
2137 | # define ECREC64_LENGTH 4 |
||
2138 | # define EC_VERSION_MADE_BY_0 12 |
||
2139 | # define EC_VERSION_NEEDED_0 14 |
||
2140 | # define NUMBER_THIS_DSK_REC64 16 |
||
2141 | # define NUM_DISK_START_CEN_DIR64 20 |
||
2142 | # define NUM_ENTRIES_CEN_DIR_THS_DISK64 24 |
||
2143 | # define TOTAL_ENTRIES_CENTRAL_DIR64 32 |
||
2144 | # define SIZE_CENTRAL_DIRECTORY64 40 |
||
2145 | # define OFFSET_START_CENTRAL_DIRECT64 48 |
||
2146 | |||
2147 | |||
2148 | /* The following structs are used to hold all header data of a zip entry. |
||
2149 | Traditionally, the structs' layouts followed the data layout of the |
||
2150 | corresponding zipfile header structures. However, the zipfile header |
||
2151 | layouts were designed in the old ages of 16-bit CPUs, they are subject |
||
2152 | to structure padding and/or alignment issues on newer systems with a |
||
2153 | "natural word width" of more than 2 bytes. |
||
2154 | Please note that the structure members are now reordered by size |
||
2155 | (top-down), to prevent internal padding and optimize memory usage! |
||
2156 | */ |
||
2157 | typedef struct local_file_header { /* LOCAL */ |
||
2158 | zusz_t csize; |
||
2159 | zusz_t ucsize; |
||
2160 | ulg last_mod_dos_datetime; |
||
2161 | ulg crc32; |
||
2162 | uch version_needed_to_extract[2]; |
||
2163 | ush general_purpose_bit_flag; |
||
2164 | ush compression_method; |
||
2165 | ush filename_length; |
||
2166 | ush extra_field_length; |
||
2167 | } local_file_hdr; |
||
2168 | |||
2169 | typedef struct central_directory_file_header { /* CENTRAL */ |
||
2170 | zusz_t csize; |
||
2171 | zusz_t ucsize; |
||
2172 | zusz_t relative_offset_local_header; |
||
2173 | ulg last_mod_dos_datetime; |
||
2174 | ulg crc32; |
||
2175 | ulg external_file_attributes; |
||
2176 | zuvl_t disk_number_start; |
||
2177 | ush internal_file_attributes; |
||
2178 | uch version_made_by[2]; |
||
2179 | uch version_needed_to_extract[2]; |
||
2180 | ush general_purpose_bit_flag; |
||
2181 | ush compression_method; |
||
2182 | ush filename_length; |
||
2183 | ush extra_field_length; |
||
2184 | ush file_comment_length; |
||
2185 | } cdir_file_hdr; |
||
2186 | |||
2187 | typedef struct end_central_dir_record { /* END CENTRAL */ |
||
2188 | zusz_t size_central_directory; |
||
2189 | zusz_t offset_start_central_directory; |
||
2190 | zucn_t num_entries_centrl_dir_ths_disk; |
||
2191 | zucn_t total_entries_central_dir; |
||
2192 | zuvl_t number_this_disk; |
||
2193 | zuvl_t num_disk_start_cdir; |
||
2194 | int have_ecr64; /* valid Zip64 ecdir-record exists */ |
||
2195 | int is_zip64_archive; /* Zip64 ecdir-record is mandatory */ |
||
2196 | ush zipfile_comment_length; |
||
2197 | } ecdir_rec; |
||
2198 | |||
2199 | |||
2200 | /* Huffman code lookup table entry--this entry is four bytes for machines |
||
2201 | that have 16-bit pointers (e.g. PC's in the small or medium model). |
||
2202 | Valid extra bits are 0..16. e == 31 is EOB (end of block), e == 32 |
||
2203 | means that v is a literal, 32 < e < 64 means that v is a pointer to |
||
2204 | the next table, which codes (e & 31) bits, and lastly e == 99 indicates |
||
2205 | an unused code. If a code with e == 99 is looked up, this implies an |
||
2206 | error in the data. */ |
||
2207 | |||
2208 | struct huft { |
||
2209 | uch e; /* number of extra bits or operation */ |
||
2210 | uch b; /* number of bits in this code or subcode */ |
||
2211 | union { |
||
2212 | ush n; /* literal, length base, or distance base */ |
||
2213 | struct huft *t; /* pointer to next level of table */ |
||
2214 | } v; |
||
2215 | }; |
||
2216 | |||
2217 | |||
2218 | typedef struct _APIDocStruct { |
||
2219 | char *compare; |
||
2220 | char *function; |
||
2221 | char *syntax; |
||
2222 | char *purpose; |
||
2223 | } APIDocStruct; |
||
2224 | |||
2225 | |||
2226 | |||
2227 | |||
2228 | /*************/ |
||
2229 | /* Globals */ |
||
2230 | /*************/ |
||
2231 | |||
2232 | #if (defined(OS2) && !defined(FUNZIP)) |
||
2233 | # include "os2/os2data.h" |
||
2234 | #endif |
||
2235 | |||
2236 | #include "globals.h" |
||
2237 | |||
2238 | |||
2239 | |||
2240 | /*************************/ |
||
2241 | /* Function Prototypes */ |
||
2242 | /*************************/ |
||
2243 | |||
2244 | /*--------------------------------------------------------------------------- |
||
2245 | Functions in unzip.c (initialization routines): |
||
2246 | ---------------------------------------------------------------------------*/ |
||
2247 | |||
2248 | #ifndef WINDLL |
||
2249 | int MAIN OF((int argc, char **argv)); |
||
2250 | int unzip OF((__GPRO__ int argc, char **argv)); |
||
2251 | int uz_opts OF((__GPRO__ int *pargc, char ***pargv)); |
||
2252 | int usage OF((__GPRO__ int error)); |
||
2253 | #endif /* !WINDLL */ |
||
2254 | |||
2255 | /*--------------------------------------------------------------------------- |
||
2256 | Functions in process.c (main driver routines): |
||
2257 | ---------------------------------------------------------------------------*/ |
||
2258 | |||
2259 | int process_zipfiles OF((__GPRO)); |
||
2260 | void free_G_buffers OF((__GPRO)); |
||
2261 | /* static int do_seekable OF((__GPRO__ int lastchance)); */ |
||
2262 | /* static int find_ecrec OF((__GPRO__ long searchlen)); */ |
||
2263 | /* static int process_central_comment OF((__GPRO)); */ |
||
2264 | int process_cdir_file_hdr OF((__GPRO)); |
||
2265 | int process_local_file_hdr OF((__GPRO)); |
||
2266 | int getZip64Data OF((__GPRO__ ZCONST uch *ef_buf, |
||
2267 | unsigned ef_len)); |
||
2268 | #ifdef UNICODE_SUPPORT |
||
2269 | int getUnicodeData OF((__GPRO__ ZCONST uch *ef_buf, |
||
2270 | unsigned ef_len)); |
||
2271 | #endif |
||
2272 | unsigned ef_scan_for_izux OF((ZCONST uch *ef_buf, unsigned ef_len, |
||
2273 | int ef_is_c, ulg dos_mdatetime, |
||
2274 | iztimes *z_utim, ulg *z_uidgid)); |
||
2275 | #if (defined(RISCOS) || defined(ACORN_FTYPE_NFS)) |
||
2276 | zvoid *getRISCOSexfield OF((ZCONST uch *ef_buf, unsigned ef_len)); |
||
2277 | #endif |
||
2278 | |||
2279 | #ifndef SFX |
||
2280 | |||
2281 | /*--------------------------------------------------------------------------- |
||
2282 | Functions in zipinfo.c (`zipinfo-style' listing routines): |
||
2283 | ---------------------------------------------------------------------------*/ |
||
2284 | |||
2285 | #ifndef NO_ZIPINFO |
||
2286 | #ifndef WINDLL |
||
2287 | int zi_opts OF((__GPRO__ int *pargc, char ***pargv)); |
||
2288 | #endif |
||
2289 | void zi_end_central OF((__GPRO)); |
||
2290 | int zipinfo OF((__GPRO)); |
||
2291 | /* static int zi_long OF((__GPRO__ zusz_t *pEndprev)); */ |
||
2292 | /* static int zi_short OF((__GPRO)); */ |
||
2293 | /* static char *zi_time OF((__GPRO__ ZCONST ulg *datetimez, |
||
2294 | ZCONST time_t *modtimez, char *d_t_str));*/ |
||
2295 | #endif /* !NO_ZIPINFO */ |
||
2296 | |||
2297 | /*--------------------------------------------------------------------------- |
||
2298 | Functions in list.c (generic zipfile-listing routines): |
||
2299 | ---------------------------------------------------------------------------*/ |
||
2300 | |||
2301 | int list_files OF((__GPRO)); |
||
2302 | #ifdef TIMESTAMP |
||
2303 | int get_time_stamp OF((__GPRO__ time_t *last_modtime, |
||
2304 | ulg *nmember)); |
||
2305 | #endif |
||
2306 | int ratio OF((zusz_t uc, zusz_t c)); |
||
2307 | void fnprint OF((__GPRO)); |
||
2308 | |||
2309 | #endif /* !SFX */ |
||
2310 | |||
2311 | /*--------------------------------------------------------------------------- |
||
2312 | Functions in fileio.c: |
||
2313 | ---------------------------------------------------------------------------*/ |
||
2314 | |||
2315 | int open_input_file OF((__GPRO)); |
||
2316 | int open_outfile OF((__GPRO)); /* also vms.c */ |
||
2317 | void undefer_input OF((__GPRO)); |
||
2318 | void defer_leftover_input OF((__GPRO)); |
||
2319 | unsigned readbuf OF((__GPRO__ char *buf, register unsigned len)); |
||
2320 | int readbyte OF((__GPRO)); |
||
2321 | int fillinbuf OF((__GPRO)); |
||
2322 | int seek_zipf OF((__GPRO__ zoff_t abs_offset)); |
||
2323 | #ifdef FUNZIP |
||
2324 | int flush OF((__GPRO__ ulg size)); /* actually funzip.c */ |
||
2325 | #else |
||
2326 | int flush OF((__GPRO__ uch *buf, ulg size, int unshrink)); |
||
2327 | #endif |
||
2328 | /* static int disk_error OF((__GPRO)); */ |
||
2329 | void handler OF((int signal)); |
||
2330 | time_t dos_to_unix_time OF((ulg dos_datetime)); |
||
2331 | int check_for_newer OF((__GPRO__ char *filename)); /* os2,vmcms,vms */ |
||
2332 | int do_string OF((__GPRO__ unsigned int length, int option)); |
||
2333 | ush makeword OF((ZCONST uch *b)); |
||
2334 | ulg makelong OF((ZCONST uch *sig)); |
||
2335 | zusz_t makeint64 OF((ZCONST uch *sig)); |
||
2336 | char *fzofft OF((__GPRO__ zoff_t val, |
||
2337 | ZCONST char *pre, ZCONST char *post)); |
||
2338 | #if (!defined(STR_TO_ISO) || defined(NEED_STR2ISO)) |
||
2339 | char *str2iso OF((char *dst, ZCONST char *src)); |
||
2340 | #endif |
||
2341 | #if (!defined(STR_TO_OEM) || defined(NEED_STR2OEM)) |
||
2342 | char *str2oem OF((char *dst, ZCONST char *src)); |
||
2343 | #endif |
||
2344 | #ifdef NO_STRNICMP |
||
2345 | int zstrnicmp OF((register ZCONST char *s1, |
||
2346 | register ZCONST char *s2, |
||
2347 | register unsigned n)); |
||
2348 | #endif |
||
2349 | #ifdef REGULUS |
||
2350 | int zstat OF((ZCONST char *p, struct stat *s)); |
||
2351 | #endif |
||
2352 | #ifdef ZMEM /* MUST be ifdef'd because of conflicts with the standard def. */ |
||
2353 | zvoid *memset OF((register zvoid *, register int, register unsigned int)); |
||
2354 | int memcmp OF((register ZCONST zvoid*, register ZCONST zvoid *, |
||
2355 | register unsigned int)); |
||
2356 | zvoid *memcpy OF((register zvoid *, register ZCONST zvoid *, |
||
2357 | register unsigned int)); |
||
2358 | #endif |
||
2359 | #ifdef NEED_UZMBCLEN |
||
2360 | extent uzmbclen OF((ZCONST unsigned char *ptr)); |
||
2361 | #endif |
||
2362 | #ifdef NEED_UZMBSCHR |
||
2363 | unsigned char *uzmbschr OF((ZCONST unsigned char *str, unsigned int c)); |
||
2364 | #endif |
||
2365 | #ifdef NEED_UZMBSRCHR |
||
2366 | unsigned char *uzmbsrchr OF((ZCONST unsigned char *str, unsigned int c)); |
||
2367 | #endif |
||
2368 | #ifdef SMALL_MEM |
||
2369 | char *fLoadFarString OF((__GPRO__ const char Far *sz)); |
||
2370 | char *fLoadFarStringSmall OF((__GPRO__ const char Far *sz)); |
||
2371 | char *fLoadFarStringSmall2 OF((__GPRO__ const char Far *sz)); |
||
2372 | #ifndef zfstrcpy |
||
2373 | char Far * Far zfstrcpy OF((char Far *s1, const char Far *s2)); |
||
2374 | #endif |
||
2375 | #if (!defined(SFX) && !defined(zfstrcmp)) |
||
2376 | int Far zfstrcmp OF((const char Far *s1, const char Far *s2)); |
||
2377 | #endif |
||
2378 | #endif |
||
2379 | |||
2380 | |||
2381 | /*--------------------------------------------------------------------------- |
||
2382 | Functions in extract.c: |
||
2383 | ---------------------------------------------------------------------------*/ |
||
2384 | |||
2385 | int extract_or_test_files OF((__GPRO)); |
||
2386 | /* static int store_info OF((void)); */ |
||
2387 | /* static int extract_or_test_member OF((__GPRO)); */ |
||
2388 | /* static int TestExtraField OF((__GPRO__ uch *ef, unsigned ef_len)); */ |
||
2389 | /* static int test_OS2 OF((__GPRO__ uch *eb, unsigned eb_size)); */ |
||
2390 | /* static int test_NT OF((__GPRO__ uch *eb, unsigned eb_size)); */ |
||
2391 | #ifndef SFX |
||
2392 | unsigned find_compr_idx OF((unsigned compr_methodnum)); |
||
2393 | #endif |
||
2394 | int memextract OF((__GPRO__ uch *tgt, ulg tgtsize, |
||
2395 | ZCONST uch *src, ulg srcsize)); |
||
2396 | int memflush OF((__GPRO__ ZCONST uch *rawbuf, ulg size)); |
||
2397 | #if (defined(VMS) || defined(VMS_TEXT_CONV)) |
||
2398 | uch *extract_izvms_block OF((__GPRO__ ZCONST uch *ebdata, |
||
2399 | unsigned size, unsigned *retlen, |
||
2400 | ZCONST uch *init, unsigned needlen)); |
||
2401 | #endif |
||
2402 | char *fnfilter OF((ZCONST char *raw, uch *space, |
||
2403 | extent size)); |
||
2404 | |||
2405 | /*--------------------------------------------------------------------------- |
||
2406 | Decompression functions: |
||
2407 | ---------------------------------------------------------------------------*/ |
||
2408 | |||
2409 | #if (!defined(SFX) && !defined(FUNZIP)) |
||
2410 | int explode OF((__GPRO)); /* explode.c */ |
||
2411 | #endif |
||
2412 | int huft_free OF((struct huft *t)); /* inflate.c */ |
||
2413 | int huft_build OF((__GPRO__ ZCONST unsigned *b, unsigned n, |
||
2414 | unsigned s, ZCONST ush *d, ZCONST uch *e, |
||
2415 | struct huft **t, unsigned *m)); |
||
2416 | #ifdef USE_ZLIB |
||
2417 | int UZinflate OF((__GPRO__ int is_defl64)); /* inflate.c */ |
||
2418 | # define inflate_free(x) inflateEnd(&((Uz_Globs *)(&G))->dstrm) |
||
2419 | #else |
||
2420 | int inflate OF((__GPRO__ int is_defl64)); /* inflate.c */ |
||
2421 | int inflate_free OF((__GPRO)); /* inflate.c */ |
||
2422 | #endif /* ?USE_ZLIB */ |
||
2423 | #if (!defined(SFX) && !defined(FUNZIP)) |
||
2424 | #ifndef COPYRIGHT_CLEAN |
||
2425 | int unreduce OF((__GPRO)); /* unreduce.c */ |
||
2426 | /* static void LoadFollowers OF((__GPRO__ f_array *follower, uch *Slen)); |
||
2427 | * unreduce.c */ |
||
2428 | #endif /* !COPYRIGHT_CLEAN */ |
||
2429 | #ifndef LZW_CLEAN |
||
2430 | int unshrink OF((__GPRO)); /* unshrink.c */ |
||
2431 | /* static void partial_clear OF((__GPRO)); * unshrink.c */ |
||
2432 | #endif /* !LZW_CLEAN */ |
||
2433 | #endif /* !SFX && !FUNZIP */ |
||
2434 | #ifdef USE_BZIP2 |
||
2435 | int UZbunzip2 OF((__GPRO)); /* extract.c */ |
||
2436 | void bz_internal_error OF((int bzerrcode)); /* ubz2err.c */ |
||
2437 | #endif |
||
2438 | |||
2439 | /*--------------------------------------------------------------------------- |
||
2440 | Internal API functions (only included in DLL versions): |
||
2441 | ---------------------------------------------------------------------------*/ |
||
2442 | |||
2443 | #ifdef DLL |
||
2444 | void setFileNotFound OF((__GPRO)); /* api.c */ |
||
2445 | int unzipToMemory OF((__GPRO__ char *zip, char *file, |
||
2446 | UzpBuffer *retstr)); /* api.c */ |
||
2447 | int redirect_outfile OF((__GPRO)); /* api.c */ |
||
2448 | int writeToMemory OF((__GPRO__ ZCONST uch *rawbuf, |
||
2449 | extent size)); /* api.c */ |
||
2450 | int close_redirect OF((__GPRO)); /* api.c */ |
||
2451 | /* this obsolescent entry point kept for compatibility: */ |
||
2452 | int UzpUnzip OF((int argc, char **argv));/* use UzpMain */ |
||
2453 | #ifdef OS2DLL |
||
2454 | int varmessage OF((__GPRO__ ZCONST uch *buf, ulg size)); |
||
2455 | int varputchar OF((__GPRO__ int c)); /* rexxapi.c */ |
||
2456 | int finish_REXX_redirect OF((__GPRO)); /* rexxapi.c */ |
||
2457 | #endif |
||
2458 | #ifdef API_DOC |
||
2459 | void APIhelp OF((__GPRO__ int argc, char **argv)); |
||
2460 | #endif /* apihelp.c */ |
||
2461 | #endif /* DLL */ |
||
2462 | |||
2463 | /*--------------------------------------------------------------------------- |
||
2464 | MSDOS-only functions: |
||
2465 | ---------------------------------------------------------------------------*/ |
||
2466 | |||
2467 | #ifdef MSDOS |
||
2468 | #if (!defined(FUNZIP) && !defined(SFX) && !defined(WINDLL)) |
||
2469 | void check_for_windows OF((ZCONST char *app)); /* msdos.c */ |
||
2470 | #endif |
||
2471 | #if (defined(__GO32__) || defined(__EMX__)) |
||
2472 | unsigned _dos_getcountryinfo(void *); /* msdos.c */ |
||
2473 | #if (!defined(__DJGPP__) || (__DJGPP__ < 2)) |
||
2474 | unsigned _dos_setftime(int, unsigned, unsigned); /* msdos.c */ |
||
2475 | unsigned _dos_setfileattr(const char *, unsigned); /* msdos.c */ |
||
2476 | unsigned _dos_creat(const char *, unsigned, int *); /* msdos.c */ |
||
2477 | void _dos_getdrive(unsigned *); /* msdos.c */ |
||
2478 | unsigned _dos_close(int); /* msdos.c */ |
||
2479 | #endif /* !__DJGPP__ || (__DJGPP__ < 2) */ |
||
2480 | #endif /* __GO32__ || __EMX__ */ |
||
2481 | #endif |
||
2482 | |||
2483 | /*--------------------------------------------------------------------------- |
||
2484 | OS/2-only functions: |
||
2485 | ---------------------------------------------------------------------------*/ |
||
2486 | |||
2487 | #ifdef OS2 /* GetFileTime conflicts with something in Win32 header files */ |
||
2488 | #if (defined(REENTRANT) && defined(USETHREADID)) |
||
2489 | ulg GetThreadId OF((void)); |
||
2490 | #endif |
||
2491 | int GetCountryInfo OF((void)); /* os2.c */ |
||
2492 | long GetFileTime OF((ZCONST char *name)); /* os2.c */ |
||
2493 | /* static void SetPathAttrTimes OF((__GPRO__ int flags, int dir)); os2.c */ |
||
2494 | /* static int SetEAs OF((__GPRO__ const char *path, |
||
2495 | void *eablock)); os2.c */ |
||
2496 | /* static int SetACL OF((__GPRO__ const char *path, |
||
2497 | void *eablock)); os2.c */ |
||
2498 | /* static int IsFileNameValid OF((const char *name)); os2.c */ |
||
2499 | /* static void map2fat OF((char *pathcomp, char **pEndFAT)); os2.c */ |
||
2500 | /* static int SetLongNameEA OF((char *name, char *longname)); os2.c */ |
||
2501 | /* static void InitNLS OF((void)); os2.c */ |
||
2502 | int IsUpperNLS OF((int nChr)); /* os2.c */ |
||
2503 | int ToLowerNLS OF((int nChr)); /* os2.c */ |
||
2504 | void DebugMalloc OF((void)); /* os2.c */ |
||
2505 | #endif |
||
2506 | |||
2507 | /*--------------------------------------------------------------------------- |
||
2508 | QDOS-only functions: |
||
2509 | ---------------------------------------------------------------------------*/ |
||
2510 | |||
2511 | #ifdef QDOS |
||
2512 | int QMatch (uch, uch); |
||
2513 | void QFilename (__GPRO__ char *); |
||
2514 | char *Qstrfix (char *); |
||
2515 | int QReturn (int zip_error); |
||
2516 | #endif |
||
2517 | |||
2518 | /*--------------------------------------------------------------------------- |
||
2519 | TOPS20-only functions: |
||
2520 | ---------------------------------------------------------------------------*/ |
||
2521 | |||
2522 | #ifdef TOPS20 |
||
2523 | int upper OF((char *s)); /* tops20.c */ |
||
2524 | int enquote OF((char *s)); /* tops20.c */ |
||
2525 | int dequote OF((char *s)); /* tops20.c */ |
||
2526 | int fnlegal OF(()); /* error if prototyped? */ /* tops20.c */ |
||
2527 | #endif |
||
2528 | |||
2529 | /*--------------------------------------------------------------------------- |
||
2530 | VM/CMS- and MVS-only functions: |
||
2531 | ---------------------------------------------------------------------------*/ |
||
2532 | |||
2533 | #ifdef CMS_MVS |
||
2534 | extent getVMMVSexfield OF((char *type, uch *ef_block, unsigned datalen)); |
||
2535 | FILE *vmmvs_open_infile OF((__GPRO)); /* vmmvs.c */ |
||
2536 | void close_infile OF((__GPRO)); /* vmmvs.c */ |
||
2537 | #endif |
||
2538 | |||
2539 | /*--------------------------------------------------------------------------- |
||
2540 | VMS-only functions: |
||
2541 | ---------------------------------------------------------------------------*/ |
||
2542 | |||
2543 | #ifdef VMS |
||
2544 | int check_format OF((__GPRO)); /* vms.c */ |
||
2545 | /* int open_outfile OF((__GPRO)); * (see fileio.c) vms.c */ |
||
2546 | /* int flush OF((__GPRO__ uch *rawbuf, unsigned size, |
||
2547 | int final_flag)); * (see fileio.c) vms.c */ |
||
2548 | char *vms_msg_text OF((void)); /* vms.c */ |
||
2549 | #ifdef RETURN_CODES |
||
2550 | void return_VMS OF((__GPRO__ int zip_error)); /* vms.c */ |
||
2551 | #else |
||
2552 | void return_VMS OF((int zip_error)); /* vms.c */ |
||
2553 | #endif |
||
2554 | #ifdef VMSCLI |
||
2555 | ulg vms_unzip_cmdline OF((int *, char ***)); /* cmdline.c */ |
||
2556 | int VMSCLI_usage OF((__GPRO__ int error)); /* cmdline.c */ |
||
2557 | #endif |
||
2558 | #endif |
||
2559 | |||
2560 | /*--------------------------------------------------------------------------- |
||
2561 | WIN32-only functions: |
||
2562 | ---------------------------------------------------------------------------*/ |
||
2563 | |||
2564 | #ifdef WIN32 |
||
2565 | int IsWinNT OF((void)); /* win32.c */ |
||
2566 | #ifdef NTSD_EAS |
||
2567 | void process_defer_NT OF((__GPRO)); /* win32.c */ |
||
2568 | int test_NTSD OF((__GPRO__ uch *eb, unsigned eb_size, |
||
2569 | uch *eb_ucptr, ulg eb_ucsize)); /* win32.c */ |
||
2570 | # define TEST_NTSD test_NTSD |
||
2571 | #endif |
||
2572 | #ifdef W32_STAT_BANDAID |
||
2573 | int zstat_win32 OF((__W32STAT_GLOBALS__ |
||
2574 | const char *path, z_stat *buf)); /* win32.c */ |
||
2575 | #endif |
||
2576 | #endif |
||
2577 | |||
2578 | /*--------------------------------------------------------------------------- |
||
2579 | Miscellaneous/shared functions: |
||
2580 | ---------------------------------------------------------------------------*/ |
||
2581 | |||
2582 | Uz_Globs *globalsCtor OF((void)); /* globals.c */ |
||
2583 | |||
2584 | int envargs OF((int *Pargc, char ***Pargv, |
||
2585 | ZCONST char *envstr, ZCONST char *envstr2)); |
||
2586 | /* envargs.c */ |
||
2587 | void mksargs OF((int *argcp, char ***argvp)); /* envargs.c */ |
||
2588 | |||
2589 | int match OF((ZCONST char *s, ZCONST char *p, |
||
2590 | int ic __WDLPRO)); /* match.c */ |
||
2591 | int iswild OF((ZCONST char *p)); /* match.c */ |
||
2592 | |||
2593 | /* declarations of public CRC-32 functions have been moved into crc32.h |
||
2594 | (free_crc_table(), get_crc_table(), crc32()) crc32.c */ |
||
2595 | |||
2596 | int dateformat OF((void)); /* local */ |
||
2597 | char dateseparator OF((void)); /* local */ |
||
2598 | #ifndef WINDLL |
||
2599 | void version OF((__GPRO)); /* local */ |
||
2600 | #endif |
||
2601 | int mapattr OF((__GPRO)); /* local */ |
||
2602 | int mapname OF((__GPRO__ int renamed)); /* local */ |
||
2603 | int checkdir OF((__GPRO__ char *pathcomp, int flag)); /* local */ |
||
2604 | char *do_wild OF((__GPRO__ ZCONST char *wildzipfn)); /* local */ |
||
2605 | char *GetLoadPath OF((__GPRO)); /* local */ |
||
2606 | #if (defined(MORE) && (defined(ATH_BEO_UNX) || defined(QDOS) || defined(VMS))) |
||
2607 | int screensize OF((int *tt_rows, int *tt_cols)); /* local */ |
||
2608 | # if defined(VMS) |
||
2609 | int screenlinewrap OF((void)); /* local */ |
||
2610 | # endif |
||
2611 | #endif /* MORE && (ATH_BEO_UNX || QDOS || VMS) */ |
||
2612 | #ifdef OS2_W32 |
||
2613 | int SetFileSize OF((FILE *file, zusz_t filesize)); /* local */ |
||
2614 | #endif |
||
2615 | #ifndef MTS /* macro in MTS */ |
||
2616 | void close_outfile OF((__GPRO)); /* local */ |
||
2617 | #endif |
||
2618 | #ifdef SET_SYMLINK_ATTRIBS |
||
2619 | int set_symlnk_attribs OF((__GPRO__ slinkentry *slnk_entry)); /* local */ |
||
2620 | #endif |
||
2621 | #ifdef SET_DIR_ATTRIB |
||
2622 | int defer_dir_attribs OF((__GPRO__ direntry **pd)); /* local */ |
||
2623 | int set_direc_attribs OF((__GPRO__ direntry *d)); /* local */ |
||
2624 | #endif |
||
2625 | #ifdef TIMESTAMP |
||
2626 | # ifdef WIN32 |
||
2627 | int stamp_file OF((__GPRO__ |
||
2628 | ZCONST char *fname, time_t modtime)); /* local */ |
||
2629 | # else |
||
2630 | int stamp_file OF((ZCONST char *fname, time_t modtime)); /* local */ |
||
2631 | # endif |
||
2632 | #endif |
||
2633 | #ifdef NEED_ISO_OEM_INIT |
||
2634 | void prepare_ISO_OEM_translat OF((__GPRO)); /* local */ |
||
2635 | #endif |
||
2636 | #if (defined(MALLOC_WORK) && defined(MY_ZCALLOC)) |
||
2637 | zvoid far *zcalloc OF((unsigned int, unsigned int)); |
||
2638 | zvoid zcfree OF((zvoid far *)); |
||
2639 | #endif /* MALLOC_WORK && MY_ZCALLOC */ |
||
2640 | #ifdef SYSTEM_SPECIFIC_CTOR |
||
2641 | void SYSTEM_SPECIFIC_CTOR OF((__GPRO)); /* local */ |
||
2642 | #endif |
||
2643 | #ifdef SYSTEM_SPECIFIC_DTOR |
||
2644 | void SYSTEM_SPECIFIC_DTOR OF((__GPRO)); /* local */ |
||
2645 | #endif |
||
2646 | |||
2647 | |||
2648 | |||
2649 | |||
2650 | |||
2651 | /************/ |
||
2652 | /* Macros */ |
||
2653 | /************/ |
||
2654 | |||
2655 | #ifndef MAX |
||
2656 | # define MAX(a,b) ((a) > (b) ? (a) : (b)) |
||
2657 | #endif |
||
2658 | #ifndef MIN |
||
2659 | # define MIN(a,b) ((a) < (b) ? (a) : (b)) |
||
2660 | #endif |
||
2661 | |||
2662 | #ifdef DEBUG |
||
2663 | # if (defined(THEOS) && defined(NO_BOGUS_SPC)) |
||
2664 | # define NO_DEBUG_IN_MACROS |
||
2665 | # define Trace(x) _fprintf x |
||
2666 | # else |
||
2667 | # define Trace(x) fprintf x |
||
2668 | # endif |
||
2669 | #else |
||
2670 | # define Trace(x) |
||
2671 | #endif |
||
2672 | |||
2673 | #ifdef DEBUG_TIME |
||
2674 | # define TTrace(x) fprintf x |
||
2675 | #else |
||
2676 | # define TTrace(x) |
||
2677 | #endif |
||
2678 | |||
2679 | #ifdef NO_DEBUG_IN_MACROS |
||
2680 | # define MTrace(x) |
||
2681 | #else |
||
2682 | # define MTrace(x) Trace(x) |
||
2683 | #endif |
||
2684 | |||
2685 | #if (defined(UNIX) || defined(T20_VMS)) /* generally old systems */ |
||
2686 | # define ToLower(x) ((char)(isupper((int)x)? tolower((int)x) : x)) |
||
2687 | #else |
||
2688 | # define ToLower tolower /* assumed "smart"; used in match() */ |
||
2689 | #endif |
||
2690 | |||
2691 | #ifdef USE_STRM_INPUT |
||
2692 | /* ``Replace'' the unbuffered UNIX style I/O function with similar |
||
2693 | * standard C functions from |
||
2694 | */ |
||
2695 | # define read(fd,buf,n) fread((buf),1,(n),(FILE *)(fd)) |
||
2696 | # ifdef zlseek |
||
2697 | # undef zlseek |
||
2698 | # endif |
||
2699 | # define zlseek(fd,o,w) zfseeko((FILE *)(fd),(o),(w)) |
||
2700 | # define close(fd) fclose((FILE *)(fd)) |
||
2701 | #endif /* USE_STRM_INPUT */ |
||
2702 | |||
2703 | /* The return value of the Info() "macro function" is never checked in |
||
2704 | * UnZip. Otherwise, to get the same behaviour as for (*G.message)(), the |
||
2705 | * Info() definition for "FUNZIP" would have to be corrected: |
||
2706 | * #define Info(buf,flag,sprf_arg) \ |
||
2707 | * (fputs((char *)(sprintf sprf_arg, (buf)), \ |
||
2708 | * (flag)&1? stderr : stdout) < 0) |
||
2709 | */ |
||
2710 | #ifndef Info /* may already have been defined for redirection */ |
||
2711 | # ifdef FUNZIP |
||
2712 | # define Info(buf,flag,sprf_arg) \ |
||
2713 | fputs((char *)(sprintf sprf_arg, (buf)), (flag)&1? stderr : stdout) |
||
2714 | # else |
||
2715 | # ifdef INT_SPRINTF /* optimized version for "int sprintf()" flavour */ |
||
2716 | # define Info(buf,flag,sprf_arg) \ |
||
2717 | (*G.message)((zvoid *)&G, (uch *)(buf), (ulg)sprintf sprf_arg, (flag)) |
||
2718 | # else /* generic version, does not use sprintf() return value */ |
||
2719 | # define Info(buf,flag,sprf_arg) \ |
||
2720 | (*G.message)((zvoid *)&G, (uch *)(buf), \ |
||
2721 | (ulg)(sprintf sprf_arg, strlen((char *)(buf))), (flag)) |
||
2722 | # endif |
||
2723 | # endif |
||
2724 | #endif /* !Info */ |
||
2725 | |||
2726 | /* This wrapper macro around fzofft() is just defined to "hide" the |
||
2727 | * argument needed to reference the global storage buffers. |
||
2728 | */ |
||
2729 | #define FmZofft(val, pre, post) fzofft(__G__ val, pre, post) |
||
2730 | |||
2731 | /* The following macro wrappers around the fnfilter function are used many |
||
2732 | * times to prepare archive entry names or name components for displaying |
||
2733 | * listings and (warning/error) messages. They use sections in the upper half |
||
2734 | * of 'slide' as buffer, since their output is normally fed through the |
||
2735 | * Info() macro with 'slide' (the start of this area) as message buffer. |
||
2736 | */ |
||
2737 | #define FnFilter1(fname) \ |
||
2738 | fnfilter((fname), slide + (extent)(WSIZE>>1), (extent)(WSIZE>>2)) |
||
2739 | #define FnFilter2(fname) \ |
||
2740 | fnfilter((fname), slide + (extent)((WSIZE>>1) + (WSIZE>>2)),\ |
||
2741 | (extent)(WSIZE>>2)) |
||
2742 | |||
2743 | #ifndef FUNZIP /* used only in inflate.c */ |
||
2744 | # define MESSAGE(str,len,flag) (*G.message)((zvoid *)&G,(str),(len),(flag)) |
||
2745 | #endif |
||
2746 | |||
2747 | #if 0 /* Optimization: use the (const) result of crc32(0L,NULL,0) */ |
||
2748 | # define CRCVAL_INITIAL crc32(0L, NULL, 0) |
||
2749 | #else |
||
2750 | # define CRCVAL_INITIAL 0L |
||
2751 | #endif |
||
2752 | |||
2753 | #ifdef SYMLINKS |
||
2754 | /* This macro defines the Zip "made by" hosts that are considered |
||
2755 | to support storing symbolic link entries. */ |
||
2756 | # define SYMLINK_HOST(hn) ((hn) == UNIX_ || (hn) == ATARI_ || \ |
||
2757 | (hn) == ATHEOS_ || (hn) == BEOS_ || (hn) == VMS_) |
||
2758 | #endif |
||
2759 | |||
2760 | #ifndef TEST_NTSD /* "NTSD valid?" checking function */ |
||
2761 | # define TEST_NTSD NULL /* ... is not available */ |
||
2762 | #endif |
||
2763 | |||
2764 | #define SKIP_(length) if(length&&((error=do_string(__G__ length,SKIP))!=0))\ |
||
2765 | {error_in_archive=error; if(error>1) return error;} |
||
2766 | |||
2767 | /* |
||
2768 | * Skip a variable-length field, and report any errors. Used in zipinfo.c |
||
2769 | * and unzip.c in several functions. |
||
2770 | * |
||
2771 | * macro SKIP_(length) |
||
2772 | * ush length; |
||
2773 | * { |
||
2774 | * if (length && ((error = do_string(length, SKIP)) != 0)) { |
||
2775 | * error_in_archive = error; /-* might be warning *-/ |
||
2776 | * if (error > 1) /-* fatal *-/ |
||
2777 | * return (error); |
||
2778 | * } |
||
2779 | * } |
||
2780 | * |
||
2781 | */ |
||
2782 | |||
2783 | |||
2784 | #ifdef FUNZIP |
||
2785 | # define FLUSH(w) flush(__G__ (ulg)(w)) |
||
2786 | # define NEXTBYTE getc(G.in) /* redefined in crypt.h if full version */ |
||
2787 | #else |
||
2788 | # define FLUSH(w) ((G.mem_mode) ? memflush(__G__ redirSlide,(ulg)(w)) \ |
||
2789 | : flush(__G__ redirSlide,(ulg)(w),0)) |
||
2790 | # define NEXTBYTE (G.incnt-- > 0 ? (int)(*G.inptr++) : readbyte(__G)) |
||
2791 | #endif |
||
2792 | |||
2793 | |||
2794 | #define READBITS(nbits,zdest) {if(nbits>G.bits_left) {int temp; G.zipeof=1;\ |
||
2795 | while (G.bits_left<=8*(int)(sizeof(G.bitbuf)-1) && (temp=NEXTBYTE)!=EOF) {\ |
||
2796 | G.bitbuf|=(ulg)temp< |
||
2797 | zdest=(shrint)((unsigned)G.bitbuf&mask_bits[nbits]);G.bitbuf>>=nbits;\ |
||
2798 | G.bits_left-=nbits;} |
||
2799 | |||
2800 | /* |
||
2801 | * macro READBITS(nbits,zdest) * only used by unreduce and unshrink * |
||
2802 | * { |
||
2803 | * if (nbits > G.bits_left) { * fill G.bitbuf, 8*sizeof(ulg) bits * |
||
2804 | * int temp; |
||
2805 | * |
||
2806 | * G.zipeof = 1; |
||
2807 | * while (G.bits_left <= 8*(int)(sizeof(G.bitbuf)-1) && |
||
2808 | * (temp = NEXTBYTE) != EOF) { |
||
2809 | * G.bitbuf |= (ulg)temp << G.bits_left; |
||
2810 | * G.bits_left += 8; |
||
2811 | * G.zipeof = 0; |
||
2812 | * } |
||
2813 | * } |
||
2814 | * zdest = (shrint)((unsigned)G.bitbuf & mask_bits[nbits]); |
||
2815 | * G.bitbuf >>= nbits; |
||
2816 | * G.bits_left -= nbits; |
||
2817 | * } |
||
2818 | * |
||
2819 | */ |
||
2820 | |||
2821 | |||
2822 | /* GRR: should use StringLower for STRLOWER macro if possible */ |
||
2823 | |||
2824 | /* |
||
2825 | * Copy the zero-terminated string in str1 into str2, converting any |
||
2826 | * uppercase letters to lowercase as we go. str2 gets zero-terminated |
||
2827 | * as well, of course. str1 and str2 may be the same character array. |
||
2828 | */ |
||
2829 | #ifdef _MBCS |
||
2830 | # define STRLOWER(str1, str2) \ |
||
2831 | { \ |
||
2832 | char *p, *q, c; unsigned i; \ |
||
2833 | p = (char *)(str1); \ |
||
2834 | q = (char *)(str2); \ |
||
2835 | while ((c = *p) != '\0') { \ |
||
2836 | if ((i = CLEN(p)) > 1) { \ |
||
2837 | while (i--) *q++ = *p++; \ |
||
2838 | } else { \ |
||
2839 | *q++ = (char)(isupper((int)(c))? tolower((int)(c)) : c); \ |
||
2840 | p++; \ |
||
2841 | } \ |
||
2842 | } \ |
||
2843 | *q = '\0'; \ |
||
2844 | } |
||
2845 | #else |
||
2846 | # define STRLOWER(str1, str2) \ |
||
2847 | { \ |
||
2848 | char *p, *q; \ |
||
2849 | p = (char *)(str1) - 1; \ |
||
2850 | q = (char *)(str2); \ |
||
2851 | while (*++p) \ |
||
2852 | *q++ = (char)(isupper((int)(*p))? tolower((int)(*p)) : *p); \ |
||
2853 | *q = '\0'; \ |
||
2854 | } |
||
2855 | #endif |
||
2856 | /* |
||
2857 | * NOTES: This macro makes no assumptions about the characteristics of |
||
2858 | * the tolower() function or macro (beyond its existence), nor does it |
||
2859 | * make assumptions about the structure of the character set (i.e., it |
||
2860 | * should work on EBCDIC machines, too). The fact that either or both |
||
2861 | * of isupper() and tolower() may be macros has been taken into account; |
||
2862 | * watch out for "side effects" (in the C sense) when modifying this |
||
2863 | * macro. |
||
2864 | */ |
||
2865 | |||
2866 | #ifndef foreign |
||
2867 | # define foreign(c) (c) |
||
2868 | #endif |
||
2869 | |||
2870 | #ifndef native |
||
2871 | # define native(c) (c) |
||
2872 | # define A_TO_N(str1) |
||
2873 | #else |
||
2874 | # ifndef NATIVE |
||
2875 | # define NATIVE "native chars" |
||
2876 | # endif |
||
2877 | # define A_TO_N(str1) {register uch *p;\ |
||
2878 | for (p=(uch *)(str1); *p; p++) *p=native(*p);} |
||
2879 | #endif |
||
2880 | /* |
||
2881 | * Translate the zero-terminated string in str1 from ASCII to the native |
||
2882 | * character set. The translation is performed in-place and uses the |
||
2883 | * "native" macro to translate each character. |
||
2884 | * |
||
2885 | * NOTE: Using the "native" macro means that is it the only part of unzip |
||
2886 | * which knows which translation table (if any) is actually in use to |
||
2887 | * produce the native character set. This makes adding new character set |
||
2888 | * translation tables easy, insofar as all that is needed is an appropriate |
||
2889 | * "native" macro definition and the translation table itself. Currently, |
||
2890 | * the only non-ASCII native character set implemented is EBCDIC, but this |
||
2891 | * may not always be so. |
||
2892 | */ |
||
2893 | |||
2894 | |||
2895 | /* default setup for internal codepage: assume ISO 8859-1 compatibility!! */ |
||
2896 | #if (!defined(NATIVE) && !defined(CRTL_CP_IS_ISO) && !defined(CRTL_CP_IS_OEM)) |
||
2897 | # define CRTL_CP_IS_ISO |
||
2898 | #endif |
||
2899 | |||
2900 | |||
2901 | /* Translate "extended ASCII" chars (OEM coding for DOS and OS/2; else |
||
2902 | * ISO-8859-1 [ISO Latin 1, Win Ansi,...]) into the internal "native" |
||
2903 | * code page. As with A_TO_N(), conversion is done in place. |
||
2904 | */ |
||
2905 | #ifndef _ISO_INTERN |
||
2906 | # ifdef CRTL_CP_IS_OEM |
||
2907 | # ifndef IZ_ISO2OEM_ARRAY |
||
2908 | # define IZ_ISO2OEM_ARRAY |
||
2909 | # endif |
||
2910 | # define _ISO_INTERN(str1) if (iso2oem) {register uch *p;\ |
||
2911 | for (p=(uch *)(str1); *p; p++)\ |
||
2912 | *p = native((*p & 0x80) ? iso2oem[*p & 0x7f] : *p);} |
||
2913 | # else |
||
2914 | # define _ISO_INTERN(str1) A_TO_N(str1) |
||
2915 | # endif |
||
2916 | #endif |
||
2917 | |||
2918 | #ifndef _OEM_INTERN |
||
2919 | # ifdef CRTL_CP_IS_OEM |
||
2920 | # define _OEM_INTERN(str1) A_TO_N(str1) |
||
2921 | # else |
||
2922 | # ifndef IZ_OEM2ISO_ARRAY |
||
2923 | # define IZ_OEM2ISO_ARRAY |
||
2924 | # endif |
||
2925 | # define _OEM_INTERN(str1) if (oem2iso) {register uch *p;\ |
||
2926 | for (p=(uch *)(str1); *p; p++)\ |
||
2927 | *p = native((*p & 0x80) ? oem2iso[*p & 0x7f] : *p);} |
||
2928 | # endif |
||
2929 | #endif |
||
2930 | |||
2931 | #ifndef STR_TO_ISO |
||
2932 | # ifdef CRTL_CP_IS_ISO |
||
2933 | # define STR_TO_ISO strcpy |
||
2934 | # else |
||
2935 | # define STR_TO_ISO str2iso |
||
2936 | # define NEED_STR2ISO |
||
2937 | # endif |
||
2938 | #endif |
||
2939 | |||
2940 | #ifndef STR_TO_OEM |
||
2941 | # ifdef CRTL_CP_IS_OEM |
||
2942 | # define STR_TO_OEM strcpy |
||
2943 | # else |
||
2944 | # define STR_TO_OEM str2oem |
||
2945 | # define NEED_STR2OEM |
||
2946 | # endif |
||
2947 | #endif |
||
2948 | |||
2949 | #if (!defined(INTERN_TO_ISO) && !defined(ASCII2ISO)) |
||
2950 | # ifdef CRTL_CP_IS_OEM |
||
2951 | /* know: "ASCII" is "OEM" */ |
||
2952 | # define ASCII2ISO(c) \ |
||
2953 | ((((c) & 0x80) && oem2iso) ? oem2iso[(c) & 0x7f] : (c)) |
||
2954 | # if (defined(NEED_STR2ISO) && !defined(CRYP_USES_OEM2ISO)) |
||
2955 | # define CRYP_USES_OEM2ISO |
||
2956 | # endif |
||
2957 | # else |
||
2958 | /* assume: "ASCII" is "ISO-ANSI" */ |
||
2959 | # define ASCII2ISO(c) (c) |
||
2960 | # endif |
||
2961 | #endif |
||
2962 | |||
2963 | #if (!defined(INTERN_TO_OEM) && !defined(ASCII2OEM)) |
||
2964 | # ifdef CRTL_CP_IS_OEM |
||
2965 | /* know: "ASCII" is "OEM" */ |
||
2966 | # define ASCII2OEM(c) (c) |
||
2967 | # else |
||
2968 | /* assume: "ASCII" is "ISO-ANSI" */ |
||
2969 | # define ASCII2OEM(c) \ |
||
2970 | ((((c) & 0x80) && iso2oem) ? iso2oem[(c) & 0x7f] : (c)) |
||
2971 | # if (defined(NEED_STR2OEM) && !defined(CRYP_USES_ISO2OEM)) |
||
2972 | # define CRYP_USES_ISO2OEM |
||
2973 | # endif |
||
2974 | # endif |
||
2975 | #endif |
||
2976 | |||
2977 | /* codepage conversion setup for testp() in crypt.c */ |
||
2978 | #ifdef CRTL_CP_IS_ISO |
||
2979 | # ifndef STR_TO_CP2 |
||
2980 | # define STR_TO_CP2 STR_TO_OEM |
||
2981 | # endif |
||
2982 | #else |
||
2983 | # ifdef CRTL_CP_IS_OEM |
||
2984 | # ifndef STR_TO_CP2 |
||
2985 | # define STR_TO_CP2 STR_TO_ISO |
||
2986 | # endif |
||
2987 | # else /* native internal CP is neither ISO nor OEM */ |
||
2988 | # ifndef STR_TO_CP1 |
||
2989 | # define STR_TO_CP1 STR_TO_ISO |
||
2990 | # endif |
||
2991 | # ifndef STR_TO_CP2 |
||
2992 | # define STR_TO_CP2 STR_TO_OEM |
||
2993 | # endif |
||
2994 | # endif |
||
2995 | #endif |
||
2996 | |||
2997 | |||
2998 | /* Convert filename (and file comment string) into "internal" charset. |
||
2999 | * This macro assumes that Zip entry filenames are coded in OEM (IBM DOS) |
||
3000 | * codepage when made on |
||
3001 | * -> DOS (this includes 16-bit Windows 3.1) (FS_FAT_) |
||
3002 | * -> OS/2 (FS_HPFS_) |
||
3003 | * -> Win95/WinNT with Nico Mak's WinZip (FS_NTFS_ && hostver == "5.0") |
||
3004 | * EXCEPTIONS: |
||
3005 | * PKZIP for Windows 2.5, 2.6, and 4.0 flag their entries as "FS_FAT_", but |
||
3006 | * the filename stored in the local header is coded in Windows ANSI (CP 1252 |
||
3007 | * resp. ISO 8859-1 on US and western Europe locale settings). |
||
3008 | * Likewise, PKZIP for UNIX 2.51 flags its entries as "FS_FAT_", but the |
||
3009 | * filenames stored in BOTH the local and the central header are coded |
||
3010 | * in the local system's codepage (usually ANSI codings like ISO 8859-1). |
||
3011 | * |
||
3012 | * All other ports are assumed to code zip entry filenames in ISO 8859-1. |
||
3013 | */ |
||
3014 | #ifndef Ext_ASCII_TO_Native |
||
3015 | # define Ext_ASCII_TO_Native(string, hostnum, hostver, isuxatt, islochdr) \ |
||
3016 | if (((hostnum) == FS_FAT_ && \ |
||
3017 | !(((islochdr) || (isuxatt)) && \ |
||
3018 | ((hostver) == 25 || (hostver) == 26 || (hostver) == 40))) || \ |
||
3019 | (hostnum) == FS_HPFS_ || \ |
||
3020 | ((hostnum) == FS_NTFS_ && (hostver) == 50)) { \ |
||
3021 | _OEM_INTERN((string)); \ |
||
3022 | } else { \ |
||
3023 | _ISO_INTERN((string)); \ |
||
3024 | } |
||
3025 | #endif |
||
3026 | |||
3027 | |||
3028 | |||
3029 | /**********************/ |
||
3030 | /* Global constants */ |
||
3031 | /**********************/ |
||
3032 | |||
3033 | extern ZCONST unsigned near mask_bits[17]; |
||
3034 | extern ZCONST char *fnames[2]; |
||
3035 | |||
3036 | #ifdef EBCDIC |
||
3037 | extern ZCONST uch ebcdic[]; |
||
3038 | #endif |
||
3039 | #ifdef IZ_ISO2OEM_ARRAY |
||
3040 | extern ZCONST uch Far *iso2oem; |
||
3041 | extern ZCONST uch Far iso2oem_850[]; |
||
3042 | #endif |
||
3043 | #ifdef IZ_OEM2ISO_ARRAY |
||
3044 | extern ZCONST uch Far *oem2iso; |
||
3045 | extern ZCONST uch Far oem2iso_850[]; |
||
3046 | #endif |
||
3047 | |||
3048 | extern ZCONST char Far VersionDate[]; |
||
3049 | extern ZCONST char Far CentSigMsg[]; |
||
3050 | #ifndef SFX |
||
3051 | extern ZCONST char Far EndSigMsg[]; |
||
3052 | #endif |
||
3053 | extern ZCONST char Far SeekMsg[]; |
||
3054 | extern ZCONST char Far FilenameNotMatched[]; |
||
3055 | extern ZCONST char Far ExclFilenameNotMatched[]; |
||
3056 | extern ZCONST char Far ReportMsg[]; |
||
3057 | |||
3058 | #ifndef SFX |
||
3059 | extern ZCONST char Far Zipnfo[]; |
||
3060 | extern ZCONST char Far CompiledWith[]; |
||
3061 | #endif /* !SFX */ |
||
3062 | |||
3063 | |||
3064 | |||
3065 | /***********************************/ |
||
3066 | /* Global (shared?) RTL variables */ |
||
3067 | /***********************************/ |
||
3068 | |||
3069 | #ifdef DECLARE_ERRNO |
||
3070 | extern int errno; |
||
3071 | #endif |
||
3072 | |||
3073 | /*--------------------------------------------------------------------- |
||
3074 | Unicode Support |
||
3075 | 28 August 2005 |
||
3076 | ---------------------------------------------------------------------*/ |
||
3077 | #if (defined(UNICODE_SUPPORT) && defined(UNICODE_WCHAR)) |
||
3078 | |||
3079 | /* Default character when a zwchar too big for wchar_t */ |
||
3080 | # define zwchar_to_wchar_t_default_char '_' |
||
3081 | |||
3082 | /* Default character string when wchar_t does not convert to mb */ |
||
3083 | # define wide_to_mb_default_string "_" |
||
3084 | |||
3085 | /* wide character type */ |
||
3086 | typedef unsigned long zwchar; |
||
3087 | |||
3088 | /* UTF-8 related conversion functions, currently found in process.c */ |
||
3089 | |||
3090 | # if 0 /* currently unused */ |
||
3091 | /* check if string is all ASCII */ |
||
3092 | int is_ascii_string OF((ZCONST char *mbstring)); |
||
3093 | # endif /* unused */ |
||
3094 | |||
3095 | /* convert UTF-8 string to multi-byte string */ |
||
3096 | char *utf8_to_local_string OF((ZCONST char *utf8_string, int escape_all)); |
||
3097 | |||
3098 | /* convert UTF-8 string to wide string */ |
||
3099 | zwchar *utf8_to_wide_string OF((ZCONST char *utf8_string)); |
||
3100 | |||
3101 | /* convert wide string to multi-byte string */ |
||
3102 | char *wide_to_local_string OF((ZCONST zwchar *wide_string, int escape_all)); |
||
3103 | |||
3104 | # if 0 /* currently unused */ |
||
3105 | /* convert local string to multi-byte display string */ |
||
3106 | char *local_to_display_string OF((ZCONST char *local_string)); |
||
3107 | # endif /* unused */ |
||
3108 | |||
3109 | /* convert wide character to escape string */ |
||
3110 | char *wide_to_escape_string OF((unsigned long)); |
||
3111 | |||
3112 | # define utf8_to_escaped_string(utf8_string) \ |
||
3113 | utf8_to_local_string(utf8_string, TRUE) |
||
3114 | |||
3115 | # if 0 /* currently unused */ |
||
3116 | /* convert escape string to wide character */ |
||
3117 | unsigned long escape_string_to_wide OF((ZCONST char *escape_string)); |
||
3118 | |||
3119 | /* convert local to UTF-8 */ |
||
3120 | char *local_to_utf8_string OF ((ZCONST char *local_string)); |
||
3121 | |||
3122 | /* convert local to wide string */ |
||
3123 | zwchar *local_to_wide_string OF ((ZCONST char *local_string)); |
||
3124 | |||
3125 | /* convert wide string to UTF-8 */ |
||
3126 | char *wide_to_utf8_string OF((ZCONST zwchar *wide_string)); |
||
3127 | # endif /* unused */ |
||
3128 | |||
3129 | #endif /* UNICODE_SUPPORT && UNICODE_WCHAR */ |
||
3130 | |||
3131 | |||
3132 | #endif /* !__unzpriv_h */><>=> |