home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / src / zip19 / tailor.h < prev    next >
C/C++ Source or Header  |  1992-08-26  |  7KB  |  286 lines

  1. /* tailor.h -- Not copyrighted 1992 Mark Adler */
  2.  
  3. /* const's are inconsistently used across ANSI libraries--kill for all
  4.    header files. */
  5. #define const
  6.  
  7.  
  8. /* Define MSDOS for Turbo C as well as Microsoft C */
  9. #ifdef __POWERC                 /* For Power C too */
  10. #  define __TURBOC__
  11. #endif /* __POWERC */
  12. #if (defined(__TURBOC__) && !defined(MSDOS))
  13. #  define MSDOS
  14. #endif
  15.  
  16. #ifdef ATARI_ST
  17. #  undef MSDOS   /* avoid the MS-DOS specific includes */
  18. #endif
  19.  
  20. /* Use prototypes and ANSI libraries if _STDC__, or Microsoft or Borland C,
  21.  * or Silicon Graphics, or IBM C Set/2, or GNU gcc under emx.
  22.  */
  23. #if (defined(__STDC__) || defined(MSDOS) || defined(sgi))
  24. #  ifndef PROTO
  25. #    define PROTO
  26. #  endif /* !PROTO */
  27. #  define MODERN
  28. #endif /* MSDOS */
  29.  
  30. #if (defined(__IBMC__) || defined(__EMX__) || defined(ATARI_ST))
  31. #  ifndef PROTO
  32. #    define PROTO
  33. #  endif /* !PROTO */
  34. #  define MODERN
  35. #endif
  36.  
  37.  
  38. #ifdef __IBMC__
  39. #  define S_IFMT 0xF000
  40. #endif /* __IBMC__ */
  41.  
  42. #ifdef __EMX__
  43. #  define __32BIT__
  44. #endif /* __EMX__ */
  45.  
  46. #ifdef __WATCOMC__
  47. #  define __32BIT__
  48. #endif
  49.  
  50. #if (defined(__OS2__) && !defined(OS2))
  51. #  define OS2
  52. #endif
  53.  
  54. #ifdef __convexc__
  55. #    define CONVEX
  56. #endif /* __convexc__ */
  57.  
  58. /* Turn off prototypes if requested */
  59. #if (defined(NOPROTO) && defined(PROTO))
  60. #  undef PROTO
  61. #endif
  62.  
  63.  
  64. /* Used to remove arguments in function prototypes for non-ANSI C */
  65. #ifdef PROTO
  66. #  define OF(a) a
  67. #else /* !PROTO */
  68. #  define OF(a) ()
  69. #endif /* ?PROTO */
  70.  
  71.  
  72. /* Memory allocation. */
  73. #ifdef MACOS
  74. #  define DYN_ALLOC
  75. #endif
  76. #if (defined(MSDOS) && !defined(__GO32__) && !defined(WIN32))
  77. #  ifdef __TURBOC__
  78. #    include <alloc.h>
  79. #    define DYN_ALLOC
  80.      /* Turbo C 2.0 does not accept far static allocations in small model */
  81.      void far * fcalloc OF((unsigned items, unsigned size));
  82. #  else /* !__TURBOC__ */
  83. #    include <malloc.h>
  84. #    define farmalloc _fmalloc
  85. #    define farfree   _ffree
  86. #    define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize))
  87. #  endif /* ?__TURBOC__ */
  88. #else /* !MSDOS */
  89. #  if defined(WIN32)
  90. #    include <malloc.h>
  91. #  endif
  92. #  ifdef far
  93. #    undef huge
  94. #    undef far
  95. #    undef near
  96. #  endif
  97. #  define huge
  98. #  define far
  99. #  define near
  100. #  define farmalloc malloc
  101. #  define farfree   free
  102. #  define fcalloc(items,size) calloc((unsigned)(items), (unsigned)(size))
  103. #  ifndef PROTO
  104.      extern char *calloc(); /* essential for 16 bit systems (AT&T 6300) */
  105. #  endif
  106. #endif /* ?MSDOS */
  107.  
  108.  
  109. #if (defined(OS2) && !defined(MSDOS))
  110. /* MSDOS is defined anyway with MS C 16-bit. So the block above works.
  111.  * For the 32-bit compilers, MSDOS must not be defined in the block above. */
  112. #  define MSDOS
  113. /* inherit MS-DOS file system etc. stuff */
  114. #endif
  115.     
  116.  
  117. /* Define MSVMS if either MSDOS or VMS defined */
  118. #if defined(MSDOS) || defined(VMS)
  119. #  define MSVMS
  120. #endif
  121.  
  122. /* case mapping functions. case_map is used to ignore case in comparisons,
  123.  * to_up is used to force upper case even on Unix (for dosify option).
  124.  */
  125. #if defined(OS2) || defined(MSDOS) || defined(VMS)
  126. #  define case_map(c) upper[c]
  127. #  define to_up(c)    upper[c]
  128. #else
  129. #  define case_map(c) (c)
  130. #  define to_up(c)    ((c) >= 'a' && (c) <= 'z' ? (c)-'a'+'A' : (c))
  131. #endif
  132.  
  133. /* Define void, voidp, and extent (size_t) */
  134. #include <stdio.h>
  135. #ifdef MODERN
  136. #  if (!defined(M_XENIX) && !(defined(__GNUC__) && defined(sun)))
  137. #    include <stddef.h>
  138. #  endif /* !M_XENIX */
  139. #  include <stdlib.h>
  140.    typedef size_t extent;
  141.    typedef void voidp;
  142. #else /* !MODERN */
  143.    typedef unsigned int extent;
  144. #  define void int
  145.    typedef char voidp;
  146. #endif /* ?MODERN */
  147.  
  148. /* Get types and stat */
  149. #ifdef VMS
  150. #  include <types.h>
  151. #  include <stat.h>
  152. #else /* !VMS */
  153. #  ifdef MACOS
  154. #    include <types.h>
  155. #    include <stddef.h>
  156. #    include <Files.h>
  157. #    include <StandardFile.h>
  158. #    include <Think.h>
  159. #    include <LoMem.h>
  160. #    include <Pascal.h>
  161. #    include "macstat.h"
  162. #  else
  163. #    ifdef ATARI_ST
  164. #      include <ext.h>
  165. #      include <tos.h>
  166. #    else
  167. #      include <sys/types.h>
  168. #      include <sys/stat.h>
  169. #    endif
  170. #  endif
  171. #endif /* ?VMS */
  172.  
  173. /* Some systems define S_IFLNK but do not support symbolic links */
  174. #if defined (S_IFLNK) && (defined(NO_SYMLINK) || defined(MACOS))
  175. #  undef S_IFLNK
  176. #endif
  177.  
  178. /* Cheap fix for unlink on VMS */
  179. #ifdef VMS
  180. #  define unlink delete
  181. #endif /* VMS */
  182.  
  183.  
  184. /* For Pyramid */
  185. #ifdef pyr
  186. #  define strrchr rindex
  187. #  define ZMEM
  188. #endif /* pyr */
  189.  
  190.  
  191. /* File operations--use "b" for binary if allowed or fixed length 512 on VMS */
  192. #ifdef VMS
  193. #  define FOPR  "r","ctx=stm"
  194. #  define FOPM  "r+","ctx=stm","rfm=fix","mrs=512"
  195. #  define FOPW  "w","ctx=stm","rfm=fix","mrs=512"
  196. #else /* !VMS */
  197. #  ifdef MODERN
  198. #    define FOPR "rb"
  199. #    define FOPM "r+b"
  200. #    define FOPW "wb"
  201. #  else /* !MODERN */
  202. #    define FOPR "r"
  203. #    define FOPM "r+"
  204. #    define FOPW "w"
  205. #  endif /* ?MODERN */
  206. #endif /* VMS */
  207.  
  208. /* Open the old zip file in exclusive mode if possible (to avoid adding
  209.  * zip file to itself).
  210.  */
  211. #ifdef OS2
  212. #  define FOPR_EX FOPM
  213. #else
  214. #  define FOPR_EX FOPR
  215. #endif
  216.  
  217. /* Define this symbol if your target allows access to unaligned data.
  218.  * This is not mandatory, just a speed optimization. The compressed
  219.  * output is strictly identical.
  220.  */
  221. #if defined(MSDOS) || defined(i386) || defined(mc68020) || defined(vax)
  222. #   define UNALIGNED_OK
  223. #endif
  224.  
  225.  
  226. /* Under MSDOS we may run out of memory when processing a large number
  227.  * of files. Compile with MEDIUM_MEM to reduce the memory requirements or
  228.  * with SMALL_MEM to use as little memory as possible.
  229.  */
  230. #ifdef SMALL_MEM
  231. #   define CBSZ 2048 /* buffer size for copying files */
  232. #   define ZBSZ 2048 /* buffer size for temporary zip file */
  233. #else
  234. # ifdef MEDIUM_MEM
  235. #   define CBSZ 8192
  236. #   define ZBSZ 8192
  237. # else
  238. #  if defined(OS2) && !defined(M_I86SM)
  239. #   define CBSZ 0xE000
  240. #   define ZBSZ 0x7F00
  241.     /* The C library of some compilers does not allow a buffer size > 32K */
  242. #  else
  243. #   define CBSZ 16384
  244. #   define ZBSZ 16384
  245. #  endif
  246. # endif
  247. #endif
  248.  
  249. #ifdef ATARI_ST
  250. #  define MSDOS
  251. #  define MSVMS
  252. #  ifndef O_BINARY
  253. #    define O_BINARY 0
  254. #  endif
  255. #  ifndef S_IFMT
  256. #    define S_IFMT        (S_IFCHR|S_IFREG|S_IFDIR)
  257. #  endif
  258.  
  259. /* a whole bunch of functions needs Tos '\\' filnames
  260.  * instead of '/',  the translation functions are in fileio.c:
  261.  */
  262. #  define unlink    st_unlink
  263. #  define chmod     st_chmod
  264. #  define mktemp    st_mktemp
  265. #  define fopen     st_fopen
  266. #  define open      st_open
  267. #  define SSTAT     st_stat
  268. #  define findfirst st_findfirst
  269. #  define link      st_rename
  270. #  define rmdir     st_rmdir
  271.  
  272.   int st_unlink    OF((char *));
  273.   int st_chmod     OF((char *, int));
  274.   char *st_mktemp  OF((char *));
  275.   FILE *st_fopen   OF((char *, char *));
  276.   int st_open      OF((char *, int));
  277.   int st_stat      OF((char *, struct stat *));
  278.   int st_findfirst OF((char *, struct ffblk *, int));
  279.   int st_rename    OF((char *, char *));
  280.   int st_rmdir     OF((char *));
  281. #else
  282. #  define SSTAT      stat
  283. #endif
  284.    
  285. /* end of tailor.h */
  286.