Coverage Report

Created: 2026-01-22 07:11

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
176k
#define MZ_OK             (0)  /* zlib */
22
0
#define MZ_STREAM_ERROR   (-1) /* zlib */
23
#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
228
#define MZ_END_OF_STREAM  (-101)
30
31
1.82k
#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
3.07k
#define MZ_EXIST_ERROR    (-107)
37
0
#define MZ_PASSWORD_ERROR (-108)
38
81
#define MZ_SUPPORT_ERROR  (-109)
39
0
#define MZ_HASH_ERROR     (-110)
40
0
#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
455
#define MZ_OPEN_MODE_READ      (0x01)
51
2.95k
#define MZ_OPEN_MODE_WRITE     (0x02)
52
0
#define MZ_OPEN_MODE_READWRITE (MZ_OPEN_MODE_READ | MZ_OPEN_MODE_WRITE)
53
455
#define MZ_OPEN_MODE_APPEND    (0x04)
54
6.93k
#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
4.55k
#define MZ_SEEK_SET (0)
60
0
#define MZ_SEEK_CUR (1)
61
910
#define MZ_SEEK_END (2)
62
63
/* MZ_COMPRESS */
64
1.58k
#define MZ_COMPRESS_METHOD_STORE   (0)
65
1.28k
#define MZ_COMPRESS_METHOD_DEFLATE (8)
66
0
#define MZ_COMPRESS_METHOD_BZIP2   (12)
67
0
#define MZ_COMPRESS_METHOD_LZMA    (14)
68
0
#define MZ_COMPRESS_METHOD_ZSTD    (93)
69
0
#define MZ_COMPRESS_METHOD_XZ      (95)
70
0
#define MZ_COMPRESS_METHOD_AES     (99)
71
72
455
#define MZ_COMPRESS_LEVEL_DEFAULT  (-1)
73
#define MZ_COMPRESS_LEVEL_FAST     (2)
74
#define MZ_COMPRESS_LEVEL_NORMAL   (6)
75
#define MZ_COMPRESS_LEVEL_BEST     (9)
76
77
/* MZ_ZIP_FLAG */
78
4.84k
#define MZ_ZIP_FLAG_ENCRYPTED          (1 << 0)
79
0
#define MZ_ZIP_FLAG_LZMA_EOS_MARKER    (1 << 1)
80
3
#define MZ_ZIP_FLAG_DEFLATE_MAX        (1 << 1)
81
#define MZ_ZIP_FLAG_DEFLATE_NORMAL     (0)
82
2
#define MZ_ZIP_FLAG_DEFLATE_FAST       (1 << 2)
83
1
#define MZ_ZIP_FLAG_DEFLATE_SUPER_FAST (MZ_ZIP_FLAG_DEFLATE_FAST | MZ_ZIP_FLAG_DEFLATE_MAX)
84
1.40k
#define MZ_ZIP_FLAG_DATA_DESCRIPTOR    (1 << 3)
85
455
#define MZ_ZIP_FLAG_UTF8               (1 << 11)
86
748
#define MZ_ZIP_FLAG_MASK_LOCAL_INFO    (1 << 13)
87
88
/* MZ_ZIP_EXTENSION */
89
354
#define MZ_ZIP_EXTENSION_ZIP64 (0x0001)
90
0
#define MZ_ZIP_EXTENSION_NTFS  (0x000a)
91
0
#define MZ_ZIP_EXTENSION_AES   (0x9901)
92
0
#define MZ_ZIP_EXTENSION_UNIX1 (0x000d)
93
#define MZ_ZIP_EXTENSION_SIGN  (0x10c5)
94
#define MZ_ZIP_EXTENSION_HASH  (0x1a51)
95
#define MZ_ZIP_EXTENSION_CDCD  (0xcdcd)
96
97
/* MZ_ZIP64 */
98
1.12k
#define MZ_ZIP64_AUTO    (0)
99
240
#define MZ_ZIP64_FORCE   (1)
100
150
#define MZ_ZIP64_DISABLE (2)
101
102
/* MZ_HOST_SYSTEM */
103
1.79k
#define MZ_HOST_SYSTEM(VERSION_MADEBY) ((uint8_t)(VERSION_MADEBY >> 8))
104
3.58k
#define MZ_HOST_SYSTEM_MSDOS           (0)
105
3.58k
#define MZ_HOST_SYSTEM_UNIX            (3)
106
1.79k
#define MZ_HOST_SYSTEM_WINDOWS_NTFS    (10)
107
0
#define MZ_HOST_SYSTEM_RISCOS          (13)
108
0
#define MZ_HOST_SYSTEM_OSX_DARWIN      (19)
109
110
/* MZ_PKCRYPT */
111
2.52k
#define MZ_PKCRYPT_HEADER_SIZE (12)
112
113
/* MZ_AES */
114
#define MZ_AES_VERSION        (1)
115
0
#define MZ_AES_MODE_ECB       (0)
116
0
#define MZ_AES_MODE_CBC       (1)
117
0
#define MZ_AES_MODE_GCM       (2)
118
#define MZ_AES_STRENGTH_128   (1)
119
#define MZ_AES_STRENGTH_192   (2)
120
0
#define MZ_AES_STRENGTH_256   (3)
121
#define MZ_AES_KEY_LENGTH_MAX (32)
122
0
#define MZ_AES_BLOCK_SIZE     (16)
123
0
#define MZ_AES_FOOTER_SIZE    (10)
124
125
/* MZ_HASH */
126
#define MZ_HASH_MD5         (10)
127
#define MZ_HASH_MD5_SIZE    (16)
128
0
#define MZ_HASH_SHA1        (20)
129
0
#define MZ_HASH_SHA1_SIZE   (20)
130
0
#define MZ_HASH_SHA224      (22)
131
#define MZ_HASH_SHA224_SIZE (28)
132
0
#define MZ_HASH_SHA256      (23)
133
0
#define MZ_HASH_SHA256_SIZE (32)
134
0
#define MZ_HASH_SHA384      (24)
135
#define MZ_HASH_SHA384_SIZE (48)
136
0
#define MZ_HASH_SHA512      (25)
137
#define MZ_HASH_SHA512_SIZE (64)
138
#define MZ_HASH_MAX_SIZE    (256)
139
140
/* MZ_ENCODING */
141
#define MZ_ENCODING_CODEPAGE_437 (437)
142
#define MZ_ENCODING_CODEPAGE_932 (932)
143
#define MZ_ENCODING_CODEPAGE_936 (936)
144
#define MZ_ENCODING_CODEPAGE_950 (950)
145
0
#define MZ_ENCODING_UTF8         (65001)
146
147
/* MZ_UTILITY */
148
5.44k
#define MZ_UNUSED(SYMBOL) ((void)SYMBOL)
149
150
#if defined(_WIN32) && defined(MZ_EXPORTS)
151
#  define MZ_EXPORT __declspec(dllexport)
152
#else
153
#  define MZ_EXPORT
154
#endif
155
156
/***************************************************************************/
157
158
#include <stdlib.h> /* size_t, NULL, malloc */
159
#include <time.h>   /* time_t, time() */
160
#include <string.h> /* memset, strncpy, strlen */
161
#include <limits.h>
162
163
#if defined(HAVE_STDINT_H)
164
#  include <stdint.h>
165
#elif defined(__has_include)
166
#  if __has_include(<stdint.h>)
167
#    include <stdint.h>
168
#  endif
169
#endif
170
171
#ifndef INT8_MAX
172
typedef signed char int8_t;
173
#endif
174
#ifndef INT16_MAX
175
typedef short int16_t;
176
#endif
177
#ifndef INT32_MAX
178
typedef int int32_t;
179
#endif
180
#ifndef INT64_MAX
181
typedef long long int64_t;
182
#endif
183
#ifndef UINT8_MAX
184
typedef unsigned char uint8_t;
185
#endif
186
#ifndef UINT16_MAX
187
typedef unsigned short uint16_t;
188
#endif
189
#ifndef UINT32_MAX
190
typedef unsigned int uint32_t;
191
#endif
192
#ifndef UINT64_MAX
193
typedef unsigned long long uint64_t;
194
#endif
195
196
#if defined(HAVE_INTTYPES_H)
197
#  include <inttypes.h>
198
#elif defined(__has_include)
199
#  if __has_include(<inttypes.h>)
200
#    include <inttypes.h>
201
#  endif
202
#endif
203
204
#ifndef PRId8
205
#  define PRId8 "hhd"
206
#endif
207
#ifndef PRIu8
208
#  define PRIu8 "hhu"
209
#endif
210
#ifndef PRIx8
211
#  define PRIx8 "hhx"
212
#endif
213
#ifndef PRId16
214
#  define PRId16 "hd"
215
#endif
216
#ifndef PRIu16
217
#  define PRIu16 "hu"
218
#endif
219
#ifndef PRIx16
220
#  define PRIx16 "hx"
221
#endif
222
#ifndef PRId32
223
#  define PRId32 "d"
224
#endif
225
#ifndef PRIu32
226
#  define PRIu32 "u"
227
#endif
228
#ifndef PRIx32
229
#  define PRIx32 "x"
230
#endif
231
#if ULONG_MAX == 0xfffffffful
232
#  ifndef PRId64
233
#    define PRId64 "ld"
234
#  endif
235
#  ifndef PRIu64
236
#    define PRIu64 "lu"
237
#  endif
238
#  ifndef PRIx64
239
#    define PRIx64 "lx"
240
#  endif
241
#else
242
#  ifndef PRId64
243
#    define PRId64 "lld"
244
#  endif
245
#  ifndef PRIu64
246
#    define PRIu64 "llu"
247
#  endif
248
#  ifndef PRIx64
249
#    define PRIx64 "llx"
250
#  endif
251
#endif
252
253
#ifndef INT16_MAX
254
#  define INT16_MAX 32767
255
#endif
256
#ifndef INT32_MAX
257
#  define INT32_MAX 2147483647L
258
#endif
259
#ifndef INT64_MAX
260
#  define INT64_MAX 9223372036854775807LL
261
#endif
262
#ifndef UINT16_MAX
263
#  define UINT16_MAX 65535U
264
#endif
265
#ifndef UINT32_MAX
266
#  define UINT32_MAX 4294967295UL
267
#endif
268
#ifndef UINT64_MAX
269
#  define UINT64_MAX 18446744073709551615ULL
270
#endif
271
272
/***************************************************************************/
273
274
#endif