home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip540.zip / msdos / doscfg.h < prev    next >
C/C++ Source or Header  |  1998-08-07  |  10KB  |  291 lines

  1. /*---------------------------------------------------------------------------
  2.     MS-DOS specific configuration section:
  3.   ---------------------------------------------------------------------------*/
  4.  
  5. #ifndef __doscfg_h
  6. #define __doscfg_h
  7.  
  8. #include <dos.h>           /* for REGS macro (TC) or _dos_setftime (MSC) */
  9.  
  10. #ifdef __TURBOC__          /* includes Power C */
  11. #  include <sys/timeb.h>   /* for structure ftime */
  12. #  ifndef __BORLANDC__     /* there appears to be a bug (?) in Borland's */
  13. #    include <mem.h>       /*  MEM.H related to __STDC__ and far poin-   */
  14. #  endif                   /*  ters. (dpk)  [mem.h included for memcpy]  */
  15. #endif
  16.  
  17. #ifdef WINDLL
  18. #  if (defined(MSC) || defined(__WATCOMC__))
  19. #    include <sys/utime.h>
  20. #  else /* !(MSC || __WATCOMC__) ==> may be BORLANDC, or GNU environment */
  21. #    include <utime.h>
  22. #  endif /* ?(MSC || __WATCOMC__) */
  23. #endif
  24.  
  25. #ifdef __WATCOMC__
  26. #  define DOS_STAT_BANDAID
  27.  
  28. #  ifdef __386__
  29. #    ifndef WATCOMC_386
  30. #      define WATCOMC_386
  31. #    endif
  32. #    define __32BIT__
  33. #    undef far
  34. #    define far
  35. #    undef near
  36. #    define near
  37.  
  38. /* Get asm routines to link properly without using "__cdecl": */
  39. #    ifndef USE_ZLIB
  40. #      pragma aux crc32         "_*" parm caller [] value [eax] modify [eax]
  41. #      pragma aux get_crc_table "_*" parm caller [] value [eax] \
  42.                                       modify [eax ecx edx]
  43. #    endif /* !USE_ZLIB */
  44. #  else /* !__386__ */
  45. #    ifndef USE_ZLIB
  46. #      pragma aux crc32         "_*" parm caller [] value [ax dx] \
  47.                                       modify [ax cx dx bx]
  48. #      pragma aux get_crc_table "_*" parm caller [] value [ax] \
  49.                                       modify [ax cx dx bx]
  50. #    endif /* !USE_ZLIB */
  51. #  endif /* ?__386__ */
  52.  
  53. #  ifndef EPIPE
  54. #    define EPIPE -1
  55. #  endif
  56. #  define PIPE_ERROR (errno == EPIPE)
  57. #endif /* __WATCOMC__ */
  58.  
  59. #ifdef __EMX__
  60. #  ifndef __32BIT__
  61. #    define __32BIT__
  62. #  endif
  63. #  define far
  64. #  ifndef HAVE_MKTIME
  65. #    define HAVE_MKTIME
  66. #  endif
  67. #endif
  68.  
  69. #if defined(__GO32__) || defined(__DJGPP__)    /* MS-DOS compiler, not OS/2 */
  70. #  ifndef __32BIT__
  71. #    define __32BIT__
  72. #  endif
  73. #  ifndef __GO32__
  74. #    define __GO32__
  75. #  endif
  76. #  ifndef HAVE_MKTIME
  77. #    define HAVE_MKTIME
  78. #  endif
  79. #  include <sys/timeb.h>           /* for structure ftime and ftime() */
  80. #  if (defined(__DJGPP__) && (__DJGPP__ > 1))
  81. #    include <unistd.h>            /* for prototypes for read/write etc. */
  82. #    include <dir.h>               /* for FA_LABEL */
  83. #    if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ == 0))
  84. #      include <libc/dosio.h>      /* for _USE_LFN, djgpp 2.0 only */
  85. #    endif
  86. #    define USE_LFN _USE_LFN       /* runtime test:  support long filenames? */
  87. #  else
  88.      int setmode(int, int);        /* not in older djgpp's include files */
  89. #  endif
  90. #endif
  91.  
  92. #ifndef __32BIT__
  93. #  define __16BIT__
  94. #endif
  95.  
  96. #if (defined(M_I86CM) || defined(M_I86LM)) || defined(WINDLL)
  97. #  define MED_MEM
  98. #endif
  99. #if (defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__))
  100. #  define MED_MEM
  101. #endif
  102. #ifdef __16BIT__
  103. #  ifndef MED_MEM
  104. #    define SMALL_MEM
  105. #  endif
  106. #endif
  107.  
  108. #define EXE_EXTENSION ".exe"  /* OS/2 has GetLoadPath() function instead */
  109.  
  110. #ifdef __16BIT__
  111. #  if defined(MSC) || defined(__WATCOMC__)
  112. #    include <malloc.h>
  113. #    define nearmalloc _nmalloc
  114. #    define nearfree _nfree
  115. #  endif
  116. #  if defined(__TURBOC__) && defined(DYNALLOC_CRCTAB)
  117. #    if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
  118. #      undef DYNALLOC_CRCTAB
  119. #    endif
  120. #  endif
  121. #  ifndef nearmalloc
  122. #    define nearmalloc malloc
  123. #    define nearfree free
  124. #  endif
  125. #  if defined(DEBUG) && defined(MSC) && (!defined(_MSC_VER) || _MSC_VER < 600)
  126.      /* for MSC 5.1, prevent macro expansion space overflow in DEBUG mode */
  127. #    define NO_DEBUG_IN_MACROS
  128. #  endif
  129. #endif
  130.  
  131.  
  132. /* another stat()/fopen() bug with some 16-bit compilers on Novell drives;
  133.  * very dangerous (silently overwrites executables in other directories)
  134.  */
  135. #define NOVELL_BUG_WORKAROUND
  136.  
  137. /* enables additional test and message code that directs UnZip to fail safely
  138.  * in case the "workaround" enabled above does not work as intended
  139.  */
  140. #define NOVELL_BUG_FAILSAFE
  141.  
  142. /* Some implementations of stat() tend to fail on "." in root directories
  143.  * or on remote (root) directories specified by an UNC network path. This
  144.  * patch of stat() is useful for at least the WATCOM compilers. The
  145.  * stat_bandaid() wrapper detects stat failures on root directories and
  146.  * fills in suitable values.
  147.  */
  148. #ifdef DOS_STAT_BANDAID
  149. #  undef SSTAT
  150. #  ifdef WILD_STAT_BUG
  151. #    define SSTAT(path,pbuf) (iswild(path) || stat_bandaid(path,pbuf))
  152. #  else
  153. #    define SSTAT stat_bandaid
  154. #  endif
  155.    int stat_bandaid(const char *path, struct stat *buf);
  156. #endif
  157.  
  158. /* the TIMESTAMP feature is now supported on MSDOS, enable it per default */
  159. #if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
  160. #  define TIMESTAMP
  161. #endif
  162.  
  163. /* check that TZ environment variable is defined before using UTC times */
  164. #if (!defined(NO_IZ_CHECK_TZ) && !defined(IZ_CHECK_TZ))
  165. #  define IZ_CHECK_TZ
  166. #endif
  167.  
  168. /* The optional "long filename" support available with some MSDOS compiler
  169.  * environments running under VFAT systems (Win95) is controlled with the
  170.  * help of the two preprocessor symbols USE_VFAT and USE_LFN:
  171.  *  - USE_VFAT is a compile time switch that selects the long filename
  172.  *             semantics in mapname()
  173.  *  - USE_LFN  is a macro equating to a boolean expression indicating
  174.  *             whether long filenames are supported. If available, this
  175.  *             macro should make use of a runtime function checking the
  176.  *             LFN support.
  177.  *
  178.  * The code in msdos.c distinguishes three cases:
  179.  * 1.) USE_VFAT is not defined:
  180.  *     No support of LFN is included; filenames are mapped to 8+3 plain FAT
  181.  *     syntax unconditionally.
  182.  *     This is achieved by ``#define MAYBE_PLAIN_FAT'' to include the plain
  183.  *     FAT name mapping code and by ``#undef USE_LFN'' to disable bypassing
  184.  *     of the FAT mapping at runtime.
  185.  * 2.) USE_VFAT is defined:
  186.  *     Support for LFN is enabled.
  187.  *  a) USE_LFN is undefined:
  188.  *     There is no (runtime) check available to distinguish between OS
  189.  *     environments that support VFAT extensions and those that do not.
  190.  *     In this case, filenames are mapped to the more liberal VFAT LFN
  191.  *     syntax unconditionally. The internal switch MAYBE_PLAIN_FAT remains
  192.  *     undefined to exclude to "map to plain FAT" code parts.
  193.  *  b) USE_LFN is defined (hopefully to a boolean runtime LFN check function):
  194.  *     "#define MAYBE_PLAIN_FAT" is applied to include the plain FAT mapping
  195.  *     code; the programs checks at runtime whether the OS supports LFN and
  196.  *     uses the appropiate mapping syntax.
  197.  */
  198. /* Some environments, like DJGPP v2, can support long filenames on VFAT
  199.  * systems and DOS 8.3 filenames on FAT systems in the same executable.  If
  200.  * such support is available, USE_LFN should be defined to an expression
  201.  * that will return non-zero when long filenames API should be used, zero
  202.  * otherwise.
  203.  */
  204. #ifndef USE_VFAT
  205. #  ifdef USE_LFN
  206. #    undef USE_LFN
  207. #  endif
  208. #  ifndef MAYBE_PLAIN_FAT
  209. #    define MAYBE_PLAIN_FAT
  210. #  endif
  211. #endif
  212. #ifdef USE_LFN
  213. #  define MAYBE_PLAIN_FAT
  214. #endif
  215.  
  216. /* handlers for OEM <--> ANSI string conversions */
  217. #ifdef WINDLL
  218. #  if 1
  219.      /* C RTL's file system support assumes OEM-coded strings */
  220. #    ifdef CRTL_CP_IS_ISO
  221. #      undef CRTL_CP_IS_ISO
  222. #    endif
  223. #    ifndef CRTL_CP_IS_OEM
  224. #      define CRTL_CP_IS_OEM
  225. #    endif
  226. #  else
  227.      /* C RTL's file system support assumes ISO-coded strings */
  228. #    ifndef CRTL_CP_IS_ISO
  229. #      define CRTL_CP_IS_ISO
  230. #    endif
  231. #    ifdef CRTL_CP_IS_OEM
  232. #      undef CRTL_CP_IS_OEM
  233. #    endif
  234. #  endif /* ?(code page of 16bit Windows compilers) */
  235.    /* include Win API declarations only in sources where conversion is
  236.     * actually used (skip EXTRACT_C, extract.c includes windll.h instead)
  237.     */
  238. #  if defined(ENVARGS_C) || defined(UNZIP_C) || defined(ZCRYPT_INTERNAL)
  239. #    include <windows.h>
  240. #  endif
  241.    /* use conversion functions of Windows API */
  242. #  ifdef CRTL_CP_IS_ISO
  243. #   define ISO_TO_INTERN(src, dst)  {if ((src) != (dst)) strcpy((dst), (src));}
  244. #   define OEM_TO_INTERN(src, dst)  OemToAnsi(src, dst)
  245. #   define INTERN_TO_ISO(src, dst)  {if ((src) != (dst)) strcpy((dst), (src));}
  246. #   define INTERN_TO_OEM(src, dst)  AnsiToOem(src, dst)
  247. #  endif
  248. #  ifdef CRTL_CP_IS_OEM
  249. #   define ISO_TO_INTERN(src, dst)  AnsiToOem(src, dst)
  250. #   define OEM_TO_INTERN(src, dst)  {if ((src) != (dst)) strcpy((dst), (src));}
  251. #   define INTERN_TO_ISO(src, dst)  OemToAnsi(src, dst)
  252. #   define INTERN_TO_OEM(src, dst)  {if ((src) != (dst)) strcpy((dst), (src));}
  253. #  endif
  254. #  define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1)
  255. #  define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1)
  256.    /* UzpPassword supplies ANSI-coded string regardless of C RTL's native CP */
  257. #  define STR_TO_CP2(dst, src)  (AnsiToOem(src, dst), dst)
  258.    /* dummy defines to disable these functions, they are not needed */
  259. #  define STR_TO_ISO
  260. #  define STR_TO_OEM
  261. #else
  262.    /* use home-brewed conversion functions; internal charset is OEM */
  263. #  ifdef CRTL_CP_IS_ISO
  264. #    undef CRTL_CP_IS_ISO
  265. #  endif
  266. #  ifndef CRTL_CP_IS_OEM
  267. #    define CRTL_CP_IS_OEM
  268. #  endif
  269. #endif
  270.  
  271. /* SCREENLINES macros for 16-bit and djgpp compilers */
  272. #ifdef __16BIT__
  273. #  define SCREENLINES (int)(*((unsigned char far*)0x00400084L) + 1)
  274. #  define SCREENWIDTH (int)(*(unsigned short far*)0x0040004AL)
  275. #endif
  276.  
  277. #if defined(__GO32__) || defined(__DJGPP__)    /* djgpp v1.x and v2.x */
  278. #  include <pc.h>
  279. #  define SCREENLINES ScreenRows()
  280. #  define SCREENWIDTH ScreenCols()
  281. #endif
  282.  
  283. #ifdef __EMX__
  284. #  define SCREENLINES screenlines()
  285. #  define SCREENWIDTH screencolumns()
  286.    int screenlines(void);
  287.    int screencolumns(void);
  288. #endif
  289.  
  290. #endif /* !__doscfg_h */
  291.