home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / zip201.zip / tailor.h < prev    next >
C/C++ Source or Header  |  1993-09-10  |  10KB  |  404 lines

  1. /* tailor.h -- Not copyrighted 1993 Mark Adler */
  2.  
  3. /* Define MSDOS for Turbo C and Power C */
  4. #ifdef __POWERC
  5. #  define __TURBOC__
  6. #  define MSDOS
  7. #endif /* __POWERC */
  8.  
  9. #if (defined(__MSDOS__) && !defined(MSDOS))
  10. #  define MSDOS
  11. #endif
  12.  
  13. #ifdef ATARI_ST
  14. #  undef MSDOS   /* avoid the MS-DOS specific includes */
  15. #endif
  16.  
  17. /* Use prototypes and ANSI libraries if _STDC__, or Microsoft or Borland C,
  18.  * or Silicon Graphics, or IBM C Set/2, or Watcom C, or GNU gcc under emx.
  19.  */
  20. #if defined(__STDC__) || defined(MSDOS) || defined(ATARI_ST) || defined(sgi)
  21. #  ifndef PROTO
  22. #    define PROTO
  23. #  endif /* !PROTO */
  24. #  define MODERN
  25. #endif
  26.  
  27. #if defined(__IBMC__) || defined(__EMX__) || defined(__WATCOMC__)
  28. #  ifndef PROTO
  29. #    define PROTO
  30. #  endif /* !PROTO */
  31. #  define MODERN
  32. #endif
  33.  
  34. #if defined(__BORLANDC__) || (defined(__alpha) && defined(VMS))
  35. #  ifndef PROTO
  36. #    define PROTO
  37. #  endif /* !PROTO */
  38. #  define MODERN
  39. #endif
  40.  
  41. #ifdef __IBMC__
  42. #  define S_IFMT 0xF000
  43. #endif /* __IBMC__ */
  44.  
  45. #if defined(__EMX__) || defined(__WATCOMC__) || defined(__BORLANDC__)
  46. #  if (defined(OS2) && !defined(__32BIT__))
  47. #    define __32BIT__
  48. #  endif
  49. #endif
  50.  
  51. #if (defined(__OS2__) && !defined(OS2))
  52. #  define OS2
  53. #endif
  54.  
  55. #ifdef __convexc__
  56. #       define CONVEX
  57. #endif /* __convexc__ */
  58.  
  59. #ifdef __COMPILER_KCC__
  60. #  define TOPS20
  61. #  define NOPROTO
  62. #  define NO_SYMLINK
  63. #  define NO_TERMIO
  64. #  define DIRENT
  65. #  define BIG_MEM
  66.   extern int isatty();
  67. # define window_size winsiz
  68. #endif
  69.  
  70. /* Turn off prototypes if requested */
  71. #if (defined(NOPROTO) && defined(PROTO))
  72. #  undef PROTO
  73. #endif
  74.  
  75. /* Used to remove arguments in function prototypes for non-ANSI C */
  76. #ifdef PROTO
  77. #  define OF(a) a
  78. #else /* !PROTO */
  79. #  define OF(a) ()
  80. #endif /* ?PROTO */
  81.  
  82. /* Avoid using const if compiler does not support it */
  83. #ifndef MODERN  /* if this fails, try: ifndef__STDC__ */
  84. #  define const
  85. #endif
  86.  
  87. #ifdef MACOS
  88. #  define DYN_ALLOC
  89. #endif
  90. #if (defined(MSDOS) && !defined(__GO32__) && !defined(WIN32))
  91. #  ifdef __TURBOC__
  92. #    include <alloc.h>
  93. #    define DYN_ALLOC
  94.      /* Turbo C 2.0 does not accept static allocations of large arrays */
  95.      void far * fcalloc OF((unsigned items, unsigned size));
  96.      void fcfree (void *ptr);
  97. #  else /* !__TURBOC__ */
  98. #    include <malloc.h>
  99. #    define farmalloc _fmalloc
  100. #    define farfree   _ffree
  101. #    define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize))
  102. #    define fcfree(ptr) hfree((void huge *)(ptr))
  103. #  endif /* ?__TURBOC__ */
  104. #else /* !MSDOS */
  105. #  if defined(WIN32)
  106. #    include <malloc.h>
  107. #  endif
  108. #  ifdef __WATCOMC__
  109. #    undef huge
  110. #    undef far
  111. #    undef near
  112. #  endif
  113. #  ifndef __IBMC__
  114. #    define huge
  115. #    define far
  116. #    define near
  117. #  endif
  118. #  define farmalloc malloc
  119. #  define farfree   free
  120. #  define fcalloc(items,size) calloc((unsigned)(items), (unsigned)(size))
  121. #  define fcfree    free
  122. #  if (!defined(PROTO) && !defined(TOPS20))
  123.      extern char *calloc(); /* essential for 16 bit systems (AT&T 6300) */
  124. #  endif
  125. #endif /* ?MSDOS */
  126.  
  127.  
  128. #if (defined(OS2) && !defined(MSDOS))
  129. /* MSDOS is defined anyway with MS C 16-bit. So the block above works.
  130.  * For the 32-bit compilers, MSDOS must not be defined in the block above. */
  131. #  define MSDOS
  132. /* inherit MS-DOS file system etc. stuff */
  133. #endif
  134.     
  135.  
  136. /* Define MSVMS if MSDOS or VMS defined -- ATARI also does, Amiga could */
  137. #if defined(MSDOS) || defined(VMS)
  138. #  define MSVMS
  139. #endif
  140.  
  141. /* case mapping functions. case_map is used to ignore case in comparisons,
  142.  * to_up is used to force upper case even on Unix (for dosify option).
  143.  */
  144. #if defined(MSDOS) || defined(VMS) || defined(OS2) || defined(WIN32) || defined(AMIGA)
  145. #  define case_map(c) upper[(c) & 0xff]
  146. #  define to_up(c)    upper[(c) & 0xff]
  147. #else
  148. #  define case_map(c) (c)
  149. #  define to_up(c)    ((c) >= 'a' && (c) <= 'z' ? (c)-'a'+'A' : (c))
  150. #endif
  151.  
  152. /* Define void, voidp, and extent (size_t) */
  153. #include <stdio.h>
  154. #ifdef MODERN
  155. #  if (!defined(M_XENIX) && !(defined(__GNUC__) && defined(sun)))
  156. #    include <stddef.h>
  157. #  endif /* !M_XENIX */
  158. #  include <stdlib.h>
  159. #  if defined(SYSV) || defined(__386BSD__)
  160. #    include <unistd.h>
  161. #  endif
  162.    typedef size_t extent;
  163.    typedef void voidp;
  164. #else /* !MODERN */
  165.    typedef unsigned int extent;
  166. #  define void int
  167.    typedef char voidp;
  168. #endif /* ?MODERN */
  169.  
  170. /* Get types and stat */
  171. #ifdef VMS
  172. #  include <types.h>
  173. #  include <stat.h>
  174. #  define unlink delete
  175. #  define NO_SYMLINK
  176. #  define SSTAT vms_stat
  177. #else /* !VMS */
  178. #  ifdef MACOS
  179. #    include <types.h>
  180. #    include <stddef.h>
  181. #    include <Files.h>
  182. #    include <StandardFile.h>
  183. #    include <Think.h>
  184. #    include <LoMem.h>
  185. #    include <Pascal.h>
  186. #    include "macstat.h"
  187. #    define NO_SYMLINK
  188. #  else
  189. #    ifdef ATARI_ST
  190. #      include <ext.h>
  191. #      include <tos.h>
  192. #    else
  193. #      ifdef AMIGA
  194.          int wild OF((char *));
  195.          /* default to MEDIUM_MEM, but allow makefile override */
  196. #        if ( (!defined(BIG_MEM)) && (!defined(SMALL_MEM)))
  197. #           define MEDIUM_MEM
  198. #        endif
  199. #        if defined(LATTICE) || defined(__SASC)
  200. #        include <sys/types.h>
  201. #          include <sys/stat.h>
  202.            extern int isatty(int);   /* SAS has no unistd.h */
  203. #      endif
  204. #        ifdef AZTEC_C
  205. #          include "amiga/z-stat.h"
  206. #          define RMDIR
  207. #        endif
  208. #      else /* !AMIGA */
  209. #        include <sys/types.h>
  210. #      include <sys/stat.h>
  211. #    endif
  212. #  endif
  213. #  endif
  214. #endif /* ?VMS */
  215.  
  216. /* Some systems define S_IFLNK but do not support symbolic links */
  217. #if defined (S_IFLNK) && defined(NO_SYMLINK)
  218. #  undef S_IFLNK
  219. #endif
  220.  
  221.  
  222. /* For Pyramid */
  223. #ifdef pyr
  224. #  define strrchr rindex
  225. #  define ZMEM
  226. #endif /* pyr */
  227.  
  228.  
  229. /* File operations--use "b" for binary if allowed or fixed length 512 on VMS */
  230. #ifdef VMS
  231. #  define FOPR  "r","ctx=stm"
  232. #  define FOPM  "r+","ctx=stm","rfm=fix","mrs=512"
  233. #  define FOPW  "w","ctx=stm","rfm=fix","mrs=512"
  234. #else /* !VMS */
  235. #  if defined(MODERN)
  236. #    define FOPR "rb"
  237. #    define FOPM "r+b"
  238. #    ifdef TOPS20 /* TOPS20 MODERN? You kidding? */
  239. #      define FOPW "w8"
  240. #    else
  241. #      define FOPW "wb"
  242. #    endif
  243. #  else /* !MODERN */
  244. #    ifdef AMIGA
  245. #      define FOPR "rb"
  246. #      define FOPM "rb+"
  247. #      define FOPW "wb"
  248. #    else /* !AMIGA */
  249. #    define FOPR "r"
  250. #    define FOPM "r+"
  251. #    define FOPW "w"
  252. #    endif /* ?AMIGA */
  253. #  endif /* ?MODERN */
  254. #endif /* VMS */
  255.  
  256. /* Open the old zip file in exclusive mode if possible (to avoid adding
  257.  * zip file to itself).
  258.  */
  259. #ifdef OS2
  260. #  define FOPR_EX FOPM
  261. #else
  262. #  define FOPR_EX FOPR
  263. #endif
  264.  
  265. /* Define this symbol if your target allows access to unaligned data.
  266.  * This is not mandatory, just a speed optimization. The compressed
  267.  * output is strictly identical.
  268.  */
  269. #if (defined(MSDOS) && !defined(WIN32)) || defined(i386)
  270. #    define UNALIGNED_OK
  271. #endif
  272. #if defined(mc68020) || defined(vax)
  273. #    define UNALIGNED_OK
  274. #endif
  275.  
  276. /* Under MSDOS we may run out of memory when processing a large number
  277.  * of files. Compile with MEDIUM_MEM to reduce the memory requirements or
  278.  * with SMALL_MEM to use as little memory as possible.
  279.  */
  280. #ifdef SMALL_MEM
  281. #   define CBSZ 2048 /* buffer size for copying files */
  282. #   define ZBSZ 2048 /* buffer size for temporary zip file */
  283. #else
  284. # ifdef MEDIUM_MEM
  285. #   define CBSZ 8192
  286. #   define ZBSZ 8192
  287. # else
  288. #  ifdef OS2
  289. #   ifdef __32BIT__
  290. #     define CBSZ 0x40000
  291. #     define ZBSZ 0x40000
  292. #   else
  293. #     define CBSZ 0xE000
  294. #     define ZBSZ 0x7F00 /* Some libraries do not allow a buffer size > 32K */
  295. #   endif
  296. #  else
  297. #   ifdef TOPS20
  298. #    define CBSZ 524288
  299. #    define ZBSZ 524288
  300. #   else
  301. #    define CBSZ 16384
  302. #    define ZBSZ 16384
  303. #   endif
  304. #  endif
  305. # endif
  306. #endif
  307.  
  308. #if (defined(BIG_MEM) || defined(MMAP)) && !defined(DYN_ALLOC)
  309. #   define DYN_ALLOC
  310. #endif
  311.  
  312. #ifdef __human68k__
  313. #  include <sys/xglob.h>
  314. #  define MSVMS
  315. #  define SSTAT h68_stat
  316.   int h68_stat OF((char *, struct stat *));
  317. #  define OS_CODE  0x300  /* pretend it's Unix */
  318. #endif
  319.  
  320. #ifdef ATARI_ST
  321. #  define MSDOS  /* what? should be fixed */
  322. #  define MSVMS
  323. #  ifndef O_BINARY
  324. #    define O_BINARY 0
  325. #  endif
  326. #  ifndef S_IFMT
  327. #    define S_IFMT        (S_IFCHR|S_IFREG|S_IFDIR)
  328. #  endif
  329.  
  330. /* a whole bunch of functions needs Tos '\\' filenames
  331.  * instead of '/',  the translation functions are in fileio.c:
  332.  */
  333. #  define unlink    st_unlink
  334. #  define chmod     st_chmod
  335. #  define mktemp    st_mktemp
  336. #  define fopen     st_fopen
  337. #  define open      st_open
  338. #  define SSTAT     st_stat
  339. #  define findfirst st_findfirst
  340. #  define link      st_rename
  341. #  define rmdir     st_rmdir
  342.  
  343.   int st_unlink    OF((char *));
  344.   int st_chmod     OF((char *, int));
  345.   char *st_mktemp  OF((char *));
  346.   FILE *st_fopen   OF((char *, char *));
  347.   int st_open      OF((char *, int));
  348.   int st_stat      OF((char *, struct stat *));
  349.   int st_findfirst OF((char *, struct ffblk *, int));
  350.   int st_rename    OF((char *, char *));
  351.   int st_rmdir     OF((char *));
  352. #endif  /* ATARI */
  353.  
  354. #ifndef SSTAT
  355. #  define SSTAT      stat
  356. #endif
  357. #ifdef S_IFLNK
  358. #  define LSTAT      lstat
  359. #else
  360. #  define LSTAT      SSTAT
  361. #endif
  362.  
  363.    
  364. /* The following OS codes are defined in pkzip appnote.txt */
  365. #ifdef AMIGA
  366. #  define OS_CODE  0x100
  367. #endif
  368. #ifdef VMS
  369. #  define OS_CODE  0x200
  370. #endif
  371. /* unix    3 */
  372. /* vms/cms 4 */
  373. #ifdef ATARI_ST
  374. #  define OS_CODE  0x500
  375. #endif
  376. #ifdef OS2
  377. #  define OS_CODE  0x600
  378. #endif
  379. #ifdef MACOS
  380. #  define OS_CODE  0x700
  381. #endif
  382. /* z system 8 */
  383. /* cp/m     9 */
  384. #ifdef TOPS20
  385. #  define OS_CODE  0xa00
  386. #endif
  387. #ifdef WIN32
  388. #  define OS_CODE  0xb00
  389. #endif
  390. /* qdos 12 */
  391.  
  392. #if defined(MSDOS) && !defined(OS_CODE)
  393. #  define OS_CODE  0x000
  394. #endif
  395. #ifndef OS_CODE
  396. #  define OS_CODE  0x300  /* assume Unix */
  397. #  ifndef UNIX
  398. #    define UNIX
  399. #  endif
  400. #endif
  401.  
  402.  
  403. /* end of tailor.h */
  404.