LMMS
Loading...
Searching...
No Matches
w32cfg.h
Go to the documentation of this file.
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 Win32 specific configuration section:
11 ---------------------------------------------------------------------------*/
12
13#ifndef __w32cfg_h
14#define __w32cfg_h
15
16#ifdef __MINGW32__
17# define USE_STRM_INPUT
18#endif
19
20#ifdef __CYGWIN__
21/* We treat the file system underneath the Cygwin Unix emulator environment
22 * as "native VFAT/NTFS" and use the WIN32 API for its special attributes...
23 */
24# ifdef UNIX
25# undef UNIX
26# endif
27#endif
28
29#if (defined(_MSC_VER) && !defined(MSC))
30# define MSC
31#endif
32
33/* enable multibyte character set support by default */
34#if (!defined(_MBCS) && !defined(NO_MBCS))
35# define _MBCS
36#endif
37#if (defined(_MBCS) && defined(NO_MBCS))
38# undef _MBCS
39#endif
40#if (defined(__CYGWIN__) && defined(_MBCS))
41# undef _MBCS /* Cygwin RTL lacks support for __mb_cur_max */
42#endif
43#if (defined(__DJGPP__) && !defined(__EMX__) && defined(_MBCS))
44# undef _MBCS /* __mb_cur_max missing for RSXNTdj 1.6 beta */
45#endif
46
47#include <sys/types.h> /* off_t, time_t, dev_t, ... */
48#include <sys/stat.h>
49#include <io.h> /* read(), open(), etc. */
50#include <time.h>
51#if ((defined(__RSXNT__) || defined(__EMX__)) && !defined(tzset))
52# define tzset _tzset
53#endif
54#if (defined(__LCC__) && !defined(tzset))
55# define tzset _tzset
56#endif
57#ifdef W32_USE_IZ_TIMEZONE
58# ifdef __BORLANDC__
59# define tzname tzname
60# define IZTZ_DEFINESTDGLOBALS
61# endif
62# ifdef __WATCOMC__
63# define IZTZ_DEFINESTDGLOBALS
64# endif
65# ifndef tzset
66# define tzset _tzset
67# endif
68# ifndef timezone
69# define timezone _timezone
70# endif
71# ifndef daylight
72# define daylight _daylight
73# endif
74# ifndef tzname
75# define tzname _tzname
76# endif
77# if (!defined(NEED__ISINDST) && !defined(__BORLANDC__))
78# define NEED__ISINDST
79# endif
80# ifdef IZTZ_GETLOCALETZINFO
81# undef IZTZ_GETLOCALETZINFO
82# endif
83# define IZTZ_GETLOCALETZINFO GetPlatformLocalTimezone
84#endif /* W32_USE_IZ_TIMEZONE */
85#include <memory.h>
86#if (!defined(__RSXNT__) && !defined(__CYGWIN__))
87# include <direct.h> /* mkdir() */
88#endif
89#include <fcntl.h>
90#ifdef __CYGWIN__
91# include <unistd.h>
92 extern int setmode(int, int); /* this is missing in <fcntl.h> */
93#endif
94#if (defined(MSC) || defined(__WATCOMC__) || defined(__MINGW32__))
95# include <sys/utime.h>
96#else
97# include <utime.h>
98#endif
99#define GOT_UTIMBUF
100
101#ifdef _MBCS
102# if (!defined(__EMX__) && !defined(__DJGPP__) && !defined(__CYGWIN__))
103# if (!defined(__MINGW32__) || defined(__MSVCRT__))
104# include <stdlib.h>
105# include <mbstring.h>
106 /* for MSC (and compatible compilers), use routines supplied by RTL */
107# define CLEN(ptr) _mbclen((const uch *)(ptr))
108# define PREINCSTR(ptr) (ptr = (char *)_mbsinc((const uch *)(ptr)))
109# define MBSCHR(str, c) (char *)_mbschr((const uch *)(str), (c))
110# define MBSRCHR(str, c) (char *)_mbsrchr((const uch *)(str), (c))
111# endif
112# endif
113# if (defined(__MINGW32__) && !defined(MB_CUR_MAX))
114# ifdef __MSVCRT__
115 extern int *__p___mb_cur_max(void);
116# define MB_CUR_MAX (*__p___mb_cur_max())
117# else
118 extern int *_imp____mb_cur_max_dll;
119# define MB_CUR_MAX (*_imp____mb_cur_max_dll)
120# endif
121# endif
122# if (defined(__LCC__) && !defined(MB_CUR_MAX))
123 extern int *_imp____mb_cur_max;
124# define MB_CUR_MAX (*_imp____mb_cur_max)
125# endif
126# if (defined(__DJGPP__) && !defined(__EMX__) && !defined(MB_CUR_MAX))
127 extern int *_imp____mb_cur_max;
128# define MB_CUR_MAX (*_imp____mb_cur_max)
129# endif
130#endif
131
132/* for UnZip, the "basic" part of the win32 api is sufficient */
133#ifndef WIN32_LEAN_AND_MEAN
134# define WIN32_LEAN_AND_MEAN
135#endif
136
137#if defined(__FILEIO_C)
138# ifndef __CYGWIN__
139# include <conio.h>
140# endif
141# include <windows.h>
142# ifdef __RSXNT__
143# include "../win32/rsxntwin.h"
144# endif
145# ifndef TIME_ZONE_ID_INVALID
146# define TIME_ZONE_ID_INVALID (DWORD)0xFFFFFFFFL
147# endif
148#endif
149#if (defined(__ENVARGS_C) || defined(__EXTRACT_C) || defined(__UNZIP_C) || \
150 defined(ZCRYPT_INTERNAL))
151# include <windows.h>
152# ifdef __RSXNT__
153# include "../win32/rsxntwin.h"
154# endif
155# ifndef TIME_ZONE_ID_INVALID
156# define TIME_ZONE_ID_INVALID (DWORD)0xFFFFFFFFL
157# endif
158#endif
159
160#ifndef Cdecl
161# define Cdecl __cdecl
162#endif
163
164/* the following definitions are considered as "obsolete" by Microsoft and
165 * might be missing in some versions of <windows.h>
166 */
167#ifndef AnsiToOem
168# define AnsiToOem CharToOemA
169#endif
170#ifndef OemToAnsi
171# define OemToAnsi OemToCharA
172#endif
173
174#define DIR_END '\\' /* OS uses '\\' as directory separator */
175#define DIR_END2 '/' /* also check for '/' (RTL may convert) */
176#ifdef DATE_FORMAT
177# undef DATE_FORMAT
178#endif
179#define DATE_FORMAT dateformat()
180#ifdef DATE_SEPCHAR
181# undef DATE_SEPCHAR
182#endif
183#define DATE_SEPCHAR dateseparator()
184#define lenEOL 2
185#define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
186
187#if (defined(__RSXNT__) && !defined(HAVE_MKTIME))
188# define HAVE_MKTIME /* use mktime() in time conversion routines */
189#endif
190#if (defined(MSC) && !defined(HAVE_MKTIME))
191# define HAVE_MKTIME /* use mktime() in time conversion routines */
192#endif
193#if (defined(__CYGWIN__) && defined(HAVE_MKTIME))
194# undef HAVE_MKTIME /* Cygnus' mktime() implementation is buggy */
195#endif
196#if (defined(W32_USE_IZ_TIMEZONE) && !defined(HAVE_MKTIME))
197# define HAVE_MKTIME /* use mktime() in time conversion routines */
198#endif
199#if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME))
200# define USE_EF_UT_TIME
201#endif
202#if (!defined(NO_DIR_ATTRIB) && !defined(SET_DIR_ATTRIB))
203# define SET_DIR_ATTRIB
204#endif
205#if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
206# define TIMESTAMP
207#endif
208#if (!defined(NO_NTSD_EAS) && !defined(NTSD_EAS))
209# define NTSD_EAS /* enable NTSD support unless explicitly suppressed */
210#endif
211#if (defined(NTSD_EAS) && !defined(RESTORE_ACL))
212# define RESTORE_ACL /* "restore ACLs" only needed when NTSD_EAS active */
213#endif
214#if (!defined(NO_UNICODE_SUPPORT) && !defined(UNICODE_SUPPORT))
215# define UNICODE_SUPPORT /* enable UTF-8 filename support by default */
216#endif
217#if (defined(UNICODE_SUPPORT) && !defined(UNICODE_WCHAR))
218# define UNICODE_WCHAR /* wchar_t is UTF-16 encoded on WIN32 */
219#endif
220#ifdef UTF8_MAYBE_NATIVE
221# undef UTF8_MAYBE_NATIVE /* UTF-8 cannot be system charset on WIN32 */
222#endif
223
224/* The following compiler systems provide or use a runtime library with a
225 * locale-aware isprint() implementation. For these systems, the "enhanced"
226 * unprintable charcode detection in fnfilter() gets enabled.
227 */
228#if (!defined(HAVE_WORKING_ISPRINT) && !defined(NO_WORKING_ISPRINT))
229# if defined(MSC) || defined(__BORLANDC__)
230# define HAVE_WORKING_ISPRINT
231# endif
232# if defined(__MINGW32__) && defined(__MSVCRT__)
233# define HAVE_WORKING_ISPRINT
234# endif
235#endif
236
237/* WIN32 runs solely on little-endian processors; enable support
238 * for the 32-bit optimized CRC-32 C code by default.
239 */
240#ifdef IZ_CRC_BE_OPTIMIZ
241# undef IZ_CRC_BE_OPTIMIZ
242#endif
243#if !defined(IZ_CRC_LE_OPTIMIZ) && !defined(NO_CRC_OPTIMIZ)
244# define IZ_CRC_LE_OPTIMIZ
245#endif
246
247/* handlers for OEM <--> ANSI string conversions */
248#ifdef __RSXNT__
249 /* RSXNT uses OEM coded strings in functions supplied by C RTL */
250# ifdef CRTL_CP_IS_ISO
251# undef CRTL_CP_IS_ISO
252# endif
253# ifndef CRTL_CP_IS_OEM
254# define CRTL_CP_IS_OEM
255# endif
256#else
257 /* "real" native WIN32 compilers use ANSI coded strings in C RTL calls */
258# ifndef CRTL_CP_IS_ISO
259# define CRTL_CP_IS_ISO
260# endif
261# ifdef CRTL_CP_IS_OEM
262# undef CRTL_CP_IS_OEM
263# endif
264#endif
265
266#ifdef CRTL_CP_IS_ISO
267 /* C RTL's file system support assumes ANSI coded strings */
268# define ISO_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
269# define OEM_TO_INTERN(src, dst) OemToAnsi(src, dst)
270# define INTERN_TO_ISO(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
271# define INTERN_TO_OEM(src, dst) AnsiToOem(src, dst)
272#endif /* CRTL_CP_IS_ISO */
273#ifdef CRTL_CP_IS_OEM
274 /* C RTL's file system support assumes OEM coded strings */
275# define ISO_TO_INTERN(src, dst) AnsiToOem(src, dst)
276# define OEM_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
277# define INTERN_TO_ISO(src, dst) OemToAnsi(src, dst)
278# define INTERN_TO_OEM(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
279#endif /* CRTL_CP_IS_OEM */
280#define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1)
281#define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1)
282#ifndef WINDLL
283 /* Despite best intentions, for the command-line version UzpPassword()
284 * could return either character set, depending on whether running under
285 * Win95 (DOS-session) or WinNT (native WinNT command interpreter)! */
286# define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst)
287# define STR_TO_CP3(dst, src) (OemToAnsi(src, dst), dst)
288#else
289 /* The WINDLL front end is known to supply ISO/ANSI-coded passwords! */
290# define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst)
291#endif
292/* dummy defines to disable these functions, they are not needed */
293#define STR_TO_OEM
294#define STR_TO_ISO
295
296/* Static variables that we have to add to Uz_Globs: */
297#define SYSTEM_SPECIFIC_GLOBALS \
298 int created_dir, renamed_fullpath, fnlen;\
299 unsigned nLabelDrive;\
300 char lastRootPath[4];\
301 int lastVolOldFAT, lastVolLocTim;\
302 char *rootpath, *buildpathHPFS, *buildpathFAT, *endHPFS, *endFAT;\
303 ZCONST char *wildname;\
304 char *dirname, matchname[FILNAMSIZ];\
305 int rootlen, have_dirname, dirnamelen, notfirstcall;\
306 zvoid *wild_dir;
307
308/* created_dir, renamed_fullpath, fnlen, and nLabelDrive are used by */
309/* both mapname() and checkdir(). */
310/* lastRootPath, lastVolOldFAT and lastVolLocTim are used by */
311/* IsVolumeOldFAT() and NTQueryVolInfo(). */
312/* rootlen, rootpath, buildpathHPFS, buildpathFAT, endHPFS, and endFAT */
313/* are used by checkdir(). */
314/* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */
315/* and notfirstcall are used by do_wild(). */
316
317/* This replacement for C-RTL-supplied getch() (or similar) functionality
318 * avoids leaving unabsorbed LFs in the keyboard buffer under Windows95,
319 * and supports the <ALT>+[0]<digit><digit><digit> feature.
320 */
321int getch_win32 OF((void));
322
323/* Up to now, all versions of Microsoft C runtime libraries lack the support
324 * for customized (non-US) switching rules between daylight saving time and
325 * standard time in the TZ environment variable string.
326 * But non-US timezone rules are correctly supported when timezone information
327 * is read from the OS system settings in the Win32 registry.
328 * The following work-around deletes any TZ environment setting from
329 * the process environment. This results in a fallback of the RTL time
330 * handling code to the (correctly interpretable) OS system settings, read
331 * from the registry.
332 */
333#ifdef USE_EF_UT_TIME
334# if (defined(__WATCOMC__) || defined(__CYGWIN__) || \
335 defined(W32_USE_IZ_TIMEZONE))
336# define iz_w32_prepareTZenv()
337# else
338# define iz_w32_prepareTZenv() putenv("TZ=")
339# endif
340#endif
341
342/* This patch of stat() is useful for at least two compilers. It is */
343/* difficult to take a stat() of a root directory under Windows95, so */
344/* zstat_win32() detects that case and fills in suitable values. */
345#ifndef __RSXNT__
346# ifndef W32_STATROOT_FIX
347# define W32_STATROOT_FIX
348# endif
349#endif /* !__RSXNT__ */
350
351#define W32_STAT_BANDAID
352#if defined(REENTRANT)
353# define __W32STAT_GLOBALS__ Uz_Globs *pG,
354# define __W32STAT_G__ pG,
355#else
356# define __W32STAT_GLOBALS__
357# define __W32STAT_G__
358#endif
359#ifdef SSTAT
360# undef SSTAT
361#endif
362#ifdef WILD_STAT_BUG
363# define SSTAT(path, pbuf) (iswild(path) || zstat_win32(__W32STAT_G__ path, pbuf))
364#else
365# define SSTAT(path, pbuf) zstat_win32(__W32STAT_G__ path, pbuf)
366#endif
367
368#ifdef __WATCOMC__
369# ifdef __386__
370# ifndef WATCOMC_386
371# define WATCOMC_386
372# endif
373# define __32BIT__
374# undef far
375# define far
376# undef near
377# define near
378# undef Cdecl
379# define Cdecl
380
381/* gaah -- Watcom's docs claim that _get_osfhandle exists, but it doesn't. */
382# define _get_osfhandle _os_handle
383
384/* Get asm routines to link properly without using "__cdecl": */
385# ifndef USE_ZLIB
386# pragma aux crc32 "_*" parm caller [] value [eax] modify [eax]
387# pragma aux get_crc_table "_*" parm caller [] value [eax] \
388 modify [eax ecx edx]
389# endif /* !USE_ZLIB */
390# endif /* __386__ */
391#endif /* __WATCOMC__ */
392
393#define SCREENWIDTH 80
394#define SCREENSIZE(scrrows, scrcols) screensize(scrrows, scrcols)
395int screensize(int *tt_rows, int *tt_cols);
396
397/* on the DOS or NT console screen, line-wraps are always enabled */
398#define SCREENLWRAP 1
399#define TABSIZE 8
400
401
402/* 64-bit-Integers & Large File Support
403 * (pasted here from Zip 3b, osdep.h - Myles Bennett 7-jun-2004)
404 * (updated from Zip 3.0d - Ed Gordon 6-oct-2004)
405 *
406 * If this is set it is assumed that the port
407 * supports 64-bit file calls. The types are
408 * defined here. Any local implementations are
409 * in w32i64.c and the prototypes for the calls are
410 * in unzip.h. Note that a port must support
411 * these calls fully or should not set
412 * LARGE_FILE_SUPPORT.
413 */
414
415/* Automatically set ZIP64_SUPPORT if supported */
416
417#ifndef NO_ZIP64_SUPPORT
418# ifndef ZIP64_SUPPORT
419# if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
420# define ZIP64_SUPPORT
421# elif defined(__LCC__)
422 /* LCC links against crtdll.dll -> no support of 64-bit offsets :( */
423# elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100))
424# define ZIP64_SUPPORT
425# elif (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520))
426 /* Borland C RTL lacks any support to get/set 64-bit file pointer :( */
427# endif
428# endif
429#endif
430
431#ifdef ZIP64_SUPPORT
432 /* base type for file offsets and file sizes */
433# if (defined(__GNUC__) || defined(ULONG_LONG_MAX))
434 typedef long long zoff_t;
435# else
436 /* all other compilers use this as intrinsic 64-bit type */
437 typedef __int64 zoff_t;
438# endif
439# define ZOFF_T_DEFINED
440
441 /* user-defined types and format strings for 64-bit numbers and
442 * file pointer functions (these depend on the rtl library and library
443 * headers used; they are NOT compiler-specific)
444 */
445# if defined(_MSC_VER) || defined(__MINGW32__) || defined(__LCC__)
446 /* MS C and VC, MinGW32, lcc32 */
447 /* these systems use the Microsoft C RTL */
448
449 /* 64-bit stat struct */
450 typedef struct _stati64 z_stat;
451# define Z_STAT_DEFINED
452
453# ifdef __LCC__
454 /* The LCC headers lack these declarations of MSC rtl functions in
455 sys/stat.h. */
456 struct _stati64 {
457 unsigned int st_dev;
458 unsigned short st_ino;
459 unsigned short st_mode;
460 short st_nlink;
461 short st_uid;
462 short st_gid;
463 unsigned int st_rdev;
464 __int64 st_size;
465 time_t st_atime;
466 time_t st_mtime;
467 time_t st_ctime;
468 };
469 int _stati64(const char *, struct _stati64 *);
470 int _fstati64(int, struct _stati64 *);
471 __int64 _lseeki64(int, __int64, int);
472# endif /* __LCC__ */
473
474 /* printf format size prefix for zoff_t values */
475# define FZOFFT_FMT "I64"
476# define FZOFFT_HEX_WID_VALUE "16"
477
478# define SHORTHDRSTATS "%9I64u %02u%c%02u%c%02u %02u:%02u %c"
479# define SHORTFILETRAILER " -------- -------\n%9I64u %9lu file%s\n"
480
481# elif (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520))
482 /* Borland C 5.2 or newer */
483
484 /* 64-bit stat struct */
485 typedef struct stati64 z_stat;
486# define Z_STAT_DEFINED
487
488 /* Borland C does not provide a 64-bit-capable _lseeki64(), so we
489 need to use the stdio.h stream functions instead. */
490# ifndef USE_STRM_INPUT
491# define USE_STRM_INPUT
492# endif
493
494 /* printf format size prefix for zoff_t values */
495# define FZOFFT_FMT "L"
496# define FZOFFT_HEX_WID_VALUE "16"
497
498# define SHORTHDRSTATS "%9Lu %02u%c%02u%c%02u %02u:%02u %c"
499# define SHORTFILETRAILER " -------- -------\n%9Lu %9lu file%s\n"
500
501# elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100))
502 /* WATCOM C */
503
504 /* 64-bit stat struct */
505 typedef struct _stati64 z_stat;
506# define Z_STAT_DEFINED
507
508 /* printf format size prefix for zoff_t values */
509# define FZOFFT_FMT "ll"
510# define FZOFFT_HEX_WID_VALUE "16"
511
512# define SHORTHDRSTATS "%9llu %02u%c%02u%c%02u %02u:%02u %c"
513# define SHORTFILETRAILER " -------- -------\n%9llu %9lu file%s\n"
514
515# elif (defined(__IBMC__) && (__IBMC__ >= 350))
516 /* IBM C */
517
518 /* 64-bit stat struct */
519
520 /* printf format size prefix for zoff_t values */
521# define FZOFFT_FMT "I64"
522# define FZOFFT_HEX_WID_VALUE "16"
523
524# define SHORTHDRSTATS "%9I64u %02u%c%02u%c%02u %02u:%02u %c"
525# define SHORTFILETRAILER " -------- -------\n%9I64u %9lu file%s\n"
526
527# endif
528
529#endif
530
531/* If port has LARGE_FILE_SUPPORT then define here
532 to make automatic unless overridden */
533
534#ifndef LARGE_FILE_SUPPORT
535# ifndef NO_LARGE_FILE_SUPPORT
536# if defined(_MSC_VER) || defined(__MINGW32__)
537# define LARGE_FILE_SUPPORT
538# elif defined(__LCC__)
539 /* LCC links against crtdll.dll -> no support of 64-bit offsets :( */
540# elif defined(__CYGWIN__)
541# define LARGE_FILE_SUPPORT
542# elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100))
543# define LARGE_FILE_SUPPORT
544# elif (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520))
545 /* Borland C RTL lacks any support to get/set 64-bit file pointer :( */
546# endif
547# endif
548#endif
549
550
551#ifndef LARGE_FILE_SUPPORT
552 /* No Large File Support */
553
554 /* base type for file offsets and file sizes */
555 typedef long zoff_t;
556# define ZOFF_T_DEFINED
557
558 /* stat struct */
559 typedef struct stat z_stat;
560# define Z_STAT_DEFINED
561
562# define FZOFFT_FMT "l"
563# define FZOFFT_HEX_WID_VALUE "8"
564
565
566# define SHORTHDRSTATS "%9lu %02u%c%02u%c%02u %02u:%02u %c"
567# define SHORTFILETRAILER " -------- -------\n%9lu %9lu file%s\n"
568
569#endif /* LARGE_FILE_SUPPORT */
570
571#endif /* !__w32cfg_h */
#define OF(a)
Definition crc32.h:22
#define __int64
off_t zoff_t
Definition unxcfg.h:59
struct stat z_stat
Definition unxcfg.h:62
int screensize(int *tt_rows, int *tt_cols)
Definition win32.c:2655
int getch_win32(void)
Definition win32.c:2909