1 #pragma pack(push, 1)
2 
3 #define MEMZIP_FILE_HEADER_SIGNATURE 0x04034b50
4 typedef struct
5 {
6     uint32_t    signature;
7     uint16_t    version;
8     uint16_t    flags;
9     uint16_t    compression_method;
10     uint16_t    last_mod_time;
11     uint16_t    last_mod_date;
12     uint32_t    crc32;
13     uint32_t    compressed_size;
14     uint32_t    uncompressed_size;
15     uint16_t    filename_len;
16     uint16_t    extra_len;
17 
18     /* char     filename[filename_len]  */
19     /* uint8_t  extra[extra_len]        */
20 
21 } MEMZIP_FILE_HDR;
22 
23 #define MEMZIP_CENTRAL_DIRECTORY_SIGNATURE 0x02014b50
24 typedef struct
25 {
26     uint32_t    signature;
27     uint16_t    version_made_by;
28     uint16_t    version_read_with;
29     uint16_t    flags;
30     uint16_t    compression_method;
31     uint16_t    last_mod_time;
32     uint16_t    last_mod_date;
33     uint32_t    crc32;
34     uint32_t    compressed_size;
35     uint32_t    uncompressed_size;
36     uint16_t    filename_len;
37     uint16_t    extra_len;
38     uint16_t    disk_num;
39     uint16_t    internal_file_attributes;
40     uint32_t    external_file_attributes;
41     uint32_t    file_header_offset;
42 
43     /* char     filename[filename_len]  */
44     /* uint8_t  extra[extra_len]        */
45 
46 } MEMZIP_CENTRAL_DIRECTORY_HDR;
47 
48 #define MEMZIP_END_OF_CENTRAL_DIRECTORY_SIGNATURE 0x06054b50
49 typedef struct
50 {
51     uint32_t    signature;
52     uint16_t    disk_num;
53     uint16_t    central_directory_disk;
54     uint16_t    num_central_directories_this_disk;
55     uint16_t    total_central_directories;
56     uint32_t    central_directory_size;
57     uint32_t    central_directory_offset;
58     uint16_t    comment_len;
59 
60     /* char     comment[comment_len]    */
61 
62 } MEMZIP_END_OF_CENTRAL_DIRECTORY;
63 
64 #pragma pack(pop)
65 
66 typedef enum {
67     MZ_OK = 0,          /* (0) Succeeded */
68     MZ_NO_FILE,         /* (1) Could not find the file. */
69     MZ_FILE_COMPRESSED, /* (2) File is compressed (expecting uncompressed) */
70 
71 } MEMZIP_RESULT;
72 
73 typedef struct {
74     uint32_t    file_size;
75     uint16_t    last_mod_date;
76     uint16_t    last_mod_time;
77     uint8_t     is_dir;
78 
79 } MEMZIP_FILE_INFO;
80 
81 MEMZIP_RESULT memzip_locate(const char *filename, void **data, size_t *len);
82 
83 MEMZIP_RESULT memzip_stat(const char *path, MEMZIP_FILE_INFO *info);
84