32x: drc: some constant propagation
[picodrive.git] / unzip / unzip.h
CommitLineData
cc68a136 1#ifndef __UNZIP_H\r
2#define __UNZIP_H\r
3\r
4#include <stdio.h>\r
5\r
6#ifdef __cplusplus\r
7extern "C" {\r
8#endif\r
9\r
10// notaz: something's missing this\r
11#ifndef UINT16\r
12#define UINT32 unsigned int\r
13#define UINT16 unsigned short\r
14#define UINT8 unsigned char\r
15#endif\r
16\r
17/***************************************************************************\r
18 * Support for retrieving files from zipfiles\r
19 ***************************************************************************/\r
20\r
21struct zipent {\r
22 UINT32 cent_file_header_sig;\r
23 UINT8 version_made_by;\r
24 UINT8 host_os;\r
25 UINT8 version_needed_to_extract;\r
26 UINT8 os_needed_to_extract;\r
27 UINT16 general_purpose_bit_flag;\r
28 UINT16 compression_method;\r
29 UINT16 last_mod_file_time;\r
30 UINT16 last_mod_file_date;\r
31 UINT32 crc32;\r
32 UINT32 compressed_size;\r
33 UINT32 uncompressed_size;\r
34 UINT16 filename_length;\r
35 UINT16 extra_field_length;\r
36 UINT16 file_comment_length;\r
37 UINT16 disk_number_start;\r
38 UINT16 internal_file_attrib;\r
39 UINT32 external_file_attrib;\r
40 UINT32 offset_lcl_hdr_frm_frst_disk;\r
41 char* name; /* 0 terminated */\r
42};\r
43\r
44typedef struct _ZIP {\r
45 char* zip; /* zip name */\r
46 FILE* fp; /* zip handler */\r
47 long length; /* length of zip file */\r
48\r
49 char* ecd; /* end_of_cent_dir data */\r
50 unsigned ecd_length; /* end_of_cent_dir length */\r
51\r
52 char* cd; /* cent_dir data */\r
53\r
54 unsigned cd_pos; /* position in cent_dir */\r
55\r
56 struct zipent ent; /* buffer for readzip */\r
57\r
58 /* end_of_cent_dir */\r
59 UINT32 end_of_cent_dir_sig;\r
60 UINT16 number_of_this_disk;\r
61 UINT16 number_of_disk_start_cent_dir;\r
62 UINT16 total_entries_cent_dir_this_disk;\r
63 UINT16 total_entries_cent_dir;\r
64 UINT32 size_of_cent_dir;\r
65 UINT32 offset_to_start_of_cent_dir;\r
66 UINT16 zipfile_comment_length;\r
67 char* zipfile_comment; /* pointer in ecd */\r
68} ZIP;\r
69\r
70/* Opens a zip stream for reading\r
71 return:\r
72 !=0 success, zip stream\r
73 ==0 error\r
74*/\r
75ZIP* openzip(const char* path);\r
76\r
77/* Closes a zip stream */\r
78void closezip(ZIP* zip);\r
79\r
80/* Reads the current entry from a zip stream\r
81 in:\r
82 zip opened zip\r
83 return:\r
84 !=0 success\r
85 ==0 error\r
86*/\r
87struct zipent* readzip(ZIP* zip);\r
88\r
89/* Suspend access to a zip file (release file handler)\r
90 in:\r
91 zip opened zip\r
92 note:\r
93 A suspended zip is automatically reopened at first call of\r
94 readuncompressd() or readcompressed() functions\r
95*/\r
96void suspendzip(ZIP* zip);\r
97\r
98/* Resets a zip stream to the first entry\r
99 in:\r
100 zip opened zip\r
101 note:\r
102 ZIP file must be opened and not suspended\r
103*/\r
104void rewindzip(ZIP* zip);\r
105\r
106/* Read compressed data from a zip entry\r
107 in:\r
108 zip opened zip\r
109 ent entry to read\r
110 out:\r
111 data buffer for data, ent.compressed_size UINT8s allocated by the caller\r
112 return:\r
113 ==0 success\r
114 <0 error\r
115*/\r
116int readcompresszip(ZIP* zip, struct zipent* ent, char* data);\r
117\r
118/* Read decompressed data from a zip entry\r
119 in:\r
120 zip zip stream open\r
121 ent entry to read\r
122 out:\r
123 data buffer for data, ent.uncompressed_size UINT8s allocated by the caller\r
124 return:\r
125 ==0 success\r
126 <0 error\r
127*/\r
128int readuncompresszip(ZIP* zip, struct zipent* ent, char* data);\r
129\r
83bd0b76 130int seekcompresszip(ZIP* zip, struct zipent* ent);\r
131\r
cc68a136 132/* public functions */\r
133int /* error */ load_zipped_file (const char *zipfile, const char *filename,\r
134 unsigned char **buf, unsigned int *length);\r
135int /* error */ checksum_zipped_file (const char *zipfile, const char *filename, unsigned int *length, unsigned int *sum);\r
136\r
137void unzip_cache_clear(void);\r
138\r
139/* public globals */\r
140extern int gUnzipQuiet; /* flag controls error messages */\r
141\r
142#ifdef __cplusplus\r
143}\r
144#endif\r
145\r
146#endif\r