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