@appzung/react-native-code-push 7.1.1 → 9.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/.azurepipelines/build-rn-code-push-1es.yml +104 -0
  2. package/.azurepipelines/test-rn-code-push.yml +94 -0
  3. package/.config/CredScanSuppressions.json +14 -0
  4. package/CONTRIBUTING.md +3 -3
  5. package/CodePush.js +20 -21
  6. package/CodePush.podspec +3 -3
  7. package/README.md +7 -5
  8. package/android/app/build.gradle +3 -1
  9. package/android/app/src/main/AndroidManifest.xml +2 -7
  10. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +14 -5
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +1 -0
  12. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +9 -1
  13. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +18 -10
  14. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +3 -1
  15. package/android/build.gradle +6 -2
  16. package/android/codepush.gradle +72 -26
  17. package/docs/api-js.md +1 -1
  18. package/docs/setup-android.md +27 -3
  19. package/docs/setup-ios.md +1 -1
  20. package/docs/setup-windows.md +23 -0
  21. package/ios/CodePush/CodePush.m +2 -1
  22. package/ios/CodePush/CodePushPackage.m +4 -0
  23. package/ios/CodePush/SSZipArchive/Info.plist +26 -0
  24. package/ios/CodePush/SSZipArchive/README.md +1 -1
  25. package/ios/CodePush/SSZipArchive/SSZipArchive.h +129 -27
  26. package/ios/CodePush/SSZipArchive/SSZipArchive.m +1119 -314
  27. package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
  28. package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
  29. package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
  30. package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
  31. package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
  32. package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
  33. package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
  34. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
  35. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
  36. package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
  37. package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
  38. package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
  39. package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
  40. package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
  41. package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
  42. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
  43. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
  44. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
  45. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
  46. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
  47. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
  48. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
  49. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
  50. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
  51. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
  52. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
  53. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
  54. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
  55. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
  56. package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
  57. package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
  58. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
  59. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
  60. package/ios/CodePush.xcodeproj/project.pbxproj +245 -130
  61. package/ios/PrivacyInfo.xcprivacy +31 -0
  62. package/package.json +2 -2
  63. package/typings/react-native-code-push.d.ts +1 -1
  64. package/windows/CodePush/CodePush.vcxproj +2 -3
  65. package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +2 -2
  66. package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +2 -2
  67. package/ios/CodePush/SSZipArchive/Common.h +0 -81
  68. package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
  69. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
  70. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
  71. package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
  72. package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
  73. package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
  74. package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
  75. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
  76. package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
  77. package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
  78. package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
  79. package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
  80. package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
  81. package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
  82. package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
  83. package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
  84. package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
  85. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
  86. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
  87. package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
  88. package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
  89. package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
  90. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
  91. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
  92. package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
  93. package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
  94. package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
  95. package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
  96. package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
  97. package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
@@ -1,1839 +0,0 @@
1
- /* unzip.c -- IO for uncompress .zip files using zlib
2
- Version 1.1, February 14h, 2010
3
- part of the MiniZip project
4
-
5
- Copyright (C) 1998-2010 Gilles Vollant
6
- http://www.winimage.com/zLibDll/minizip.html
7
- Modifications of Unzip for Zip64
8
- Copyright (C) 2007-2008 Even Rouault
9
- Modifications for Zip64 support on both zip and unzip
10
- Copyright (C) 2009-2010 Mathias Svensson
11
- http://result42.com
12
- Modifications for AES, PKWARE disk spanning
13
- Copyright (C) 2010-2014 Nathan Moinvaziri
14
-
15
- This program is distributed under the terms of the same license as zlib.
16
- See the accompanying LICENSE file for the full text of the license.
17
- */
18
-
19
-
20
- #include <stdio.h>
21
- #include <stdlib.h>
22
- #include <string.h>
23
-
24
- /*#ifndef NOUNCRYPT
25
- # define NOUNCRYPT
26
- #endif*/
27
-
28
- #include "zlib.h"
29
- #include "unzip.h"
30
-
31
- #include "Common.h"
32
-
33
- #ifdef STDC
34
- # include <stddef.h>
35
- # include <string.h>
36
- # include <stdlib.h>
37
- #endif
38
- #ifdef NO_ERRNO_H
39
- extern int errno;
40
- #else
41
- # include <errno.h>
42
- #endif
43
-
44
- #ifdef HAVE_AES
45
- # define AES_METHOD (99)
46
- # define AES_PWVERIFYSIZE (2)
47
- # define AES_MAXSALTLENGTH (16)
48
- # define AES_AUTHCODESIZE (10)
49
- # define AES_HEADERSIZE (11)
50
- # define AES_KEYSIZE(mode) (64 + (mode * 64))
51
-
52
- # include "aes.h"
53
- # include "fileenc.h"
54
- #endif
55
- #ifndef NOUNCRYPT
56
- # include "crypt.h"
57
- #endif
58
-
59
- #ifndef local
60
- # define local static
61
- #endif
62
- /* compile with -Dlocal if your debugger can't find static symbols */
63
-
64
- #define DISKHEADERMAGIC (0x08074b50)
65
- #define LOCALHEADERMAGIC (0x04034b50)
66
- #define CENTRALHEADERMAGIC (0x02014b50)
67
- #define ENDHEADERMAGIC (0x06054b50)
68
- #define ZIP64ENDHEADERMAGIC (0x06064b50)
69
- #define ZIP64ENDLOCHEADERMAGIC (0x07064b50)
70
-
71
- #define SIZECENTRALDIRITEM (0x2e)
72
- #define SIZECENTRALHEADERLOCATOR (0x14) /* 20 */
73
- #define SIZEZIPLOCALHEADER (0x1e)
74
-
75
- #ifndef BUFREADCOMMENT
76
- # define BUFREADCOMMENT (0x400)
77
- #endif
78
-
79
- #ifndef UNZ_BUFSIZE
80
- # define UNZ_BUFSIZE (64 * 1024)
81
- #endif
82
- #ifndef UNZ_MAXFILENAMEINZIP
83
- # define UNZ_MAXFILENAMEINZIP (256)
84
- #endif
85
-
86
- #ifndef ALLOC
87
- # define ALLOC(size) (malloc(size))
88
- #endif
89
- #ifndef TRYFREE
90
- # define TRYFREE(p) {if (p) free(p); }
91
- #endif
92
-
93
- const char unz_copyright[] =
94
- " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
95
-
96
- /* unz_file_info_interntal contain internal info about a file in zipfile*/
97
- typedef struct unz_file_info64_internal_s {
98
- ZPOS64_T offset_curfile; /* relative offset of local header 8 bytes */
99
- ZPOS64_T byte_before_the_zipfile; /* byte before the zipfile, (>0 for sfx) */
100
- #ifdef HAVE_AES
101
- uLong aes_encryption_mode;
102
- uLong aes_compression_method;
103
- uLong aes_version;
104
- #endif
105
- } unz_file_info64_internal;
106
-
107
- /* file_in_zip_read_info_s contain internal information about a file in zipfile */
108
- typedef struct {
109
- Bytef *read_buffer; /* internal buffer for compressed data */
110
- z_stream stream; /* zLib stream structure for inflate */
111
-
112
- #ifdef HAVE_BZIP2
113
- bz_stream bstream; /* bzLib stream structure for bziped */
114
- #endif
115
- #ifdef HAVE_AES
116
- fcrypt_ctx aes_ctx;
117
- #endif
118
-
119
- ZPOS64_T pos_in_zipfile; /* position in byte on the zipfile, for fseek */
120
- uLong stream_initialised; /* flag set if stream structure is initialised */
121
-
122
- ZPOS64_T offset_local_extrafield; /* offset of the local extra field */
123
- uInt size_local_extrafield; /* size of the local extra field */
124
- ZPOS64_T pos_local_extrafield; /* position in the local extra field in read */
125
- ZPOS64_T total_out_64;
126
-
127
- uLong crc32; /* crc32 of all data uncompressed */
128
- uLong crc32_wait; /* crc32 we must obtain after decompress all */
129
- ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */
130
- ZPOS64_T rest_read_uncompressed; /* number of byte to be obtained after decomp */
131
-
132
- zlib_filefunc64_32_def z_filefunc;
133
-
134
- voidpf filestream; /* io structore of the zipfile */
135
- uLong compression_method; /* compression method (0==store) */
136
- ZPOS64_T byte_before_the_zipfile; /* byte before the zipfile, (>0 for sfx) */
137
- int raw;
138
- } file_in_zip64_read_info_s;
139
-
140
- /* unz64_s contain internal information about the zipfile */
141
- typedef struct {
142
- zlib_filefunc64_32_def z_filefunc;
143
- voidpf filestream; /* io structure of the current zipfile */
144
- voidpf filestream_with_CD; /* io structure of the disk with the central directory */
145
- unz_global_info64 gi; /* public global information */
146
- ZPOS64_T byte_before_the_zipfile; /* byte before the zipfile, (>0 for sfx)*/
147
- ZPOS64_T num_file; /* number of the current file in the zipfile*/
148
- ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/
149
- ZPOS64_T current_file_ok; /* flag about the usability of the current file*/
150
- ZPOS64_T central_pos; /* position of the beginning of the central dir*/
151
- uLong number_disk; /* number of the current disk, used for spanning ZIP*/
152
- ZPOS64_T size_central_dir; /* size of the central directory */
153
- ZPOS64_T offset_central_dir; /* offset of start of central directory with
154
- respect to the starting disk number */
155
-
156
- unz_file_info64 cur_file_info; /* public info about the current file in zip*/
157
- unz_file_info64_internal cur_file_info_internal;
158
- /* private info about it*/
159
- file_in_zip64_read_info_s *pfile_in_zip_read;
160
- /* structure about the current file if we are decompressing it */
161
- int isZip64; /* is the current file zip64 */
162
- #ifndef NOUNCRYPT
163
- unsigned long keys[3]; /* keys defining the pseudo-random sequence */
164
- const unsigned long *pcrc_32_tab;
165
- #endif
166
- } unz64_s;
167
-
168
- /* Translate date/time from Dos format to tm_unz (readable more easily) */
169
- local void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz *ptm)
170
- {
171
- ZPOS64_T uDate = (ZPOS64_T)(ulDosDate >> 16);
172
-
173
- ptm->tm_mday = (uInt)(uDate & 0x1f);
174
- ptm->tm_mon = (uInt)((((uDate) & 0x1E0) / 0x20) - 1);
175
- ptm->tm_year = (uInt)(((uDate & 0x0FE00) / 0x0200) + 1980);
176
- ptm->tm_hour = (uInt)((ulDosDate & 0xF800) / 0x800);
177
- ptm->tm_min = (uInt)((ulDosDate & 0x7E0) / 0x20);
178
- ptm->tm_sec = (uInt)(2 * (ulDosDate & 0x1f));
179
-
180
- #define unz64local_in_range(min, max, value) ((min) <= (value) && (value) <= (max))
181
- if (!unz64local_in_range(0, 11, ptm->tm_mon) ||
182
- !unz64local_in_range(1, 31, ptm->tm_mday) ||
183
- !unz64local_in_range(0, 23, ptm->tm_hour) ||
184
- !unz64local_in_range(0, 59, ptm->tm_min) ||
185
- !unz64local_in_range(0, 59, ptm->tm_sec))
186
- /* Invalid date stored, so don't return it. */
187
- memset(ptm, 0, sizeof(tm_unz));
188
- #undef unz64local_in_range
189
- }
190
-
191
- /* Read a byte from a gz_stream; Return EOF for end of file. */
192
- local int unz64local_getByte(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)
193
- {
194
- unsigned char c;
195
- int err = (int)ZREAD64(*pzlib_filefunc_def, filestream, &c, 1);
196
- if (err == 1) {
197
- *pi = (int)c;
198
- return UNZ_OK;
199
- }
200
- if (ZERROR64(*pzlib_filefunc_def, filestream))
201
- return UNZ_ERRNO;
202
- return UNZ_EOF;
203
- }
204
-
205
- local int unz64local_getShort OF((const zlib_filefunc64_32_def * pzlib_filefunc_def, voidpf filestream, uLong * pX));
206
- local int unz64local_getShort(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
207
- {
208
- uLong x;
209
- int i = 0;
210
- int err;
211
-
212
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
213
- x = (uLong)i;
214
- if (err == UNZ_OK)
215
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
216
- x |= ((uLong)i) << 8;
217
-
218
- if (err == UNZ_OK)
219
- *pX = x;
220
- else
221
- *pX = 0;
222
- return err;
223
- }
224
-
225
- local int unz64local_getLong OF((const zlib_filefunc64_32_def * pzlib_filefunc_def, voidpf filestream, uLong * pX));
226
- local int unz64local_getLong(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
227
- {
228
- uLong x;
229
- int i = 0;
230
- int err;
231
-
232
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
233
- x = (uLong)i;
234
- if (err == UNZ_OK)
235
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
236
- x |= ((uLong)i) << 8;
237
- if (err == UNZ_OK)
238
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
239
- x |= ((uLong)i) << 16;
240
- if (err == UNZ_OK)
241
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
242
- x += ((uLong)i) << 24;
243
-
244
- if (err == UNZ_OK)
245
- *pX = x;
246
- else
247
- *pX = 0;
248
- return err;
249
- }
250
-
251
- local int unz64local_getLong64 OF((const zlib_filefunc64_32_def * pzlib_filefunc_def, voidpf filestream, ZPOS64_T * pX));
252
- local int unz64local_getLong64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
253
- {
254
- ZPOS64_T x;
255
- int i = 0;
256
- int err;
257
-
258
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
259
- x = (ZPOS64_T)i;
260
- if (err == UNZ_OK)
261
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
262
- x |= ((ZPOS64_T)i) << 8;
263
- if (err == UNZ_OK)
264
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
265
- x |= ((ZPOS64_T)i) << 16;
266
- if (err == UNZ_OK)
267
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
268
- x |= ((ZPOS64_T)i) << 24;
269
- if (err == UNZ_OK)
270
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
271
- x |= ((ZPOS64_T)i) << 32;
272
- if (err == UNZ_OK)
273
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
274
- x |= ((ZPOS64_T)i) << 40;
275
- if (err == UNZ_OK)
276
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
277
- x |= ((ZPOS64_T)i) << 48;
278
- if (err == UNZ_OK)
279
- err = unz64local_getByte(pzlib_filefunc_def, filestream, &i);
280
- x |= ((ZPOS64_T)i) << 56;
281
-
282
- if (err == UNZ_OK)
283
- *pX = x;
284
- else
285
- *pX = 0;
286
- return err;
287
- }
288
-
289
- /* Locate the Central directory of a zip file (at the end, just before the global comment) */
290
- local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def * pzlib_filefunc_def, voidpf filestream));
291
- local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
292
- {
293
- unsigned char *buf;
294
- ZPOS64_T file_size;
295
- ZPOS64_T back_read = 4;
296
- ZPOS64_T max_back = 0xffff; /* maximum size of global comment */
297
- ZPOS64_T pos_found = 0;
298
- uLong read_size;
299
- ZPOS64_T read_pos;
300
- int i;
301
-
302
- buf = (unsigned char *)ALLOC(BUFREADCOMMENT + 4);
303
- if (buf == NULL)
304
- return 0;
305
-
306
- if (ZSEEK64(*pzlib_filefunc_def, filestream, 0, ZLIB_FILEFUNC_SEEK_END) != 0) {
307
- TRYFREE(buf);
308
- return 0;
309
- }
310
-
311
- file_size = ZTELL64(*pzlib_filefunc_def, filestream);
312
-
313
- if (max_back > file_size)
314
- max_back = file_size;
315
-
316
- while (back_read < max_back) {
317
- if (back_read + BUFREADCOMMENT > max_back)
318
- back_read = max_back;
319
- else
320
- back_read += BUFREADCOMMENT;
321
-
322
- read_pos = file_size - back_read;
323
- read_size = ((BUFREADCOMMENT + 4) < (file_size - read_pos)) ?
324
- (BUFREADCOMMENT + 4) : (uLong)(file_size - read_pos);
325
-
326
- if (ZSEEK64(*pzlib_filefunc_def, filestream, read_pos, ZLIB_FILEFUNC_SEEK_SET) != 0)
327
- break;
328
- if (ZREAD64(*pzlib_filefunc_def, filestream, buf, read_size) != read_size)
329
- break;
330
-
331
- for (i = (int)read_size - 3; (i--) > 0; )
332
- if (((*(buf + i)) == (ENDHEADERMAGIC & 0xff)) &&
333
- ((*(buf + i + 1)) == (ENDHEADERMAGIC >> 8 & 0xff)) &&
334
- ((*(buf + i + 2)) == (ENDHEADERMAGIC >> 16 & 0xff)) &&
335
- ((*(buf + i + 3)) == (ENDHEADERMAGIC >> 24 & 0xff))) {
336
- pos_found = read_pos + i;
337
- break;
338
- }
339
-
340
- if (pos_found != 0)
341
- break;
342
- }
343
- TRYFREE(buf);
344
- return pos_found;
345
- }
346
-
347
- /* Locate the Central directory 64 of a zipfile (at the end, just before the global comment) */
348
- local ZPOS64_T unz64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def * pzlib_filefunc_def, voidpf filestream,
349
- const ZPOS64_T endcentraloffset));
350
- local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream,
351
- const ZPOS64_T endcentraloffset)
352
- {
353
- ZPOS64_T offset;
354
- uLong uL;
355
-
356
- /* Zip64 end of central directory locator */
357
- if (ZSEEK64(*pzlib_filefunc_def, filestream, endcentraloffset - SIZECENTRALHEADERLOCATOR, ZLIB_FILEFUNC_SEEK_SET) != 0)
358
- return 0;
359
-
360
- /* read locator signature */
361
- if (unz64local_getLong(pzlib_filefunc_def, filestream, &uL) != UNZ_OK)
362
- return 0;
363
- if (uL != ZIP64ENDLOCHEADERMAGIC)
364
- return 0;
365
- /* number of the disk with the start of the zip64 end of central directory */
366
- if (unz64local_getLong(pzlib_filefunc_def, filestream, &uL) != UNZ_OK)
367
- return 0;
368
- /* relative offset of the zip64 end of central directory record */
369
- if (unz64local_getLong64(pzlib_filefunc_def, filestream, &offset) != UNZ_OK)
370
- return 0;
371
- /* total number of disks */
372
- if (unz64local_getLong(pzlib_filefunc_def, filestream, &uL) != UNZ_OK)
373
- return 0;
374
- /* Goto end of central directory record */
375
- if (ZSEEK64(*pzlib_filefunc_def, filestream, offset, ZLIB_FILEFUNC_SEEK_SET) != 0)
376
- return 0;
377
- /* the signature */
378
- if (unz64local_getLong(pzlib_filefunc_def, filestream, &uL) != UNZ_OK)
379
- return 0;
380
- if (uL != ZIP64ENDHEADERMAGIC)
381
- return 0;
382
-
383
- return offset;
384
- }
385
-
386
- local unzFile unzOpenInternal(const void *path, zlib_filefunc64_32_def *pzlib_filefunc64_32_def)
387
- {
388
- unz64_s us;
389
- unz64_s *s;
390
- ZPOS64_T central_pos;
391
- uLong uL;
392
- voidpf filestream = NULL;
393
- ZPOS64_T number_entry_CD;
394
- int err = UNZ_OK;
395
-
396
- if (unz_copyright[0] != ' ')
397
- return NULL;
398
-
399
- us.filestream = NULL;
400
- us.filestream_with_CD = NULL;
401
- us.z_filefunc.zseek32_file = NULL;
402
- us.z_filefunc.ztell32_file = NULL;
403
- if (pzlib_filefunc64_32_def == NULL)
404
- fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);
405
- else
406
- us.z_filefunc = *pzlib_filefunc64_32_def;
407
-
408
- us.filestream = ZOPEN64(us.z_filefunc, path, ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_EXISTING);
409
-
410
- if (us.filestream == NULL)
411
- return NULL;
412
-
413
- us.filestream_with_CD = us.filestream;
414
- us.isZip64 = 0;
415
-
416
- /* Use unz64local_SearchCentralDir first. Only based on the result
417
- is it necessary to locate the unz64local_SearchCentralDir64 */
418
- central_pos = unz64local_SearchCentralDir(&us.z_filefunc, us.filestream);
419
- if (central_pos) {
420
- if (ZSEEK64(us.z_filefunc, us.filestream, central_pos, ZLIB_FILEFUNC_SEEK_SET) != 0)
421
- err = UNZ_ERRNO;
422
-
423
- /* the signature, already checked */
424
- if (unz64local_getLong(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)
425
- err = UNZ_ERRNO;
426
- /* number of this disk */
427
- if (unz64local_getShort(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)
428
- err = UNZ_ERRNO;
429
- us.number_disk = uL;
430
- /* number of the disk with the start of the central directory */
431
- if (unz64local_getShort(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)
432
- err = UNZ_ERRNO;
433
- us.gi.number_disk_with_CD = uL;
434
- /* total number of entries in the central directory on this disk */
435
- if (unz64local_getShort(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)
436
- err = UNZ_ERRNO;
437
- us.gi.number_entry = uL;
438
- /* total number of entries in the central directory */
439
- if (unz64local_getShort(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)
440
- err = UNZ_ERRNO;
441
- number_entry_CD = uL;
442
- if (number_entry_CD != us.gi.number_entry)
443
- err = UNZ_BADZIPFILE;
444
- /* size of the central directory */
445
- if (unz64local_getLong(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)
446
- err = UNZ_ERRNO;
447
- us.size_central_dir = uL;
448
- /* offset of start of central directory with respect to the starting disk number */
449
- if (unz64local_getLong(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)
450
- err = UNZ_ERRNO;
451
- us.offset_central_dir = uL;
452
- /* zipfile comment length */
453
- if (unz64local_getShort(&us.z_filefunc, us.filestream, &us.gi.size_comment) != UNZ_OK)
454
- err = UNZ_ERRNO;
455
-
456
- if ((err == UNZ_OK) &&
457
- ((us.gi.number_entry == 0xffff) || (us.size_central_dir == 0xffff) || (us.offset_central_dir == 0xffffffff))) {
458
- /* Format should be Zip64, as the central directory or file size is too large */
459
- central_pos = unz64local_SearchCentralDir64(&us.z_filefunc, us.filestream, central_pos);
460
- if (central_pos) {
461
- ZPOS64_T uL64;
462
-
463
- us.isZip64 = 1;
464
-
465
- if (ZSEEK64(us.z_filefunc, us.filestream, central_pos, ZLIB_FILEFUNC_SEEK_SET) != 0)
466
- err = UNZ_ERRNO;
467
-
468
- /* the signature, already checked */
469
- if (unz64local_getLong(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)
470
- err = UNZ_ERRNO;
471
- /* size of zip64 end of central directory record */
472
- if (unz64local_getLong64(&us.z_filefunc, us.filestream, &uL64) != UNZ_OK)
473
- err = UNZ_ERRNO;
474
- /* version made by */
475
- if (unz64local_getShort(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)
476
- err = UNZ_ERRNO;
477
- /* version needed to extract */
478
- if (unz64local_getShort(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)
479
- err = UNZ_ERRNO;
480
- /* number of this disk */
481
- if (unz64local_getLong(&us.z_filefunc, us.filestream, &us.number_disk) != UNZ_OK)
482
- err = UNZ_ERRNO;
483
- /* number of the disk with the start of the central directory */
484
- if (unz64local_getLong(&us.z_filefunc, us.filestream, &us.gi.number_disk_with_CD) != UNZ_OK)
485
- err = UNZ_ERRNO;
486
- /* total number of entries in the central directory on this disk */
487
- if (unz64local_getLong64(&us.z_filefunc, us.filestream, &us.gi.number_entry) != UNZ_OK)
488
- err = UNZ_ERRNO;
489
- /* total number of entries in the central directory */
490
- if (unz64local_getLong64(&us.z_filefunc, us.filestream, &number_entry_CD) != UNZ_OK)
491
- err = UNZ_ERRNO;
492
- if (number_entry_CD != us.gi.number_entry)
493
- err = UNZ_BADZIPFILE;
494
- /* size of the central directory */
495
- if (unz64local_getLong64(&us.z_filefunc, us.filestream, &us.size_central_dir) != UNZ_OK)
496
- err = UNZ_ERRNO;
497
- /* offset of start of central directory with respect to the starting disk number */
498
- if (unz64local_getLong64(&us.z_filefunc, us.filestream, &us.offset_central_dir) != UNZ_OK)
499
- err = UNZ_ERRNO;
500
- } else
501
- err = UNZ_BADZIPFILE;
502
- }
503
- } else
504
- err = UNZ_ERRNO;
505
-
506
- if ((err == UNZ_OK) && (central_pos < us.offset_central_dir + us.size_central_dir))
507
- err = UNZ_BADZIPFILE;
508
-
509
- if (err != UNZ_OK) {
510
- ZCLOSE64(us.z_filefunc, us.filestream);
511
- return NULL;
512
- }
513
-
514
- if (us.gi.number_disk_with_CD == 0) {
515
- /* If there is only one disk open another stream so we don't have to seek between the CD
516
- and the file headers constantly */
517
- filestream = ZOPEN64(us.z_filefunc, path, ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_EXISTING);
518
- if (filestream != NULL)
519
- us.filestream = filestream;
520
- }
521
-
522
- /* Hack for zip files that have no respect for zip64
523
- if ((central_pos > 0xffffffff) && (us.offset_central_dir < 0xffffffff))
524
- us.offset_central_dir = central_pos - us.size_central_dir;*/
525
-
526
- us.byte_before_the_zipfile = central_pos - (us.offset_central_dir + us.size_central_dir);
527
- us.central_pos = central_pos;
528
- us.pfile_in_zip_read = NULL;
529
-
530
- s = (unz64_s *)ALLOC(sizeof(unz64_s));
531
- if (s != NULL) {
532
- *s = us;
533
- unzGoToFirstFile((unzFile)s);
534
- }
535
- return (unzFile)s;
536
- }
537
-
538
- extern unzFile ZEXPORT unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc32_def)
539
- {
540
- if (pzlib_filefunc32_def != NULL) {
541
- zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
542
- fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill, pzlib_filefunc32_def);
543
- return unzOpenInternal(path, &zlib_filefunc64_32_def_fill);
544
- }
545
- return unzOpenInternal(path, NULL);
546
- }
547
-
548
- extern unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def)
549
- {
550
- if (pzlib_filefunc_def != NULL) {
551
- zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
552
- zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
553
- zlib_filefunc64_32_def_fill.ztell32_file = NULL;
554
- zlib_filefunc64_32_def_fill.zseek32_file = NULL;
555
- return unzOpenInternal(path, &zlib_filefunc64_32_def_fill);
556
- }
557
- return unzOpenInternal(path, NULL);
558
- }
559
-
560
- extern unzFile ZEXPORT unzOpen(const char *path)
561
- {
562
- return unzOpenInternal(path, NULL);
563
- }
564
-
565
- extern unzFile ZEXPORT unzOpen64(const void *path)
566
- {
567
- return unzOpenInternal(path, NULL);
568
- }
569
-
570
- extern int ZEXPORT unzClose(unzFile file)
571
- {
572
- unz64_s *s;
573
- if (file == NULL)
574
- return UNZ_PARAMERROR;
575
- s = (unz64_s *)file;
576
-
577
- if (s->pfile_in_zip_read != NULL)
578
- unzCloseCurrentFile(file);
579
-
580
- if ((s->filestream != NULL) && (s->filestream != s->filestream_with_CD))
581
- ZCLOSE64(s->z_filefunc, s->filestream);
582
- if (s->filestream_with_CD != NULL)
583
- ZCLOSE64(s->z_filefunc, s->filestream_with_CD);
584
-
585
- s->filestream = NULL;
586
- s->filestream_with_CD = NULL;
587
- TRYFREE(s);
588
- return UNZ_OK;
589
- }
590
-
591
- /* Goto to the next available disk for spanned archives */
592
- local int unzGoToNextDisk OF((unzFile file));
593
- local int unzGoToNextDisk(unzFile file)
594
- {
595
- unz64_s *s;
596
- file_in_zip64_read_info_s *pfile_in_zip_read_info;
597
- uLong number_disk_next = 0;
598
-
599
- s = (unz64_s *)file;
600
- if (s == NULL)
601
- return UNZ_PARAMERROR;
602
- pfile_in_zip_read_info = s->pfile_in_zip_read;
603
- number_disk_next = s->number_disk;
604
-
605
- if ((pfile_in_zip_read_info != NULL) && (pfile_in_zip_read_info->rest_read_uncompressed > 0))
606
- /* We are currently reading a file and we need the next sequential disk */
607
- number_disk_next += 1;
608
- else
609
- /* Goto the disk for the current file */
610
- number_disk_next = s->cur_file_info.disk_num_start;
611
-
612
- if (number_disk_next != s->number_disk) {
613
- /* Switch disks */
614
- if ((s->filestream != NULL) && (s->filestream != s->filestream_with_CD))
615
- ZCLOSE64(s->z_filefunc, s->filestream);
616
-
617
- if (number_disk_next == s->gi.number_disk_with_CD) {
618
- s->filestream = s->filestream_with_CD;
619
- } else {
620
- s->filestream = ZOPENDISK64(s->z_filefunc, s->filestream_with_CD, (unsigned int)number_disk_next,
621
- ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_EXISTING);
622
- }
623
-
624
- if (s->filestream == NULL)
625
- return UNZ_ERRNO;
626
-
627
- s->number_disk = number_disk_next;
628
- }
629
-
630
- return UNZ_OK;
631
- }
632
-
633
- extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info32)
634
- {
635
- unz64_s *s;
636
- if (file == NULL)
637
- return UNZ_PARAMERROR;
638
- s = (unz64_s *)file;
639
- /* to do : check if number_entry is not truncated */
640
- pglobal_info32->number_entry = (uLong)s->gi.number_entry;
641
- pglobal_info32->size_comment = s->gi.size_comment;
642
- pglobal_info32->number_disk_with_CD = s->gi.number_disk_with_CD;
643
- return UNZ_OK;
644
- }
645
-
646
- extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info)
647
- {
648
- unz64_s *s;
649
- if (file == NULL)
650
- return UNZ_PARAMERROR;
651
- s = (unz64_s *)file;
652
- *pglobal_info = s->gi;
653
- return UNZ_OK;
654
- }
655
-
656
- extern int ZEXPORT unzGetGlobalComment(unzFile file, char *comment, uLong comment_size)
657
- {
658
- unz64_s *s;
659
- uLong bytes_to_read = comment_size;
660
- if (file == NULL)
661
- return (int)UNZ_PARAMERROR;
662
- s = (unz64_s *)file;
663
-
664
- if (bytes_to_read > s->gi.size_comment)
665
- bytes_to_read = s->gi.size_comment;
666
-
667
- if (ZSEEK64(s->z_filefunc, s->filestream_with_CD, s->central_pos + 22, ZLIB_FILEFUNC_SEEK_SET) != 0)
668
- return UNZ_ERRNO;
669
-
670
- if (bytes_to_read > 0) {
671
- *comment = 0;
672
- if (ZREAD64(s->z_filefunc, s->filestream_with_CD, comment, bytes_to_read) != bytes_to_read)
673
- return UNZ_ERRNO;
674
- }
675
-
676
- if ((comment != NULL) && (comment_size > s->gi.size_comment))
677
- *(comment + s->gi.size_comment) = 0;
678
- return (int)bytes_to_read;
679
- }
680
-
681
- /* Get Info about the current file in the zipfile, with internal only info */
682
- local int unz64local_GetCurrentFileInfoInternal(unzFile file, unz_file_info64 *pfile_info,
683
- unz_file_info64_internal *pfile_info_internal, char *filename, uLong filename_size, void *extrafield,
684
- uLong extrafield_size, char *comment, uLong comment_size)
685
- {
686
- unz64_s *s;
687
- unz_file_info64 file_info;
688
- unz_file_info64_internal file_info_internal;
689
- ZPOS64_T bytes_to_read;
690
- int err = UNZ_OK;
691
- uLong uMagic;
692
- long lSeek = 0;
693
- ZPOS64_T current_pos = 0;
694
- uLong acc = 0;
695
- uLong uL;
696
- ZPOS64_T uL64;
697
-
698
- if (file == NULL)
699
- return UNZ_PARAMERROR;
700
- s = (unz64_s *)file;
701
-
702
- if (ZSEEK64(s->z_filefunc, s->filestream_with_CD,
703
- s->pos_in_central_dir + s->byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0)
704
- err = UNZ_ERRNO;
705
-
706
- /* Check the magic */
707
- if (err == UNZ_OK) {
708
- if (unz64local_getLong(&s->z_filefunc, s->filestream_with_CD, &uMagic) != UNZ_OK)
709
- err = UNZ_ERRNO;
710
- else if (uMagic != CENTRALHEADERMAGIC)
711
- err = UNZ_BADZIPFILE;
712
- }
713
-
714
- /* Read central directory header */
715
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &file_info.version) != UNZ_OK)
716
- err = UNZ_ERRNO;
717
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &file_info.version_needed) != UNZ_OK)
718
- err = UNZ_ERRNO;
719
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &file_info.flag) != UNZ_OK)
720
- err = UNZ_ERRNO;
721
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &file_info.compression_method) != UNZ_OK)
722
- err = UNZ_ERRNO;
723
- if (unz64local_getLong(&s->z_filefunc, s->filestream_with_CD, &file_info.dosDate) != UNZ_OK)
724
- err = UNZ_ERRNO;
725
- unz64local_DosDateToTmuDate(file_info.dosDate, &file_info.tmu_date);
726
- if (unz64local_getLong(&s->z_filefunc, s->filestream_with_CD, &file_info.crc) != UNZ_OK)
727
- err = UNZ_ERRNO;
728
- if (unz64local_getLong(&s->z_filefunc, s->filestream_with_CD, &uL) != UNZ_OK)
729
- err = UNZ_ERRNO;
730
- file_info.compressed_size = uL;
731
- if (unz64local_getLong(&s->z_filefunc, s->filestream_with_CD, &uL) != UNZ_OK)
732
- err = UNZ_ERRNO;
733
- file_info.uncompressed_size = uL;
734
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &file_info.size_filename) != UNZ_OK)
735
- err = UNZ_ERRNO;
736
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &file_info.size_file_extra) != UNZ_OK)
737
- err = UNZ_ERRNO;
738
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &file_info.size_file_comment) != UNZ_OK)
739
- err = UNZ_ERRNO;
740
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &file_info.disk_num_start) != UNZ_OK)
741
- err = UNZ_ERRNO;
742
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &file_info.internal_fa) != UNZ_OK)
743
- err = UNZ_ERRNO;
744
- if (unz64local_getLong(&s->z_filefunc, s->filestream_with_CD, &file_info.external_fa) != UNZ_OK)
745
- err = UNZ_ERRNO;
746
- /* Relative offset of local header */
747
- if (unz64local_getLong(&s->z_filefunc, s->filestream_with_CD, &uL) != UNZ_OK)
748
- err = UNZ_ERRNO;
749
-
750
- file_info.size_file_extra_internal = 0;
751
- file_info.disk_offset = uL;
752
- file_info_internal.offset_curfile = uL;
753
- #ifdef HAVE_AES
754
- file_info_internal.aes_compression_method = 0;
755
- file_info_internal.aes_encryption_mode = 0;
756
- file_info_internal.aes_version = 0;
757
- #endif
758
-
759
- lSeek += file_info.size_filename;
760
-
761
- if ((err == UNZ_OK) && (filename != NULL)) {
762
- if (file_info.size_filename < filename_size) {
763
- *(filename + file_info.size_filename) = 0;
764
- bytes_to_read = file_info.size_filename;
765
- } else
766
- bytes_to_read = filename_size;
767
-
768
- if ((file_info.size_filename > 0) && (filename_size > 0))
769
- if (ZREAD64(s->z_filefunc, s->filestream_with_CD, filename, (uLong)bytes_to_read) != bytes_to_read)
770
- err = UNZ_ERRNO;
771
- lSeek -= (uLong)bytes_to_read;
772
- }
773
-
774
- /* Read extrafield */
775
- if ((err == UNZ_OK) && (extrafield != NULL)) {
776
- if (file_info.size_file_extra < extrafield_size)
777
- bytes_to_read = file_info.size_file_extra;
778
- else
779
- bytes_to_read = extrafield_size;
780
-
781
- if (lSeek != 0) {
782
- if (ZSEEK64(s->z_filefunc, s->filestream_with_CD, lSeek, ZLIB_FILEFUNC_SEEK_CUR) == 0)
783
- lSeek = 0;
784
- else
785
- err = UNZ_ERRNO;
786
- }
787
-
788
- if ((file_info.size_file_extra > 0) && (extrafield_size > 0))
789
- if (ZREAD64(s->z_filefunc, s->filestream_with_CD, extrafield, (uLong)bytes_to_read) != bytes_to_read)
790
- err = UNZ_ERRNO;
791
- lSeek += file_info.size_file_extra - (uLong)bytes_to_read;
792
- } else
793
- lSeek += file_info.size_file_extra;
794
-
795
- if ((err == UNZ_OK) && (file_info.size_file_extra != 0)) {
796
- if (lSeek != 0) {
797
- if (ZSEEK64(s->z_filefunc, s->filestream_with_CD, lSeek, ZLIB_FILEFUNC_SEEK_CUR) == 0)
798
- lSeek = 0;
799
- else
800
- err = UNZ_ERRNO;
801
- }
802
-
803
- /* We are going to parse the extra field so we need to move back */
804
- current_pos = ZTELL64(s->z_filefunc, s->filestream_with_CD);
805
- if (current_pos < file_info.size_file_extra)
806
- err = UNZ_ERRNO;
807
- current_pos -= file_info.size_file_extra;
808
- if (ZSEEK64(s->z_filefunc, s->filestream_with_CD, current_pos, ZLIB_FILEFUNC_SEEK_SET) != 0)
809
- err = UNZ_ERRNO;
810
-
811
- while ((err != UNZ_ERRNO) && (acc < file_info.size_file_extra)) {
812
- uLong headerid;
813
- uLong datasize;
814
-
815
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &headerid) != UNZ_OK)
816
- err = UNZ_ERRNO;
817
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &datasize) != UNZ_OK)
818
- err = UNZ_ERRNO;
819
-
820
- /* ZIP64 extra fields */
821
- if (headerid == 0x0001) {
822
- /* Subtract size of ZIP64 field, since ZIP64 is handled internally */
823
- file_info.size_file_extra_internal += 2 + 2 + datasize;
824
-
825
- if (file_info.uncompressed_size == 0xffffffff) {
826
- if (unz64local_getLong64(&s->z_filefunc, s->filestream_with_CD, &file_info.uncompressed_size) != UNZ_OK)
827
- err = UNZ_ERRNO;
828
- }
829
- if (file_info.compressed_size == 0xffffffff) {
830
- if (unz64local_getLong64(&s->z_filefunc, s->filestream_with_CD, &file_info.compressed_size) != UNZ_OK)
831
- err = UNZ_ERRNO;
832
- }
833
- if (file_info_internal.offset_curfile == 0xffffffff) {
834
- /* Relative Header offset */
835
- if (unz64local_getLong64(&s->z_filefunc, s->filestream_with_CD, &uL64) != UNZ_OK)
836
- err = UNZ_ERRNO;
837
- file_info_internal.offset_curfile = uL64;
838
- file_info.disk_offset = uL64;
839
- }
840
- if (file_info.disk_num_start == 0xffffffff) {
841
- /* Disk Start Number */
842
- if (unz64local_getLong(&s->z_filefunc, s->filestream_with_CD, &file_info.disk_num_start) != UNZ_OK)
843
- err = UNZ_ERRNO;
844
- }
845
- }
846
- #ifdef HAVE_AES
847
- /* AES header */
848
- else if (headerid == 0x9901) {
849
- /* Subtract size of AES field, since AES is handled internally */
850
- file_info.size_file_extra_internal += 2 + 2 + datasize;
851
-
852
- /* Verify version info */
853
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &uL) != UNZ_OK)
854
- err = UNZ_ERRNO;
855
- /* Support AE-1 and AE-2 */
856
- if (uL != 1 && uL != 2)
857
- err = UNZ_ERRNO;
858
- file_info_internal.aes_version = uL;
859
- if (unz64local_getByte(&s->z_filefunc, s->filestream_with_CD, (int *)&uL) != UNZ_OK)
860
- err = UNZ_ERRNO;
861
- if ((char)uL != 'A')
862
- err = UNZ_ERRNO;
863
- if (unz64local_getByte(&s->z_filefunc, s->filestream_with_CD, (int *)&uL) != UNZ_OK)
864
- err = UNZ_ERRNO;
865
- if ((char)uL != 'E')
866
- err = UNZ_ERRNO;
867
- /* Get AES encryption strength and actual compression method */
868
- if (unz64local_getByte(&s->z_filefunc, s->filestream_with_CD, (int *)&uL) != UNZ_OK)
869
- err = UNZ_ERRNO;
870
- file_info_internal.aes_encryption_mode = uL;
871
- if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &uL) != UNZ_OK)
872
- err = UNZ_ERRNO;
873
- file_info_internal.aes_compression_method = uL;
874
- }
875
- #endif
876
- else {
877
- if (ZSEEK64(s->z_filefunc, s->filestream_with_CD, datasize, ZLIB_FILEFUNC_SEEK_CUR) != 0)
878
- err = UNZ_ERRNO;
879
- }
880
-
881
- acc += 2 + 2 + datasize;
882
- }
883
- }
884
-
885
- if (file_info.disk_num_start == s->gi.number_disk_with_CD)
886
- file_info_internal.byte_before_the_zipfile = s->byte_before_the_zipfile;
887
- else
888
- file_info_internal.byte_before_the_zipfile = 0;
889
-
890
- if ((err == UNZ_OK) && (comment != NULL)) {
891
- if (file_info.size_file_comment < comment_size) {
892
- *(comment + file_info.size_file_comment) = 0;
893
- bytes_to_read = file_info.size_file_comment;
894
- } else
895
- bytes_to_read = comment_size;
896
-
897
- if (lSeek != 0) {
898
- if (ZSEEK64(s->z_filefunc, s->filestream_with_CD, lSeek, ZLIB_FILEFUNC_SEEK_CUR) != 0)
899
- err = UNZ_ERRNO;
900
- }
901
-
902
- if ((file_info.size_file_comment > 0) && (comment_size > 0))
903
- if (ZREAD64(s->z_filefunc, s->filestream_with_CD, comment, (uLong)bytes_to_read) != bytes_to_read)
904
- err = UNZ_ERRNO;
905
- lSeek += file_info.size_file_comment - (uLong)bytes_to_read;
906
- } else
907
- lSeek += file_info.size_file_comment;
908
-
909
- if ((err == UNZ_OK) && (pfile_info != NULL))
910
- *pfile_info = file_info;
911
-
912
- if ((err == UNZ_OK) && (pfile_info_internal != NULL))
913
- *pfile_info_internal = file_info_internal;
914
-
915
- return err;
916
- }
917
-
918
- extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename,
919
- uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size)
920
- {
921
- unz_file_info64 file_info64;
922
- int err;
923
-
924
- err = unz64local_GetCurrentFileInfoInternal(file, &file_info64, NULL, filename, filename_size,
925
- extrafield, extrafield_size, comment, comment_size);
926
-
927
- if ((err == UNZ_OK) && (pfile_info != NULL)) {
928
- pfile_info->version = file_info64.version;
929
- pfile_info->version_needed = file_info64.version_needed;
930
- pfile_info->flag = file_info64.flag;
931
- pfile_info->compression_method = file_info64.compression_method;
932
- pfile_info->dosDate = file_info64.dosDate;
933
- pfile_info->crc = file_info64.crc;
934
-
935
- pfile_info->size_filename = file_info64.size_filename;
936
- pfile_info->size_file_extra = file_info64.size_file_extra - file_info64.size_file_extra_internal;
937
- pfile_info->size_file_comment = file_info64.size_file_comment;
938
-
939
- pfile_info->disk_num_start = file_info64.disk_num_start;
940
- pfile_info->internal_fa = file_info64.internal_fa;
941
- pfile_info->external_fa = file_info64.external_fa;
942
-
943
- pfile_info->tmu_date = file_info64.tmu_date,
944
-
945
- pfile_info->compressed_size = (uLong)file_info64.compressed_size;
946
- pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
947
-
948
- }
949
- return err;
950
- }
951
-
952
- extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *filename,
953
- uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size)
954
- {
955
- return unz64local_GetCurrentFileInfoInternal(file, pfile_info, NULL, filename, filename_size,
956
- extrafield, extrafield_size, comment, comment_size);
957
- }
958
-
959
- /* Read the local header of the current zipfile. Check the coherency of the local header and info in the
960
- end of central directory about this file store in *piSizeVar the size of extra info in local header
961
- (filename and size of extra field data) */
962
- local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s *s, uInt *piSizeVar, ZPOS64_T *poffset_local_extrafield,
963
- uInt *psize_local_extrafield)
964
- {
965
- uLong uMagic, uL, uFlags;
966
- uLong size_filename;
967
- uLong size_extra_field;
968
- int err = UNZ_OK;
969
- int compression_method = 0;
970
-
971
- *piSizeVar = 0;
972
- *poffset_local_extrafield = 0;
973
- *psize_local_extrafield = 0;
974
-
975
- err = unzGoToNextDisk((unzFile)s);
976
- if (err != UNZ_OK)
977
- return err;
978
-
979
- if (ZSEEK64(s->z_filefunc, s->filestream, s->cur_file_info_internal.offset_curfile +
980
- s->cur_file_info_internal.byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0)
981
- return UNZ_ERRNO;
982
-
983
- if (err == UNZ_OK) {
984
- if (unz64local_getLong(&s->z_filefunc, s->filestream, &uMagic) != UNZ_OK)
985
- err = UNZ_ERRNO;
986
- else if (uMagic != LOCALHEADERMAGIC)
987
- err = UNZ_BADZIPFILE;
988
- }
989
-
990
- if (unz64local_getShort(&s->z_filefunc, s->filestream, &uL) != UNZ_OK)
991
- err = UNZ_ERRNO;
992
- if (unz64local_getShort(&s->z_filefunc, s->filestream, &uFlags) != UNZ_OK)
993
- err = UNZ_ERRNO;
994
- if (unz64local_getShort(&s->z_filefunc, s->filestream, &uL) != UNZ_OK)
995
- err = UNZ_ERRNO;
996
- else if ((err == UNZ_OK) && (uL != s->cur_file_info.compression_method))
997
- err = UNZ_BADZIPFILE;
998
-
999
- compression_method = (int)s->cur_file_info.compression_method;
1000
- #ifdef HAVE_AES
1001
- if (compression_method == AES_METHOD)
1002
- compression_method = (int)s->cur_file_info_internal.aes_compression_method;
1003
- #endif
1004
-
1005
- if ((err == UNZ_OK) && (compression_method != 0) &&
1006
- #ifdef HAVE_BZIP2
1007
- (compression_method != Z_BZIP2ED) &&
1008
- #endif
1009
- (compression_method != Z_DEFLATED))
1010
- err = UNZ_BADZIPFILE;
1011
-
1012
- if (unz64local_getLong(&s->z_filefunc, s->filestream, &uL) != UNZ_OK) /* date/time */
1013
- err = UNZ_ERRNO;
1014
- if (unz64local_getLong(&s->z_filefunc, s->filestream, &uL) != UNZ_OK) /* crc */
1015
- err = UNZ_ERRNO;
1016
- else if ((err == UNZ_OK) && (uL != s->cur_file_info.crc) && ((uFlags & 8) == 0))
1017
- err = UNZ_BADZIPFILE;
1018
- if (unz64local_getLong(&s->z_filefunc, s->filestream, &uL) != UNZ_OK) /* size compr */
1019
- err = UNZ_ERRNO;
1020
- else if ((uL != 0xffffffff) && (err == UNZ_OK) && (uL != s->cur_file_info.compressed_size) && ((uFlags & 8) == 0))
1021
- err = UNZ_BADZIPFILE;
1022
- if (unz64local_getLong(&s->z_filefunc, s->filestream, &uL) != UNZ_OK) /* size uncompr */
1023
- err = UNZ_ERRNO;
1024
- else if ((uL != 0xffffffff) && (err == UNZ_OK) && (uL != s->cur_file_info.uncompressed_size) && ((uFlags & 8) == 0))
1025
- err = UNZ_BADZIPFILE;
1026
- if (unz64local_getShort(&s->z_filefunc, s->filestream, &size_filename) != UNZ_OK)
1027
- err = UNZ_ERRNO;
1028
- else if ((err == UNZ_OK) && (size_filename != s->cur_file_info.size_filename))
1029
- err = UNZ_BADZIPFILE;
1030
-
1031
- *piSizeVar += (uInt)size_filename;
1032
-
1033
- if (unz64local_getShort(&s->z_filefunc, s->filestream, &size_extra_field) != UNZ_OK)
1034
- err = UNZ_ERRNO;
1035
- *poffset_local_extrafield = s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + size_filename;
1036
- *psize_local_extrafield = (uInt)size_extra_field;
1037
-
1038
- *piSizeVar += (uInt)size_extra_field;
1039
-
1040
- return err;
1041
- }
1042
-
1043
- /*
1044
- Open for reading data the current file in the zipfile.
1045
- If there is no error and the file is opened, the return value is UNZ_OK.
1046
- */
1047
- extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password)
1048
- {
1049
- int err = UNZ_OK;
1050
- int compression_method;
1051
- uInt iSizeVar;
1052
- unz64_s *s;
1053
- file_in_zip64_read_info_s *pfile_in_zip_read_info;
1054
- ZPOS64_T offset_local_extrafield;
1055
- uInt size_local_extrafield;
1056
- #ifndef NOUNCRYPT
1057
- char source[12];
1058
- #else
1059
- if (password != NULL)
1060
- return UNZ_PARAMERROR;
1061
- #endif
1062
- if (file == NULL)
1063
- return UNZ_PARAMERROR;
1064
- s = (unz64_s *)file;
1065
- if (!s->current_file_ok)
1066
- return UNZ_PARAMERROR;
1067
-
1068
- if (s->pfile_in_zip_read != NULL)
1069
- unzCloseCurrentFile(file);
1070
-
1071
- if (unz64local_CheckCurrentFileCoherencyHeader(s, &iSizeVar, &offset_local_extrafield, &size_local_extrafield) != UNZ_OK)
1072
- return UNZ_BADZIPFILE;
1073
-
1074
- pfile_in_zip_read_info = (file_in_zip64_read_info_s *)ALLOC(sizeof(file_in_zip64_read_info_s));
1075
- if (pfile_in_zip_read_info == NULL)
1076
- return UNZ_INTERNALERROR;
1077
-
1078
- pfile_in_zip_read_info->read_buffer = (Bytef *)ALLOC(UNZ_BUFSIZE);
1079
- pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
1080
- pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
1081
- pfile_in_zip_read_info->pos_local_extrafield = 0;
1082
- pfile_in_zip_read_info->raw = raw;
1083
-
1084
- if (pfile_in_zip_read_info->read_buffer == NULL) {
1085
- TRYFREE(pfile_in_zip_read_info);
1086
- return UNZ_INTERNALERROR;
1087
- }
1088
-
1089
- pfile_in_zip_read_info->stream_initialised = 0;
1090
-
1091
- compression_method = (int)s->cur_file_info.compression_method;
1092
- #ifdef HAVE_AES
1093
- if (compression_method == AES_METHOD)
1094
- compression_method = (int)s->cur_file_info_internal.aes_compression_method;
1095
- #endif
1096
-
1097
- if (method != NULL)
1098
- *method = compression_method;
1099
-
1100
- if (level != NULL) {
1101
- *level = 6;
1102
- switch (s->cur_file_info.flag & 0x06) {
1103
- case 6: *level = 1; break;
1104
- case 4: *level = 2; break;
1105
- case 2: *level = 9; break;
1106
- }
1107
- }
1108
-
1109
- if ((compression_method != 0) &&
1110
- #ifdef HAVE_BZIP2
1111
- (compression_method != Z_BZIP2ED) &&
1112
- #endif
1113
- (compression_method != Z_DEFLATED))
1114
- err = UNZ_BADZIPFILE;
1115
-
1116
- pfile_in_zip_read_info->crc32_wait = s->cur_file_info.crc;
1117
- pfile_in_zip_read_info->crc32 = 0;
1118
- pfile_in_zip_read_info->total_out_64 = 0;
1119
- pfile_in_zip_read_info->compression_method = compression_method;
1120
- pfile_in_zip_read_info->filestream = s->filestream;
1121
- pfile_in_zip_read_info->z_filefunc = s->z_filefunc;
1122
- if (s->number_disk == s->gi.number_disk_with_CD)
1123
- pfile_in_zip_read_info->byte_before_the_zipfile = s->byte_before_the_zipfile;
1124
- else
1125
- pfile_in_zip_read_info->byte_before_the_zipfile = 0;
1126
- pfile_in_zip_read_info->stream.total_out = 0;
1127
- pfile_in_zip_read_info->stream.total_in = 0;
1128
- pfile_in_zip_read_info->stream.next_in = NULL;
1129
-
1130
- if (!raw) {
1131
- if (compression_method == Z_BZIP2ED) {
1132
- #ifdef HAVE_BZIP2
1133
- pfile_in_zip_read_info->bstream.bzalloc = (void *(*)(void *, int, int)) 0;
1134
- pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
1135
- pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
1136
- pfile_in_zip_read_info->bstream.state = (voidpf)0;
1137
-
1138
- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
1139
- pfile_in_zip_read_info->stream.zfree = (free_func)0;
1140
- pfile_in_zip_read_info->stream.opaque = (voidpf)0;
1141
- pfile_in_zip_read_info->stream.next_in = (voidpf)0;
1142
- pfile_in_zip_read_info->stream.avail_in = 0;
1143
-
1144
- err = BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
1145
- if (err == Z_OK)
1146
- pfile_in_zip_read_info->stream_initialised = Z_BZIP2ED;
1147
- else {
1148
- TRYFREE(pfile_in_zip_read_info);
1149
- return err;
1150
- }
1151
- #else
1152
- pfile_in_zip_read_info->raw = 1;
1153
- #endif
1154
- } else if (compression_method == Z_DEFLATED) {
1155
- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
1156
- pfile_in_zip_read_info->stream.zfree = (free_func)0;
1157
- pfile_in_zip_read_info->stream.opaque = (voidpf)s;
1158
- pfile_in_zip_read_info->stream.next_in = 0;
1159
- pfile_in_zip_read_info->stream.avail_in = 0;
1160
-
1161
- err = inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
1162
- if (err == Z_OK)
1163
- pfile_in_zip_read_info->stream_initialised = Z_DEFLATED;
1164
- else {
1165
- TRYFREE(pfile_in_zip_read_info);
1166
- return err;
1167
- }
1168
- /* windowBits is passed < 0 to tell that there is no zlib header.
1169
- * Note that in this case inflate *requires* an extra "dummy" byte
1170
- * after the compressed stream in order to complete decompression and
1171
- * return Z_STREAM_END.
1172
- * In unzip, i don't wait absolutely Z_STREAM_END because I known the
1173
- * size of both compressed and uncompressed data
1174
- */
1175
- }
1176
- }
1177
-
1178
- pfile_in_zip_read_info->rest_read_compressed = s->cur_file_info.compressed_size;
1179
- pfile_in_zip_read_info->rest_read_uncompressed = s->cur_file_info.uncompressed_size;
1180
- pfile_in_zip_read_info->pos_in_zipfile = s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + iSizeVar;
1181
- pfile_in_zip_read_info->stream.avail_in = (uInt)0;
1182
-
1183
- s->pfile_in_zip_read = pfile_in_zip_read_info;
1184
-
1185
- #ifndef NOUNCRYPT
1186
- if ((password != NULL) && ((s->cur_file_info.flag & 1) != 0)) {
1187
- if (ZSEEK64(s->z_filefunc, s->filestream,
1188
- s->pfile_in_zip_read->pos_in_zipfile + s->pfile_in_zip_read->byte_before_the_zipfile,
1189
- ZLIB_FILEFUNC_SEEK_SET) != 0)
1190
- return UNZ_INTERNALERROR;
1191
- #ifdef HAVE_AES
1192
- if (s->cur_file_info.compression_method == AES_METHOD) {
1193
- unsigned char passverify[AES_PWVERIFYSIZE];
1194
- unsigned char saltvalue[AES_MAXSALTLENGTH];
1195
- uInt saltlength;
1196
-
1197
- if ((s->cur_file_info_internal.aes_encryption_mode < 1) ||
1198
- (s->cur_file_info_internal.aes_encryption_mode > 3))
1199
- return UNZ_INTERNALERROR;
1200
-
1201
- saltlength = SALT_LENGTH(s->cur_file_info_internal.aes_encryption_mode);
1202
-
1203
- if (ZREAD64(s->z_filefunc, s->filestream, saltvalue, saltlength) != saltlength)
1204
- return UNZ_INTERNALERROR;
1205
- if (ZREAD64(s->z_filefunc, s->filestream, passverify, AES_PWVERIFYSIZE) != AES_PWVERIFYSIZE)
1206
- return UNZ_INTERNALERROR;
1207
-
1208
- fcrypt_init((int)s->cur_file_info_internal.aes_encryption_mode, (unsigned char *)password, (unsigned int)strlen(password), saltvalue,
1209
- passverify, &s->pfile_in_zip_read->aes_ctx);
1210
-
1211
- pfile_in_zip_read_info->rest_read_compressed -= saltlength + AES_PWVERIFYSIZE;
1212
- pfile_in_zip_read_info->rest_read_compressed -= AES_AUTHCODESIZE;
1213
-
1214
- s->pfile_in_zip_read->pos_in_zipfile += saltlength + AES_PWVERIFYSIZE;
1215
- } else
1216
- #endif
1217
- {
1218
- int i;
1219
- s->pcrc_32_tab = (const unsigned long *)get_crc_table();
1220
- init_keys(password, s->keys, s->pcrc_32_tab);
1221
-
1222
- if (ZREAD64(s->z_filefunc, s->filestream, source, 12) < 12)
1223
- return UNZ_INTERNALERROR;
1224
-
1225
- for (i = 0; i < 12; i++)
1226
- zdecode(s->keys, s->pcrc_32_tab, source[i]);
1227
-
1228
- pfile_in_zip_read_info->rest_read_compressed -= 12;
1229
-
1230
- s->pfile_in_zip_read->pos_in_zipfile += 12;
1231
- }
1232
- }
1233
- #endif
1234
-
1235
- return UNZ_OK;
1236
- }
1237
-
1238
- extern int ZEXPORT unzOpenCurrentFile(unzFile file)
1239
- {
1240
- return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
1241
- }
1242
-
1243
- extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char *password)
1244
- {
1245
- return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
1246
- }
1247
-
1248
- extern int ZEXPORT unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw)
1249
- {
1250
- return unzOpenCurrentFile3(file, method, level, raw, NULL);
1251
- }
1252
-
1253
- /* Read bytes from the current file.
1254
- buf contain buffer where data must be copied
1255
- len the size of buf.
1256
-
1257
- return the number of byte copied if some bytes are copied
1258
- return 0 if the end of file was reached
1259
- return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */
1260
- extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len)
1261
- {
1262
- int err = UNZ_OK;
1263
- uInt read = 0;
1264
- unz64_s *s;
1265
- file_in_zip64_read_info_s *pfile_in_zip_read_info;
1266
- if (file == NULL)
1267
- return UNZ_PARAMERROR;
1268
- s = (unz64_s *)file;
1269
- pfile_in_zip_read_info = s->pfile_in_zip_read;
1270
-
1271
- if (pfile_in_zip_read_info == NULL)
1272
- return UNZ_PARAMERROR;
1273
- if (pfile_in_zip_read_info->read_buffer == NULL)
1274
- return UNZ_END_OF_LIST_OF_FILE;
1275
- if (len == 0)
1276
- return 0;
1277
-
1278
- pfile_in_zip_read_info->stream.next_out = (Bytef *)buf;
1279
- pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1280
-
1281
- if (pfile_in_zip_read_info->raw) {
1282
- if (len > pfile_in_zip_read_info->rest_read_compressed + pfile_in_zip_read_info->stream.avail_in)
1283
- pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_compressed +
1284
- pfile_in_zip_read_info->stream.avail_in;
1285
- } else {
1286
-
1287
- // NOTE:
1288
- // This bit of code seems to try to set the amount of space in the output buffer based on the
1289
- // value stored in the headers stored in the .zip file. However, if those values are incorrect
1290
- // it may result in a loss of data when uncompresssing that file. The compressed data is still
1291
- // legit and will deflate without knowing the uncompressed code so this tidbit is unnecessary and
1292
- // may cause issues for some .zip files.
1293
- //
1294
- // It's removed in here to fix those issues.
1295
- //
1296
- // See: https://github.com/ZipArchive/ziparchive/issues/16
1297
- //
1298
-
1299
- /*
1300
-
1301
-
1302
- FIXME: Upgrading to minizip 1.1 caused issues here, Uncommented the code that was commented before. 11/24/2015
1303
- */
1304
-
1305
- if (len > pfile_in_zip_read_info->rest_read_uncompressed)
1306
- pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
1307
-
1308
-
1309
-
1310
- }
1311
-
1312
- while (pfile_in_zip_read_info->stream.avail_out > 0) {
1313
- if (pfile_in_zip_read_info->stream.avail_in == 0) {
1314
- uInt bytes_to_read = UNZ_BUFSIZE;
1315
- uInt bytes_not_read = 0;
1316
- uInt bytes_read = 0;
1317
- uInt total_bytes_read = 0;
1318
-
1319
- if (pfile_in_zip_read_info->stream.next_in != NULL)
1320
- bytes_not_read = (uInt)(pfile_in_zip_read_info->read_buffer + UNZ_BUFSIZE -
1321
- pfile_in_zip_read_info->stream.next_in);
1322
- bytes_to_read -= bytes_not_read;
1323
- if (bytes_not_read > 0)
1324
- memcpy(pfile_in_zip_read_info->read_buffer, pfile_in_zip_read_info->stream.next_in, bytes_not_read);
1325
- if (pfile_in_zip_read_info->rest_read_compressed < bytes_to_read)
1326
- bytes_to_read = (uInt)pfile_in_zip_read_info->rest_read_compressed;
1327
-
1328
- while (total_bytes_read != bytes_to_read) {
1329
- if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream,
1330
- pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile,
1331
- ZLIB_FILEFUNC_SEEK_SET) != 0)
1332
- return UNZ_ERRNO;
1333
-
1334
- bytes_read = (int)ZREAD64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream,
1335
- pfile_in_zip_read_info->read_buffer + bytes_not_read + total_bytes_read,
1336
- bytes_to_read - total_bytes_read);
1337
-
1338
- total_bytes_read += bytes_read;
1339
- pfile_in_zip_read_info->pos_in_zipfile += bytes_read;
1340
-
1341
- if (bytes_read == 0) {
1342
- if (ZERROR64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream))
1343
- return UNZ_ERRNO;
1344
-
1345
- err = unzGoToNextDisk(file);
1346
- if (err != UNZ_OK)
1347
- return err;
1348
-
1349
- pfile_in_zip_read_info->pos_in_zipfile = 0;
1350
- pfile_in_zip_read_info->filestream = s->filestream;
1351
- }
1352
- }
1353
-
1354
- #ifndef NOUNCRYPT
1355
- if ((s->cur_file_info.flag & 1) != 0) {
1356
- #ifdef HAVE_AES
1357
- if (s->cur_file_info.compression_method == AES_METHOD) {
1358
- fcrypt_decrypt(pfile_in_zip_read_info->read_buffer, bytes_to_read, &s->pfile_in_zip_read->aes_ctx);
1359
- } else
1360
- #endif
1361
- {
1362
- uInt i;
1363
- for (i = 0; i < total_bytes_read; i++)
1364
- pfile_in_zip_read_info->read_buffer[i] =
1365
- zdecode(s->keys, s->pcrc_32_tab, pfile_in_zip_read_info->read_buffer[i]);
1366
- }
1367
- }
1368
- #endif
1369
-
1370
- pfile_in_zip_read_info->rest_read_compressed -= total_bytes_read;
1371
- pfile_in_zip_read_info->stream.next_in = (Bytef *)pfile_in_zip_read_info->read_buffer;
1372
- pfile_in_zip_read_info->stream.avail_in = (uInt)bytes_not_read + total_bytes_read;
1373
- }
1374
-
1375
- if ((pfile_in_zip_read_info->compression_method == 0) || (pfile_in_zip_read_info->raw)) {
1376
- uInt copy, i;
1377
-
1378
- if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
1379
- (pfile_in_zip_read_info->rest_read_compressed == 0))
1380
- return (read == 0) ? UNZ_EOF : read;
1381
-
1382
- if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in)
1383
- copy = pfile_in_zip_read_info->stream.avail_out;
1384
- else
1385
- copy = pfile_in_zip_read_info->stream.avail_in;
1386
-
1387
- for (i = 0; i < copy; i++)
1388
- *(pfile_in_zip_read_info->stream.next_out + i) =
1389
- *(pfile_in_zip_read_info->stream.next_in + i);
1390
-
1391
- pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + copy;
1392
- pfile_in_zip_read_info->rest_read_uncompressed -= copy;
1393
- pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
1394
- pfile_in_zip_read_info->stream.next_out, copy);
1395
-
1396
- pfile_in_zip_read_info->stream.avail_in -= copy;
1397
- pfile_in_zip_read_info->stream.avail_out -= copy;
1398
- pfile_in_zip_read_info->stream.next_out += copy;
1399
- pfile_in_zip_read_info->stream.next_in += copy;
1400
- pfile_in_zip_read_info->stream.total_out += copy;
1401
- read += copy;
1402
- } else if (pfile_in_zip_read_info->compression_method == Z_BZIP2ED) {
1403
- #ifdef HAVE_BZIP2
1404
- uLong total_out_before, total_out_after;
1405
- const Bytef *buf_before;
1406
- uLong out_bytes;
1407
-
1408
- pfile_in_zip_read_info->bstream.next_in = (char *)pfile_in_zip_read_info->stream.next_in;
1409
- pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in;
1410
- pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in;
1411
- pfile_in_zip_read_info->bstream.total_in_hi32 = 0;
1412
- pfile_in_zip_read_info->bstream.next_out = (char *)pfile_in_zip_read_info->stream.next_out;
1413
- pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out;
1414
- pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
1415
- pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
1416
-
1417
- total_out_before = pfile_in_zip_read_info->bstream.total_out_lo32;
1418
- buf_before = (const Bytef *)pfile_in_zip_read_info->bstream.next_out;
1419
-
1420
- err = BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
1421
-
1422
- total_out_after = pfile_in_zip_read_info->bstream.total_out_lo32;
1423
- out_bytes = total_out_after - total_out_before;
1424
-
1425
- pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + out_bytes;
1426
- pfile_in_zip_read_info->rest_read_uncompressed -= out_bytes;
1427
- pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, buf_before, (uInt)(out_bytes));
1428
-
1429
- read += (uInt)(total_out_after - total_out_before);
1430
-
1431
- pfile_in_zip_read_info->stream.next_in = (Bytef *)pfile_in_zip_read_info->bstream.next_in;
1432
- pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in;
1433
- pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32;
1434
- pfile_in_zip_read_info->stream.next_out = (Bytef *)pfile_in_zip_read_info->bstream.next_out;
1435
- pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
1436
- pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
1437
-
1438
- if (err == BZ_STREAM_END)
1439
- return (read == 0) ? UNZ_EOF : read;
1440
- if (err != BZ_OK)
1441
- break;
1442
- #endif
1443
- } else {
1444
- ZPOS64_T total_out_before, total_out_after;
1445
- const Bytef *buf_before;
1446
- ZPOS64_T out_bytes;
1447
- int flush = Z_SYNC_FLUSH;
1448
-
1449
- total_out_before = pfile_in_zip_read_info->stream.total_out;
1450
- buf_before = pfile_in_zip_read_info->stream.next_out;
1451
-
1452
- /*
1453
- if ((pfile_in_zip_read_info->rest_read_uncompressed ==
1454
- pfile_in_zip_read_info->stream.avail_out) &&
1455
- (pfile_in_zip_read_info->rest_read_compressed == 0))
1456
- flush = Z_FINISH;
1457
- */
1458
- err = inflate(&pfile_in_zip_read_info->stream, flush);
1459
-
1460
- if ((err >= 0) && (pfile_in_zip_read_info->stream.msg != NULL))
1461
- err = Z_DATA_ERROR;
1462
-
1463
- total_out_after = pfile_in_zip_read_info->stream.total_out;
1464
- out_bytes = total_out_after - total_out_before;
1465
-
1466
- pfile_in_zip_read_info->total_out_64 += out_bytes;
1467
- pfile_in_zip_read_info->rest_read_uncompressed -= out_bytes;
1468
- pfile_in_zip_read_info->crc32 =
1469
- crc32(pfile_in_zip_read_info->crc32, buf_before, (uInt)(out_bytes));
1470
-
1471
- read += (uInt)(total_out_after - total_out_before);
1472
-
1473
- if (err == Z_STREAM_END)
1474
- return (read == 0) ? UNZ_EOF : read;
1475
- if (err != Z_OK)
1476
- break;
1477
- }
1478
- }
1479
-
1480
- if (err == Z_OK)
1481
- return read;
1482
- return err;
1483
- }
1484
-
1485
- extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file)
1486
- {
1487
- unz64_s *s;
1488
- file_in_zip64_read_info_s *pfile_in_zip_read_info;
1489
- s = (unz64_s *)file;
1490
- if (file == NULL)
1491
- return 0; /* UNZ_PARAMERROR */
1492
- pfile_in_zip_read_info = s->pfile_in_zip_read;
1493
- if (pfile_in_zip_read_info == NULL)
1494
- return 0; /* UNZ_PARAMERROR */
1495
- return pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile;
1496
- }
1497
-
1498
- extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len)
1499
- {
1500
- unz64_s *s;
1501
- file_in_zip64_read_info_s *pfile_in_zip_read_info;
1502
- uInt read_now;
1503
- ZPOS64_T size_to_read;
1504
-
1505
- if (file == NULL)
1506
- return UNZ_PARAMERROR;
1507
- s = (unz64_s *)file;
1508
- pfile_in_zip_read_info = s->pfile_in_zip_read;
1509
-
1510
- if (pfile_in_zip_read_info == NULL)
1511
- return UNZ_PARAMERROR;
1512
-
1513
- size_to_read = pfile_in_zip_read_info->size_local_extrafield - pfile_in_zip_read_info->pos_local_extrafield;
1514
-
1515
- if (buf == NULL)
1516
- return (int)size_to_read;
1517
-
1518
- if (len > size_to_read)
1519
- read_now = (uInt)size_to_read;
1520
- else
1521
- read_now = (uInt)len;
1522
-
1523
- if (read_now == 0)
1524
- return 0;
1525
-
1526
- if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream,
1527
- pfile_in_zip_read_info->offset_local_extrafield + pfile_in_zip_read_info->pos_local_extrafield,
1528
- ZLIB_FILEFUNC_SEEK_SET) != 0)
1529
- return UNZ_ERRNO;
1530
-
1531
- if (ZREAD64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, buf, read_now) != read_now)
1532
- return UNZ_ERRNO;
1533
-
1534
- return (int)read_now;
1535
- }
1536
-
1537
- extern int ZEXPORT unzCloseCurrentFile(unzFile file)
1538
- {
1539
- int err = UNZ_OK;
1540
-
1541
- unz64_s *s;
1542
- file_in_zip64_read_info_s *pfile_in_zip_read_info;
1543
- if (file == NULL)
1544
- return UNZ_PARAMERROR;
1545
- s = (unz64_s *)file;
1546
- pfile_in_zip_read_info = s->pfile_in_zip_read;
1547
-
1548
- if (pfile_in_zip_read_info == NULL)
1549
- return UNZ_PARAMERROR;
1550
-
1551
- #ifdef HAVE_AES
1552
- if (s->cur_file_info.compression_method == AES_METHOD) {
1553
- unsigned char authcode[AES_AUTHCODESIZE];
1554
- unsigned char rauthcode[AES_AUTHCODESIZE];
1555
-
1556
- if (ZREAD64(s->z_filefunc, s->filestream, authcode, AES_AUTHCODESIZE) != AES_AUTHCODESIZE)
1557
- return UNZ_ERRNO;
1558
-
1559
- if (fcrypt_end(rauthcode, &s->pfile_in_zip_read->aes_ctx) != AES_AUTHCODESIZE)
1560
- err = UNZ_CRCERROR;
1561
- if (memcmp(authcode, rauthcode, AES_AUTHCODESIZE) != 0)
1562
- err = UNZ_CRCERROR;
1563
- }
1564
- /* AES zip version AE-1 will expect a valid crc as well */
1565
- if ((s->cur_file_info.compression_method != AES_METHOD) ||
1566
- (s->cur_file_info_internal.aes_version == 0x0001))
1567
- #endif
1568
- {
1569
- if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
1570
- (!pfile_in_zip_read_info->raw)) {
1571
- if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
1572
- err = UNZ_CRCERROR;
1573
- }
1574
- }
1575
-
1576
- TRYFREE(pfile_in_zip_read_info->read_buffer);
1577
- pfile_in_zip_read_info->read_buffer = NULL;
1578
- if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
1579
- inflateEnd(&pfile_in_zip_read_info->stream);
1580
- #ifdef HAVE_BZIP2
1581
- else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
1582
- BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
1583
- #endif
1584
-
1585
- pfile_in_zip_read_info->stream_initialised = 0;
1586
- TRYFREE(pfile_in_zip_read_info);
1587
-
1588
- s->pfile_in_zip_read = NULL;
1589
-
1590
- return err;
1591
- }
1592
-
1593
- extern int ZEXPORT unzGoToFirstFile2(unzFile file, unz_file_info64 *pfile_info, char *filename,
1594
- uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size)
1595
- {
1596
- int err = UNZ_OK;
1597
- unz64_s *s;
1598
- if (file == NULL)
1599
- return UNZ_PARAMERROR;
1600
- s = (unz64_s *)file;
1601
- s->pos_in_central_dir = s->offset_central_dir;
1602
- s->num_file = 0;
1603
- err = unz64local_GetCurrentFileInfoInternal(file, &s->cur_file_info, &s->cur_file_info_internal,
1604
- filename, filename_size, extrafield, extrafield_size, comment, comment_size);
1605
- s->current_file_ok = (err == UNZ_OK);
1606
- if ((err == UNZ_OK) && (pfile_info != NULL))
1607
- memcpy(pfile_info, &s->cur_file_info, sizeof(unz_file_info64));
1608
- return err;
1609
- }
1610
-
1611
- extern int ZEXPORT unzGoToFirstFile(unzFile file)
1612
- {
1613
- return unzGoToFirstFile2(file, NULL, NULL, 0, NULL, 0, NULL, 0);
1614
- }
1615
-
1616
- extern int ZEXPORT unzGoToNextFile2(unzFile file, unz_file_info64 *pfile_info, char *filename,
1617
- uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size)
1618
- {
1619
- unz64_s *s;
1620
- int err;
1621
-
1622
- if (file == NULL)
1623
- return UNZ_PARAMERROR;
1624
- s = (unz64_s *)file;
1625
- if (!s->current_file_ok)
1626
- return UNZ_END_OF_LIST_OF_FILE;
1627
- if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */
1628
- if (s->num_file + 1 == s->gi.number_entry)
1629
- return UNZ_END_OF_LIST_OF_FILE;
1630
- s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
1631
- s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment;
1632
- s->num_file++;
1633
- err = unz64local_GetCurrentFileInfoInternal(file, &s->cur_file_info, &s->cur_file_info_internal,
1634
- filename, filename_size, extrafield, extrafield_size, comment, comment_size);
1635
- s->current_file_ok = (err == UNZ_OK);
1636
- if ((err == UNZ_OK) && (pfile_info != NULL))
1637
- memcpy(pfile_info, &s->cur_file_info, sizeof(unz_file_info64));
1638
- return err;
1639
- }
1640
-
1641
- extern int ZEXPORT unzGoToNextFile(unzFile file)
1642
- {
1643
- return unzGoToNextFile2(file, NULL, NULL, 0, NULL, 0, NULL, 0);
1644
- }
1645
-
1646
- extern int ZEXPORT unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func)
1647
- {
1648
- unz64_s *s;
1649
- int err;
1650
- unz_file_info64 cur_file_info_saved;
1651
- unz_file_info64_internal cur_file_info_internal_saved;
1652
- ZPOS64_T num_file_saved;
1653
- ZPOS64_T pos_in_central_dir_saved;
1654
- char current_filename[UNZ_MAXFILENAMEINZIP + 1];
1655
-
1656
- if (file == NULL)
1657
- return UNZ_PARAMERROR;
1658
- if (strlen(filename) >= UNZ_MAXFILENAMEINZIP)
1659
- return UNZ_PARAMERROR;
1660
- s = (unz64_s *)file;
1661
- if (!s->current_file_ok)
1662
- return UNZ_END_OF_LIST_OF_FILE;
1663
-
1664
- /* Save the current state */
1665
- num_file_saved = s->num_file;
1666
- pos_in_central_dir_saved = s->pos_in_central_dir;
1667
- cur_file_info_saved = s->cur_file_info;
1668
- cur_file_info_internal_saved = s->cur_file_info_internal;
1669
-
1670
- err = unzGoToFirstFile2(file, NULL, current_filename, sizeof(current_filename) - 1, NULL, 0, NULL, 0);
1671
-
1672
- while (err == UNZ_OK) {
1673
- if (filename_compare_func != NULL)
1674
- err = filename_compare_func(file, current_filename, filename);
1675
- else
1676
- err = strcmp(current_filename, filename);
1677
- if (err == 0)
1678
- return UNZ_OK;
1679
- err = unzGoToNextFile2(file, NULL, current_filename, sizeof(current_filename) - 1, NULL, 0, NULL, 0);
1680
- }
1681
-
1682
- /* We failed, so restore the state of the 'current file' to where we were. */
1683
- s->num_file = num_file_saved;
1684
- s->pos_in_central_dir = pos_in_central_dir_saved;
1685
- s->cur_file_info = cur_file_info_saved;
1686
- s->cur_file_info_internal = cur_file_info_internal_saved;
1687
- return err;
1688
- }
1689
-
1690
- extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos *file_pos)
1691
- {
1692
- unz64_file_pos file_pos64;
1693
- int err = unzGetFilePos64(file, &file_pos64);
1694
- if (err == UNZ_OK) {
1695
- file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;
1696
- file_pos->num_of_file = (uLong)file_pos64.num_of_file;
1697
- }
1698
- return err;
1699
- }
1700
-
1701
- extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos *file_pos)
1702
- {
1703
- unz64_file_pos file_pos64;
1704
-
1705
- if (file_pos == NULL)
1706
- return UNZ_PARAMERROR;
1707
- file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;
1708
- file_pos64.num_of_file = file_pos->num_of_file;
1709
- return unzGoToFilePos64(file, &file_pos64);
1710
- }
1711
-
1712
- extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos *file_pos)
1713
- {
1714
- unz64_s *s;
1715
-
1716
- if (file == NULL || file_pos == NULL)
1717
- return UNZ_PARAMERROR;
1718
- s = (unz64_s *)file;
1719
- if (!s->current_file_ok)
1720
- return UNZ_END_OF_LIST_OF_FILE;
1721
-
1722
- file_pos->pos_in_zip_directory = s->pos_in_central_dir;
1723
- file_pos->num_of_file = s->num_file;
1724
-
1725
- return UNZ_OK;
1726
- }
1727
-
1728
- extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos)
1729
- {
1730
- unz64_s *s;
1731
- int err;
1732
-
1733
- if (file == NULL || file_pos == NULL)
1734
- return UNZ_PARAMERROR;
1735
- s = (unz64_s *)file;
1736
-
1737
- /* jump to the right spot */
1738
- s->pos_in_central_dir = file_pos->pos_in_zip_directory;
1739
- s->num_file = file_pos->num_of_file;
1740
-
1741
- /* set the current file */
1742
- err = unz64local_GetCurrentFileInfoInternal(file, &s->cur_file_info, &s->cur_file_info_internal, NULL, 0, NULL, 0, NULL, 0);
1743
- /* return results */
1744
- s->current_file_ok = (err == UNZ_OK);
1745
- return err;
1746
- }
1747
-
1748
- extern uLong ZEXPORT unzGetOffset(unzFile file)
1749
- {
1750
- ZPOS64_T offset64;
1751
-
1752
- if (file == NULL)
1753
- return 0; /* UNZ_PARAMERROR; */
1754
- offset64 = unzGetOffset64(file);
1755
- return (uLong)offset64;
1756
- }
1757
-
1758
- extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
1759
- {
1760
- unz64_s *s;
1761
-
1762
- if (file == NULL)
1763
- return 0; /* UNZ_PARAMERROR; */
1764
- s = (unz64_s *)file;
1765
- if (!s->current_file_ok)
1766
- return 0;
1767
- if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
1768
- if (s->num_file == s->gi.number_entry)
1769
- return 0;
1770
- return s->pos_in_central_dir;
1771
- }
1772
-
1773
- extern int ZEXPORT unzSetOffset(unzFile file, uLong pos)
1774
- {
1775
- return unzSetOffset64(file, pos);
1776
- }
1777
-
1778
- extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
1779
- {
1780
- unz64_s *s;
1781
- int err;
1782
-
1783
- if (file == NULL)
1784
- return UNZ_PARAMERROR;
1785
- s = (unz64_s *)file;
1786
-
1787
- s->pos_in_central_dir = pos;
1788
- s->num_file = s->gi.number_entry; /* hack */
1789
- err = unz64local_GetCurrentFileInfoInternal(file, &s->cur_file_info, &s->cur_file_info_internal, NULL, 0, NULL, 0, NULL, 0);
1790
- s->current_file_ok = (err == UNZ_OK);
1791
- return err;
1792
- }
1793
-
1794
- extern z_off_t ZEXPORT unztell(unzFile file)
1795
- {
1796
- unz64_s *s;
1797
- file_in_zip64_read_info_s *pfile_in_zip_read_info;
1798
- if (file == NULL)
1799
- return UNZ_PARAMERROR;
1800
- s = (unz64_s *)file;
1801
- pfile_in_zip_read_info = s->pfile_in_zip_read;
1802
- if (pfile_in_zip_read_info == NULL)
1803
- return UNZ_PARAMERROR;
1804
- return (z_off_t)pfile_in_zip_read_info->stream.total_out;
1805
- }
1806
-
1807
- extern ZPOS64_T ZEXPORT unztell64(unzFile file)
1808
- {
1809
-
1810
- unz64_s *s;
1811
- file_in_zip64_read_info_s *pfile_in_zip_read_info;
1812
- if (file == NULL)
1813
- return (ZPOS64_T)-1;
1814
- s = (unz64_s *)file;
1815
- pfile_in_zip_read_info = s->pfile_in_zip_read;
1816
-
1817
- if (pfile_in_zip_read_info == NULL)
1818
- return (ZPOS64_T)-1;
1819
-
1820
- return pfile_in_zip_read_info->total_out_64;
1821
- }
1822
-
1823
- extern int ZEXPORT unzeof(unzFile file)
1824
- {
1825
- unz64_s *s;
1826
- file_in_zip64_read_info_s *pfile_in_zip_read_info;
1827
- if (file == NULL)
1828
- return UNZ_PARAMERROR;
1829
- s = (unz64_s *)file;
1830
- pfile_in_zip_read_info = s->pfile_in_zip_read;
1831
-
1832
- if (pfile_in_zip_read_info == NULL)
1833
- return UNZ_PARAMERROR;
1834
-
1835
- if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
1836
- return 1;
1837
- return 0;
1838
- }
1839
-