vms.h 11 KB

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