/* HETLIB.C (c) Copyright Leland Lucius, 2000-2012 */ /* Header for the Hercules Emulated Tape library */ /* */ /* Released under "The Q Public License Version 1" */ /* (http://www.hercules-390.org/herclic.html) as modifications to */ /* Hercules. */ #if !defined( _HETLIB_H_ ) #define _HETLIB_H_ /* || ---------------------------------------------------------------------------- || || HETLIB.H (c) Copyright Leland Lucius, 2000-2009 || Released under terms of the Q Public License. || || Header for the Hercules Emulated Tape library. || || ---------------------------------------------------------------------------- */ #ifndef _HETLIB_C_ #ifndef _HTAPE_DLL_ #define HET_DLL_IMPORT DLL_IMPORT #else /* _HUTIL_DLL_ */ #define HET_DLL_IMPORT extern #endif /* _HUTIL_DLL_ */ #else #define HET_DLL_IMPORT DLL_EXPORT #endif #if !defined( TRUE ) #define TRUE (1L) #endif #if !defined( FALSE ) #define FALSE (0L) #endif /* || Chunk header for an HET. Physically compatable with AWSTAPE format. */ typedef struct _hethdr { uint8_t clen[ 2 ]; /* Length of current block */ uint8_t plen[ 2 ]; /* Length of previous block */ uint8_t flags1; /* Flags byte 1 */ uint8_t flags2; /* Flags byte 2 */ } HETHDR; /* || Macros for accessing current and previous sizes - accept ptr to HETHDR */ #define HETHDR_CLEN( h ) ( ( (h)->chdr.clen[ 1 ] << 8 ) + (h)->chdr.clen[ 0 ] ) #define HETHDR_PLEN( h ) ( ( (h)->chdr.plen[ 1 ] << 8 ) + (h)->chdr.plen[ 0 ] ) /* || Definitions for HETHDR flags byte 1 (compression incompatable with AWSTAPE) */ #define HETHDR_FLAGS1_BOR 0x80 /* Start of new record */ #define HETHDR_FLAGS1_TAPEMARK 0x40 /* Tape mark */ #define HETHDR_FLAGS1_EOR 0x20 /* End of record */ #define HETHDR_FLAGS1_COMPRESS 0x03 /* Compression method mask */ #define HETHDR_FLAGS1_BZLIB 0x02 /* BZLIB compression */ #define HETHDR_FLAGS1_ZLIB 0x01 /* ZLIB compression */ /* || Definitions for HETHDR flags byte 2 (incompatable with AWSTAPE and HET) */ #define HETHDR_FLAGS2_COMPRESS 0x80 /* Compression method mask */ #define HETHDR_FLAGS2_ZLIB_BUSTECH 0x80 /* Bus-Tech ZLIB compression */ /* || Control block for Hercules Emulated Tape files */ typedef struct _hetb { FILE *fh; /* Tape file handle */ int fd; /* Tape file descriptor */ uint32_t chksize; /* Size of output chunks */ uint32_t ublksize; /* Current block compressed size */ uint32_t cblksize; /* Current block uncompressed size */ uint32_t cblk; /* Current block number */ HETHDR chdr; /* Current block header */ u_int writeprotect:1; /* TRUE=write protected */ u_int readlast:1; /* TRUE=last i/o was read */ u_int truncated:1; /* TRUE=file truncated */ u_int compress:1; /* TRUE=compress written data */ u_int decompress:1; /* TRUE=decompress read data */ u_int method:2; /* 1=ZLIB, 2=BZLIB compresion */ u_int level:4; /* 1=