home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / zip21.zip / tailor.h < prev    next >
C/C++ Source or Header  |  1996-04-14  |  6KB  |  319 lines

  1. /* tailor.h -- Not copyrighted 1993 Mark Adler */
  2.  
  3. #ifdef AMIGA
  4. #include "amiga/osdep.h"
  5. #endif
  6.  
  7. #ifdef AOSVS
  8. #include "aosvs/osdep.h"
  9. #endif
  10.  
  11. #ifdef ATARI
  12. #include "atari/osdep.h"
  13. #endif
  14.  
  15. #ifdef DOS
  16. #include "msdos/osdep.h"
  17. #endif
  18.  
  19. #ifdef __human68k__
  20. #include "human68k/osdep.h"
  21. #endif
  22.  
  23. #ifdef OS2
  24. #include "os2/osdep.h"
  25. #endif
  26.  
  27. #ifdef __arm
  28. #include "acorn/osdep.h"
  29. #endif
  30.  
  31. #ifdef UNIX
  32. #include "unix/osdep.h"
  33. #endif
  34.  
  35. #if defined(VMS) || defined(__VMS)
  36. #include "vms/osdep.h"
  37. #endif
  38.  
  39. #if defined(VM_CMS) || defined(MVS)
  40. #include "cmsmvs.h"
  41. #endif
  42.  
  43. #ifdef WIN32
  44. #include "win32/osdep.h"
  45. #endif
  46.  
  47. /* When "void" is an alias for "int", prototypes cannot be used. */
  48. #if (defined(NO_VOID) && !defined(NO_PROTO))
  49. #  define NO_PROTO
  50. #endif
  51.  
  52. /* Used to remove arguments in function prototypes for non-ANSI C */
  53. #ifndef NO_PROTO
  54. #  define OF(a) a
  55. #else /* NO_PROTO */
  56. #  define OF(a) ()
  57. #endif /* ?NO_PROTO */
  58.  
  59. /* Avoid using const if compiler does not support it */
  60. #ifdef NO_CONST
  61. #  define const
  62. #endif
  63.  
  64. /*
  65.  * case mapping functions. case_map is used to ignore case in comparisons,
  66.  * to_up is used to force upper case even on Unix (for dosify option).
  67.  */
  68. #if defined(MSVMS) || defined(AMIGA) || defined(ATARI) || defined(CMS_MVS)
  69. #  define case_map(c) upper[(c) & 0xff]
  70. #  define to_up(c)    upper[(c) & 0xff]
  71. #else /* !(MSVMS || AMIGA || ATARI || CMS_MVS) */
  72. #  define case_map(c) (c)
  73. #  define to_up(c)    ((c) >= 'a' && (c) <= 'z' ? (c)-'a'+'A' : (c))
  74. #endif /* ? (MSVMS || AMIGA || ATARI || CMS_MVS) */
  75.  
  76. /* Define void, zvoid, and extent (size_t) */
  77. #include <stdio.h>
  78.  
  79. #ifndef NO_STDDEF_H
  80. #  include <stddef.h>
  81. #endif /* !NO_STDDEF_H */
  82.  
  83. #ifndef NO_STDLIB_H
  84. #  include <stdlib.h>
  85. #endif /* !NO_STDLIB_H */
  86.  
  87. #ifndef NO_UNISTD_H
  88. #  include <unistd.h> /* usually defines _POSIX_VERSION */
  89. #endif /* !NO_UNISTD_H */
  90.  
  91. #ifndef NO_FCNTL_H
  92. #  include <fcntl.h>
  93. #endif /* !NO_FNCTL_H */
  94.  
  95. #ifndef NO_STRING_H
  96. #  include <string.h>
  97. #else
  98. #  include <strings.h>
  99. #endif /* NO_STRING_H */
  100.  
  101. #ifdef NO_VOID
  102. #  define void int
  103.    typedef char zvoid;
  104. #else /* !NO_VOID */
  105. # ifdef NO_TYPEDEF_VOID
  106. #  define zvoid void
  107. # else
  108.    typedef void zvoid;
  109. # endif
  110. #endif /* ?NO_VOID */
  111.  
  112. #ifdef NO_STRRCHR
  113. #  define strrchr rindex
  114. #endif
  115.  
  116. /*
  117.  * A couple of forward declarations that are needed on systems that do
  118.  * not supply C runtime library prototypes.
  119.  */
  120. #ifdef NO_PROTO
  121. char *strcpy();
  122. char *strcat();
  123. char *strrchr();
  124. #ifndef ZMEM
  125. char *memset();
  126. char *memcpy();
  127. #endif /* !ZMEM */
  128.  
  129. char *calloc();
  130. char *malloc();
  131. char *getenv();
  132. long atol();
  133.  
  134. #endif /* NO_PROTO */
  135.  
  136. #ifndef NO_MKTEMP
  137. char *mktemp();
  138. #endif /* !NO_MKTEMP */
  139.  
  140. /*
  141.  * SEEK_* macros, should be defined in stdio.h
  142.  */
  143. /* Define fseek() commands */
  144. #ifndef SEEK_SET
  145. #  define SEEK_SET 0
  146. #endif /* !SEEK_SET */
  147.  
  148. #ifndef SEEK_CUR
  149. #  define SEEK_CUR 1
  150. #endif /* !SEEK_CUR */
  151.  
  152. #ifdef NO_SIZE_T
  153.    typedef unsigned int extent;
  154. #else
  155.    typedef size_t extent;
  156. #endif
  157.  
  158. #ifdef NO_TIME_T
  159.    typedef long time_t;
  160. #endif
  161.  
  162. /* System independent replacement for "struct utimbuf", which is missing
  163.  * in many older OS environments.
  164.  */
  165. typedef struct ztimbuf {
  166.     time_t actime;              /* new access time */
  167.     time_t modtime;             /* new modification time */
  168. } ztimbuf;
  169.  
  170. /* Some systems define S_IFLNK but do not support symbolic links */
  171. #if defined (S_IFLNK) && defined(NO_SYMLINK)
  172. #  undef S_IFLNK
  173. #endif
  174.  
  175. #ifndef FOPR    /* fallback default definitions for FOPR, FOPM, FOPW: */
  176. #  define FOPR "r"
  177. #  define FOPM "r+"
  178. #  define FOPW "w"
  179. #endif /* fallback definition */
  180.  
  181. /* Open the old zip file in exclusive mode if possible (to avoid adding
  182.  * zip file to itself).
  183.  */
  184. #ifdef OS2
  185. #  define FOPR_EX FOPM
  186. #else
  187. #  define FOPR_EX FOPR
  188. #endif
  189.  
  190.  
  191. /* MDOS file attribute for directories */
  192. #define MSDOS_DIR_ATTR 0x10
  193.  
  194.  
  195. /* Define this symbol if your target allows access to unaligned data.
  196.  * This is not mandatory, just a speed optimization. The compressed
  197.  * output is strictly identical.
  198.  */
  199. #if (defined(MSDOS) && !defined(WIN32)) || defined(i386)
  200. #    define UNALIGNED_OK
  201. #endif
  202. #if defined(mc68020) || defined(vax)
  203. #    define UNALIGNED_OK
  204. #endif
  205.  
  206. #ifdef SMALL_MEM
  207. #   define CBSZ 2048 /* buffer size for copying files */
  208. #   define ZBSZ 2048 /* buffer size for temporary zip file */
  209. #endif
  210.  
  211. #ifdef MEDIUM_MEM
  212. #  define CBSZ 8192
  213. #  define ZBSZ 8192
  214. #endif
  215.  
  216. #ifndef CBSZ
  217. #  define CBSZ 16384
  218. #  define ZBSZ 16384
  219. #endif
  220.  
  221. #ifndef MEMORY16
  222. #  ifdef __WATCOMC__
  223. #    undef huge
  224. #    undef far
  225. #    undef near
  226. #  endif
  227. #  ifndef __IBMC__
  228. #    define huge
  229. #    define far
  230. #    define near
  231. #  endif
  232. #  define nearmalloc malloc
  233. #  define nearfree free
  234. #  define farmalloc malloc
  235. #  define farfree free
  236. #endif /* !MEMORY16 */
  237.  
  238. #if (defined(BIG_MEM) || defined(MMAP)) && !defined(DYN_ALLOC)
  239. #   define DYN_ALLOC
  240. #endif
  241.  
  242. #ifndef SSTAT
  243. #  define SSTAT      stat
  244. #endif
  245. #ifdef S_IFLNK
  246. #  define LSTAT      lstat
  247. #  define LSSTAT(n, s)  (linkput ? lstat((n), (s)) : SSTAT((n), (s)))
  248. #else
  249. #  define LSTAT      SSTAT
  250. #  define LSSTAT     SSTAT
  251. #endif
  252.  
  253.  
  254. /* The following OS codes are defined in pkzip appnote.txt */
  255. #ifdef AMIGA
  256. #  define OS_CODE  0x100
  257. #endif
  258. #ifdef VMS
  259. #  define OS_CODE  0x200
  260. #endif
  261. /* unix    3 */
  262. #ifdef VM_CMS
  263. #  define OS_CODE  0x400
  264. #endif
  265. #ifdef ATARI
  266. #  define OS_CODE  0x500
  267. #endif
  268. #ifdef OS2
  269. #  define OS_CODE  0x600
  270. #endif
  271. #ifdef MACOS
  272. #  define OS_CODE  0x700
  273. #endif
  274. /* z system 8 */
  275. /* cp/m     9 */
  276. #ifdef TOPS20
  277. #  define OS_CODE  0xa00
  278. #endif
  279. #ifdef WIN32
  280. #  define OS_CODE  0xb00
  281. #endif
  282. /* QDOS 12 */
  283. #ifdef RISCOS
  284. #  define OS_CODE  0xd00
  285. #endif
  286. #ifdef VFAT
  287. #  define OS_CODE  0xe00
  288. #endif
  289. #ifdef MVS
  290. #  define OS_CODE  0xf00
  291. #endif
  292.  
  293. #define NUM_HOSTS 16
  294. /* Number of operating systems. Should be updated when new ports are made */
  295.  
  296. #if defined(DOS) && !defined(OS_CODE)
  297. #  define OS_CODE  0x000
  298. #endif
  299.  
  300. #ifndef OS_CODE
  301. #  define OS_CODE  0x300  /* assume Unix */
  302. #endif
  303.  
  304. /* can't use "return 0" from main() on VMS */
  305. #ifndef EXIT
  306. #  define EXIT  exit
  307. #endif
  308. #ifndef RETURN
  309. #  define RETURN return
  310. #endif
  311.  
  312. #ifndef MY_ZCALLOC /* Any system without a special calloc function */
  313. #  define zcalloc(items,size) \
  314.           (zvoid far *)calloc((unsigned)(items), (unsigned)(size))
  315. #  define zcfree    free
  316. #endif /* !MY_ZCALLOC */
  317.  
  318. /* end of tailor.h */
  319.