Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

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