home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip520.exe / 32-dll / unzip.h < prev    next >
C/C++ Source or Header  |  1996-04-20  |  12KB  |  421 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.   unzip.h (new)
  4.  
  5.   This header file contains the public macros and typedefs required by
  6.   both the UnZip sources and by any application using the UnZip API.  If
  7.   UNZIP_INTERNAL is defined, it includes unzpriv.h (containing includes,
  8.   prototypes and extern variables used by the actual UnZip sources).
  9.  
  10.   ---------------------------------------------------------------------------*/
  11.  
  12.  
  13. #ifndef __unzip_h   /* prevent multiple inclusions */
  14. #define __unzip_h
  15.  
  16.  
  17. /*****************************************/
  18. /*  Predefined, Machine-specific Macros  */
  19. /*****************************************/
  20.  
  21. #ifdef __GO32__                 /* MS-DOS extender:  NOT Unix */
  22. #  ifdef unix
  23. #    undef unix
  24. #  endif
  25. #  ifdef __unix
  26. #    undef __unix
  27. #  endif
  28. #  ifdef __unix__
  29. #    undef __unix__
  30. #  endif
  31. #endif
  32.  
  33. #if ((defined(__convex__) || defined(__convexc__)) && !defined(CONVEX))
  34. #  define CONVEX
  35. #endif
  36.  
  37. #if (defined(unix) || defined(__unix) || defined(__unix__))
  38. #  ifndef UNIX
  39. #    define UNIX
  40. #  endif
  41. #endif /* unix || __unix || __unix__ */
  42. #if (defined(M_XENIX) || defined(COHERENT) || defined(__hpux))
  43. #  ifndef UNIX
  44. #    define UNIX
  45. #  endif
  46. #endif /* M_XENIX || COHERENT || __hpux */
  47. #if (defined(CONVEX) || defined(MINIX) || defined(_AIX) || defined(__QNX__))
  48. #  ifndef UNIX
  49. #    define UNIX
  50. #  endif
  51. #endif /* CONVEX || MINIX || _AIX || __QNX__ */
  52.  
  53. #if (defined(VM_CMS) || defined(MVS))
  54. #  define CMS_MVS
  55. #endif
  56.  
  57. #if (defined(__OS2__) && !defined(OS2))
  58. #  define OS2
  59. #endif
  60.  
  61. #if (defined(__VMS) && !defined(VMS))
  62. #  define VMS
  63. #endif
  64.  
  65. #if (defined(__WIN32__) && !defined(WIN32))
  66. #  define WIN32
  67. #endif
  68.  
  69. #ifdef __COMPILER_KCC__
  70. #  include <c-env.h>
  71. #  ifdef SYS_T20
  72. #    define TOPS20
  73. #  endif
  74. #endif /* __COMPILER_KCC__ */
  75.  
  76. /* Borland C does not define __TURBOC__ if compiling for a 32 bit platform */
  77. #ifdef __BORLANDC__
  78. #  ifndef __TURBOC__
  79. #    define __TURBOC__
  80. #  endif
  81. #  if (!defined(__MSDOS__) && !defined(OS2) && !defined(WIN32))
  82. #    define __MSDOS__
  83. #  endif
  84. #endif
  85.  
  86. /* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
  87. #ifdef __POWERC
  88. #  define __TURBOC__
  89. #  define MSDOS
  90. #endif /* __POWERC */
  91.  
  92. #if (defined(__MSDOS__) && !defined(MSDOS))   /* just to make sure */
  93. #  define MSDOS
  94. #endif
  95.  
  96. #if (defined(linux) && !defined(LINUX))
  97. #  define LINUX
  98. #endif
  99.  
  100. #ifdef __arm
  101. #  define RISCOS
  102. #endif
  103.  
  104. /* use prototypes and ANSI libraries if __STDC__, or Microsoft or Borland C, or
  105.  * Silicon Graphics, or Convex?, or IBM C Set/2, or GNU gcc/emx, or Watcom C,
  106.  * or Macintosh, or Windows NT, or Sequent, or Atari or IBM RS/6000.
  107.  */
  108. #if (defined(__STDC__) || defined(MSDOS) || defined(sgi) || defined(RISCOS))
  109. #  ifndef PROTO
  110. #    define PROTO
  111. #  endif
  112. #  ifndef MODERN
  113. #    define MODERN
  114. #  endif
  115. #endif
  116. #if (defined(__IBMC__) || defined(__EMX__) || defined(__WATCOMC__))
  117. #  ifndef PROTO
  118. #    define PROTO
  119. #  endif
  120. #  ifndef MODERN
  121. #    define MODERN
  122. #  endif
  123. #endif
  124. #if (defined(THINK_C) || defined(MPW) || defined(WIN32) || defined(_SEQUENT_))
  125. #  ifndef PTX   /* Sequent running Dynix/ptx:  non-modern compiler */
  126. #    ifndef PROTO
  127. #      define PROTO
  128. #    endif
  129. #    ifndef MODERN
  130. #      define MODERN
  131. #    endif
  132. #  endif
  133. #endif
  134. #if (defined(ATARI_ST) || defined(__BORLANDC__))  /* || defined(CONVEX) */
  135. #  ifndef PROTO
  136. #    define PROTO
  137. #  endif
  138. #  ifndef MODERN
  139. #    define MODERN
  140. #  endif
  141. #endif
  142. #if (defined(_AIX) || defined(CMS_MVS))
  143. #  ifndef PROTO
  144. #    define PROTO
  145. #  endif
  146. #  ifndef MODERN
  147. #    define MODERN
  148. #  endif
  149. #endif
  150.  
  151. /* turn off prototypes if requested */
  152. #if (defined(NOPROTO) && defined(PROTO))
  153. #  undef PROTO
  154. #endif
  155.  
  156. /* used to remove arguments in function prototypes for non-ANSI C */
  157. #ifdef PROTO
  158. #  define OF(a) a
  159. #else
  160. #  define OF(a) ()
  161. #endif
  162.  
  163. /* Be cautious and disable the "const" keyword if in doubt. */
  164. #if (!defined(MODERN) && !defined(NO_CONST))
  165. #  define NO_CONST
  166. #endif /* !MODERN && !NO_CONST */
  167.  
  168. /* Avoid using const if compiler does not support it */
  169. #ifdef NO_CONST
  170. #  ifdef const
  171. #    undef const
  172. #  endif
  173. #  define const
  174. #endif
  175.  
  176. /* bad or (occasionally?) missing stddef.h: */
  177. #if (defined(M_XENIX) || defined(DNIX))
  178. #  define NO_STDDEF_H
  179. #endif
  180.  
  181. #if (defined(M_XENIX) && !defined(M_UNIX))   /* SCO Xenix only, not SCO Unix */
  182. #  define NO_LIMITS_H        /* no limits.h, but MODERN defined */
  183. #  define NO_UID_GID         /* no uid_t/gid_t */
  184. #endif
  185.  
  186. #ifdef realix   /* Modcomp Real/IX, real-time SysV.3 variant */
  187. #  define SYSV
  188. #  define NO_UID_GID         /* no uid_t/gid_t */
  189. #endif
  190.  
  191. #if (defined(_AIX) && !defined(_ALL_SOURCE))
  192. #  define _ALL_SOURCE
  193. #endif
  194.  
  195. #if defined(apollo)          /* defines __STDC__ */
  196. #    define NO_STDLIB_H
  197. #endif
  198.  
  199. #ifdef DNIX
  200. #  define SYSV
  201. #  define SHORT_NAMES         /* 14-char limitation on path components */
  202. /* #  define FILENAME_MAX  14 */
  203. #  define FILENAME_MAX  NAME_MAX    /* GRR:  experiment */
  204. #endif
  205.  
  206. #if (defined(SYSTEM_FIVE) || defined(__SYSTEM_FIVE))
  207. #  ifndef SYSV
  208. #    define SYSV
  209. #  endif
  210. #endif /* SYSTEM_FIVE || __SYSTEM_FIVE */
  211. #if (defined(M_SYSV) || defined(M_SYS5))
  212. #  ifndef SYSV
  213. #    define SYSV
  214. #  endif
  215. #endif /* M_SYSV || M_SYS5 */
  216. /* __SVR4 and __svr4__ catch Solaris on at least some combos of compiler+OS */
  217. #if (defined(__SVR4) || defined(__svr4__) || defined(sgi) || defined(__hpux))
  218. #  ifndef SYSV
  219. #    define SYSV
  220. #  endif
  221. #endif /* __SVR4 || __svr4__ || sgi || __hpux */
  222. #if (defined(LINUX) || defined(__QNX__))
  223. #  ifndef SYSV
  224. #    define SYSV
  225. #  endif
  226. #endif /* LINUX || __QNX__ */
  227.  
  228. #if (defined(ultrix) || defined(__ultrix) || defined(bsd4_2))
  229. #  if (!defined(BSD) && !defined(SYSV))
  230. #    define BSD
  231. #  endif
  232. #endif /* ultrix || __ultrix || bsd4_2 */
  233. #if (defined(sun) || defined(pyr) || defined(CONVEX))
  234. #  if (!defined(BSD) && !defined(SYSV))
  235. #    define BSD
  236. #  endif
  237. #endif /* sun || pyr || CONVEX */
  238.  
  239. #ifdef pyr  /* Pyramid:  has BSD and AT&T "universes" */
  240. #  ifdef BSD
  241. #    define pyr_bsd
  242. #    define USE_STRINGS_H  /* instead of more common string.h */
  243. #    define ZMEM           /* ZMEM now uses bcopy/bzero: not in AT&T universe */
  244. #  endif                   /* (AT&T memcpy claimed to be very slow, though) */
  245. #  define DECLARE_ERRNO
  246. #endif /* pyr */
  247.  
  248. /* stat() bug for Borland, Watcom, VAX C (also GNU?), and Atari ST MiNT on
  249.  * TOS filesystems:  returns 0 for wildcards!  (returns 0xffffffff on Minix
  250.  * filesystem or `U:' drive under Atari MiNT) */
  251. #if (defined(__TURBOC__) || defined(__WATCOMC__) || defined(VMS))
  252. #  define WILD_STAT_BUG
  253. #endif
  254. #if (defined(__MINT__))
  255. #  define WILD_STAT_BUG
  256. #endif
  257.  
  258. #ifdef WILD_STAT_BUG
  259. #  define SSTAT(path,pbuf) (iswild(path) || stat(path,pbuf))
  260. #else
  261. #  define SSTAT stat
  262. #endif
  263.  
  264. #ifdef REGULUS  /* returns the inode number on success(!)...argh argh argh */
  265. #  define stat(p,s) zstat(p,s)
  266. #endif
  267.  
  268. #define STRNICMP zstrnicmp
  269.  
  270.  
  271.  
  272. /***************************/
  273. /*  OS-Dependent Includes  */
  274. /***************************/
  275.  
  276. #ifdef EFT
  277. #  define LONGINT off_t  /* Amdahl UTS nonsense ("extended file types") */
  278. #else
  279. #  define LONGINT long
  280. #endif
  281.  
  282. #ifdef MODERN
  283. #  ifndef NO_STDDEF_H
  284. #    include <stddef.h>
  285. #  endif
  286. #  ifndef NO_STDLIB_H
  287. #    include <stdlib.h>  /* standard library prototypes, malloc(), etc. */
  288. #  endif
  289.    typedef size_t extent;
  290.    typedef void zvoid;
  291. #else /* !MODERN */
  292. #  ifndef AOS_VS         /* mostly modern? */
  293. #    ifndef CMS_MVS
  294.        LONGINT lseek();
  295. #    endif
  296. #    ifdef VAXC          /* not fully modern, but does have stdlib.h and void */
  297. #      include <stdlib.h>
  298. #    else
  299.        char *malloc();
  300. #      define void int
  301. #    endif /* ?VAXC */
  302. #  endif /* !AOS_VS */
  303.    typedef unsigned int extent;
  304.    typedef char zvoid;
  305. #endif /* ?MODERN */
  306.  
  307.  
  308.  
  309. typedef unsigned char   uch;    /* code assumes unsigned bytes; these type-  */
  310. typedef unsigned short  ush;    /*  defs replace byte/UWORD/ULONG (which are */
  311. typedef unsigned long   ulg;    /*  predefined on some systems) & match zip  */
  312.  
  313. /* InputFn is not yet used and is likely to change: */
  314. #ifdef PROTO
  315.    typedef int   (MsgFn)    (zvoid *pG, uch *buf, ulg size, int flag);
  316.    typedef int   (InputFn)  (zvoid *pG, uch *buf, int *size, int flag);
  317.    typedef void  (PauseFn)  (zvoid *pG, const char *prompt, int flag);
  318. #else
  319.    typedef int   (MsgFn)    ();
  320.    typedef int   (InputFn)  ();
  321.    typedef void  (PauseFn)  ();
  322. #endif
  323.  
  324. typedef struct _UzpBuffer {   /* rxstr */
  325.     ulg   strlength;          /* length of string  */
  326.     char  *strptr;            /* pointer to string */
  327. } UzpBuffer;
  328.  
  329. typedef struct _UzpInit {
  330.     ulg structlen;            /* length of the struct being passed */
  331.  
  332.     /* GRR: can we assume that each of these is a 32-bit pointer?  if not,
  333.      * does it matter? add "far" keyword to make sure? */
  334.     MsgFn *msgfn;
  335.     InputFn *inputfn;
  336.     PauseFn *pausefn;
  337.  
  338.     void (*userfn)();   /* user init function to be called after globals */
  339.                         /*  constructed and initialized */
  340.  
  341.     /* pointer to program's environment area or something? */
  342.     /* hooks for performance testing? */
  343.     /* hooks for extra unzip -v output? (detect CPU or other hardware?) */
  344.     /* anything else?  let me (Greg) know... */
  345. } UzpInit;
  346.  
  347. /* intended to be a private struct: */
  348. typedef struct _ver {
  349.     uch major;              /* e.g., integer 5 */
  350.     uch minor;              /* e.g., 2 */
  351.     uch patchlevel;         /* e.g., 0 */
  352.     uch not_used;
  353. } _version_type;
  354.  
  355. typedef struct _UzpVer {
  356.     ulg structlen;          /* length of the struct being passed */
  357.     ulg flag;               /* bit 0: is_beta   bit 1: uses_zlib */
  358.     char *betalevel;        /* e.g., "g BETA" or "" */
  359.     char *date;             /* e.g., "4 Sep 95" (beta) or "4 September 1995" */
  360.     char *zlib_version;     /* e.g., "0.95" or NULL */
  361.     _version_type unzip;
  362.     _version_type zipinfo;
  363.     _version_type os2dll;
  364.     _version_type windll;
  365. } UzpVer;
  366.  
  367. typedef struct central_directory_file_header { /* CENTRAL */
  368.     uch version_made_by[2];
  369.     uch version_needed_to_extract[2];
  370.     ush general_purpose_bit_flag;
  371.     ush compression_method;
  372.     ush last_mod_file_time;
  373.     ush last_mod_file_date;
  374.     ulg crc32;
  375.     ulg csize;
  376.     ulg ucsize;
  377.     ush filename_length;
  378.     ush extra_field_length;
  379.     ush file_comment_length;
  380.     ush disk_number_start;
  381.     ush internal_file_attributes;
  382.     ulg external_file_attributes;
  383.     ulg relative_offset_local_header;
  384. } cdir_file_hdr;
  385.  
  386.  
  387. #define UZPINIT_LEN   sizeof(UzpInit)
  388. #define UZPVER_LEN    sizeof(UzpVer)
  389. #define cbList(func)  int (*func)(char *filename, cdir_file_hdr *crec)
  390.  
  391.  
  392. /*---------------------------------------------------------------------------
  393.     Prototypes for public UnZip API (DLL) functions.
  394.   ---------------------------------------------------------------------------*/
  395.  
  396. int      UzpMain            OF((int argc, char **argv));
  397. int      UzpAltMain         OF((int argc, char **argv, UzpInit *init));
  398. UzpVer  *UzpVersion         OF((void));
  399. int      UzpUnzipToMemory   OF((char *zip, char *file, UzpBuffer *retstr));
  400. int      UzpFileTree        OF((char *name, cbList(callBack),
  401.                                 char *cpInclude[], char *cpExclude[]));
  402.  
  403. /* default I/O functions (can be swapped out via UzpAltMain() entry point): */
  404.  
  405. int      UzpMessagePrnt     OF((zvoid *pG, uch *buf, ulg size, int flag));
  406. int      UzpMessageNull     OF((zvoid *pG, uch *buf, ulg size, int flag));
  407. int      UzpInput           OF((zvoid *pG, uch *buf, int *size, int flag));
  408. void     UzpMorePause       OF((zvoid *pG, const char *prompt, int flag));
  409.  
  410.  
  411. /*---------------------------------------------------------------------------
  412.     Remaining private stuff for UnZip compilation.
  413.   ---------------------------------------------------------------------------*/
  414.  
  415. #ifdef UNZIP_INTERNAL
  416. #  include "unzpriv.h"
  417. #endif
  418.  
  419.  
  420. #endif /* !__unzip_h */
  421.