vms.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. /*
  2. Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
  3. See the accompanying file LICENSE, version 2007-Mar-4 or later
  4. (the contents of which are also included in zip.h) for terms of use.
  5. If, for some reason, all these files are missing, the Info-ZIP license
  6. also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
  7. */
  8. /*---------------------------------------------------------------------------
  9. vms.h
  10. Generic VMS header file for Info-ZIP's Zip and UnZip.
  11. ---------------------------------------------------------------------------*/
  12. #ifndef __vms_h
  13. #define __vms_h 1
  14. #ifndef __DESCRIP_LOADED
  15. #include <descrip.h>
  16. #endif
  17. #ifndef __STARLET_LOADED
  18. #include <starlet.h>
  19. #endif
  20. #ifndef __SYIDEF_LOADED
  21. #include <syidef.h>
  22. #endif
  23. #ifndef __ATRDEF_LOADED
  24. #include <atrdef.h>
  25. #endif
  26. #ifndef __FIBDEF_LOADED
  27. #include <fibdef.h>
  28. #endif
  29. #ifndef __IODEF_LOADED
  30. #include <iodef.h>
  31. #endif
  32. #if !defined(_RMS_H) && !defined(__RMS_LOADED)
  33. #include <rms.h>
  34. #endif
  35. #define ERR(s) !((s) & 1) /* VMS system error */
  36. #ifndef SYI$_VERSION
  37. #define SYI$_VERSION 4096 /* VMS 5.4 definition */
  38. #endif
  39. /*
  40. * Under Alpha (DEC C in VAXC mode) and under `good old' VAXC, the FIB unions
  41. * are declared as variant_unions. DEC C (Alpha) in ANSI modes and third
  42. * party compilers which do not support `variant_union' define preprocessor
  43. * symbols to `hide' the "intermediate union/struct" names from the
  44. * programmer's API.
  45. * We check the presence of these defines and for DEC's FIBDEF.H defining
  46. * __union as variant_union to make sure we access the structure correctly.
  47. */
  48. #define variant_union 1
  49. #if defined(fib$w_did) || (defined(__union) && (__union == variant_union))
  50. # define FIB$W_DID fib$w_did
  51. # define FIB$W_FID fib$w_fid
  52. # define FIB$L_ACCTL fib$l_acctl
  53. # define FIB$W_EXCTL fib$w_exctl
  54. #else
  55. # define FIB$W_DID fib$r_did_overlay.fib$w_did
  56. # define FIB$W_FID fib$r_fid_overlay.fib$w_fid
  57. # define FIB$L_ACCTL fib$r_acctl_overlay.fib$l_acctl
  58. # define FIB$W_EXCTL fib$r_exctl_overlay.fib$w_exctl
  59. #endif
  60. #undef variant_union
  61. /* 2005-02-08 SMS. Moved NAM[L] macros here from VMS.C. */
  62. /* Define macros for use with either NAM or NAML. */
  63. #ifdef NAML$C_MAXRSS /* NAML is available. Use it. */
  64. # define NAM_STRUCT NAML
  65. # define FAB_OR_NAML( fab, nam) nam
  66. # define FAB_OR_NAML_DNA naml$l_long_defname
  67. # define FAB_OR_NAML_DNS naml$l_long_defname_size
  68. # define FAB_OR_NAML_FNA naml$l_long_filename
  69. # define FAB_OR_NAML_FNS naml$l_long_filename_size
  70. # define CC_RMS_NAM cc$rms_naml
  71. # define FAB_NAM fab$l_naml
  72. # define NAM_DID naml$w_did
  73. # define NAM_DVI naml$t_dvi
  74. # define NAM_ESA naml$l_long_expand
  75. # define NAM_ESL naml$l_long_expand_size
  76. # define NAM_ESS naml$l_long_expand_alloc
  77. # define NAM_FID naml$w_fid
  78. # define NAM_FNB naml$l_fnb
  79. # define NAM_RSA naml$l_long_result
  80. # define NAM_RSL naml$l_long_result_size
  81. # define NAM_RSS naml$l_long_result_alloc
  82. # define NAM_MAXRSS NAML$C_MAXRSS
  83. # define NAM_NOP naml$b_nop
  84. # define NAM_M_EXP_DEV NAML$M_EXP_DEV
  85. # define NAM_M_SYNCHK NAML$M_SYNCHK
  86. # define NAM_B_DEV naml$l_long_dev_size
  87. # define NAM_L_DEV naml$l_long_dev
  88. # define NAM_B_DIR naml$l_long_dir_size
  89. # define NAM_L_DIR naml$l_long_dir
  90. # define NAM_B_NAME naml$l_long_name_size
  91. # define NAM_L_NAME naml$l_long_name
  92. # define NAM_B_TYPE naml$l_long_type_size
  93. # define NAM_L_TYPE naml$l_long_type
  94. # define NAM_B_VER naml$l_long_ver_size
  95. # define NAM_L_VER naml$l_long_ver
  96. #else /* def NAML$C_MAXRSS */ /* NAML is not available. Use NAM. */
  97. # define NAM_STRUCT NAM
  98. # define FAB_OR_NAML( fab, nam) fab
  99. # define FAB_OR_NAML_DNA fab$l_dna
  100. # define FAB_OR_NAML_DNS fab$b_dns
  101. # define FAB_OR_NAML_FNA fab$l_fna
  102. # define FAB_OR_NAML_FNS fab$b_fns
  103. # define CC_RMS_NAM cc$rms_nam
  104. # define FAB_NAM fab$l_nam
  105. # define NAM_DID nam$w_did
  106. # define NAM_DVI nam$t_dvi
  107. # define NAM_ESA nam$l_esa
  108. # define NAM_ESL nam$b_esl
  109. # define NAM_ESS nam$b_ess
  110. # define NAM_FID nam$w_fid
  111. # define NAM_FNB nam$l_fnb
  112. # define NAM_RSA nam$l_rsa
  113. # define NAM_RSL nam$b_rsl
  114. # define NAM_RSS nam$b_rss
  115. # define NAM_MAXRSS NAM$C_MAXRSS
  116. # define NAM_NOP nam$b_nop
  117. # define NAM_M_EXP_DEV NAM$M_EXP_DEV
  118. # define NAM_M_SYNCHK NAM$M_SYNCHK
  119. # define NAM_B_DEV nam$b_dev
  120. # define NAM_L_DEV nam$l_dev
  121. # define NAM_B_DIR nam$b_dir
  122. # define NAM_L_DIR nam$l_dir
  123. # define NAM_B_NAME nam$b_name
  124. # define NAM_L_NAME nam$l_name
  125. # define NAM_B_TYPE nam$b_type
  126. # define NAM_L_TYPE nam$l_type
  127. # define NAM_B_VER nam$b_ver
  128. # define NAM_L_VER nam$l_ver
  129. #endif /* def NAML$C_MAXRSS */
  130. struct EB_header /* Common header of extra block */
  131. { ush tag;
  132. ush size;
  133. uch data[1];
  134. };
  135. #ifndef EB_HEADSIZE
  136. # define EB_HEADSIZE 4
  137. #endif
  138. /*------ Old style Info-ZIP extra field definitions -----*/
  139. #if (!defined(VAXC) && !defined(_RMS_H) && !defined(__RMS_LOADED))
  140. struct XAB { /* This definition may be skipped */
  141. unsigned char xab$b_cod;
  142. unsigned char xab$b_bln;
  143. short int xabdef$$_fill_1;
  144. char *xab$l_nxt;
  145. };
  146. #endif /* !VAXC && !_RMS_H && !__RMS_LOADED */
  147. #ifndef EB_IZVMS_BCMASK
  148. # define EB_IZVMS_BCMASK 07 /* 3 bits for compression type */
  149. #endif
  150. #ifndef EB_IZVMS_BCSTOR
  151. # define EB_IZVMS_BCSTOR 0 /* Stored */
  152. #endif
  153. #ifndef EB_IZVMS_BC00
  154. # define EB_IZVMS_BC00 1 /* 0byte -> 0bit compression */
  155. #endif
  156. #ifndef EB_IZVMS_BCDEFL
  157. # define EB_IZVMS_BCDEFL 2 /* Deflated */
  158. #endif
  159. /*
  160. * Extra record format
  161. * ===================
  162. * signature (2 bytes) = 'I','M'
  163. * size (2 bytes)
  164. * block signature (4 bytes)
  165. * flags (2 bytes)
  166. * uncomprssed size(2 bytes)
  167. * reserved (4 bytes)
  168. * data ((size-12) bytes)
  169. * ....
  170. */
  171. struct IZ_block /* Extra field block header structure */
  172. {
  173. ush sig;
  174. ush size;
  175. ulg bid;
  176. ush flags;
  177. ush length;
  178. ulg reserved;
  179. uch body[1]; /* The actual size is unknown */
  180. };
  181. /*
  182. * Extra field signature and block signatures
  183. */
  184. #define IZ_SIGNATURE "IM"
  185. #define FABSIG "VFAB"
  186. #define XALLSIG "VALL"
  187. #define XFHCSIG "VFHC"
  188. #define XDATSIG "VDAT"
  189. #define XRDTSIG "VRDT"
  190. #define XPROSIG "VPRO"
  191. #define XKEYSIG "VKEY"
  192. #define XNAMSIG "VNAM"
  193. #define VERSIG "VMSV"
  194. /*
  195. * Block sizes
  196. */
  197. #define FABL (cc$rms_fab.fab$b_bln)
  198. #define RABL (cc$rms_rab.rab$b_bln)
  199. #define XALLL (cc$rms_xaball.xab$b_bln)
  200. #define XDATL (cc$rms_xabdat.xab$b_bln)
  201. #define XFHCL (cc$rms_xabfhc.xab$b_bln)
  202. #define XKEYL (cc$rms_xabkey.xab$b_bln)
  203. #define XPROL (cc$rms_xabpro.xab$b_bln)
  204. #define XRDTL (cc$rms_xabrdt.xab$b_bln)
  205. #define XSUML (cc$rms_xabsum.xab$b_bln)
  206. #define EXTBSL 4 /* Block signature length */
  207. #define RESL 8 /* Reserved 8 bytes */
  208. #define EXTHL (EB_HEADSIZE+EXTBSL+RESL)
  209. typedef unsigned char byte;
  210. struct iosb
  211. {
  212. ush status;
  213. ush count;
  214. ulg spec;
  215. };
  216. /*------------ PKWARE extra block definitions ----------*/
  217. /* Structure of PKWARE extra header */
  218. #ifdef VMS_ZIP
  219. #if defined(__DECC) || defined(__DECCXX)
  220. #pragma __nostandard
  221. #endif /* __DECC || __DECCXX */
  222. #if defined(__DECC) || defined(__DECCXX)
  223. #pragma __member_alignment __save
  224. #pragma __nomember_alignment
  225. #endif /* __DECC || __DECCXX */
  226. #ifdef VMS_ORIGINAL_PK_LAYOUT
  227. /* The original order of ATR fields in the PKZIP VMS-extra field leads
  228. * to unaligned fields in the PK_info structure representing the
  229. * extra field layout. When compiled for Alpha AXP, this results in
  230. * some performance (and code size) penalty. It is not allowed to
  231. * apply structure padding, since this is explicitely forbidden in
  232. * the specification (APPNOTE.TXT) for the PK VMS extra field.
  233. */
  234. typedef struct
  235. {
  236. ush tag_ra; ush len_ra; byte ra[ATR$S_RECATTR];
  237. ush tag_uc; ush len_uc; byte uc[ATR$S_UCHAR];
  238. ush tag_jr; ush len_jr; byte jr[ATR$S_JOURNAL];
  239. ush tag_cd; ush len_cd; byte cd[ATR$S_CREDATE];
  240. ush tag_rd; ush len_rd; byte rd[ATR$S_REVDATE];
  241. ush tag_ed; ush len_ed; byte ed[ATR$S_EXPDATE];
  242. ush tag_bd; ush len_bd; byte bd[ATR$S_BAKDATE];
  243. ush tag_rn; ush len_rn; ush rn;
  244. ush tag_ui; ush len_ui; byte ui[ATR$S_UIC];
  245. ush tag_fp; ush len_fp; byte fp[ATR$S_FPRO];
  246. ush tag_rp; ush len_rp; byte rp[ATR$S_RPRO];
  247. } PK_info_t;
  248. #else /* !VMS_ORIGINAL_PK_LAYOUT */
  249. /* The Info-ZIP support for the PK VMS extra field uses a reordered
  250. * field layout to achieve ``natural alignment'' of the PK_info structure
  251. * members whenever possible. This rearrangement does not violate the
  252. * PK's VMS extra field specification and should not break any ``well
  253. * behaving'' (PK)Unzip utility. (`Well behaving' means that (PK)Unzip
  254. * should use the field tag to identify the ATR$ field rather than
  255. * assuming a fixed order of ATR$ fields in the PK VMS extra field.)
  256. */
  257. typedef struct
  258. {
  259. ush tag_ra; ush len_ra; byte ra[ATR$S_RECATTR];
  260. ush tag_uc; ush len_uc; byte uc[ATR$S_UCHAR];
  261. ush tag_cd; ush len_cd; byte cd[ATR$S_CREDATE];
  262. ush tag_rd; ush len_rd; byte rd[ATR$S_REVDATE];
  263. ush tag_ed; ush len_ed; byte ed[ATR$S_EXPDATE];
  264. ush tag_bd; ush len_bd; byte bd[ATR$S_BAKDATE];
  265. ush tag_rn; ush len_rn; ush rn;
  266. ush tag_ui; ush len_ui; byte ui[ATR$S_UIC];
  267. ush tag_fp; ush len_fp; byte fp[ATR$S_FPRO];
  268. ush tag_rp; ush len_rp; byte rp[ATR$S_RPRO];
  269. ush tag_jr; ush len_jr; byte jr[ATR$S_JOURNAL];
  270. } PK_info_t;
  271. #endif /* ?VMS_ORIGINAL_PK_LAYOUT */
  272. #if defined(__DECC) || defined(__DECCXX)
  273. #pragma __member_alignment __restore
  274. #endif /* __DECC || __DECCXX */
  275. #if defined(__DECC) || defined(__DECCXX)
  276. #pragma __standard
  277. #endif /* __DECC || __DECCXX */
  278. #endif /* VMS_ZIP */
  279. /* PKWARE "VMS" tag */
  280. #define PK_SIGNATURE 0x000C
  281. /* Total number of attributes to be saved */
  282. #define VMS_ATTR_COUNT 11
  283. #define VMS_MAX_ATRCNT 20
  284. struct PK_field
  285. {
  286. ush tag;
  287. ush size;
  288. byte value[1];
  289. };
  290. #define PK_FLDHDR_SIZE 4
  291. struct PK_header
  292. {
  293. ush tag;
  294. ush size;
  295. ulg crc32;
  296. byte data[1];
  297. };
  298. #define PK_HEADER_SIZE 8
  299. char *vms_file_version( char *s);
  300. #endif /* !__vms_h */