home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip531.zip / msdos / doscfg.h < prev    next >
C/C++ Source or Header  |  1997-02-20  |  8KB  |  242 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. #  undef SSTAT
  27. #  define SSTAT stat_bandaid
  28.    int stat_bandaid(const char *path, struct stat *buf);
  29.  
  30. #  ifdef __386__
  31. #    ifndef WATCOMC_386
  32. #      define WATCOMC_386
  33. #    endif
  34. #    define __32BIT__
  35. #    undef far
  36. #    define far
  37. #    undef near
  38. #    define near
  39.  
  40. /* Get asm routines to link properly without using "__cdecl": */
  41. #    ifndef USE_ZLIB
  42. #      pragma aux crc32         "_*" parm caller [] value [eax] modify [eax]
  43. #      pragma aux get_crc_table "_*" parm caller [] value [eax] \
  44.                                       modify [eax ecx edx]
  45. #    endif /* !USE_ZLIB */
  46. #  else /* !__386__ */
  47. #    ifndef USE_ZLIB
  48. #      pragma aux crc32         "_*" parm caller [] value [ax dx] \
  49.                                       modify [ax cx dx bx]
  50. #      pragma aux get_crc_table "_*" parm caller [] value [ax] \
  51.                                       modify [ax cx dx bx]
  52. #    endif /* !USE_ZLIB */
  53. #  endif /* ?__386__ */
  54.  
  55. #  ifndef EPIPE
  56. #    define EPIPE -1
  57. #  endif
  58. #  define PIPE_ERROR (errno == EPIPE)
  59. #endif /* __WATCOMC__ */
  60.  
  61. #ifdef __EMX__
  62. #  ifndef __32BIT__
  63. #    define __32BIT__
  64. #  endif
  65. #  define far
  66. #endif
  67.  
  68. #if defined(__GO32__) || defined(__DJGPP__)    /* MS-DOS compiler, not OS/2 */
  69. #  ifndef __32BIT__
  70. #    define __32BIT__
  71. #  endif
  72. #  ifndef __GO32__
  73. #    define __GO32__
  74. #  endif
  75. #  include <sys/timeb.h>           /* for structure ftime */
  76. #  if (defined(__DJGPP__) && (__DJGPP__ > 1))
  77. #    include <unistd.h>            /* for prototypes for read/write etc. */
  78. #    include <dir.h>               /* for FA_LABEL */
  79. #    if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ == 0))
  80. #      include <libc/dosio.h>      /* for _USE_LFN, djgpp 2.0 only */
  81. #    endif
  82. #    define USE_LFN _USE_LFN       /* runtime test:  support long filenames? */
  83. #  else
  84.      int setmode(int, int);        /* not in older djgpp's include files */
  85. #  endif
  86. #endif
  87.  
  88. #ifndef __32BIT__
  89. #  define __16BIT__
  90. #endif
  91.  
  92. #if (defined(M_I86CM) || defined(M_I86LM)) || defined(WINDLL)
  93. #  define MED_MEM
  94. #endif
  95. #if (defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__))
  96. #  define MED_MEM
  97. #endif
  98. #ifdef __16BIT__
  99. #  ifndef MED_MEM
  100. #    define SMALL_MEM
  101. #  endif
  102. #endif
  103.  
  104. #define EXE_EXTENSION ".exe"  /* OS/2 has GetLoadPath() function instead */
  105.  
  106. #ifdef __16BIT__
  107. #  if defined(MSC) || defined(__WATCOMC__)
  108. #    include <malloc.h>
  109. #    define nearmalloc _nmalloc
  110. #    define nearfree _nfree
  111. #  endif
  112. #  if defined(__TURBOC__) && defined(DYNALLOC_CRCTAB)
  113. #    if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
  114. #      undef DYNALLOC_CRCTAB
  115. #    endif
  116. #  endif
  117. #  ifndef nearmalloc
  118. #    define nearmalloc malloc
  119. #    define nearfree free
  120. #  endif
  121. #  if defined(USE_ZLIB) && !defined(USE_OWN_CRCTAB)
  122. #    define USE_OWN_CRCTAB
  123. #  endif
  124. #endif
  125.  
  126.  
  127. /* another stat()/fopen() bug with some 16-bit compilers on Novell drives;
  128.  * very dangerous (silently overwrites executables in other directories)
  129.  */
  130. #define NOVELL_BUG_WORKAROUND
  131.  
  132. /* enables additional test and message code that directs UnZip to fail safely
  133.  * in case the "workaround" enabled above does not work as intended
  134.  */
  135. #define NOVELL_BUG_FAILSAFE
  136.  
  137.  
  138. /* The optional "long filename" support available with some MSDOS compiler
  139.  * environment running under VFAT systems (Win95) is controlled with the
  140.  * help of the two preprocessor symbols USE_VFAT and USE_LFN:
  141.  *  - USE_VFAT is a compile time switch that selects the long filename
  142.  *             semantics in mapname()
  143.  *  - USE_LFN  is a macro equating to a boolean expression indicating
  144.  *             whether long filenames are supported. If available, this
  145.  *             macro should make use of a runtime function checking the
  146.  *             LFN support.
  147.  *
  148.  * The code in msdos.c distinguishes three cases:
  149.  * 1.) USE_VFAT is not defined:
  150.  *     No support of LFN is included; filenames are mapped to 8+3 plain FAT
  151.  *     syntax unconditionally.
  152.  *     This is achieved by ``#define MAYBE_PLAIN_FAT'' to include the plain
  153.  *     FAT name mapping code and by ``#undef USE_LFN'' to disable bypassing
  154.  *     of the FAT mapping at runtime.
  155.  * 2.) USE_VFAT is defined:
  156.  *     Support for LFN is enabled.
  157.  *  a) USE_LFN is undefined:
  158.  *     There is no (runtime) check available to distinguish between OS
  159.  *     environments that support VFAT extensions and those that do not.
  160.  *     In this case, filenames are mapped to the more liberal VFAT LFN
  161.  *     syntax unconditionally. The internal switch MAYBE_PLAIN_FAT remains
  162.  *     undefined to exclude to "map to plain FAT" code parts.
  163.  *  b) USE_LFN is defined (hopefully to a boolean runtime LFN check function):
  164.  *     "#define MAYBE_PLAIN_FAT" is applied to include the plain FAT mapping
  165.  *     code; the programs checks at runtime whether the OS supports LFN and
  166.  *     uses the appropiate mapping syntax.
  167.  */
  168. /* Some environments, like DJGPP v2, can support long filenames on VFAT
  169.  * systems and DOS 8.3 filenames on FAT systems in the same executable.  If
  170.  * such support is available, USE_LFN should be defined to an expression
  171.  * that will return non-zero when long filenames API should be used, zero
  172.  * otherwise.
  173.  */
  174. #ifndef USE_VFAT
  175. #  ifdef USE_LFN
  176. #    undef USE_LFN
  177. #  endif
  178. #  ifndef MAYBE_PLAIN_FAT
  179. #    define MAYBE_PLAIN_FAT
  180. #  endif
  181. #endif
  182. #ifdef USE_LFN
  183. #  define MAYBE_PLAIN_FAT
  184. #endif
  185.  
  186. /* handlers for OEM <--> ANSI string conversions */
  187. #ifdef WINDLL
  188. #  if 1
  189.      /* C RTL's file system support assumes OEM-coded strings */
  190. #    ifdef CRTL_CP_IS_ISO
  191. #      undef CRTL_CP_IS_ISO
  192. #    endif
  193. #    ifndef CRTL_CP_IS_OEM
  194. #      define CRTL_CP_IS_OEM
  195. #    endif
  196. #  else
  197.      /* C RTL's file system support assumes ISO-coded strings */
  198. #    ifndef CRTL_CP_IS_ISO
  199. #      define CRTL_CP_IS_ISO
  200. #    endif
  201. #    ifdef CRTL_CP_IS_OEM
  202. #      undef CRTL_CP_IS_OEM
  203. #    endif
  204. #  endif /* ?(code page of 16bit Windows compilers) */
  205.    /* include Win API declarations only in sources where conversion is
  206.     * actually used (skip EXTRACT_C, extract.c includes windll.h instead)
  207.     */
  208. #  if defined(ENVARGS_C) || defined(UNZIP_C) || defined(ZCRYPT_INTERNAL)
  209. #    include <windows.h>
  210. #  endif
  211.    /* use conversion functions of Windows API */
  212. #  ifdef CRTL_CP_IS_ISO
  213. #   define ISO_TO_INTERN(src, dst)  {if ((src) != (dst)) strcpy((dst), (src));}
  214. #   define OEM_TO_INTERN(src, dst)  OemToAnsi(src, dst)
  215. #   define INTERN_TO_ISO(src, dst)  {if ((src) != (dst)) strcpy((dst), (src));}
  216. #   define INTERN_TO_OEM(src, dst)  AnsiToOem(src, dst)
  217. #  endif
  218. #  ifdef CRTL_CP_IS_OEM
  219. #   define ISO_TO_INTERN(src, dst)  AnsiToOem(src, dst)
  220. #   define OEM_TO_INTERN(src, dst)  {if ((src) != (dst)) strcpy((dst), (src));}
  221. #   define INTERN_TO_ISO(src, dst)  OemToAnsi(src, dst)
  222. #   define INTERN_TO_OEM(src, dst)  {if ((src) != (dst)) strcpy((dst), (src));}
  223. #  endif
  224. #  define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1)
  225. #  define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1)
  226.    /* UzpPassword supplies ANSI-coded string regardless of C RTL's native CP */
  227. #  define STR_TO_CP2(dst, src)  (AnsiToOem(src, dst), dst)
  228.    /* dummy defines to disable these functions, they are not needed */
  229. #  define STR_TO_ISO
  230. #  define STR_TO_OEM
  231. #else
  232.    /* use home-brewed conversion functions; internal charset is OEM */
  233. #  ifdef CRTL_CP_IS_ISO
  234. #    undef CRTL_CP_IS_ISO
  235. #  endif
  236. #  ifndef CRTL_CP_IS_OEM
  237. #    define CRTL_CP_IS_OEM
  238. #  endif
  239. #endif
  240.  
  241. #endif /* !__doscfg_h */
  242.