]> Shamusworld >> Repos - virtualjaguar/blob - src/unzip.h
Fixed types in types.h to use C99 standard types, also removed all references
[virtualjaguar] / src / unzip.h
1 #ifndef __UNZIP_H__
2 #define __UNZIP_H__
3
4 //#include "types.h"
5 #include <stdio.h>
6 #include <stdint.h>
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 /***************************************************************************
13  * Support for retrieving files from zipfiles
14  ***************************************************************************/
15
16 struct zipent
17 {
18         uint32_t        cent_file_header_sig;
19         uint8_t version_made_by;
20         uint8_t host_os;
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;
27         uint32_t        crc32;
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 */
38 };
39
40 typedef struct _ZIP
41 {
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 */
51         /* end_of_cent_dir */
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 */
61 } ZIP;
62
63 /* Opens a zip stream for reading
64    return:
65      !=0 success, zip stream
66      ==0 error
67 */
68 ZIP * openzip(int pathtype, int pathindex, const char * path);
69
70 /* Closes a zip stream */
71 void closezip(ZIP * zip);
72
73 /* Reads the current entry from a zip stream
74    in:
75      zip opened zip
76    return:
77      !=0 success
78      ==0 error
79 */
80 struct zipent * readzip(ZIP * zip);
81
82 /* Suspend access to a zip file (release file handler)
83    in:
84       zip opened zip
85    note:
86      A suspended zip is automatically reopened at first call of
87      readuncompressd() or readcompressed() functions
88 */
89 void suspendzip(ZIP * zip);
90
91 /* Resets a zip stream to the first entry
92    in:
93      zip opened zip
94    note:
95      ZIP file must be opened and not suspended
96 */
97 void rewindzip(ZIP * zip);
98
99 /* Read compressed data from a zip entry
100    in:
101      zip opened zip
102      ent entry to read
103    out:
104      data buffer for data, ent.compressed_size uint8_ts allocated by the caller
105    return:
106      ==0 success
107      <0 error
108 */
109 int readcompresszip(ZIP * zip, struct zipent * ent, char * data);
110
111 /* Read decompressed data from a zip entry
112    in:
113      zip zip stream open
114      ent entry to read
115    out:
116      data buffer for data, ent.uncompressed_size uint8_ts allocated by the caller
117    return:
118      ==0 success
119      <0 error
120 */
121 int readuncompresszip(ZIP * zip, struct zipent * ent, char * data);
122
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);
126
127 void unzip_cache_clear(void);
128
129 /* public globals */
130 extern int      gUnzipQuiet;    /* flag controls error messages */
131
132 #ifdef __cplusplus
133 }
134 #endif
135
136 #endif  // __UNZIP_H__