osdep.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
  3. See the accompanying file LICENSE, version 2007-Mar-4 or later
  4. (the contents of which are also included in zip.h) for terms of use.
  5. If, for some reason, all these files are missing, the Info-ZIP license
  6. also may be found at: ftp://ftp.info-zip.org/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. /* Symbolic links are not supported, but some compilers may define S_IFLNK. */
  108. #ifndef NO_SYMLINKS
  109. # define NO_SYMLINKS
  110. #endif
  111. #ifdef MATCH
  112. # undef MATCH
  113. #endif
  114. #define MATCH dosmatch /* use DOS style wildcard matching */
  115. #define USE_CASE_MAP
  116. #define ROUNDED_TIME(time) (((time) + 1) & (~1))
  117. #define PROCNAME(n) (action == ADD || action == UPDATE ? wild(n) : \
  118. procname(n, 1))
  119. #define FOPR "rb"
  120. #define FOPM "r+b"
  121. #define FOPW "wb"
  122. #include <sys/types.h>
  123. #include <sys/stat.h>
  124. #include <io.h>
  125. #ifdef ZCRYPT_INTERNAL
  126. # ifdef WINDLL
  127. # define ZCR_SEED2 (unsigned)3141592654L /* use PI as seed pattern */
  128. # else
  129. # ifndef __GO32__
  130. # include <process.h> /* getpid() declaration for srand seed */
  131. # endif
  132. # endif
  133. #endif
  134. /*
  135. * djgpp 1.x did not declare these
  136. */
  137. #if defined(__GO32__) && !defined(__DJGPP__)
  138. char *strlwr(char *);
  139. int setmode(int, int);
  140. #endif
  141. #ifdef __WATCOMC__
  142. # define NO_MKTEMP
  143. # define HAS_OPENDIR
  144. # define SSTAT stat_bandaid
  145. int stat_bandaid(const char *path, struct stat *buf);
  146. /* Get asm routines to link properly without using "__cdecl": */
  147. # ifdef __386__
  148. # ifdef ASMV
  149. # pragma aux match_init "_*" parm caller [] modify []
  150. # pragma aux longest_match "_*" parm caller [] value [eax] \
  151. modify [eax ecx edx]
  152. # endif
  153. # ifndef USE_ZLIB
  154. # pragma aux crc32 "_*" parm caller [] value [eax] modify [eax]
  155. # pragma aux get_crc_table "_*" parm caller [] value [eax] \
  156. modify [eax ecx edx]
  157. # endif /* !USE_ZLIB */
  158. # else /* !__386__ */
  159. # ifdef ASMV
  160. # pragma aux match_init "_*" parm caller [] loadds modify [ax bx]
  161. # pragma aux longest_match "_*" parm caller [] loadds value [ax] \
  162. modify [ax bx cx dx es]
  163. # endif /* ASMV */
  164. # ifndef USE_ZLIB
  165. # pragma aux crc32 "_*" parm caller [] value [ax dx] \
  166. modify [ax bx cx dx es]
  167. # pragma aux get_crc_table "_*" parm caller [] value [ax] \
  168. modify [ax bx cx dx]
  169. # endif /* !USE_ZLIB */
  170. # endif /* ?__386__ */
  171. #endif /* __WATCOMC__ */
  172. /*
  173. * Wrapper function to get around the MSC7 00:00:00 31 Dec 1899 time base,
  174. * see msdos.c for more info
  175. */
  176. #if defined(_MSC_VER) && _MSC_VER == 700
  177. # define localtime(t) msc7_localtime(t)
  178. #endif
  179. #ifdef __TURBOC__
  180. # ifdef __FILEIO_C
  181. # include <dir.h> /* supplies mktemp() prototype */
  182. # endif
  183. #endif
  184. #if (defined(__TURBOC__) && !defined(__BORLANDC__) && __TURBOC__ <= 0x0201)
  185. # ifndef NO_MKTIME
  186. # define NO_MKTIME /* TC 2.01 and earlier do not supply mktime() */
  187. # endif
  188. #endif
  189. void check_for_windows(char *app);