fast_excel 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -7
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +1 -1
  5. data/examples/example.rb +2 -0
  6. data/examples/example_date_time.rb +38 -0
  7. data/fast_excel.gemspec +2 -2
  8. data/lib/fast_excel/binding/format.rb +17 -0
  9. data/lib/fast_excel/binding/workbook.rb +39 -17
  10. data/lib/fast_excel/binding/worksheet.rb +57 -13
  11. data/lib/fast_excel/binding.rb +7 -7
  12. data/lib/fast_excel.rb +27 -20
  13. data/libxlsxwriter/.github/FUNDING.yml +1 -0
  14. data/libxlsxwriter/.github/ISSUE_TEMPLATE.md +85 -0
  15. data/libxlsxwriter/.github/PULL_REQUEST_TEMPLATE.md +130 -0
  16. data/libxlsxwriter/.github/workflows/cmake_actions.yml +48 -0
  17. data/libxlsxwriter/.github/workflows/code_style.yml +23 -0
  18. data/libxlsxwriter/.github/workflows/coverity.yml +22 -0
  19. data/libxlsxwriter/.github/workflows/make_actions.yml +52 -0
  20. data/libxlsxwriter/.github/workflows/valgrind.yml +23 -0
  21. data/libxlsxwriter/.github/workflows/windows_build.yml +54 -0
  22. data/libxlsxwriter/.github/workflows/zig_build.yml +22 -0
  23. data/libxlsxwriter/.gitignore +16 -1
  24. data/libxlsxwriter/.indent.pro +24 -0
  25. data/libxlsxwriter/CMakeLists.txt +156 -56
  26. data/libxlsxwriter/CONTRIBUTING.md +2 -2
  27. data/libxlsxwriter/Changes.txt +344 -2
  28. data/libxlsxwriter/LICENSE.txt +66 -8
  29. data/libxlsxwriter/Makefile +151 -54
  30. data/libxlsxwriter/Package.swift +42 -0
  31. data/libxlsxwriter/Readme.md +4 -2
  32. data/libxlsxwriter/build.zig +324 -0
  33. data/libxlsxwriter/build.zig.zon +11 -0
  34. data/libxlsxwriter/cmake/FindMINIZIP.cmake +3 -3
  35. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +6 -0
  36. data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
  37. data/libxlsxwriter/include/xlsxwriter/chart.h +236 -32
  38. data/libxlsxwriter/include/xlsxwriter/chartsheet.h +7 -7
  39. data/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
  40. data/libxlsxwriter/include/xlsxwriter/common.h +111 -50
  41. data/libxlsxwriter/include/xlsxwriter/content_types.h +8 -1
  42. data/libxlsxwriter/include/xlsxwriter/core.h +1 -1
  43. data/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
  44. data/libxlsxwriter/include/xlsxwriter/drawing.h +11 -20
  45. data/libxlsxwriter/include/xlsxwriter/format.h +121 -8
  46. data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  47. data/libxlsxwriter/include/xlsxwriter/metadata.h +49 -0
  48. data/libxlsxwriter/include/xlsxwriter/packager.h +27 -16
  49. data/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
  50. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
  51. data/libxlsxwriter/include/xlsxwriter/styles.h +13 -7
  52. data/libxlsxwriter/include/xlsxwriter/table.h +51 -0
  53. data/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
  54. data/libxlsxwriter/include/xlsxwriter/third_party/emyg_dtoa.h +26 -0
  55. data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +27 -25
  56. data/libxlsxwriter/include/xlsxwriter/third_party/md5.h +45 -0
  57. data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +155 -153
  58. data/libxlsxwriter/include/xlsxwriter/utility.h +70 -8
  59. data/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
  60. data/libxlsxwriter/include/xlsxwriter/workbook.h +218 -47
  61. data/libxlsxwriter/include/xlsxwriter/worksheet.h +2770 -241
  62. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +12 -8
  63. data/libxlsxwriter/include/xlsxwriter.h +4 -2
  64. data/libxlsxwriter/libxlsxwriter.podspec +8 -5
  65. data/libxlsxwriter/src/Makefile +58 -21
  66. data/libxlsxwriter/src/app.c +5 -2
  67. data/libxlsxwriter/src/chart.c +396 -81
  68. data/libxlsxwriter/src/chartsheet.c +22 -22
  69. data/libxlsxwriter/src/comment.c +443 -0
  70. data/libxlsxwriter/src/content_types.c +40 -1
  71. data/libxlsxwriter/src/core.c +2 -2
  72. data/libxlsxwriter/src/custom.c +1 -1
  73. data/libxlsxwriter/src/drawing.c +160 -40
  74. data/libxlsxwriter/src/format.c +109 -25
  75. data/libxlsxwriter/src/hash_table.c +1 -1
  76. data/libxlsxwriter/src/metadata.c +283 -0
  77. data/libxlsxwriter/src/packager.c +794 -94
  78. data/libxlsxwriter/src/relationships.c +1 -1
  79. data/libxlsxwriter/src/shared_strings.c +2 -4
  80. data/libxlsxwriter/src/styles.c +353 -58
  81. data/libxlsxwriter/src/table.c +304 -0
  82. data/libxlsxwriter/src/theme.c +1 -1
  83. data/libxlsxwriter/src/utility.c +143 -43
  84. data/libxlsxwriter/src/vml.c +1062 -0
  85. data/libxlsxwriter/src/workbook.c +567 -77
  86. data/libxlsxwriter/src/worksheet.c +6668 -1462
  87. data/libxlsxwriter/src/xmlwriter.c +95 -5
  88. data/libxlsxwriter/third_party/dtoa/Makefile +42 -0
  89. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.c +461 -0
  90. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.h +26 -0
  91. data/libxlsxwriter/third_party/md5/Makefile +42 -0
  92. data/libxlsxwriter/third_party/md5/md5.c +291 -0
  93. data/libxlsxwriter/third_party/md5/md5.h +45 -0
  94. data/libxlsxwriter/third_party/minizip/Makefile +3 -8
  95. data/libxlsxwriter/third_party/minizip/Makefile.orig +8 -4
  96. data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +1 -1
  97. data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
  98. data/libxlsxwriter/third_party/minizip/crypt.h +13 -16
  99. data/libxlsxwriter/third_party/minizip/ioapi.c +31 -57
  100. data/libxlsxwriter/third_party/minizip/ioapi.h +31 -23
  101. data/libxlsxwriter/third_party/minizip/iowin32.c +29 -45
  102. data/libxlsxwriter/third_party/minizip/iowin32.h +4 -4
  103. data/libxlsxwriter/third_party/minizip/miniunz.c +29 -56
  104. data/libxlsxwriter/third_party/minizip/minizip.c +38 -49
  105. data/libxlsxwriter/third_party/minizip/mztools.c +1 -7
  106. data/libxlsxwriter/third_party/minizip/unzip.c +202 -342
  107. data/libxlsxwriter/third_party/minizip/unzip.h +74 -74
  108. data/libxlsxwriter/third_party/minizip/zip.c +165 -218
  109. data/libxlsxwriter/third_party/minizip/zip.h +164 -154
  110. data/libxlsxwriter/third_party/tmpfileplus/Makefile +3 -3
  111. data/libxlsxwriter/version.txt +1 -1
  112. data/test/auto_width_test.rb +20 -0
  113. data/test/default_format_test.rb +1 -1
  114. data/test/validations_test.rb +3 -3
  115. data/test/worksheet_test.rb +6 -1
  116. metadata +33 -7
  117. data/libxlsxwriter/.travis.yml +0 -37
@@ -49,12 +49,12 @@
49
49
  Copyright (C) 2007-2008 Even Rouault
50
50
 
51
51
 
52
- Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).
52
+ Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).
53
53
  Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G
54
54
  should only read the compressed/uncompressed size from the Zip64 format if
55
55
  the size from normal header was 0xFFFFFFFF
56
- Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant
57
- Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required)
56
+ Oct-2009 - Mathias Svensson - Applied some bug fixes from patches received from Gilles Vollant
57
+ Oct-2009 - Mathias Svensson - Applied support to unzip files with compression method BZIP2 (bzip2 lib is required)
58
58
  Patch created by Daniel Borca
59
59
 
60
60
  Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
@@ -77,8 +77,6 @@
77
77
 
78
78
  #ifdef STDC
79
79
  # include <stddef.h>
80
- # include <string.h>
81
- # include <stdlib.h>
82
80
  #endif
83
81
  #ifdef NO_ERRNO_H
84
82
  extern int errno;
@@ -111,9 +109,6 @@
111
109
  #ifndef ALLOC
112
110
  # define ALLOC(size) (malloc(size))
113
111
  #endif
114
- #ifndef TRYFREE
115
- # define TRYFREE(p) {if (p) free(p);}
116
- #endif
117
112
 
118
113
  #define SIZECENTRALDIRITEM (0x2e)
119
114
  #define SIZEZIPLOCALHEADER (0x1e)
@@ -153,7 +148,7 @@ typedef struct
153
148
  ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */
154
149
  ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/
155
150
  zlib_filefunc64_32_def z_filefunc;
156
- voidpf filestream; /* io structore of the zipfile */
151
+ voidpf filestream; /* io structure of the zipfile */
157
152
  uLong compression_method; /* compression method (0==store) */
158
153
  ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
159
154
  int raw;
@@ -166,7 +161,7 @@ typedef struct
166
161
  {
167
162
  zlib_filefunc64_32_def z_filefunc;
168
163
  int is64bitOpenFunction;
169
- voidpf filestream; /* io structore of the zipfile */
164
+ voidpf filestream; /* io structure of the zipfile */
170
165
  unz_global_info64 gi; /* public global information */
171
166
  ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
172
167
  ZPOS64_T num_file; /* number of the current file in the zipfile*/
@@ -197,29 +192,24 @@ typedef struct
197
192
  #include "crypt.h"
198
193
  #endif
199
194
 
195
+
200
196
  /* ===========================================================================
201
- Read a byte from a gz_stream; update next_in and avail_in. Return EOF
202
- for end of file.
203
- IN assertion: the stream s has been sucessfully opened for reading.
197
+ Reads a long in LSB order from the given gz_stream. Sets
204
198
  */
205
199
 
206
-
207
- local int unz64local_getByte OF((
208
- const zlib_filefunc64_32_def* pzlib_filefunc_def,
209
- voidpf filestream,
210
- int *pi));
211
-
212
- local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)
213
- {
214
- unsigned char c;
215
- int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
216
- if (err==1)
200
+ local int unz64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def,
201
+ voidpf filestream,
202
+ uLong *pX) {
203
+ unsigned char c[2];
204
+ int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,2);
205
+ if (err==2)
217
206
  {
218
- *pi = (int)c;
207
+ *pX = c[0] | ((uLong)c[1] << 8);
219
208
  return UNZ_OK;
220
209
  }
221
210
  else
222
211
  {
212
+ *pX = 0;
223
213
  if (ZERROR64(*pzlib_filefunc_def,filestream))
224
214
  return UNZ_ERRNO;
225
215
  else
@@ -227,127 +217,50 @@ local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, v
227
217
  }
228
218
  }
229
219
 
230
-
231
- /* ===========================================================================
232
- Reads a long in LSB order from the given gz_stream. Sets
233
- */
234
- local int unz64local_getShort OF((
235
- const zlib_filefunc64_32_def* pzlib_filefunc_def,
236
- voidpf filestream,
237
- uLong *pX));
238
-
239
- local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
220
+ local int unz64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def,
240
221
  voidpf filestream,
241
- uLong *pX)
242
- {
243
- uLong x ;
244
- int i = 0;
245
- int err;
246
-
247
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
248
- x = (uLong)i;
249
-
250
- if (err==UNZ_OK)
251
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
252
- x |= ((uLong)i)<<8;
253
-
254
- if (err==UNZ_OK)
255
- *pX = x;
256
- else
257
- *pX = 0;
258
- return err;
259
- }
260
-
261
- local int unz64local_getLong OF((
262
- const zlib_filefunc64_32_def* pzlib_filefunc_def,
263
- voidpf filestream,
264
- uLong *pX));
265
-
266
- local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
267
- voidpf filestream,
268
- uLong *pX)
269
- {
270
- uLong x ;
271
- int i = 0;
272
- int err;
273
-
274
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
275
- x = (uLong)i;
276
-
277
- if (err==UNZ_OK)
278
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
279
- x |= ((uLong)i)<<8;
280
-
281
- if (err==UNZ_OK)
282
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
283
- x |= ((uLong)i)<<16;
284
-
285
- if (err==UNZ_OK)
286
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
287
- x += ((uLong)i)<<24;
288
-
289
- if (err==UNZ_OK)
290
- *pX = x;
222
+ uLong *pX) {
223
+ unsigned char c[4];
224
+ int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,4);
225
+ if (err==4)
226
+ {
227
+ *pX = c[0] | ((uLong)c[1] << 8) | ((uLong)c[2] << 16) | ((uLong)c[3] << 24);
228
+ return UNZ_OK;
229
+ }
291
230
  else
231
+ {
292
232
  *pX = 0;
293
- return err;
233
+ if (ZERROR64(*pzlib_filefunc_def,filestream))
234
+ return UNZ_ERRNO;
235
+ else
236
+ return UNZ_EOF;
237
+ }
294
238
  }
295
239
 
296
- local int unz64local_getLong64 OF((
297
- const zlib_filefunc64_32_def* pzlib_filefunc_def,
298
- voidpf filestream,
299
- ZPOS64_T *pX));
300
-
301
-
302
- local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
303
- voidpf filestream,
304
- ZPOS64_T *pX)
305
- {
306
- ZPOS64_T x ;
307
- int i = 0;
308
- int err;
309
-
310
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
311
- x = (ZPOS64_T)i;
312
-
313
- if (err==UNZ_OK)
314
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
315
- x |= ((ZPOS64_T)i)<<8;
316
-
317
- if (err==UNZ_OK)
318
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
319
- x |= ((ZPOS64_T)i)<<16;
320
-
321
- if (err==UNZ_OK)
322
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
323
- x |= ((ZPOS64_T)i)<<24;
324
-
325
- if (err==UNZ_OK)
326
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
327
- x |= ((ZPOS64_T)i)<<32;
328
-
329
- if (err==UNZ_OK)
330
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
331
- x |= ((ZPOS64_T)i)<<40;
332
240
 
333
- if (err==UNZ_OK)
334
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
335
- x |= ((ZPOS64_T)i)<<48;
336
-
337
- if (err==UNZ_OK)
338
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
339
- x |= ((ZPOS64_T)i)<<56;
340
-
341
- if (err==UNZ_OK)
342
- *pX = x;
241
+ local int unz64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
242
+ voidpf filestream,
243
+ ZPOS64_T *pX) {
244
+ unsigned char c[8];
245
+ int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,8);
246
+ if (err==8)
247
+ {
248
+ *pX = c[0] | ((ZPOS64_T)c[1] << 8) | ((ZPOS64_T)c[2] << 16) | ((ZPOS64_T)c[3] << 24)
249
+ | ((ZPOS64_T)c[4] << 32) | ((ZPOS64_T)c[5] << 40) | ((ZPOS64_T)c[6] << 48) | ((ZPOS64_T)c[7] << 56);
250
+ return UNZ_OK;
251
+ }
343
252
  else
253
+ {
344
254
  *pX = 0;
345
- return err;
255
+ if (ZERROR64(*pzlib_filefunc_def,filestream))
256
+ return UNZ_ERRNO;
257
+ else
258
+ return UNZ_EOF;
259
+ }
346
260
  }
347
261
 
348
262
  /* My own strcmpi / strcasecmp */
349
- local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2)
350
- {
263
+ local int strcmpcasenosensitive_internal(const char* fileName1, const char* fileName2) {
351
264
  for (;;)
352
265
  {
353
266
  char c1=*(fileName1++);
@@ -379,19 +292,17 @@ local int strcmpcasenosensitive_internal (const char* fileName1, const char* fil
379
292
  #endif
380
293
 
381
294
  /*
382
- Compare two filename (fileName1,fileName2).
383
- If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
384
- If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
295
+ Compare two filenames (fileName1,fileName2).
296
+ If iCaseSensitivity = 1, comparison is case sensitive (like strcmp)
297
+ If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi
385
298
  or strcasecmp)
386
- If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
299
+ If iCaseSensitivity = 0, case sensitivity is default of your operating system
387
300
  (like 1 on Unix, 2 on Windows)
388
301
 
389
302
  */
390
303
  extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
391
- const char* fileName2,
392
- int iCaseSensitivity)
393
-
394
- {
304
+ const char* fileName2,
305
+ int iCaseSensitivity) {
395
306
  if (iCaseSensitivity==0)
396
307
  iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
397
308
 
@@ -405,21 +316,23 @@ extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
405
316
  #define BUFREADCOMMENT (0x400)
406
317
  #endif
407
318
 
319
+ #ifndef CENTRALDIRINVALID
320
+ #define CENTRALDIRINVALID ((ZPOS64_T)(-1))
321
+ #endif
322
+
408
323
  /*
409
324
  Locate the Central directory of a zipfile (at the end, just before
410
325
  the global comment)
411
326
  */
412
- local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
413
- local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
414
- {
327
+ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
415
328
  unsigned char* buf;
416
329
  ZPOS64_T uSizeFile;
417
330
  ZPOS64_T uBackRead;
418
331
  ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
419
- ZPOS64_T uPosFound=0;
332
+ ZPOS64_T uPosFound=CENTRALDIRINVALID;
420
333
 
421
334
  if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
422
- return 0;
335
+ return CENTRALDIRINVALID;
423
336
 
424
337
 
425
338
  uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
@@ -429,7 +342,7 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
429
342
 
430
343
  buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
431
344
  if (buf==NULL)
432
- return 0;
345
+ return CENTRALDIRINVALID;
433
346
 
434
347
  uBackRead = 4;
435
348
  while (uBackRead<uMaxBack)
@@ -455,14 +368,14 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
455
368
  if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
456
369
  ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
457
370
  {
458
- uPosFound = uReadPos+i;
371
+ uPosFound = uReadPos+(unsigned)i;
459
372
  break;
460
373
  }
461
374
 
462
- if (uPosFound!=0)
375
+ if (uPosFound!=CENTRALDIRINVALID)
463
376
  break;
464
377
  }
465
- TRYFREE(buf);
378
+ free(buf);
466
379
  return uPosFound;
467
380
  }
468
381
 
@@ -471,23 +384,18 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
471
384
  Locate the Central directory 64 of a zipfile (at the end, just before
472
385
  the global comment)
473
386
  */
474
- local ZPOS64_T unz64local_SearchCentralDir64 OF((
475
- const zlib_filefunc64_32_def* pzlib_filefunc_def,
476
- voidpf filestream));
477
-
478
387
  local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
479
- voidpf filestream)
480
- {
388
+ voidpf filestream) {
481
389
  unsigned char* buf;
482
390
  ZPOS64_T uSizeFile;
483
391
  ZPOS64_T uBackRead;
484
392
  ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
485
- ZPOS64_T uPosFound=0;
393
+ ZPOS64_T uPosFound=CENTRALDIRINVALID;
486
394
  uLong uL;
487
395
  ZPOS64_T relativeOffset;
488
396
 
489
397
  if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
490
- return 0;
398
+ return CENTRALDIRINVALID;
491
399
 
492
400
 
493
401
  uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
@@ -497,7 +405,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
497
405
 
498
406
  buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
499
407
  if (buf==NULL)
500
- return 0;
408
+ return CENTRALDIRINVALID;
501
409
 
502
410
  uBackRead = 4;
503
411
  while (uBackRead<uMaxBack)
@@ -523,51 +431,51 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
523
431
  if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
524
432
  ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
525
433
  {
526
- uPosFound = uReadPos+i;
434
+ uPosFound = uReadPos+(unsigned)i;
527
435
  break;
528
436
  }
529
437
 
530
- if (uPosFound!=0)
438
+ if (uPosFound!=CENTRALDIRINVALID)
531
439
  break;
532
440
  }
533
- TRYFREE(buf);
534
- if (uPosFound == 0)
535
- return 0;
441
+ free(buf);
442
+ if (uPosFound == CENTRALDIRINVALID)
443
+ return CENTRALDIRINVALID;
536
444
 
537
445
  /* Zip64 end of central directory locator */
538
446
  if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
539
- return 0;
447
+ return CENTRALDIRINVALID;
540
448
 
541
449
  /* the signature, already checked */
542
450
  if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
543
- return 0;
451
+ return CENTRALDIRINVALID;
544
452
 
545
453
  /* number of the disk with the start of the zip64 end of central directory */
546
454
  if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
547
- return 0;
455
+ return CENTRALDIRINVALID;
548
456
  if (uL != 0)
549
- return 0;
457
+ return CENTRALDIRINVALID;
550
458
 
551
459
  /* relative offset of the zip64 end of central directory record */
552
460
  if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
553
- return 0;
461
+ return CENTRALDIRINVALID;
554
462
 
555
463
  /* total number of disks */
556
464
  if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
557
- return 0;
465
+ return CENTRALDIRINVALID;
558
466
  if (uL != 1)
559
- return 0;
467
+ return CENTRALDIRINVALID;
560
468
 
561
469
  /* Goto end of central directory record */
562
470
  if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
563
- return 0;
471
+ return CENTRALDIRINVALID;
564
472
 
565
473
  /* the signature */
566
474
  if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
567
- return 0;
475
+ return CENTRALDIRINVALID;
568
476
 
569
477
  if (uL != 0x06064b50)
570
- return 0;
478
+ return CENTRALDIRINVALID;
571
479
 
572
480
  return relativeOffset;
573
481
  }
@@ -581,19 +489,18 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
581
489
  Else, the return value is a unzFile Handle, usable with other function
582
490
  of this unzip package.
583
491
  */
584
- local unzFile unzOpenInternal (const void *path,
585
- zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
586
- int is64bitOpenFunction)
587
- {
492
+ local unzFile unzOpenInternal(const void *path,
493
+ zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
494
+ int is64bitOpenFunction) {
588
495
  unz64_s us;
589
496
  unz64_s *s;
590
497
  ZPOS64_T central_pos;
591
498
  uLong uL;
592
499
 
593
500
  uLong number_disk; /* number of the current dist, used for
594
- spaning ZIP, unsupported, always 0*/
501
+ spanning ZIP, unsupported, always 0*/
595
502
  uLong number_disk_with_CD; /* number the the disk with central dir, used
596
- for spaning ZIP, unsupported, always 0*/
503
+ for spanning ZIP, unsupported, always 0*/
597
504
  ZPOS64_T number_entry_CD; /* total number of entries in
598
505
  the central dir
599
506
  (same than number_entry on nospan) */
@@ -621,7 +528,7 @@ local unzFile unzOpenInternal (const void *path,
621
528
  return NULL;
622
529
 
623
530
  central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
624
- if (central_pos)
531
+ if (central_pos!=CENTRALDIRINVALID)
625
532
  {
626
533
  uLong uS;
627
534
  ZPOS64_T uL64;
@@ -683,7 +590,7 @@ local unzFile unzOpenInternal (const void *path,
683
590
  else
684
591
  {
685
592
  central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream);
686
- if (central_pos==0)
593
+ if (central_pos==CENTRALDIRINVALID)
687
594
  err=UNZ_ERRNO;
688
595
 
689
596
  us.isZip64 = 0;
@@ -762,9 +669,8 @@ local unzFile unzOpenInternal (const void *path,
762
669
  }
763
670
 
764
671
 
765
- extern unzFile ZEXPORT unzOpen2 (const char *path,
766
- zlib_filefunc_def* pzlib_filefunc32_def)
767
- {
672
+ extern unzFile ZEXPORT unzOpen2(const char *path,
673
+ zlib_filefunc_def* pzlib_filefunc32_def) {
768
674
  if (pzlib_filefunc32_def != NULL)
769
675
  {
770
676
  zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
@@ -775,9 +681,8 @@ extern unzFile ZEXPORT unzOpen2 (const char *path,
775
681
  return unzOpenInternal(path, NULL, 0);
776
682
  }
777
683
 
778
- extern unzFile ZEXPORT unzOpen2_64 (const void *path,
779
- zlib_filefunc64_def* pzlib_filefunc_def)
780
- {
684
+ extern unzFile ZEXPORT unzOpen2_64(const void *path,
685
+ zlib_filefunc64_def* pzlib_filefunc_def) {
781
686
  if (pzlib_filefunc_def != NULL)
782
687
  {
783
688
  zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
@@ -790,13 +695,11 @@ extern unzFile ZEXPORT unzOpen2_64 (const void *path,
790
695
  return unzOpenInternal(path, NULL, 1);
791
696
  }
792
697
 
793
- extern unzFile ZEXPORT unzOpen (const char *path)
794
- {
698
+ extern unzFile ZEXPORT unzOpen(const char *path) {
795
699
  return unzOpenInternal(path, NULL, 0);
796
700
  }
797
701
 
798
- extern unzFile ZEXPORT unzOpen64 (const void *path)
799
- {
702
+ extern unzFile ZEXPORT unzOpen64(const void *path) {
800
703
  return unzOpenInternal(path, NULL, 1);
801
704
  }
802
705
 
@@ -805,8 +708,7 @@ extern unzFile ZEXPORT unzOpen64 (const void *path)
805
708
  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
806
709
  these files MUST be closed with unzCloseCurrentFile before call unzClose.
807
710
  return UNZ_OK if there is no problem. */
808
- extern int ZEXPORT unzClose (unzFile file)
809
- {
711
+ extern int ZEXPORT unzClose(unzFile file) {
810
712
  unz64_s* s;
811
713
  if (file==NULL)
812
714
  return UNZ_PARAMERROR;
@@ -816,7 +718,7 @@ extern int ZEXPORT unzClose (unzFile file)
816
718
  unzCloseCurrentFile(file);
817
719
 
818
720
  ZCLOSE64(s->z_filefunc, s->filestream);
819
- TRYFREE(s);
721
+ free(s);
820
722
  return UNZ_OK;
821
723
  }
822
724
 
@@ -825,8 +727,7 @@ extern int ZEXPORT unzClose (unzFile file)
825
727
  Write info about the ZipFile in the *pglobal_info structure.
826
728
  No preparation of the structure is needed
827
729
  return UNZ_OK if there is no problem. */
828
- extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info)
829
- {
730
+ extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64* pglobal_info) {
830
731
  unz64_s* s;
831
732
  if (file==NULL)
832
733
  return UNZ_PARAMERROR;
@@ -835,8 +736,7 @@ extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_
835
736
  return UNZ_OK;
836
737
  }
837
738
 
838
- extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32)
839
- {
739
+ extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32) {
840
740
  unz64_s* s;
841
741
  if (file==NULL)
842
742
  return UNZ_PARAMERROR;
@@ -847,46 +747,33 @@ extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info
847
747
  return UNZ_OK;
848
748
  }
849
749
  /*
850
- Translate date/time from Dos format to tm_unz (readable more easilty)
750
+ Translate date/time from Dos format to tm_unz (readable more easily)
851
751
  */
852
- local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
853
- {
752
+ local void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz* ptm) {
854
753
  ZPOS64_T uDate;
855
754
  uDate = (ZPOS64_T)(ulDosDate>>16);
856
- ptm->tm_mday = (uInt)(uDate&0x1f) ;
857
- ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
858
- ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
755
+ ptm->tm_mday = (int)(uDate&0x1f) ;
756
+ ptm->tm_mon = (int)((((uDate)&0x1E0)/0x20)-1) ;
757
+ ptm->tm_year = (int)(((uDate&0x0FE00)/0x0200)+1980) ;
859
758
 
860
- ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
861
- ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
862
- ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
759
+ ptm->tm_hour = (int) ((ulDosDate &0xF800)/0x800);
760
+ ptm->tm_min = (int) ((ulDosDate&0x7E0)/0x20) ;
761
+ ptm->tm_sec = (int) (2*(ulDosDate&0x1f)) ;
863
762
  }
864
763
 
865
764
  /*
866
765
  Get Info about the current file in the zipfile, with internal only info
867
766
  */
868
- local int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
869
- unz_file_info64 *pfile_info,
870
- unz_file_info64_internal
871
- *pfile_info_internal,
872
- char *szFileName,
873
- uLong fileNameBufferSize,
874
- void *extraField,
875
- uLong extraFieldBufferSize,
876
- char *szComment,
877
- uLong commentBufferSize));
878
-
879
- local int unz64local_GetCurrentFileInfoInternal (unzFile file,
880
- unz_file_info64 *pfile_info,
881
- unz_file_info64_internal
882
- *pfile_info_internal,
883
- char *szFileName,
884
- uLong fileNameBufferSize,
885
- void *extraField,
886
- uLong extraFieldBufferSize,
887
- char *szComment,
888
- uLong commentBufferSize)
889
- {
767
+ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
768
+ unz_file_info64 *pfile_info,
769
+ unz_file_info64_internal
770
+ *pfile_info_internal,
771
+ char *szFileName,
772
+ uLong fileNameBufferSize,
773
+ void *extraField,
774
+ uLong extraFieldBufferSize,
775
+ char *szComment,
776
+ uLong commentBufferSize) {
890
777
  unz64_s* s;
891
778
  unz_file_info64 file_info;
892
779
  unz_file_info64_internal file_info_internal;
@@ -993,7 +880,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
993
880
 
994
881
  if (lSeek!=0)
995
882
  {
996
- if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
883
+ if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
997
884
  lSeek=0;
998
885
  else
999
886
  err=UNZ_ERRNO;
@@ -1018,7 +905,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
1018
905
 
1019
906
  if (lSeek!=0)
1020
907
  {
1021
- if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
908
+ if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
1022
909
  lSeek=0;
1023
910
  else
1024
911
  err=UNZ_ERRNO;
@@ -1038,33 +925,31 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
1038
925
  /* ZIP64 extra fields */
1039
926
  if (headerId == 0x0001)
1040
927
  {
1041
- uLong uL;
1042
-
1043
- if(file_info.uncompressed_size == MAXU32)
1044
- {
1045
- if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
1046
- err=UNZ_ERRNO;
1047
- }
1048
-
1049
- if(file_info.compressed_size == MAXU32)
1050
- {
1051
- if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
1052
- err=UNZ_ERRNO;
1053
- }
1054
-
1055
- if(file_info_internal.offset_curfile == MAXU32)
1056
- {
1057
- /* Relative Header offset */
1058
- if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
1059
- err=UNZ_ERRNO;
1060
- }
1061
-
1062
- if(file_info.disk_num_start == MAXU32)
1063
- {
1064
- /* Disk Start Number */
1065
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
1066
- err=UNZ_ERRNO;
1067
- }
928
+ if(file_info.uncompressed_size == MAXU32)
929
+ {
930
+ if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
931
+ err=UNZ_ERRNO;
932
+ }
933
+
934
+ if(file_info.compressed_size == MAXU32)
935
+ {
936
+ if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
937
+ err=UNZ_ERRNO;
938
+ }
939
+
940
+ if(file_info_internal.offset_curfile == MAXU32)
941
+ {
942
+ /* Relative Header offset */
943
+ if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
944
+ err=UNZ_ERRNO;
945
+ }
946
+
947
+ if(file_info.disk_num_start == 0xffff)
948
+ {
949
+ /* Disk Start Number */
950
+ if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
951
+ err=UNZ_ERRNO;
952
+ }
1068
953
 
1069
954
  }
1070
955
  else
@@ -1090,7 +975,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
1090
975
 
1091
976
  if (lSeek!=0)
1092
977
  {
1093
- if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
978
+ if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
1094
979
  lSeek=0;
1095
980
  else
1096
981
  err=UNZ_ERRNO;
@@ -1121,24 +1006,22 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
1121
1006
  No preparation of the structure is needed
1122
1007
  return UNZ_OK if there is no problem.
1123
1008
  */
1124
- extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
1125
- unz_file_info64 * pfile_info,
1126
- char * szFileName, uLong fileNameBufferSize,
1127
- void *extraField, uLong extraFieldBufferSize,
1128
- char* szComment, uLong commentBufferSize)
1129
- {
1009
+ extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file,
1010
+ unz_file_info64 * pfile_info,
1011
+ char * szFileName, uLong fileNameBufferSize,
1012
+ void *extraField, uLong extraFieldBufferSize,
1013
+ char* szComment, uLong commentBufferSize) {
1130
1014
  return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
1131
- szFileName,fileNameBufferSize,
1132
- extraField,extraFieldBufferSize,
1133
- szComment,commentBufferSize);
1015
+ szFileName,fileNameBufferSize,
1016
+ extraField,extraFieldBufferSize,
1017
+ szComment,commentBufferSize);
1134
1018
  }
1135
1019
 
1136
- extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
1137
- unz_file_info * pfile_info,
1138
- char * szFileName, uLong fileNameBufferSize,
1139
- void *extraField, uLong extraFieldBufferSize,
1140
- char* szComment, uLong commentBufferSize)
1141
- {
1020
+ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
1021
+ unz_file_info * pfile_info,
1022
+ char * szFileName, uLong fileNameBufferSize,
1023
+ void *extraField, uLong extraFieldBufferSize,
1024
+ char* szComment, uLong commentBufferSize) {
1142
1025
  int err;
1143
1026
  unz_file_info64 file_info64;
1144
1027
  err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
@@ -1162,7 +1045,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
1162
1045
  pfile_info->internal_fa = file_info64.internal_fa;
1163
1046
  pfile_info->external_fa = file_info64.external_fa;
1164
1047
 
1165
- pfile_info->tmu_date = file_info64.tmu_date,
1048
+ pfile_info->tmu_date = file_info64.tmu_date;
1166
1049
 
1167
1050
 
1168
1051
  pfile_info->compressed_size = (uLong)file_info64.compressed_size;
@@ -1175,8 +1058,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
1175
1058
  Set the current file of the zipfile to the first file.
1176
1059
  return UNZ_OK if there is no problem
1177
1060
  */
1178
- extern int ZEXPORT unzGoToFirstFile (unzFile file)
1179
- {
1061
+ extern int ZEXPORT unzGoToFirstFile(unzFile file) {
1180
1062
  int err=UNZ_OK;
1181
1063
  unz64_s* s;
1182
1064
  if (file==NULL)
@@ -1196,8 +1078,7 @@ extern int ZEXPORT unzGoToFirstFile (unzFile file)
1196
1078
  return UNZ_OK if there is no problem
1197
1079
  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
1198
1080
  */
1199
- extern int ZEXPORT unzGoToNextFile (unzFile file)
1200
- {
1081
+ extern int ZEXPORT unzGoToNextFile(unzFile file) {
1201
1082
  unz64_s* s;
1202
1083
  int err;
1203
1084
 
@@ -1229,8 +1110,7 @@ extern int ZEXPORT unzGoToNextFile (unzFile file)
1229
1110
  UNZ_OK if the file is found. It becomes the current file.
1230
1111
  UNZ_END_OF_LIST_OF_FILE if the file is not found
1231
1112
  */
1232
- extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
1233
- {
1113
+ extern int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity) {
1234
1114
  unz64_s* s;
1235
1115
  int err;
1236
1116
 
@@ -1305,8 +1185,7 @@ typedef struct unz_file_pos_s
1305
1185
  } unz_file_pos;
1306
1186
  */
1307
1187
 
1308
- extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos)
1309
- {
1188
+ extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) {
1310
1189
  unz64_s* s;
1311
1190
 
1312
1191
  if (file==NULL || file_pos==NULL)
@@ -1321,10 +1200,7 @@ extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos)
1321
1200
  return UNZ_OK;
1322
1201
  }
1323
1202
 
1324
- extern int ZEXPORT unzGetFilePos(
1325
- unzFile file,
1326
- unz_file_pos* file_pos)
1327
- {
1203
+ extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos* file_pos) {
1328
1204
  unz64_file_pos file_pos64;
1329
1205
  int err = unzGetFilePos64(file,&file_pos64);
1330
1206
  if (err==UNZ_OK)
@@ -1335,8 +1211,7 @@ extern int ZEXPORT unzGetFilePos(
1335
1211
  return err;
1336
1212
  }
1337
1213
 
1338
- extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos)
1339
- {
1214
+ extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) {
1340
1215
  unz64_s* s;
1341
1216
  int err;
1342
1217
 
@@ -1357,10 +1232,7 @@ extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos
1357
1232
  return err;
1358
1233
  }
1359
1234
 
1360
- extern int ZEXPORT unzGoToFilePos(
1361
- unzFile file,
1362
- unz_file_pos* file_pos)
1363
- {
1235
+ extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos* file_pos) {
1364
1236
  unz64_file_pos file_pos64;
1365
1237
  if (file_pos == NULL)
1366
1238
  return UNZ_PARAMERROR;
@@ -1382,10 +1254,9 @@ extern int ZEXPORT unzGoToFilePos(
1382
1254
  store in *piSizeVar the size of extra info in local header
1383
1255
  (filename and size of extra field data)
1384
1256
  */
1385
- local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar,
1386
- ZPOS64_T * poffset_local_extrafield,
1387
- uInt * psize_local_extrafield)
1388
- {
1257
+ local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar,
1258
+ ZPOS64_T * poffset_local_extrafield,
1259
+ uInt * psize_local_extrafield) {
1389
1260
  uLong uMagic,uData,uFlags;
1390
1261
  uLong size_filename;
1391
1262
  uLong size_extra_field;
@@ -1469,9 +1340,8 @@ local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVa
1469
1340
  Open for reading data the current file in the zipfile.
1470
1341
  If there is no error and the file is opened, the return value is UNZ_OK.
1471
1342
  */
1472
- extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
1473
- int* level, int raw, const char* password)
1474
- {
1343
+ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
1344
+ int* level, int raw, const char* password) {
1475
1345
  int err=UNZ_OK;
1476
1346
  uInt iSizeVar;
1477
1347
  unz64_s* s;
@@ -1509,7 +1379,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
1509
1379
 
1510
1380
  if (pfile_in_zip_read_info->read_buffer==NULL)
1511
1381
  {
1512
- TRYFREE(pfile_in_zip_read_info);
1382
+ free(pfile_in_zip_read_info);
1513
1383
  return UNZ_INTERNALERROR;
1514
1384
  }
1515
1385
 
@@ -1566,7 +1436,8 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
1566
1436
  pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
1567
1437
  else
1568
1438
  {
1569
- TRYFREE(pfile_in_zip_read_info);
1439
+ free(pfile_in_zip_read_info->read_buffer);
1440
+ free(pfile_in_zip_read_info);
1570
1441
  return err;
1571
1442
  }
1572
1443
  #else
@@ -1586,7 +1457,8 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
1586
1457
  pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
1587
1458
  else
1588
1459
  {
1589
- TRYFREE(pfile_in_zip_read_info);
1460
+ free(pfile_in_zip_read_info->read_buffer);
1461
+ free(pfile_in_zip_read_info);
1590
1462
  return err;
1591
1463
  }
1592
1464
  /* windowBits is passed < 0 to tell that there is no zlib header.
@@ -1638,25 +1510,21 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
1638
1510
  return UNZ_OK;
1639
1511
  }
1640
1512
 
1641
- extern int ZEXPORT unzOpenCurrentFile (unzFile file)
1642
- {
1513
+ extern int ZEXPORT unzOpenCurrentFile(unzFile file) {
1643
1514
  return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
1644
1515
  }
1645
1516
 
1646
- extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password)
1647
- {
1517
+ extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char* password) {
1648
1518
  return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
1649
1519
  }
1650
1520
 
1651
- extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw)
1652
- {
1521
+ extern int ZEXPORT unzOpenCurrentFile2(unzFile file, int* method, int* level, int raw) {
1653
1522
  return unzOpenCurrentFile3(file, method, level, raw, NULL);
1654
1523
  }
1655
1524
 
1656
1525
  /** Addition for GDAL : START */
1657
1526
 
1658
- extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
1659
- {
1527
+ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) {
1660
1528
  unz64_s* s;
1661
1529
  file_in_zip64_read_info_s* pfile_in_zip_read_info;
1662
1530
  s=(unz64_s*)file;
@@ -1676,13 +1544,12 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
1676
1544
  buf contain buffer where data must be copied
1677
1545
  len the size of buf.
1678
1546
 
1679
- return the number of byte copied if somes bytes are copied
1547
+ return the number of byte copied if some bytes are copied
1680
1548
  return 0 if the end of file was reached
1681
1549
  return <0 with error code if there is an error
1682
1550
  (UNZ_ERRNO for IO error, or zLib error for uncompress error)
1683
1551
  */
1684
- extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
1685
- {
1552
+ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
1686
1553
  int err=UNZ_OK;
1687
1554
  uInt iRead = 0;
1688
1555
  unz64_s* s;
@@ -1767,7 +1634,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
1767
1634
 
1768
1635
  if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
1769
1636
  (pfile_in_zip_read_info->rest_read_compressed == 0))
1770
- return (iRead==0) ? UNZ_EOF : iRead;
1637
+ return (iRead==0) ? UNZ_EOF : (int)iRead;
1771
1638
 
1772
1639
  if (pfile_in_zip_read_info->stream.avail_out <
1773
1640
  pfile_in_zip_read_info->stream.avail_in)
@@ -1857,6 +1724,9 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
1857
1724
  err = Z_DATA_ERROR;
1858
1725
 
1859
1726
  uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
1727
+ /* Detect overflow, because z_stream.total_out is uLong (32 bits) */
1728
+ if (uTotalOutAfter<uTotalOutBefore)
1729
+ uTotalOutAfter += 1LL << 32; /* Add maximum value of uLong + 1 */
1860
1730
  uOutThis = uTotalOutAfter-uTotalOutBefore;
1861
1731
 
1862
1732
  pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
@@ -1871,14 +1741,14 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
1871
1741
  iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
1872
1742
 
1873
1743
  if (err==Z_STREAM_END)
1874
- return (iRead==0) ? UNZ_EOF : iRead;
1744
+ return (iRead==0) ? UNZ_EOF : (int)iRead;
1875
1745
  if (err!=Z_OK)
1876
1746
  break;
1877
1747
  }
1878
1748
  }
1879
1749
 
1880
1750
  if (err==Z_OK)
1881
- return iRead;
1751
+ return (int)iRead;
1882
1752
  return err;
1883
1753
  }
1884
1754
 
@@ -1886,8 +1756,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
1886
1756
  /*
1887
1757
  Give the current position in uncompressed data
1888
1758
  */
1889
- extern z_off_t ZEXPORT unztell (unzFile file)
1890
- {
1759
+ extern z_off_t ZEXPORT unztell(unzFile file) {
1891
1760
  unz64_s* s;
1892
1761
  file_in_zip64_read_info_s* pfile_in_zip_read_info;
1893
1762
  if (file==NULL)
@@ -1901,8 +1770,7 @@ extern z_off_t ZEXPORT unztell (unzFile file)
1901
1770
  return (z_off_t)pfile_in_zip_read_info->stream.total_out;
1902
1771
  }
1903
1772
 
1904
- extern ZPOS64_T ZEXPORT unztell64 (unzFile file)
1905
- {
1773
+ extern ZPOS64_T ZEXPORT unztell64(unzFile file) {
1906
1774
 
1907
1775
  unz64_s* s;
1908
1776
  file_in_zip64_read_info_s* pfile_in_zip_read_info;
@@ -1921,8 +1789,7 @@ extern ZPOS64_T ZEXPORT unztell64 (unzFile file)
1921
1789
  /*
1922
1790
  return 1 if the end of file was reached, 0 elsewhere
1923
1791
  */
1924
- extern int ZEXPORT unzeof (unzFile file)
1925
- {
1792
+ extern int ZEXPORT unzeof(unzFile file) {
1926
1793
  unz64_s* s;
1927
1794
  file_in_zip64_read_info_s* pfile_in_zip_read_info;
1928
1795
  if (file==NULL)
@@ -1953,8 +1820,7 @@ more info in the local-header version than in the central-header)
1953
1820
  the return value is the number of bytes copied in buf, or (if <0)
1954
1821
  the error code
1955
1822
  */
1956
- extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
1957
- {
1823
+ extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len) {
1958
1824
  unz64_s* s;
1959
1825
  file_in_zip64_read_info_s* pfile_in_zip_read_info;
1960
1826
  uInt read_now;
@@ -2001,8 +1867,7 @@ extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
2001
1867
  Close the file in zip opened with unzOpenCurrentFile
2002
1868
  Return UNZ_CRCERROR if all the file was read but the CRC is not good
2003
1869
  */
2004
- extern int ZEXPORT unzCloseCurrentFile (unzFile file)
2005
- {
1870
+ extern int ZEXPORT unzCloseCurrentFile(unzFile file) {
2006
1871
  int err=UNZ_OK;
2007
1872
 
2008
1873
  unz64_s* s;
@@ -2024,7 +1889,7 @@ extern int ZEXPORT unzCloseCurrentFile (unzFile file)
2024
1889
  }
2025
1890
 
2026
1891
 
2027
- TRYFREE(pfile_in_zip_read_info->read_buffer);
1892
+ free(pfile_in_zip_read_info->read_buffer);
2028
1893
  pfile_in_zip_read_info->read_buffer = NULL;
2029
1894
  if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
2030
1895
  inflateEnd(&pfile_in_zip_read_info->stream);
@@ -2035,7 +1900,7 @@ extern int ZEXPORT unzCloseCurrentFile (unzFile file)
2035
1900
 
2036
1901
 
2037
1902
  pfile_in_zip_read_info->stream_initialised = 0;
2038
- TRYFREE(pfile_in_zip_read_info);
1903
+ free(pfile_in_zip_read_info);
2039
1904
 
2040
1905
  s->pfile_in_zip_read=NULL;
2041
1906
 
@@ -2048,8 +1913,7 @@ extern int ZEXPORT unzCloseCurrentFile (unzFile file)
2048
1913
  uSizeBuf is the size of the szComment buffer.
2049
1914
  return the number of byte copied or an error code <0
2050
1915
  */
2051
- extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf)
2052
- {
1916
+ extern int ZEXPORT unzGetGlobalComment(unzFile file, char * szComment, uLong uSizeBuf) {
2053
1917
  unz64_s* s;
2054
1918
  uLong uReadThis ;
2055
1919
  if (file==NULL)
@@ -2076,8 +1940,7 @@ extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uS
2076
1940
  }
2077
1941
 
2078
1942
  /* Additions by RX '2004 */
2079
- extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
2080
- {
1943
+ extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) {
2081
1944
  unz64_s* s;
2082
1945
 
2083
1946
  if (file==NULL)
@@ -2091,8 +1954,7 @@ extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
2091
1954
  return s->pos_in_central_dir;
2092
1955
  }
2093
1956
 
2094
- extern uLong ZEXPORT unzGetOffset (unzFile file)
2095
- {
1957
+ extern uLong ZEXPORT unzGetOffset(unzFile file) {
2096
1958
  ZPOS64_T offset64;
2097
1959
 
2098
1960
  if (file==NULL)
@@ -2101,8 +1963,7 @@ extern uLong ZEXPORT unzGetOffset (unzFile file)
2101
1963
  return (uLong)offset64;
2102
1964
  }
2103
1965
 
2104
- extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
2105
- {
1966
+ extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) {
2106
1967
  unz64_s* s;
2107
1968
  int err;
2108
1969
 
@@ -2119,7 +1980,6 @@ extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
2119
1980
  return err;
2120
1981
  }
2121
1982
 
2122
- extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
2123
- {
1983
+ extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) {
2124
1984
  return unzSetOffset64(file,pos);
2125
1985
  }