11 /***************************************************************************
12 * Support for retrieving files from zipfiles
13 ***************************************************************************/
17 uint32_t cent_file_header_sig;
18 uint8_t version_made_by;
20 uint8_t version_needed_to_extract;
21 uint8_t os_needed_to_extract;
22 uint16_t general_purpose_bit_flag;
23 uint16_t compression_method;
24 uint16_t last_mod_file_time;
25 uint16_t last_mod_file_date;
27 uint32_t compressed_size;
28 uint32_t uncompressed_size;
29 uint16_t filename_length;
30 uint16_t extra_field_length;
31 uint16_t file_comment_length;
32 uint16_t disk_number_start;
33 uint16_t internal_file_attrib;
34 uint32_t external_file_attrib;
35 uint32_t offset_lcl_hdr_frm_frst_disk;
36 char * name; /* 0 terminated */
41 char * zip; /* zip name */
42 FILE * fp; /* zip handler */
43 int pathtype, pathindex; /* additional path info */
44 long length; /* length of zip file */
45 char * ecd; /* end_of_cent_dir data */
46 unsigned ecd_length; /* end_of_cent_dir length */
47 char * cd; /* cent_dir data */
48 unsigned cd_pos; /* position in cent_dir */
49 struct zipent ent; /* buffer for readzip */
51 uint32_t end_of_cent_dir_sig;
52 uint16_t number_of_this_disk;
53 uint16_t number_of_disk_start_cent_dir;
54 uint16_t total_entries_cent_dir_this_disk;
55 uint16_t total_entries_cent_dir;
56 uint32_t size_of_cent_dir;
57 uint32_t offset_to_start_of_cent_dir;
58 uint16_t zipfile_comment_length;
59 char * zipfile_comment; /* pointer in ecd */
62 /* Opens a zip stream for reading
64 !=0 success, zip stream
67 ZIP * openzip(int pathtype, int pathindex, const char * path);
69 /* Closes a zip stream */
70 void closezip(ZIP * zip);
72 /* Reads the current entry from a zip stream
79 struct zipent * readzip(ZIP * zip);
81 /* Suspend access to a zip file (release file handler)
85 A suspended zip is automatically reopened at first call of
86 readuncompressd() or readcompressed() functions
88 void suspendzip(ZIP * zip);
90 /* Resets a zip stream to the first entry
94 ZIP file must be opened and not suspended
96 void rewindzip(ZIP * zip);
98 /* Read compressed data from a zip entry
103 data buffer for data, ent.compressed_size uint8_ts allocated by the caller
108 int readcompresszip(ZIP * zip, struct zipent * ent, char * data);
110 /* Read decompressed data from a zip entry
115 data buffer for data, ent.uncompressed_size uint8_ts allocated by the caller
120 int readuncompresszip(ZIP * zip, struct zipent * ent, char * data);
122 /* public functions */
123 int /* error */ load_zipped_file(int pathtype, int pathindex, const char * zipfile, const char * filename,
124 unsigned char ** buf, uint32_t * length);
126 void unzip_cache_clear(void);
129 extern int gUnzipQuiet; /* flag controls error messages */
135 #endif // __UNZIP_H__