Coverage Report

Created: 2026-02-14 07:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/minizip-ng/mz.h
Line
Count
Source
1
/* mz.h -- Errors codes, zip flags and magic
2
   part of the minizip-ng project
3
4
   Copyright (C) Nathan Moinvaziri
5
     https://github.com/zlib-ng/minizip-ng
6
7
   This program is distributed under the terms of the same license as zlib.
8
   See the accompanying LICENSE file for the full text of the license.
9
*/
10
11
#ifndef MZ_H
12
#define MZ_H
13
14
/***************************************************************************/
15
16
/* MZ_VERSION */
17
#define MZ_VERSION       ("4.1.0")
18
#define MZ_VERSION_BUILD (0x040100)
19
20
/* MZ_ERROR */
21
969k
#define MZ_OK             (0)  /* zlib */
22
0
#define MZ_STREAM_ERROR   (-1) /* zlib */
23
0
#define MZ_DATA_ERROR     (-3) /* zlib */
24
0
#define MZ_MEM_ERROR      (-4) /* zlib */
25
0
#define MZ_BUF_ERROR      (-5) /* zlib */
26
#define MZ_VERSION_ERROR  (-6) /* zlib */
27
28
0
#define MZ_END_OF_LIST    (-100)
29
272
#define MZ_END_OF_STREAM  (-101)
30
31
8.61k
#define MZ_PARAM_ERROR    (-102)
32
0
#define MZ_FORMAT_ERROR   (-103)
33
0
#define MZ_INTERNAL_ERROR (-104)
34
0
#define MZ_CRC_ERROR      (-105)
35
0
#define MZ_CRYPT_ERROR    (-106)
36
14.2k
#define MZ_EXIST_ERROR    (-107)
37
0
#define MZ_PASSWORD_ERROR (-108)
38
47
#define MZ_SUPPORT_ERROR  (-109)
39
0
#define MZ_HASH_ERROR     (-110)
40
70
#define MZ_OPEN_ERROR     (-111)
41
0
#define MZ_CLOSE_ERROR    (-112)
42
0
#define MZ_SEEK_ERROR     (-113)
43
0
#define MZ_TELL_ERROR     (-114)
44
0
#define MZ_READ_ERROR     (-115)
45
0
#define MZ_WRITE_ERROR    (-116)
46
#define MZ_SIGN_ERROR     (-117)
47
#define MZ_SYMLINK_ERROR  (-118)
48
49
/* MZ_OPEN */
50
2.15k
#define MZ_OPEN_MODE_READ      (0x01)
51
16.9k
#define MZ_OPEN_MODE_WRITE     (0x02)
52
0
#define MZ_OPEN_MODE_READWRITE (MZ_OPEN_MODE_READ | MZ_OPEN_MODE_WRITE)
53
2.15k
#define MZ_OPEN_MODE_APPEND    (0x04)
54
33.6k
#define MZ_OPEN_MODE_CREATE    (0x08)
55
#define MZ_OPEN_MODE_EXISTING  (0x10)
56
0
#define MZ_OPEN_MODE_NOFOLLOW  (0x20)
57
58
/* MZ_SEEK */
59
21.5k
#define MZ_SEEK_SET (0)
60
0
#define MZ_SEEK_CUR (1)
61
4.30k
#define MZ_SEEK_END (2)
62
63
/* MZ_COMPRESS */
64
2.56k
#define MZ_COMPRESS_METHOD_STORE   (0)
65
6.55k
#define MZ_COMPRESS_METHOD_DEFLATE (8)
66
0
#define MZ_COMPRESS_METHOD_BZIP2   (12)
67
4.19k
#define MZ_COMPRESS_METHOD_LZMA    (14)
68
0
#define MZ_COMPRESS_METHOD_ZSTD    (93)
69
738
#define MZ_COMPRESS_METHOD_XZ      (95)
70
8.04k
#define MZ_COMPRESS_METHOD_PPMD    (98)
71
0
#define MZ_COMPRESS_METHOD_AES     (99)
72
73
4.03k
#define MZ_COMPRESS_LEVEL_DEFAULT  (-1)
74
#define MZ_COMPRESS_LEVEL_FAST     (2)
75
#define MZ_COMPRESS_LEVEL_NORMAL   (6)
76
#define MZ_COMPRESS_LEVEL_BEST     (9)
77
78
/* MZ_ZIP_FLAG */
79
25.4k
#define MZ_ZIP_FLAG_ENCRYPTED          (1 << 0)
80
0
#define MZ_ZIP_FLAG_LZMA_EOS_MARKER    (1 << 1)
81
4
#define MZ_ZIP_FLAG_DEFLATE_MAX        (1 << 1)
82
#define MZ_ZIP_FLAG_DEFLATE_NORMAL     (0)
83
3
#define MZ_ZIP_FLAG_DEFLATE_FAST       (1 << 2)
84
2
#define MZ_ZIP_FLAG_DEFLATE_SUPER_FAST (MZ_ZIP_FLAG_DEFLATE_FAST | MZ_ZIP_FLAG_DEFLATE_MAX)
85
6.48k
#define MZ_ZIP_FLAG_DATA_DESCRIPTOR    (1 << 3)
86
2.15k
#define MZ_ZIP_FLAG_UTF8               (1 << 11)
87
4.19k
#define MZ_ZIP_FLAG_MASK_LOCAL_INFO    (1 << 13)
88
89
/* MZ_ZIP_EXTENSION */
90
1.78k
#define MZ_ZIP_EXTENSION_ZIP64 (0x0001)
91
0
#define MZ_ZIP_EXTENSION_NTFS  (0x000a)
92
0
#define MZ_ZIP_EXTENSION_AES   (0x9901)
93
0
#define MZ_ZIP_EXTENSION_UNIX1 (0x000d)
94
#define MZ_ZIP_EXTENSION_SIGN  (0x10c5)
95
#define MZ_ZIP_EXTENSION_HASH  (0x1a51)
96
#define MZ_ZIP_EXTENSION_CDCD  (0xcdcd)
97
98
/* MZ_ZIP64 */
99
6.22k
#define MZ_ZIP64_AUTO    (0)
100
1.23k
#define MZ_ZIP64_FORCE   (1)
101
1.17k
#define MZ_ZIP64_DISABLE (2)
102
103
/* MZ_HOST_SYSTEM */
104
9.71k
#define MZ_HOST_SYSTEM(VERSION_MADEBY) ((uint8_t)(VERSION_MADEBY >> 8))
105
19.4k
#define MZ_HOST_SYSTEM_MSDOS           (0)
106
19.4k
#define MZ_HOST_SYSTEM_UNIX            (3)
107
9.71k
#define MZ_HOST_SYSTEM_WINDOWS_NTFS    (10)
108
0
#define MZ_HOST_SYSTEM_RISCOS          (13)
109
0
#define MZ_HOST_SYSTEM_OSX_DARWIN      (19)
110
111
/* MZ_PKCRYPT */
112
3.34k
#define MZ_PKCRYPT_HEADER_SIZE (12)
113
114
/* MZ_AES */
115
#define MZ_AES_VERSION        (1)
116
0
#define MZ_AES_MODE_ECB       (0)
117
0
#define MZ_AES_MODE_CBC       (1)
118
0
#define MZ_AES_MODE_GCM       (2)
119
#define MZ_AES_STRENGTH_128   (1)
120
#define MZ_AES_STRENGTH_192   (2)
121
0
#define MZ_AES_STRENGTH_256   (3)
122
#define MZ_AES_KEY_LENGTH_MAX (32)
123
0
#define MZ_AES_BLOCK_SIZE     (16)
124
0
#define MZ_AES_FOOTER_SIZE    (10)
125
126
/* MZ_HASH */
127
#define MZ_HASH_MD5         (10)
128
#define MZ_HASH_MD5_SIZE    (16)
129
0
#define MZ_HASH_SHA1        (20)
130
0
#define MZ_HASH_SHA1_SIZE   (20)
131
0
#define MZ_HASH_SHA224      (22)
132
#define MZ_HASH_SHA224_SIZE (28)
133
0
#define MZ_HASH_SHA256      (23)
134
0
#define MZ_HASH_SHA256_SIZE (32)
135
0
#define MZ_HASH_SHA384      (24)
136
#define MZ_HASH_SHA384_SIZE (48)
137
0
#define MZ_HASH_SHA512      (25)
138
#define MZ_HASH_SHA512_SIZE (64)
139
#define MZ_HASH_MAX_SIZE    (256)
140
141
/* MZ_ENCODING */
142
#define MZ_ENCODING_CODEPAGE_437 (437)
143
#define MZ_ENCODING_CODEPAGE_932 (932)
144
#define MZ_ENCODING_CODEPAGE_936 (936)
145
#define MZ_ENCODING_CODEPAGE_950 (950)
146
0
#define MZ_ENCODING_UTF8         (65001)
147
148
/* MZ_UTILITY */
149
28.7k
#define MZ_UNUSED(SYMBOL) ((void)SYMBOL)
150
151
#if defined(_WIN32) && defined(MZ_EXPORTS)
152
#  define MZ_EXPORT __declspec(dllexport)
153
#else
154
#  define MZ_EXPORT
155
#endif
156
157
/***************************************************************************/
158
159
#include <stdlib.h> /* size_t, NULL, malloc */
160
#include <time.h>   /* time_t, time() */
161
#include <string.h> /* memset, strncpy, strlen */
162
#include <limits.h>
163
164
#if defined(HAVE_STDINT_H)
165
#  include <stdint.h>
166
#elif defined(__has_include)
167
#  if __has_include(<stdint.h>)
168
#    include <stdint.h>
169
#  endif
170
#endif
171
172
#ifndef INT8_MAX
173
typedef signed char int8_t;
174
#endif
175
#ifndef INT16_MAX
176
typedef short int16_t;
177
#endif
178
#ifndef INT32_MAX
179
typedef int int32_t;
180
#endif
181
#ifndef INT64_MAX
182
typedef long long int64_t;
183
#endif
184
#ifndef UINT8_MAX
185
typedef unsigned char uint8_t;
186
#endif
187
#ifndef UINT16_MAX
188
typedef unsigned short uint16_t;
189
#endif
190
#ifndef UINT32_MAX
191
typedef unsigned int uint32_t;
192
#endif
193
#ifndef UINT64_MAX
194
typedef unsigned long long uint64_t;
195
#endif
196
197
#if defined(HAVE_INTTYPES_H)
198
#  include <inttypes.h>
199
#elif defined(__has_include)
200
#  if __has_include(<inttypes.h>)
201
#    include <inttypes.h>
202
#  endif
203
#endif
204
205
#ifndef PRId8
206
#  define PRId8 "hhd"
207
#endif
208
#ifndef PRIu8
209
#  define PRIu8 "hhu"
210
#endif
211
#ifndef PRIx8
212
#  define PRIx8 "hhx"
213
#endif
214
#ifndef PRId16
215
#  define PRId16 "hd"
216
#endif
217
#ifndef PRIu16
218
#  define PRIu16 "hu"
219
#endif
220
#ifndef PRIx16
221
#  define PRIx16 "hx"
222
#endif
223
#ifndef PRId32
224
#  define PRId32 "d"
225
#endif
226
#ifndef PRIu32
227
#  define PRIu32 "u"
228
#endif
229
#ifndef PRIx32
230
#  define PRIx32 "x"
231
#endif
232
#if ULONG_MAX == 0xfffffffful
233
#  ifndef PRId64
234
#    define PRId64 "ld"
235
#  endif
236
#  ifndef PRIu64
237
#    define PRIu64 "lu"
238
#  endif
239
#  ifndef PRIx64
240
#    define PRIx64 "lx"
241
#  endif
242
#else
243
#  ifndef PRId64
244
#    define PRId64 "lld"
245
#  endif
246
#  ifndef PRIu64
247
#    define PRIu64 "llu"
248
#  endif
249
#  ifndef PRIx64
250
#    define PRIx64 "llx"
251
#  endif
252
#endif
253
254
#ifndef INT16_MAX
255
#  define INT16_MAX 32767
256
#endif
257
#ifndef INT32_MAX
258
#  define INT32_MAX 2147483647L
259
#endif
260
#ifndef INT64_MAX
261
#  define INT64_MAX 9223372036854775807LL
262
#endif
263
#ifndef UINT16_MAX
264
#  define UINT16_MAX 65535U
265
#endif
266
#ifndef UINT32_MAX
267
#  define UINT32_MAX 4294967295UL
268
#endif
269
#ifndef UINT64_MAX
270
#  define UINT64_MAX 18446744073709551615ULL
271
#endif
272
273
/***************************************************************************/
274
275
#endif