| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# csutil/zip.h

Go to the documentation of this file.

    00001 /*
    00002     ZIP archive support for Crystal Space 3D library
    00003     Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru>
    00004
    00005     This library is free software; you can redistribute it and/or
    00006     modify it under the terms of the GNU Library General Public
    00007     License as published by the Free Software Foundation; either
    00008     version 2 of the License, or (at your option) any later version.
    00009
    00010     This library is distributed in the hope that it will be useful,
    00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013     Library General Public License for more details.
    00014
    00015     You should have received a copy of the GNU Library General Public
    00016     License along with this library; if not, write to the Free
    00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00018 */
    00019
    00020 #ifndef __CS_ZIP_H__
    00021 #define __CS_ZIP_H__
    00022
    00027 #if defined(__cplusplus) && !defined(CS_COMPILER_BCC)
    00028 extern "C" {
    00029 #endif
    00030
    00031 #define Byte z_Byte     /* Kludge to avoid conflicting typedef in zconf.h */
    00032 #include <zlib.h>
    00033 #undef Byte
    00034
    00035 #if defined(__cplusplus) && !defined(CS_COMPILER_BCC)
    00036 }
    00037 #endif
    00038
    00039 #define CENTRAL_HDR_SIG '\001','\002'   /* the infamous "PK" signature bytes, */
    00040 #define LOCAL_HDR_SIG   '\003','\004'   /*  sans "PK" (so unzip executable not */
    00041 #define END_CENTRAL_SIG '\005','\006'   /*  mistaken for zipfile itself) */
    00042 #define EXTD_LOCAL_SIG  '\007','\010'   /* [ASCII "\113" == EBCDIC "\080" ??] */
    00043
    00044 #define DEF_WBITS       15              /* Default LZ77 window size */
    00045 #define ZIP_STORE       0               /* 'STORED' method id */
    00046 #define ZIP_DEFLATE     8               /* 'DEFLATE' method id */
    00047
    00048 typedef uint8  uch;
    00049 typedef uint16 ush;
    00050 typedef uint32 u32;
    00051
    00052 #if 0            /* Optimization: use the (const) result of crc32(0L,0,0) */
    00053 #  define CRCVAL_INITIAL  crc32(0L, 0, 0)
    00054 #else
    00055 #  define CRCVAL_INITIAL  0L
    00056 #endif
    00057
    00058 typedef struct
    00059 {
    00060   uch version_needed_to_extract[2];
    00061   ush general_purpose_bit_flag;
    00062   ush compression_method;
    00063   ush last_mod_file_time;
    00064   ush last_mod_file_date;
    00065   u32 crc32;
    00066   u32 csize;
    00067   u32 ucsize;
    00068   ush filename_length;
    00069   ush extra_field_length;
    00070 } ZIP_local_file_header;
    00071
    00072 typedef struct
    00073 {
    00074   uch version_made_by[2];
    00075   uch version_needed_to_extract[2];
    00076   ush general_purpose_bit_flag;
    00077   ush compression_method;
    00078   ush last_mod_file_time;
    00079   ush last_mod_file_date;
    00080   u32 crc32;
    00081   u32 csize;
    00082   u32 ucsize;
    00083   ush filename_length;
    00084   ush extra_field_length;
    00085   ush file_comment_length;
    00086   ush disk_number_start;
    00087   ush internal_file_attributes;
    00088   u32 external_file_attributes;
    00089   u32 relative_offset_local_header;
    00090 } ZIP_central_directory_file_header;
    00091
    00092 typedef struct
    00093 {
    00094   ush number_this_disk;
    00095   ush num_disk_start_cdir;
    00096   ush num_entries_centrl_dir_ths_disk;
    00097   ush total_entries_central_dir;
    00098   u32 size_central_directory;
    00099   u32 offset_start_central_directory;
    00100   ush zipfile_comment_length;
    00101 } ZIP_end_central_dir_record;
    00102
    00103 //--- ZIP_local_file_header layout ---------------------------------------------
    00104 #define ZIP_LOCAL_FILE_HEADER_SIZE              26
    00105 #      define L_VERSION_NEEDED_TO_EXTRACT_0     0
    00106 #      define L_VERSION_NEEDED_TO_EXTRACT_1     1
    00107 #      define L_GENERAL_PURPOSE_BIT_FLAG        2
    00108 #      define L_COMPRESSION_METHOD              4
    00109 #      define L_LAST_MOD_FILE_TIME              6
    00110 #      define L_LAST_MOD_FILE_DATE              8
    00111 #      define L_CRC32                           10
    00112 #      define L_COMPRESSED_SIZE                 14
    00113 #      define L_UNCOMPRESSED_SIZE               18
    00114 #      define L_FILENAME_LENGTH                 22
    00115 #      define L_EXTRA_FIELD_LENGTH              24
    00116
    00117 //--- ZIP_central_directory_file_header layout ---------------------------------
    00118 #define ZIP_CENTRAL_DIRECTORY_FILE_HEADER_SIZE  42
    00119 #      define C_VERSION_MADE_BY_0               0
    00120 #      define C_VERSION_MADE_BY_1               1
    00121 #      define C_VERSION_NEEDED_TO_EXTRACT_0     2
    00122 #      define C_VERSION_NEEDED_TO_EXTRACT_1     3
    00123 #      define C_GENERAL_PURPOSE_BIT_FLAG        4
    00124 #      define C_COMPRESSION_METHOD              6
    00125 #      define C_LAST_MOD_FILE_TIME              8
    00126 #      define C_LAST_MOD_FILE_DATE              10
    00127 #      define C_CRC32                           12
    00128 #      define C_COMPRESSED_SIZE                 16
    00129 #      define C_UNCOMPRESSED_SIZE               20
    00130 #      define C_FILENAME_LENGTH                 24
    00131 #      define C_EXTRA_FIELD_LENGTH              26
    00132 #      define C_FILE_COMMENT_LENGTH             28
    00133 #      define C_DISK_NUMBER_START               30
    00134 #      define C_INTERNAL_FILE_ATTRIBUTES        32
    00135 #      define C_EXTERNAL_FILE_ATTRIBUTES        34
    00136 #      define C_RELATIVE_OFFSET_LOCAL_HEADER    38
    00137
    00138 //--- ZIP_end_central_dir_record layout ----------------------------------------
    00139 #define ZIP_END_CENTRAL_DIR_RECORD_SIZE         18
    00140 #      define E_NUMBER_THIS_DISK                0
    00141 #      define E_NUM_DISK_WITH_START_CENTRAL_DIR 2
    00142 #      define E_NUM_ENTRIES_CENTRL_DIR_THS_DISK 4
    00143 #      define E_TOTAL_ENTRIES_CENTRAL_DIR       6
    00144 #      define E_SIZE_CENTRAL_DIRECTORY          8
    00145 #      define E_OFFSET_START_CENTRAL_DIRECTORY  12
    00146 #      define E_ZIPFILE_COMMENT_LENGTH          16
    00147
    00148 #endif // __CS_ZIP_H__