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