summaryrefslogtreecommitdiff
path: root/src/minizip/mztools.c.diff
blob: 1e4f2cd68e21ee279bbc14ef4c667a05b3b10e16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--- mztools.c.orig	2012-01-21 20:58:45.000000000 +0100
+++ mztools.c	2014-05-24 13:27:22.516230485 +0200
@@ -10,6 +10,7 @@
 #include <string.h>
 #include "zlib.h"
 #include "unzip.h"
+#include "mztools.h"
 
 #define READ_8(adr)  ((unsigned char)*(adr))
 #define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) )
@@ -27,12 +28,9 @@
   WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
 } while(0)
 
-extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
-const char* file;
-const char* fileOut;
-const char* fileOutTmp;
-uLong* nRecovered;
-uLong* bytesRecovered;
+int ZEXPORT unzRepair(const char* file, const char* fileOut,
+                      const char* fileOutTmp, uLong* nRecovered,
+                      uLong* bytesRecovered)
 {
   int err = Z_OK;
   FILE* fpZip = fopen(file, "rb");
@@ -147,8 +145,8 @@
         /* Central directory entry */
         {
           char header[46];
-          char* comment = "";
-          int comsize = (int) strlen(comment);
+          const char* comment = "";
+          const size_t comsize = strlen(comment);
           WRITE_32(header, 0x02014b50);
           WRITE_16(header + 4, version);
           WRITE_16(header + 6, version);
@@ -195,7 +193,7 @@
 
             /* Comment field */
             if (comsize > 0) {
-              if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) {
+              if (fwrite(comment, 1, comsize, fpOutCD) == comsize) {
                 offsetCD += comsize;
               } else {
                 err = Z_ERRNO;
@@ -222,8 +220,8 @@
     {
       int entriesZip = entries;
       char header[22];
-      char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
-      int comsize = (int) strlen(comment);
+      const char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
+      const size_t comsize = strlen(comment);
       if (entriesZip > 0xffff) {
         entriesZip = 0xffff;
       }
@@ -241,7 +239,7 @@
 
         /* Comment field */
         if (comsize > 0) {
-          if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {
+          if (fwrite(comment, 1, comsize, fpOutCD) != comsize) {
             err = Z_ERRNO;
           }
         }