12 /***************************************************************************
13 * Support for retrieving files from zipfiles
14 ***************************************************************************/
18 uint32_t cent_file_header_sig;
19 uint8_t version_made_by;
21 uint8_t version_needed_to_extract;
22 uint8_t os_needed_to_extract;
23 uint16_t general_purpose_bit_flag;
24 uint16_t compression_method;
25 uint16_t last_mod_file_time;
26 uint16_t last_mod_file_date;
28 uint32_t compressed_size;
29 uint32_t uncompressed_size;
30 uint16_t filename_length;
31 uint16_t extra_field_length;
32 uint16_t file_comment_length;
33 uint16_t disk_number_start;
34 uint16_t internal_file_attrib;
35 uint32_t external_file_attrib;
36 uint32_t offset_lcl_hdr_frm_frst_disk;
37 char * name; /* 0 terminated */
42 char * zip; /* zip name */
43 FILE * fp; /* zip handler */
44 int pathtype, pathindex; /* additional path info */
45 long length; /* length of zip file */
46 char * ecd; /* end_of_cent_dir data */
47 unsigned ecd_length; /* end_of_cent_dir length */
48 char * cd; /* cent_dir data */
49 unsigned cd_pos; /* position in cent_dir */
50 struct zipent ent; /* buffer for readzip */
52 uint32_t end_of_cent_dir_sig;
53 uint16_t number_of_this_disk;
54 uint16_t number_of_disk_start_cent_dir;
55 uint16_t total_entries_cent_dir_this_disk;
56 uint16_t total_entries_cent_dir;
57 uint32_t size_of_cent_dir;
58 uint32_t offset_to_start_of_cent_dir;
59 uint16_t zipfile_comment_length;
60 char * zipfile_comment; /* pointer in ecd */
63 /* Opens a zip stream for reading
65 !=0 success, zip stream
68 ZIP * openzip(int pathtype, int pathindex, const char * path);
70 /* Closes a zip stream */
71 void closezip(ZIP * zip);
73 /* Reads the current entry from a zip stream
80 struct zipent * readzip(ZIP * zip);
82 /* Suspend access to a zip file (release file handler)
86 A suspended zip is automatically reopened at first call of
87 readuncompressd() or readcompressed() functions
89 void suspendzip(ZIP * zip);
91 /* Resets a zip stream to the first entry
95 ZIP file must be opened and not suspended
97 void rewindzip(ZIP * zip);
99 /* Read compressed data from a zip entry
104 data buffer for data, ent.compressed_size uint8_ts allocated by the caller
109 int readcompresszip(ZIP * zip, struct zipent * ent, char * data);
111 /* Read decompressed data from a zip entry
116 data buffer for data, ent.uncompressed_size uint8_ts allocated by the caller
121 int readuncompresszip(ZIP * zip, struct zipent * ent, char * data);
123 /* public functions */
124 int /* error */ load_zipped_file(int pathtype, int pathindex, const char * zipfile, const char * filename,
125 unsigned char ** buf, uint32_t * length);
127 void unzip_cache_clear(void);
130 extern int gUnzipQuiet; /* flag controls error messages */
136 #endif // __UNZIP_H__