00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_ZIP_H__
00021 #define __CS_ZIP_H__
00022
00023 #if defined(__cplusplus) && !defined(COMP_BC)
00024 extern "C" {
00025 #endif
00026
00027 #define Byte z_Byte
00028 #include <zlib.h>
00029 #undef Byte
00030
00031 #if defined(__cplusplus) && !defined(COMP_BC)
00032 }
00033 #endif
00034
00035 #define CENTRAL_HDR_SIG '\001','\002'
00036 #define LOCAL_HDR_SIG '\003','\004'
00037 #define END_CENTRAL_SIG '\005','\006'
00038 #define EXTD_LOCAL_SIG '\007','\010'
00039
00040 #define DEF_WBITS 15
00041 #define ZIP_STORE 0
00042 #define ZIP_DEFLATE 8
00043
00044 typedef unsigned char uch;
00045 typedef unsigned short ush;
00046 typedef unsigned int u32;
00047
00048 #if 0
00049 # define CRCVAL_INITIAL crc32(0L, NULL, 0)
00050 #else
00051 # define CRCVAL_INITIAL 0L
00052 #endif
00053
00054 typedef struct
00055 {
00056 uch version_needed_to_extract[2];
00057 ush general_purpose_bit_flag;
00058 ush compression_method;
00059 ush last_mod_file_time;
00060 ush last_mod_file_date;
00061 u32 crc32;
00062 u32 csize;
00063 u32 ucsize;
00064 ush filename_length;
00065 ush extra_field_length;
00066 } ZIP_local_file_header;
00067
00068 typedef struct
00069 {
00070 uch version_made_by[2];
00071 uch version_needed_to_extract[2];
00072 ush general_purpose_bit_flag;
00073 ush compression_method;
00074 ush last_mod_file_time;
00075 ush last_mod_file_date;
00076 u32 crc32;
00077 u32 csize;
00078 u32 ucsize;
00079 ush filename_length;
00080 ush extra_field_length;
00081 ush file_comment_length;
00082 ush disk_number_start;
00083 ush internal_file_attributes;
00084 u32 external_file_attributes;
00085 u32 relative_offset_local_header;
00086 } ZIP_central_directory_file_header;
00087
00088 typedef struct
00089 {
00090 ush number_this_disk;
00091 ush num_disk_start_cdir;
00092 ush num_entries_centrl_dir_ths_disk;
00093 ush total_entries_central_dir;
00094 u32 size_central_directory;
00095 u32 offset_start_central_directory;
00096 ush zipfile_comment_length;
00097 } ZIP_end_central_dir_record;
00098
00099
00100 #define ZIP_LOCAL_FILE_HEADER_SIZE 26
00101 # define L_VERSION_NEEDED_TO_EXTRACT_0 0
00102 # define L_VERSION_NEEDED_TO_EXTRACT_1 1
00103 # define L_GENERAL_PURPOSE_BIT_FLAG 2
00104 # define L_COMPRESSION_METHOD 4
00105 # define L_LAST_MOD_FILE_TIME 6
00106 # define L_LAST_MOD_FILE_DATE 8
00107 # define L_CRC32 10
00108 # define L_COMPRESSED_SIZE 14
00109 # define L_UNCOMPRESSED_SIZE 18
00110 # define L_FILENAME_LENGTH 22
00111 # define L_EXTRA_FIELD_LENGTH 24
00112
00113
00114 #define ZIP_CENTRAL_DIRECTORY_FILE_HEADER_SIZE 42
00115 # define C_VERSION_MADE_BY_0 0
00116 # define C_VERSION_MADE_BY_1 1
00117 # define C_VERSION_NEEDED_TO_EXTRACT_0 2
00118 # define C_VERSION_NEEDED_TO_EXTRACT_1 3
00119 # define C_GENERAL_PURPOSE_BIT_FLAG 4
00120 # define C_COMPRESSION_METHOD 6
00121 # define C_LAST_MOD_FILE_TIME 8
00122 # define C_LAST_MOD_FILE_DATE 10
00123 # define C_CRC32 12
00124 # define C_COMPRESSED_SIZE 16
00125 # define C_UNCOMPRESSED_SIZE 20
00126 # define C_FILENAME_LENGTH 24
00127 # define C_EXTRA_FIELD_LENGTH 26
00128 # define C_FILE_COMMENT_LENGTH 28
00129 # define C_DISK_NUMBER_START 30
00130 # define C_INTERNAL_FILE_ATTRIBUTES 32
00131 # define C_EXTERNAL_FILE_ATTRIBUTES 34
00132 # define C_RELATIVE_OFFSET_LOCAL_HEADER 38
00133
00134
00135 #define ZIP_END_CENTRAL_DIR_RECORD_SIZE 18
00136 # define E_NUMBER_THIS_DISK 0
00137 # define E_NUM_DISK_WITH_START_CENTRAL_DIR 2
00138 # define E_NUM_ENTRIES_CENTRL_DIR_THS_DISK 4
00139 # define E_TOTAL_ENTRIES_CENTRAL_DIR 6
00140 # define E_SIZE_CENTRAL_DIRECTORY 8
00141 # define E_OFFSET_START_CENTRAL_DIRECTORY 12
00142 # define E_ZIPFILE_COMMENT_LENGTH 16
00143
00144 #endif // __CS_ZIP_H__