home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / zip21.zip / vms / vms.h < prev    next >
C/C++ Source or Header  |  1996-02-12  |  7KB  |  269 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.   vms.h
  4.  
  5.   Generic VMS header file for Info-ZIP's Zip and UnZip.
  6.  
  7.   ---------------------------------------------------------------------------*/
  8.  
  9. #ifndef __vms_h
  10. #define __vms_h 1
  11.  
  12. #ifndef __DESCRIP_LOADED
  13. #include <descrip.h>
  14. #endif
  15. #ifndef __STARLET_LOADED
  16. #include <starlet.h>
  17. #endif
  18. #ifndef __SYIDEF_LOADED
  19. #include <syidef.h>
  20. #endif
  21. #ifndef __ATRDEF_LOADED
  22. #include <atrdef.h>
  23. #endif
  24. #ifndef __FIBDEF_LOADED
  25. #include <fibdef.h>
  26. #endif
  27. #ifndef __IODEF_LOADED
  28. #include <iodef.h>
  29. #endif
  30. #if !defined(_RMS_H) && !defined(__RMS_LOADED)
  31. #include <rms.h>
  32. #endif
  33.  
  34. #define ERR(s) !((s) & 1)       /* VMS system error */
  35.  
  36. #ifndef SYI$_VERSION
  37. #define SYI$_VERSION 4096       /* VMS 5.4 definition */
  38. #endif
  39.  
  40. /*
  41.  *  Under Alpha (DEC C?), the FIB unions are declared as variant_unions.
  42.  *  FIBDEF.H includes the definition of __union, which we check
  43.  *  below to make sure we access the structure correctly.
  44.  */
  45. #define variant_union 1
  46. #if defined(fib$w_did) || (defined(__union) && (__union == variant_union))
  47. #  define FIB$W_DID       fib$w_did
  48. #  define FIB$W_FID       fib$w_fid
  49. #  define FIB$L_ACCTL     fib$l_acctl
  50. #  define FIB$W_EXCTL     fib$w_exctl
  51. #else
  52. #  define FIB$W_DID       fib$r_did_overlay.fib$w_did
  53. #  define FIB$W_FID       fib$r_fid_overlay.fib$w_fid
  54. #  define FIB$L_ACCTL     fib$r_acctl_overlay.fib$l_acctl
  55. #  define FIB$W_EXCTL     fib$r_exctl_overlay.fib$w_exctl
  56. #endif
  57. #undef variant_union
  58.  
  59.  
  60. struct EB_header    /* Common header of extra block */
  61. {   ush tag;
  62.     ush size;
  63.     uch data[1];
  64. };
  65.  
  66. #ifndef EB_HEADSIZE
  67. #  define EB_HEADSIZE 4
  68. #endif
  69.  
  70. /*------ Old style INFO-ZIP extra field definitions -----*/
  71.  
  72. #if (!defined(VAXC) && !defined(_RMS_H) && !defined(__RMS_LOADED))
  73.  
  74. struct XAB {                    /* This definition may be skipped */
  75.     unsigned char xab$b_cod;
  76.     unsigned char xab$b_bln;
  77.     short int xabdef$$_fill_1;
  78.     char *xab$l_nxt;
  79. };
  80.  
  81. #endif /* !VAXC && !_RMS_H && !__RMS_LOADED */
  82.  
  83. #define BC_MASK    07   /* 3 bits for compression type */
  84. #define BC_STORED  0    /* Stored */
  85. #define BC_00      1    /* 0byte -> 0bit compression */
  86. #define BC_DEFL    2    /* Deflated */
  87.  
  88. /*
  89.  *  Extra record format
  90.  *  ===================
  91.  *  signature       (2 bytes)   = 'I','M'
  92.  *  size            (2 bytes)
  93.  *  block signature (4 bytes)
  94.  *  flags           (2 bytes)
  95.  *  uncomprssed size(2 bytes)
  96.  *  reserved        (4 bytes)
  97.  *  data            ((size-12) bytes)
  98.  *  ....
  99.  */
  100.  
  101. struct IZ_block                 /* Extra field block header structure */
  102. {
  103.     ush sig;
  104.     ush size;
  105.     ulg bid;
  106.     ush flags;
  107.     ush length;
  108.     ulg reserved;
  109.     uch body[1];                /* The actual size is unknown */
  110. };
  111.  
  112. /*
  113.  *   Extra field signature and block signatures
  114.  */
  115.  
  116. #define IZ_SIGNATURE "IM"
  117. #define FABSIG  "VFAB"
  118. #define XALLSIG "VALL"
  119. #define XFHCSIG "VFHC"
  120. #define XDATSIG "VDAT"
  121. #define XRDTSIG "VRDT"
  122. #define XPROSIG "VPRO"
  123. #define XKEYSIG "VKEY"
  124. #define XNAMSIG "VNAM"
  125. #define VERSIG  "VMSV"
  126.  
  127. /*
  128.  *   Block sizes
  129.  */
  130.  
  131. #define FABL    (cc$rms_fab.fab$b_bln)
  132. #define RABL    (cc$rms_rab.rab$b_bln)
  133. #define XALLL   (cc$rms_xaball.xab$b_bln)
  134. #define XDATL   (cc$rms_xabdat.xab$b_bln)
  135. #define XFHCL   (cc$rms_xabfhc.xab$b_bln)
  136. #define XKEYL   (cc$rms_xabkey.xab$b_bln)
  137. #define XPROL   (cc$rms_xabpro.xab$b_bln)
  138. #define XRDTL   (cc$rms_xabrdt.xab$b_bln)
  139. #define XSUML   (cc$rms_xabsum.xab$b_bln)
  140. #define EXTBSL  4               /* Block signature length */
  141. #define RESL    8               /* Reserved 8 bytes */
  142. #define EXTHL   (EB_HEADSIZE+EXTBSL+RESL)
  143.  
  144. typedef unsigned char byte;
  145.  
  146. struct iosb
  147. {
  148.     ush status;
  149.     ush count;
  150.     ulg spec;
  151. };
  152.  
  153. /*------------ PKWARE extra block definitions ----------*/
  154.  
  155. /* Structure of PKWARE extra header */
  156.  
  157. #ifdef VMS_ZIP
  158.  
  159. #if defined(__DECC) || defined(__DECCXX)
  160. #pragma __nostandard
  161. #endif /* __DECC || __DECCXX */
  162.  
  163. #if defined(__DECC) || defined(__DECCXX)
  164. #pragma __member_alignment __save
  165. #pragma __nomember_alignment
  166. #endif /* __DECC || __DECCXX */
  167.  
  168. #ifdef VMS_ORIGINAL_PK_LAYOUT
  169. /*  The original order of ATR fields in the PKZIP VMS-extra field leads
  170.  *  to unaligned fields in the PK_info structure representing the
  171.  *  extra field layout.  When compiled for Alpha AXP, this results in
  172.  *  some performance (and code size) penalty.  It is not allowed to
  173.  *  apply structure padding, since this is explicitely forbidden in
  174.  *  the specification (APPNOTE.TXT) for the PK VMS extra field.
  175.  */
  176. struct PK_info
  177. {
  178.     ush tag_ra; ush len_ra;     byte ra[ATR$S_RECATTR];
  179.     ush tag_uc; ush len_uc;     byte uc[ATR$S_UCHAR];
  180.     ush tag_jr; ush len_jr;     byte jr[ATR$S_JOURNAL];
  181.     ush tag_cd; ush len_cd;     byte cd[ATR$S_CREDATE];
  182.     ush tag_rd; ush len_rd;     byte rd[ATR$S_REVDATE];
  183.     ush tag_ed; ush len_ed;     byte ed[ATR$S_EXPDATE];
  184.     ush tag_bd; ush len_bd;     byte bd[ATR$S_BAKDATE];
  185.     ush tag_rn; ush len_rn;     ush  rn;
  186.     ush tag_ui; ush len_ui;     byte ui[ATR$S_UIC];
  187.     ush tag_fp; ush len_fp;     byte fp[ATR$S_FPRO];
  188.     ush tag_rp; ush len_rp;     byte rp[ATR$S_RPRO];
  189. };
  190. #else /* !VMS_ORIGINAL_PK_LAYOUT */
  191. /*  The Info-Zip support for the PK VMS extra field uses a reordered
  192.  *  field layout to archive ``natural alignment'' of the PK_info structure
  193.  *  members whenever possible.  This rearrangement does not violate the
  194.  *  PK's VMS extra field specification and should not break any ``well
  195.  *  behaving'' (PK)Unzip utility. (`Well behaving' means that (PK)Unzip
  196.  *  should use the field tag to identify the ATR$ field rather than
  197.  *  assuming a fixed order of ATR$ fields in the PK VMS extra field.)
  198.  */
  199. struct PK_info
  200. {
  201.     ush tag_ra; ush len_ra;     byte ra[ATR$S_RECATTR];
  202.     ush tag_uc; ush len_uc;     byte uc[ATR$S_UCHAR];
  203.     ush tag_cd; ush len_cd;     byte cd[ATR$S_CREDATE];
  204.     ush tag_rd; ush len_rd;     byte rd[ATR$S_REVDATE];
  205.     ush tag_ed; ush len_ed;     byte ed[ATR$S_EXPDATE];
  206.     ush tag_bd; ush len_bd;     byte bd[ATR$S_BAKDATE];
  207.     ush tag_rn; ush len_rn;     ush  rn;
  208.     ush tag_ui; ush len_ui;     byte ui[ATR$S_UIC];
  209.     ush tag_fp; ush len_fp;     byte fp[ATR$S_FPRO];
  210.     ush tag_rp; ush len_rp;     byte rp[ATR$S_RPRO];
  211.     ush tag_jr; ush len_jr;     byte jr[ATR$S_JOURNAL];
  212. };
  213. #endif /* ?VMS_ORIGINAL_PK_LAYOUT */
  214.  
  215. #if defined(__DECC) || defined(__DECCXX)
  216. #pragma __member_alignment __restore
  217. #endif /* __DECC || __DECCXX */
  218.  
  219. #if defined(__DECC) || defined(__DECCXX)
  220. #pragma __standard
  221. #endif /* __DECC || __DECCXX */
  222.  
  223. #endif /* VMS_ZIP */
  224.  
  225. /* PKWARE "VMS" tag */
  226. #define PK_SIGNATURE        0x000C
  227.  
  228. /* Total number of attributes to be saved */
  229. #define VMS_ATTR_COUNT  11
  230. #define VMS_MAX_ATRCNT  20
  231.  
  232. struct PK_field
  233. {
  234.     ush         tag;
  235.     ush         size;
  236.     byte        value[1];
  237. };
  238.  
  239. #define PK_FLDHDR_SIZE  4
  240.  
  241. struct PK_header
  242. {
  243.     ush tag;
  244.     ush size;
  245.     ulg crc32;
  246.     byte data[1];
  247. };
  248.  
  249. #define PK_HEADER_SIZE  8
  250.  
  251. #ifdef VMS_ZIP
  252. /* File description structure for Zip low level I/O */
  253. struct ioctx
  254. {
  255.     struct iosb         iosb;
  256.     long                vbn;
  257.     long                size;
  258.     long                rest;
  259.     int                 status;
  260.     ush                 chan;
  261.     ush                 chan_pad;       /* alignment member */
  262.     long                acllen;
  263.     uch                 aclbuf[ATR$S_READACL];
  264.     struct PK_info      PKi;
  265. };
  266. #endif /* VMS_ZIP */
  267.  
  268. #endif /* !__vms_h */
  269.