]> Shamusworld >> Repos - virtualjaguar/blob - src/include/unzip.h
Changes to accomodate PAL/NTSC screen heights
[virtualjaguar] / src / include / unzip.h
1 #ifndef __UNZIP_H__
2 #define __UNZIP_H__
3
4 #include "types.h"
5 #include <stdio.h>
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 /***************************************************************************
12  * Support for retrieving files from zipfiles
13  ***************************************************************************/
14
15 struct zipent
16 {
17         UINT32  cent_file_header_sig;
18         UINT8   version_made_by;
19         UINT8   host_os;
20         UINT8   version_needed_to_extract;
21         UINT8   os_needed_to_extract;
22         UINT16  general_purpose_bit_flag;
23         UINT16  compression_method;
24         UINT16  last_mod_file_time;
25         UINT16  last_mod_file_date;
26         UINT32  crc32;
27         UINT32  compressed_size;
28         UINT32  uncompressed_size;
29         UINT16  filename_length;
30         UINT16  extra_field_length;
31         UINT16  file_comment_length;
32         UINT16  disk_number_start;
33         UINT16  internal_file_attrib;
34         UINT32  external_file_attrib;
35         UINT32  offset_lcl_hdr_frm_frst_disk;
36         char *  name; /* 0 terminated */
37 };
38
39 typedef struct _ZIP
40 {
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 */
50         /* end_of_cent_dir */
51         UINT32  end_of_cent_dir_sig;
52         UINT16  number_of_this_disk;
53         UINT16  number_of_disk_start_cent_dir;
54         UINT16  total_entries_cent_dir_this_disk;
55         UINT16  total_entries_cent_dir;
56         UINT32  size_of_cent_dir;
57         UINT32  offset_to_start_of_cent_dir;
58         UINT16  zipfile_comment_length;
59         char *  zipfile_comment;        /* pointer in ecd */
60 } ZIP;
61
62 /* Opens a zip stream for reading
63    return:
64      !=0 success, zip stream
65      ==0 error
66 */
67 ZIP * openzip(int pathtype, int pathindex, const char * path);
68
69 /* Closes a zip stream */
70 void closezip(ZIP * zip);
71
72 /* Reads the current entry from a zip stream
73    in:
74      zip opened zip
75    return:
76      !=0 success
77      ==0 error
78 */
79 struct zipent * readzip(ZIP * zip);
80
81 /* Suspend access to a zip file (release file handler)
82    in:
83       zip opened zip
84    note:
85      A suspended zip is automatically reopened at first call of
86      readuncompressd() or readcompressed() functions
87 */
88 void suspendzip(ZIP * zip);
89
90 /* Resets a zip stream to the first entry
91    in:
92      zip opened zip
93    note:
94      ZIP file must be opened and not suspended
95 */
96 void rewindzip(ZIP * zip);
97
98 /* Read compressed data from a zip entry
99    in:
100      zip opened zip
101      ent entry to read
102    out:
103      data buffer for data, ent.compressed_size UINT8s allocated by the caller
104    return:
105      ==0 success
106      <0 error
107 */
108 int readcompresszip(ZIP * zip, struct zipent * ent, char * data);
109
110 /* Read decompressed data from a zip entry
111    in:
112      zip zip stream open
113      ent entry to read
114    out:
115      data buffer for data, ent.uncompressed_size UINT8s allocated by the caller
116    return:
117      ==0 success
118      <0 error
119 */
120 int readuncompresszip(ZIP * zip, struct zipent * ent, char * data);
121
122 /* public functions */
123 int /* error */ load_zipped_file(int pathtype, int pathindex, const char * zipfile, const char * filename,
124         unsigned char ** buf, uint32 * length);
125
126 void unzip_cache_clear(void);
127
128 /* public globals */
129 extern int      gUnzipQuiet;    /* flag controls error messages */
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif  // __UNZIP_H__