osdep.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
  3. See the accompanying file LICENSE, version 1999-Oct-05 or later
  4. (the contents of which are also included in zip.h) for terms of use.
  5. If, for some reason, both of these files are missing, the Info-ZIP license
  6. also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
  7. */
  8. /* The symbol DOS is used throughout the Zip source to identify code portions
  9. * specific to the MSDOS port.
  10. * Just to make sure, we check that it is set.
  11. * (Currently, this should should not be neccessary, since currently it has
  12. * to be set on the compiler command line to get this file read in.)
  13. */
  14. #ifndef DOS
  15. # define DOS
  16. #endif
  17. /* The symbol MSDOS is consistently used in the generic source files
  18. * to identify code to support for MSDOS (and MSDOS related) stuff.
  19. * e.g: FAT or (FAT like) file systems,
  20. * '\\' as directory separator in paths,
  21. * "\r\n" as record (line) terminator in text files, ...
  22. *
  23. * IMPORTANT Note:
  24. * This symbol is not unique for the MSDOS port !!!!!!
  25. * It is also defined by ports to some other OS which are (to some extend)
  26. * considered DOS compatible.
  27. * Examples are: OS/2 (OS2), Windows NT and Windows 95 (WIN32).
  28. *
  29. */
  30. #ifndef MSDOS
  31. # define MSDOS
  32. #endif
  33. /* Power C is similar to Turbo C */
  34. #ifdef __POWERC
  35. # define __TURBOC__
  36. #endif /* __POWERC */
  37. /* Automatic setting of the common Microsoft C idenfifier MSC.
  38. * NOTE: Watcom also defines M_I*86 !
  39. */
  40. #if defined(_MSC_VER) || (defined(M_I86) && !defined(__WATCOMC__))
  41. # ifndef MSC
  42. # define MSC /* This should work for older MSC, too! */
  43. # endif
  44. #endif
  45. #if !defined(__GO32__) && !defined(__EMX__)
  46. # define NO_UNISTD_H
  47. #endif
  48. #if defined(__WATCOMC__) && defined(__386__)
  49. # define WATCOMC_386
  50. #endif
  51. #ifdef WINDLL
  52. # define MSWIN
  53. # define MEMORY16
  54. #endif
  55. #if !defined(__EMX__) && !defined(__GO32__) && !defined(WATCOMC_386)
  56. #if !defined(WINDLL)
  57. # define MSDOS16 /* 16 bit MSDOS only */
  58. # define MEMORY16
  59. #endif
  60. #endif
  61. #if !defined(NO_ASM) && !defined(ASMV)
  62. # define ASMV
  63. #endif
  64. /* enable creation of UTC time fields unless explicitely suppressed */
  65. #if !defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME)
  66. # define USE_EF_UT_TIME
  67. #endif
  68. /* check that TZ environment variable is defined before using UTC times */
  69. #if (!defined(NO_IZ_CHECK_TZ) && !defined(IZ_CHECK_TZ))
  70. # define IZ_CHECK_TZ
  71. #endif
  72. #ifdef MEMORY16
  73. # ifndef NO_ASM
  74. # define ASM_CRC 1
  75. # endif /* ?NO_ASM */
  76. # ifdef __TURBOC__
  77. # include <alloc.h>
  78. # if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
  79. # if defined(DYNAMIC_CRC_TABLE) && defined(DYNALLOC_CRCTAB)
  80. error: No dynamic CRC table allocation with Borland C far data models.
  81. # endif /* DYNAMIC_CRC_TABLE */
  82. # endif /* Turbo/Borland C far data memory models */
  83. # define nearmalloc malloc
  84. # define nearfree free
  85. # define DYN_ALLOC
  86. # else /* !__TURBOC__ */
  87. # include <malloc.h>
  88. # define nearmalloc _nmalloc
  89. # define nearfree _nfree
  90. # define farmalloc _fmalloc
  91. # define farfree _ffree
  92. # endif /* ?__TURBOC__ */
  93. # define MY_ZCALLOC 1
  94. # ifdef SMALL_MEM
  95. # define CBSZ 2048
  96. # define ZBSZ 2048
  97. # endif
  98. # ifdef MEDIUM_MEM
  99. # define CBSZ 4096
  100. # define ZBSZ 4096
  101. # endif
  102. # ifndef CBSZ
  103. # define CBSZ 8192
  104. # define ZBSZ 8192
  105. # endif
  106. #endif /* MEMORY16 */
  107. #ifdef MATCH
  108. # undef MATCH
  109. #endif
  110. #define MATCH dosmatch /* use DOS style wildcard matching */
  111. #define USE_CASE_MAP
  112. #define ROUNDED_TIME(time) (((time) + 1) & (~1))
  113. #define PROCNAME(n) (action == ADD || action == UPDATE ? wild(n) : \
  114. procname(n, 1))
  115. #define FOPR "rb"
  116. #define FOPM "r+b"
  117. #define FOPW "wb"
  118. #include <sys/types.h>
  119. #include <sys/stat.h>
  120. #include <io.h>
  121. #ifdef ZCRYPT_INTERNAL
  122. # ifdef WINDLL
  123. # define ZCR_SEED2 (unsigned)3141592654L /* use PI as seed pattern */
  124. # else
  125. # ifndef __GO32__
  126. # include <process.h> /* getpid() declaration for srand seed */
  127. # endif
  128. # endif
  129. #endif
  130. /*
  131. * djgpp 1.x did not declare these
  132. */
  133. #if defined(__GO32__) && !defined(__DJGPP__)
  134. char *strlwr(char *);
  135. int setmode(int, int);
  136. #endif
  137. #ifdef __WATCOMC__
  138. # define NO_MKTEMP
  139. # define HAS_OPENDIR
  140. # define SSTAT stat_bandaid
  141. int stat_bandaid(const char *path, struct stat *buf);
  142. /* Get asm routines to link properly without using "__cdecl": */
  143. # ifdef __386__
  144. # ifdef ASMV
  145. # pragma aux match_init "_*" parm caller [] modify []
  146. # pragma aux longest_match "_*" parm caller [] value [eax] \
  147. modify [eax ecx edx]
  148. # endif
  149. # ifndef USE_ZLIB
  150. # pragma aux crc32 "_*" parm caller [] value [eax] modify [eax]
  151. # pragma aux get_crc_table "_*" parm caller [] value [eax] \
  152. modify [eax ecx edx]
  153. # endif /* !USE_ZLIB */
  154. # else /* !__386__ */
  155. # ifdef ASMV
  156. # pragma aux match_init "_*" parm caller [] loadds modify [ax bx]
  157. # pragma aux longest_match "_*" parm caller [] loadds value [ax] \
  158. modify [ax bx cx dx es]
  159. # endif /* ASMV */
  160. # ifndef USE_ZLIB
  161. # pragma aux crc32 "_*" parm caller [] value [ax dx] \
  162. modify [ax bx cx dx es]
  163. # pragma aux get_crc_table "_*" parm caller [] value [ax] \
  164. modify [ax bx cx dx]
  165. # endif /* !USE_ZLIB */
  166. # endif /* ?__386__ */
  167. #endif /* __WATCOMC__ */
  168. /*
  169. * Wrapper function to get around the MSC7 00:00:00 31 Dec 1899 time base,
  170. * see msdos.c for more info
  171. */
  172. #if defined(_MSC_VER) && _MSC_VER == 700
  173. # define localtime(t) msc7_localtime(t)
  174. #endif
  175. #if (defined(__TURBOC__) && !defined(__BORLANDC__) && __TURBOC__ <= 0x0201)
  176. # ifndef NO_MKTIME
  177. # define NO_MKTIME /* TC 2.01 and earlier do not supply mktime() */
  178. # endif
  179. #endif