CMS 3D CMS Logo

ZConstants.h

Go to the documentation of this file.
00001 #ifndef CLASSLIB_Z_CONSTANTS_H
00002 # define CLASSLIB_Z_CONSTANTS_H
00003 
00004 //<<<<<< INCLUDES                                                       >>>>>>
00005 
00006 # include "classlib/zip/ZipUtils.h"
00007 
00008 namespace lat {
00009 //<<<<<< PUBLIC DEFINES                                                 >>>>>>
00010 //<<<<<< PUBLIC CONSTANTS                                               >>>>>>
00011 //<<<<<< PUBLIC TYPES                                                   >>>>>>
00012 //<<<<<< PUBLIC VARIABLES                                               >>>>>>
00013 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>
00014 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
00015 
00017 struct ZConstants : ZipUtils
00018 {
00019     // ZLIB constants
00020     // - Compression method and strategy (FIXME: data type: ascii/binary?)
00021     enum Method {
00022         STORED                          = 0, //< Stored as is
00023         DEFLATED                        = 8  //< Stored using deflate
00024     };
00025     enum Strategy {
00026         DEFAULT                         = 0, //< Default compression strategy
00027         FILTERED                        = 1, //< FIXME
00028         HUFFMAN_ONLY                    = 2  //< FIXME
00029     };
00030 
00031     // - Compression levels
00032     enum { BEST_COMPRESSION             = 9 }; //< Best compression level
00033     enum { DEFAULT_COMPRESSION          = 6 }; //< Default compression level
00034     enum { BEST_SPEED                   = 1 }; //< Fastest compression level
00035 
00036     // - Other settings
00037     enum { DEFAULT_WINDOW_BITS          = 15 };
00038     enum { DEFAULT_MEM_LEVEL            = 8 };
00039 
00040     // ZIP archive constants
00041     // - Archive version required (and made)
00042     enum { ARCHIVE_VERSION              = 20 };
00043 
00044     // - Magic header constants
00045     enum { DIR_HEADER_MAGIC             = 0x02014b50 };
00046     enum { ENTRY_HEADER_MAGIC           = 0x04034b50 };
00047     enum { END_HEADER_MAGIC             = 0x06054b50 };
00048     enum { ZIP_MAGIC_LEN                = 4 };
00049     enum { MAX_VAR_LEN                  = 0xffff };     //< Max variable-width field length
00050     enum { MAX_SIZE                     = 0xffffffff }; //< Max size of things
00051 
00052 
00053     // - Offsets into the central directory headers
00054     enum {
00055         DIR_MAGIC_OFF           = 0,
00056         DIR_VMADE_OFF           = 4,    DIR_VMADE_LEN           = 2,
00057         DIR_VREQD_OFF           = 6,    DIR_VREQD_LEN           = 2,
00058         DIR_FLAG_OFF            = 8,    DIR_FLAG_LEN            = 2,
00059         DIR_METHOD_OFF          = 10,   DIR_METHOD_LEN          = 2,
00060         DIR_DATE_OFF            = 12,   DIR_DATE_LEN            = 4,
00061         DIR_CRC32_OFF           = 16,   DIR_CRC32_LEN           = 4,
00062         DIR_CSIZE_OFF           = 20,   DIR_CSIZE_LEN           = 4,
00063         DIR_USIZE_OFF           = 24,   DIR_USIZE_LEN           = 4,
00064         DIR_NAMELEN_OFF         = 28,   DIR_NAMELEN_LEN         = 2,
00065         DIR_EXTRALEN_OFF        = 30,   DIR_EXTRALEN_LEN        = 2,
00066         DIR_COMMENTLEN_OFF      = 32,   DIR_COMMENTLEN_LEN      = 2,
00067         DIR_DISK_START_OFF      = 34,   DIR_DISK_START_LEN      = 2,
00068         DIR_INT_ATTR_OFF        = 36,   DIR_INT_ATTR_LEN        = 2,
00069         DIR_EXT_ATTR_OFF        = 38,   DIR_EXT_ATTR_LEN        = 4,
00070         DIR_ENTRY_POS_OFF       = 42,   DIR_ENTRY_POS_LEN       = 4,
00071         DIR_HEADER_SIZE         = 46
00072     };
00073 
00074     // - Offsets into the end-of-archive header
00075     enum{
00076         END_MAGIC_OFF           = 0,
00077         END_DISK_OFF            = 4,    END_DISK_LEN            = 2,
00078         END_DIR_DISK_OFF        = 6,    END_DIR_DISK_LEN        = 2,
00079         END_DISK_HDRS_OFF       = 8,    END_DISK_HDRS_LEN       = 2,
00080         END_TOTAL_HDRS_OFF      = 10,   END_TOTAL_HDRS_LEN      = 2,
00081         END_DIR_SIZE_OFF        = 12,   END_DIR_SIZE_LEN        = 4,
00082         END_DIR_OFFSET_OFF      = 16,   END_DIR_OFFSET_LEN      = 4,
00083         END_COMMENTLEN_OFF      = 20,   END_COMMENTLEN_LEN      = 2,
00084         END_HEADER_SIZE         = 22
00085     };
00086 
00087     // - Offsets into the local entry headers
00088     enum {
00089         ENTRY_MAGIC_OFF         = 0,
00090         ENTRY_VREQD_OFF         = 4,    ENTRY_VREQD_LEN         = 2,
00091         ENTRY_FLAG_OFF          = 6,    ENTRY_FLAG_LEN          = 2,
00092         ENTRY_METHOD_OFF        = 8,    ENTRY_METHOD_LEN        = 2,
00093         ENTRY_DATE_OFF          = 10,   ENTRY_DATE_LEN          = 4,
00094         ENTRY_CRC32_OFF         = 14,   ENTRY_CRC32_LEN         = 4,
00095         ENTRY_CSIZE_OFF         = 18,   ENTRY_CSIZE_LEN         = 4,
00096         ENTRY_USIZE_OFF         = 22,   ENTRY_USIZE_LEN         = 4,
00097         ENTRY_NAMELEN_OFF       = 26,   ENTRY_NAMELEN_LEN       = 2,
00098         ENTRY_EXTRALEN_OFF      = 28,   ENTRY_EXTRALEN_LEN      = 2,
00099         ENTRY_HEADER_SIZE       = 30
00100     };
00101 
00102     // GZIP file format constants
00103     enum { GZIP_MAGIC = 0x8b1f };
00104     enum {
00105         GZHDR_MAGIC_OFF  = 0, GZHDR_MAGIC_LEN  = 2,
00106         GZHDR_METHOD_OFF = 2, GZHDR_METHOD_LEN = 1,
00107         GZHDR_FLAGS_OFF  = 3, GZHDR_FLAGS_LEN  = 1,
00108         GZHDR_TIME_OFF   = 4, GZHDR_TIME_LEN   = 4,
00109         GZHDR_XFLAGS_OFF = 8, GZHDR_XFLAGS_LEN = 1,
00110         GZHDR_OS_OFF     = 9, GZHDR_OS_LEN     = 1,
00111         GZHDR_SIZE       = 10,
00112 
00113         // The standard header can be followed by:
00114         //   - extra field: 2-byte len + data (flags & EXTRA_FIELD)
00115         //   - original file name: EOF-terminated string (flags & ORIG_NAME)
00116         //   - comment: EOF-terminaed string (flags & COMMENT)
00117         //   - header crc: 2-byte value (flags & HEAD_CRC)
00118         //
00119         // This is followed by data, and finally 4-byte CRC-32 and a
00120         // 4-byte original uncompressed data length (FIXME: .gz files
00121         // can be concatenated back-to-back, need to reset total_out
00122         // in z_stream and reinit crc32).
00123 
00124         GZHDR_FLAG_ASCII        = 1,  // bit 0: file is probably ascii text
00125         GZHDR_FLAG_HEAD_CRC     = 2,  // bit 1: header crc16 present
00126         GZHDR_FLAG_EXTRA_FIELD  = 4,  // bit 2: extra field present
00127         GZHDR_FLAG_ORIG_NAME    = 8,  // bit 3: original file name present
00128         GZHDR_FLAG_COMMENT      = 16, // bit 4: file comment present
00129         GZHDR_FLAG_RESERVED     = 0xe0 // bits 5-7: reserved
00130     };
00131 };
00132 
00133 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
00134 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
00135 
00136 } // namespace lat
00137 #endif // CLASSLIB_Z_CONSTANTS_H

Generated on Tue Jun 9 17:39:00 2009 for CMSSW by  doxygen 1.5.4