diff options
author | Vollstrecker <werner@vollstreckernet.de> | 2024-12-26 14:02:31 +0100 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2025-01-31 20:01:41 -0800 |
commit | 9d25fa340ef7dc35606ea3373b090e9d4e8267b9 (patch) | |
tree | cdbb41700931c62dfce36380d6e3d71d7f150165 | |
parent | e677f1f1c71231ba1befb9da6ed02b6db38dedc3 (diff) | |
download | zlib-9d25fa340ef7dc35606ea3373b090e9d4e8267b9.tar.gz zlib-9d25fa340ef7dc35606ea3373b090e9d4e8267b9.tar.bz2 zlib-9d25fa340ef7dc35606ea3373b090e9d4e8267b9.zip |
Use consistent comment style in minizip.
-rw-r--r-- | contrib/minizip/ioapi.c | 2 | ||||
-rw-r--r-- | contrib/minizip/ioapi.h | 8 | ||||
-rw-r--r-- | contrib/minizip/minizip.c | 2 | ||||
-rw-r--r-- | contrib/minizip/mztools.c | 2 | ||||
-rw-r--r-- | contrib/minizip/skipset.h | 144 | ||||
-rw-r--r-- | contrib/minizip/unzip.c | 16 | ||||
-rw-r--r-- | contrib/minizip/zip.c | 218 | ||||
-rw-r--r-- | contrib/minizip/zip.h | 2 |
8 files changed, 197 insertions, 197 deletions
diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c index 782d324..3dbefe4 100644 --- a/contrib/minizip/ioapi.c +++ b/contrib/minizip/ioapi.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | #if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) | 17 | #if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) |
18 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions | 18 | /* In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions */ |
19 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) | 19 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) |
20 | #define FTELLO_FUNC(stream) ftello(stream) | 20 | #define FTELLO_FUNC(stream) ftello(stream) |
21 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) | 21 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) |
diff --git a/contrib/minizip/ioapi.h b/contrib/minizip/ioapi.h index f3b193d..6b9968c 100644 --- a/contrib/minizip/ioapi.h +++ b/contrib/minizip/ioapi.h | |||
@@ -23,8 +23,8 @@ | |||
23 | 23 | ||
24 | #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) | 24 | #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) |
25 | 25 | ||
26 | // Linux needs this to support file operation on files larger then 4+GB | 26 | /* Linux needs this to support file operation on files larger then 4+GB */ |
27 | // But might need better if/def to select just the platforms that needs them. | 27 | /* But might need better if/def to select just the platforms that needs them.*/ |
28 | 28 | ||
29 | #ifndef __USE_FILE_OFFSET64 | 29 | #ifndef __USE_FILE_OFFSET64 |
30 | #define __USE_FILE_OFFSET64 | 30 | #define __USE_FILE_OFFSET64 |
@@ -161,8 +161,8 @@ typedef struct zlib_filefunc64_32_def_s | |||
161 | 161 | ||
162 | #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) | 162 | #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) |
163 | #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) | 163 | #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) |
164 | //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) | 164 | /*#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) */ |
165 | //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) | 165 | /*#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) */ |
166 | #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) | 166 | #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) |
167 | #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) | 167 | #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) |
168 | 168 | ||
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c index a44e36a..18d866b 100644 --- a/contrib/minizip/minizip.c +++ b/contrib/minizip/minizip.c | |||
@@ -435,7 +435,7 @@ int main(int argc, char *argv[]) { | |||
435 | } | 435 | } |
436 | if( lastslash != NULL ) | 436 | if( lastslash != NULL ) |
437 | { | 437 | { |
438 | savefilenameinzip = lastslash+1; // base filename follows last slash. | 438 | savefilenameinzip = lastslash+1; /* base filename follows last slash. */ |
439 | } | 439 | } |
440 | } | 440 | } |
441 | 441 | ||
diff --git a/contrib/minizip/mztools.c b/contrib/minizip/mztools.c index f86c1e7..6260cb0 100644 --- a/contrib/minizip/mztools.c +++ b/contrib/minizip/mztools.c | |||
@@ -219,7 +219,7 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* | |||
219 | { | 219 | { |
220 | int entriesZip = entries; | 220 | int entriesZip = entries; |
221 | char end[22]; | 221 | char end[22]; |
222 | char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; | 222 | char* comment = ""; /* "ZIP File recovered by zlib/minizip/mztools"; */ |
223 | int comsize = (int) strlen(comment); | 223 | int comsize = (int) strlen(comment); |
224 | if (entriesZip > 0xffff) { | 224 | if (entriesZip > 0xffff) { |
225 | entriesZip = 0xffff; | 225 | entriesZip = 0xffff; |
diff --git a/contrib/minizip/skipset.h b/contrib/minizip/skipset.h index 5e648b9..9f0aad6 100644 --- a/contrib/minizip/skipset.h +++ b/contrib/minizip/skipset.h | |||
@@ -1,4 +1,4 @@ | |||
1 | // skipset.h -- set operations using a skiplist | 1 | /* skipset.h -- set operations using a skiplist |
2 | // Copyright (C) 2024 Mark Adler | 2 | // Copyright (C) 2024 Mark Adler |
3 | // See MiniZip_info.txt for the license. | 3 | // See MiniZip_info.txt for the license. |
4 | 4 | ||
@@ -50,20 +50,20 @@ | |||
50 | // Auxiliary functions available to the application: | 50 | // Auxiliary functions available to the application: |
51 | // - set_alloc() allocates memory with optional tracking (#define SET_TRACK) | 51 | // - set_alloc() allocates memory with optional tracking (#define SET_TRACK) |
52 | // - set_free() deallocates memory allocated by set_alloc() | 52 | // - set_free() deallocates memory allocated by set_alloc() |
53 | // - set_rand() returns 32 random bits (seeded by set_start()) | 53 | // - set_rand() returns 32 random bits (seeded by set_start()) */ |
54 | 54 | ||
55 | #ifndef SKIPSET_H | 55 | #ifndef SKIPSET_H |
56 | #define SKIPSET_H | 56 | #define SKIPSET_H |
57 | 57 | ||
58 | #include <stdlib.h> // realloc(), free(), NULL, size_t | 58 | #include <stdlib.h> /* realloc(), free(), NULL, size_t */ |
59 | #include <stddef.h> // ptrdiff_t | 59 | #include <stddef.h> /* ptrdiff_t */ |
60 | #include <setjmp.h> // jmp_buf, longjmp() | 60 | #include <setjmp.h> /* jmp_buf, longjmp() */ |
61 | #include <errno.h> // ENOMEM | 61 | #include <errno.h> /* ENOMEM */ |
62 | #include <time.h> // time(), clock() | 62 | #include <time.h> /* time(), clock() */ |
63 | #include <assert.h> // assert.h | 63 | #include <assert.h> /* assert.h */ |
64 | #include "ints.h" // i16_t, ui32_t, ui64_t | 64 | #include "ints.h" /* i16_t, ui32_t, ui64_t */ |
65 | 65 | ||
66 | // Structures and functions below noted as "--private--" should not be used by | 66 | /* Structures and functions below noted as "--private--" should not be used by |
67 | // the application. set_t is partially private and partially public -- see the | 67 | // the application. set_t is partially private and partially public -- see the |
68 | // comments there. | 68 | // comments there. |
69 | 69 | ||
@@ -73,18 +73,18 @@ | |||
73 | 73 | ||
74 | // *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / www.pcg-random.org | 74 | // *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / www.pcg-random.org |
75 | // Licensed under Apache License 2.0 (NO WARRANTY, etc. see website) | 75 | // Licensed under Apache License 2.0 (NO WARRANTY, etc. see website) |
76 | // --private-- Random number generator state. | 76 | // --private-- Random number generator state. */ |
77 | typedef struct { | 77 | typedef struct { |
78 | ui64_t state; // 64-bit generator state | 78 | ui64_t state; /* 64-bit generator state */ |
79 | ui64_t inc; // 63-bit sequence id | 79 | ui64_t inc; /* 63-bit sequence id */ |
80 | } set_rand_t; | 80 | } set_rand_t; |
81 | // --private-- Initialize the state *gen using seed and seq. seed seeds the | 81 | /* --private-- Initialize the state *gen using seed and seq. seed seeds the |
82 | // advancing 64-bit state. seq is a sequence selection constant. | 82 | // advancing 64-bit state. seq is a sequence selection constant. */ |
83 | void set_seed(set_rand_t *gen, ui64_t seed, ui64_t seq) { | 83 | void set_seed(set_rand_t *gen, ui64_t seed, ui64_t seq) { |
84 | gen->inc = (seq << 1) | 1; | 84 | gen->inc = (seq << 1) | 1; |
85 | gen->state = (seed + gen->inc) * 6364136223846793005ULL + gen->inc; | 85 | gen->state = (seed + gen->inc) * 6364136223846793005ULL + gen->inc; |
86 | } | 86 | } |
87 | // Return 32 random bits, advancing the state *gen. | 87 | /* Return 32 random bits, advancing the state *gen. */ |
88 | ui32_t set_rand(set_rand_t *gen) { | 88 | ui32_t set_rand(set_rand_t *gen) { |
89 | ui64_t state = gen->state; | 89 | ui64_t state = gen->state; |
90 | gen->state = state * 6364136223846793005ULL + gen->inc; | 90 | gen->state = state * 6364136223846793005ULL + gen->inc; |
@@ -92,40 +92,40 @@ ui32_t set_rand(set_rand_t *gen) { | |||
92 | int rot = state >> 59; | 92 | int rot = state >> 59; |
93 | return (mix >> rot) | (mix << ((-rot) & 31)); | 93 | return (mix >> rot) | (mix << ((-rot) & 31)); |
94 | } | 94 | } |
95 | // End of PCG32 code. | 95 | /* End of PCG32 code. */ |
96 | 96 | ||
97 | // --private-- Linked-list node. | 97 | /* --private-- Linked-list node. */ |
98 | typedef struct set_node_s set_node_t; | 98 | typedef struct set_node_s set_node_t; |
99 | struct set_node_s { | 99 | struct set_node_s { |
100 | set_key_t key; // the key (not used for head or path) | 100 | set_key_t key; /* the key (not used for head or path) */ |
101 | i16_t size; // number of allocated pointers in right[] | 101 | i16_t size; /* number of allocated pointers in right[] */ |
102 | i16_t fill; // number of pointers in right[] filled in | 102 | i16_t fill; /* number of pointers in right[] filled in */ |
103 | set_node_t **right; // pointer for each level, each to the right | 103 | set_node_t **right; /* pointer for each level, each to the right */ |
104 | }; | 104 | }; |
105 | 105 | ||
106 | // A set. The application sets env, may use gen with set_rand(), and may read | 106 | /* A set. The application sets env, may use gen with set_rand(), and may read |
107 | // allocs and memory. The remaining variables are --private-- . | 107 | // allocs and memory. The remaining variables are --private-- . */ |
108 | typedef struct set_s { | 108 | typedef struct set_s { |
109 | set_node_t *head; // skiplist head -- no key, just links | 109 | set_node_t *head; /* skiplist head -- no key, just links */ |
110 | set_node_t *path; // right[] is path to key from set_found() | 110 | set_node_t *path; /* right[] is path to key from set_found() */ |
111 | set_node_t *node; // node under construction, in case of longjmp() | 111 | set_node_t *node; /* node under construction, in case of longjmp() */ |
112 | i16_t depth; // maximum depth of the skiplist | 112 | i16_t depth; /* maximum depth of the skiplist */ |
113 | ui64_t ran; // a precious trove of random bits | 113 | ui64_t ran; /* a precious trove of random bits */ |
114 | set_rand_t gen; // random number generator state | 114 | set_rand_t gen; /* random number generator state */ |
115 | jmp_buf env; // setjmp() environment for allocation errors | 115 | jmp_buf env; /* setjmp() environment for allocation errors */ |
116 | #ifdef SET_TRACK | 116 | #ifdef SET_TRACK |
117 | size_t allocs; // number of allocations | 117 | size_t allocs; /* number of allocations */ |
118 | size_t memory; // total amount of allocated memory (>= requests) | 118 | size_t memory; /* total amount of allocated memory (>= requests) */ |
119 | #endif | 119 | #endif |
120 | } set_t; | 120 | } set_t; |
121 | 121 | ||
122 | // Memory allocation and deallocation. set_alloc(set, ptr, size) returns a | 122 | /* Memory allocation and deallocation. set_alloc(set, ptr, size) returns a |
123 | // pointer to an allocation of size bytes if ptr is NULL, or the previous | 123 | // pointer to an allocation of size bytes if ptr is NULL, or the previous |
124 | // allocation ptr resized to size bytes. set_alloc() will never return NULL. | 124 | // allocation ptr resized to size bytes. set_alloc() will never return NULL. |
125 | // set_free(set, ptr) frees an allocation created by set_alloc(). These may be | 125 | // set_free(set, ptr) frees an allocation created by set_alloc(). These may be |
126 | // used by the application. e.g. if allocation tracking is desired. | 126 | // used by the application. e.g. if allocation tracking is desired. */ |
127 | #ifdef SET_TRACK | 127 | #ifdef SET_TRACK |
128 | // Track the number of allocations and the total backing memory size. | 128 | /* Track the number of allocations and the total backing memory size. */ |
129 | # if defined(_WIN32) | 129 | # if defined(_WIN32) |
130 | # include <malloc.h> | 130 | # include <malloc.h> |
131 | # define SET_ALLOC_SIZE(ptr) _msize(ptr) | 131 | # define SET_ALLOC_SIZE(ptr) _msize(ptr) |
@@ -162,7 +162,7 @@ void set_free(set_t *set, void *ptr) { | |||
162 | } | 162 | } |
163 | } | 163 | } |
164 | #else | 164 | #else |
165 | // Without tracking. | 165 | /* Without tracking. */ |
166 | void *set_alloc(set_t *set, void *ptr, size_t size) { | 166 | void *set_alloc(set_t *set, void *ptr, size_t size) { |
167 | void *mem = realloc(ptr, size); | 167 | void *mem = realloc(ptr, size); |
168 | if (mem == NULL) | 168 | if (mem == NULL) |
@@ -175,10 +175,10 @@ void set_free(set_t *set, void *ptr) { | |||
175 | } | 175 | } |
176 | #endif | 176 | #endif |
177 | 177 | ||
178 | // --private-- Grow node's array right[] as needed to be able to hold at least | 178 | /* --private-- Grow node's array right[] as needed to be able to hold at least |
179 | // want links. If fill is true, assure that the first want links are filled in, | 179 | // want links. If fill is true, assure that the first want links are filled in, |
180 | // setting them to set->head if not previously filled in. Otherwise it is | 180 | // setting them to set->head if not previously filled in. Otherwise it is |
181 | // assumed that the first want links are about to be filled in. | 181 | // assumed that the first want links are about to be filled in. */ |
182 | void set_grow(set_t *set, set_node_t *node, int want, int fill) { | 182 | void set_grow(set_t *set, set_node_t *node, int want, int fill) { |
183 | if (node->size < want) { | 183 | if (node->size < want) { |
184 | int more = node->size ? node->size : 1; | 184 | int more = node->size ? node->size : 1; |
@@ -194,7 +194,7 @@ void set_grow(set_t *set, set_node_t *node, int want, int fill) { | |||
194 | node->fill = (i16_t)want; | 194 | node->fill = (i16_t)want; |
195 | } | 195 | } |
196 | 196 | ||
197 | // --private-- Return a new node. key is left uninitialized. | 197 | /* --private-- Return a new node. key is left uninitialized. */ |
198 | set_node_t *set_node(set_t *set) { | 198 | set_node_t *set_node(set_t *set) { |
199 | set_node_t *node = set_alloc(set, NULL, sizeof(set_node_t)); | 199 | set_node_t *node = set_alloc(set, NULL, sizeof(set_node_t)); |
200 | node->size = 0; | 200 | node->size = 0; |
@@ -203,11 +203,11 @@ set_node_t *set_node(set_t *set) { | |||
203 | return node; | 203 | return node; |
204 | } | 204 | } |
205 | 205 | ||
206 | // --private-- Free the list linked from head, along with the keys. | 206 | /* --private-- Free the list linked from head, along with the keys. */ |
207 | void set_sweep(set_t *set) { | 207 | void set_sweep(set_t *set) { |
208 | set_node_t *step = set->head->right[0]; | 208 | set_node_t *step = set->head->right[0]; |
209 | while (step != set->head) { | 209 | while (step != set->head) { |
210 | set_node_t *next = step->right[0]; // save link to next node | 210 | set_node_t *next = step->right[0]; /* save link to next node */ |
211 | set_drop(set, step->key); | 211 | set_drop(set, step->key); |
212 | set_free(set, step->right); | 212 | set_free(set, step->right); |
213 | set_free(set, step); | 213 | set_free(set, step); |
@@ -215,59 +215,59 @@ void set_sweep(set_t *set) { | |||
215 | } | 215 | } |
216 | } | 216 | } |
217 | 217 | ||
218 | // Initialize a new set. set->env must be initialized using setjmp() before | 218 | /* Initialize a new set. set->env must be initialized using setjmp() before |
219 | // set_start() is called. A longjmp(set->env, ENOMEM) will be used to handle a | 219 | // set_start() is called. A longjmp(set->env, ENOMEM) will be used to handle a |
220 | // memory allocation failure during any of the operations. (See setjmp.h and | 220 | // memory allocation failure during any of the operations. (See setjmp.h and |
221 | // errno.h.) The set can still be used if this happens, assuming that it didn't | 221 | // errno.h.) The set can still be used if this happens, assuming that it didn't |
222 | // happen during set_start(). Whether set_start() completed or not, set_end() | 222 | // happen during set_start(). Whether set_start() completed or not, set_end() |
223 | // can be used to free the set's memory after a longjmp(). | 223 | // can be used to free the set's memory after a longjmp(). */ |
224 | void set_start(set_t *set) { | 224 | void set_start(set_t *set) { |
225 | #ifdef SET_TRACK | 225 | #ifdef SET_TRACK |
226 | set->allocs = 0; | 226 | set->allocs = 0; |
227 | set->memory = 0; | 227 | set->memory = 0; |
228 | #endif | 228 | #endif |
229 | set->head = set->path = set->node = NULL; // in case set_node() fails | 229 | set->head = set->path = set->node = NULL; /* in case set_node() fails */ |
230 | set->path = set_node(set); | 230 | set->path = set_node(set); |
231 | set->head = set_node(set); | 231 | set->head = set_node(set); |
232 | set_grow(set, set->head, 1, 1); // one link back to head for an empty set | 232 | set_grow(set, set->head, 1, 1); /* one link back to head for an empty set */ |
233 | *(unsigned char *)&set->head->key = 137; // set id | 233 | *(unsigned char *)&set->head->key = 137; /* set id */ |
234 | set->depth = 0; | 234 | set->depth = 0; |
235 | set_seed(&set->gen, ((ui64_t)(ptrdiff_t)set << 32) ^ | 235 | set_seed(&set->gen, ((ui64_t)(ptrdiff_t)set << 32) ^ |
236 | ((ui64_t)time(NULL) << 12) ^ clock(), 0); | 236 | ((ui64_t)time(NULL) << 12) ^ clock(), 0); |
237 | set->ran = 1; | 237 | set->ran = 1; |
238 | } | 238 | } |
239 | 239 | ||
240 | // Return true if *set appears to be in a usable state. If *set has been zeroed | 240 | /* Return true if *set appears to be in a usable state. If *set has been zeroed |
241 | // out, then set_ok(set) will be false and set_end(set) will be safe. | 241 | // out, then set_ok(set) will be false and set_end(set) will be safe. */ |
242 | int set_ok(set_t *set) { | 242 | int set_ok(set_t *set) { |
243 | return set->head != NULL && | 243 | return set->head != NULL && |
244 | set->head->right != NULL && | 244 | set->head->right != NULL && |
245 | *(unsigned char *)&set->head->key == 137; | 245 | *(unsigned char *)&set->head->key == 137; |
246 | } | 246 | } |
247 | 247 | ||
248 | // Empty the set. This frees the memory used for the previous set contents. | 248 | /* Empty the set. This frees the memory used for the previous set contents. |
249 | // After set_clear(), *set is ready for use, as if after a set_start(). | 249 | // After set_clear(), *set is ready for use, as if after a set_start(). */ |
250 | void set_clear(set_t *set) { | 250 | void set_clear(set_t *set) { |
251 | assert(set_ok(set) && "improper use"); | 251 | assert(set_ok(set) && "improper use"); |
252 | 252 | ||
253 | // Free all the keys and their nodes. | 253 | /* Free all the keys and their nodes. */ |
254 | set_sweep(set); | 254 | set_sweep(set); |
255 | 255 | ||
256 | // Leave the head and path allocations as is. Clear their contents, with | 256 | /* Leave the head and path allocations as is. Clear their contents, with |
257 | // head pointing to itself and setting depth to zero, for an empty set. | 257 | // head pointing to itself and setting depth to zero, for an empty set. */ |
258 | set->head->right[0] = set->head; | 258 | set->head->right[0] = set->head; |
259 | set->head->fill = 1; | 259 | set->head->fill = 1; |
260 | set->path->fill = 0; | 260 | set->path->fill = 0; |
261 | set->depth = 0; | 261 | set->depth = 0; |
262 | } | 262 | } |
263 | 263 | ||
264 | // Done using the set -- free all allocations. The only operation on *set | 264 | /* Done using the set -- free all allocations. The only operation on *set |
265 | // permitted after this is set_start(). Though another set_end() would do no | 265 | // permitted after this is set_start(). Though another set_end() would do no |
266 | // harm. This can be done at any time after a set_start(), or after a longjmp() | 266 | // harm. This can be done at any time after a set_start(), or after a longjmp() |
267 | // on any allocation failure, including during a set_start(). | 267 | // on any allocation failure, including during a set_start(). */ |
268 | void set_end(set_t *set) { | 268 | void set_end(set_t *set) { |
269 | if (set->head != NULL) { | 269 | if (set->head != NULL) { |
270 | // Empty the set and free the head node. | 270 | /* Empty the set and free the head node. */ |
271 | if (set->head->right != NULL) { | 271 | if (set->head->right != NULL) { |
272 | set_sweep(set); | 272 | set_sweep(set); |
273 | set_free(set, set->head->right); | 273 | set_free(set, set->head->right); |
@@ -276,13 +276,13 @@ void set_end(set_t *set) { | |||
276 | set->head = NULL; | 276 | set->head = NULL; |
277 | } | 277 | } |
278 | if (set->path != NULL) { | 278 | if (set->path != NULL) { |
279 | // Free the path work area. | 279 | /* Free the path work area. */ |
280 | set_free(set, set->path->right); | 280 | set_free(set, set->path->right); |
281 | set_free(set, set->path); | 281 | set_free(set, set->path); |
282 | set->path = NULL; | 282 | set->path = NULL; |
283 | } | 283 | } |
284 | if (set->node != NULL) { | 284 | if (set->node != NULL) { |
285 | // Free the node that was under construction when longjmp() hit. | 285 | /* Free the node that was under construction when longjmp() hit. */ |
286 | set_drop(set, set->node->key); | 286 | set_drop(set, set->node->key); |
287 | set_free(set, set->node->right); | 287 | set_free(set, set->node->right); |
288 | set_free(set, set->node); | 288 | set_free(set, set->node); |
@@ -290,12 +290,12 @@ void set_end(set_t *set) { | |||
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | // Look for key. Return 1 if found or 0 if not. This also puts the path to get | 293 | /* Look for key. Return 1 if found or 0 if not. This also puts the path to get |
294 | // there in set->path, for use by set_insert(). | 294 | // there in set->path, for use by set_insert(). */ |
295 | int set_found(set_t *set, set_key_t key) { | 295 | int set_found(set_t *set, set_key_t key) { |
296 | assert(set_ok(set) && "improper use"); | 296 | assert(set_ok(set) && "improper use"); |
297 | 297 | ||
298 | // Start at depth and work down and right as determined by key comparisons. | 298 | /* Start at depth and work down and right as determined by key comparisons. */ |
299 | set_node_t *head = set->head, *here = head; | 299 | set_node_t *head = set->head, *here = head; |
300 | int i = set->depth; | 300 | int i = set->depth; |
301 | set_grow(set, set->path, i + 1, 0); | 301 | set_grow(set, set->path, i + 1, 0); |
@@ -306,25 +306,25 @@ int set_found(set_t *set, set_key_t key) { | |||
306 | set->path->right[i] = here; | 306 | set->path->right[i] = here; |
307 | } while (i--); | 307 | } while (i--); |
308 | 308 | ||
309 | // See if the key matches. | 309 | /* See if the key matches. */ |
310 | here = here->right[0]; | 310 | here = here->right[0]; |
311 | return here != head && set_cmp(here->key, key) == 0; | 311 | return here != head && set_cmp(here->key, key) == 0; |
312 | } | 312 | } |
313 | 313 | ||
314 | // Insert the key key. Return 0 on success, or 1 if key is already in the set. | 314 | /* Insert the key key. Return 0 on success, or 1 if key is already in the set. */ |
315 | int set_insert(set_t *set, set_key_t key) { | 315 | int set_insert(set_t *set, set_key_t key) { |
316 | assert(set_ok(set) && "improper use"); | 316 | assert(set_ok(set) && "improper use"); |
317 | 317 | ||
318 | if (set_found(set, key)) | 318 | if (set_found(set, key)) |
319 | // That key is already in the set. | 319 | /* That key is already in the set. */ |
320 | return 1; | 320 | return 1; |
321 | 321 | ||
322 | // Randomly generate a new level-- level 0 with probability 1/2, 1 with | 322 | /* Randomly generate a new level-- level 0 with probability 1/2, 1 with |
323 | // probability 1/4, 2 with probability 1/8, etc. | 323 | // probability 1/4, 2 with probability 1/8, etc. */ |
324 | int level = 0; | 324 | int level = 0; |
325 | for (;;) { | 325 | for (;;) { |
326 | if (set->ran == 1) | 326 | if (set->ran == 1) |
327 | // Ran out. Get another 32 random bits. | 327 | /* Ran out. Get another 32 random bits. */ |
328 | set->ran = set_rand(&set->gen) | (1ULL << 32); | 328 | set->ran = set_rand(&set->gen) | (1ULL << 32); |
329 | int bit = set->ran & 1; | 329 | int bit = set->ran & 1; |
330 | set->ran >>= 1; | 330 | set->ran >>= 1; |
@@ -335,14 +335,14 @@ int set_insert(set_t *set, set_key_t key) { | |||
335 | level++; | 335 | level++; |
336 | } | 336 | } |
337 | if (level > set->depth) { | 337 | if (level > set->depth) { |
338 | // The maximum depth is now deeper. Update the structures. | 338 | /* The maximum depth is now deeper. Update the structures. */ |
339 | set_grow(set, set->path, level + 1, 1); | 339 | set_grow(set, set->path, level + 1, 1); |
340 | set_grow(set, set->head, level + 1, 1); | 340 | set_grow(set, set->head, level + 1, 1); |
341 | set->depth = (i16_t)level; | 341 | set->depth = (i16_t)level; |
342 | } | 342 | } |
343 | 343 | ||
344 | // Make a new node for the provided key, and insert it in the lists up to | 344 | /* Make a new node for the provided key, and insert it in the lists up to |
345 | // and including level. | 345 | // and including level. */ |
346 | set->node = set_node(set); | 346 | set->node = set_node(set); |
347 | set->node->key = key; | 347 | set->node->key = key; |
348 | set_grow(set, set->node, level + 1, 0); | 348 | set_grow(set, set->node, level + 1, 0); |
@@ -357,5 +357,5 @@ int set_insert(set_t *set, set_key_t key) { | |||
357 | 357 | ||
358 | #else | 358 | #else |
359 | #error ** another skiplist set already created here | 359 | #error ** another skiplist set already created here |
360 | // Would need to implement a prefix in order to support multiple sets. | 360 | /* Would need to implement a prefix in order to support multiple sets. */ |
361 | #endif | 361 | #endif |
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index a2ee14b..e9088bd 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c | |||
@@ -842,7 +842,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, | |||
842 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) | 842 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) |
843 | err=UNZ_ERRNO; | 843 | err=UNZ_ERRNO; |
844 | 844 | ||
845 | // relative offset of local header | 845 | /* relative offset of local header */ |
846 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) | 846 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) |
847 | err=UNZ_ERRNO; | 847 | err=UNZ_ERRNO; |
848 | file_info_internal.offset_curfile = uL; | 848 | file_info_internal.offset_curfile = uL; |
@@ -865,7 +865,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, | |||
865 | lSeek -= uSizeRead; | 865 | lSeek -= uSizeRead; |
866 | } | 866 | } |
867 | 867 | ||
868 | // Read extrafield | 868 | /* Read extrafield */ |
869 | if ((err==UNZ_OK) && (extraField!=NULL)) | 869 | if ((err==UNZ_OK) && (extraField!=NULL)) |
870 | { | 870 | { |
871 | ZPOS64_T uSizeRead ; | 871 | ZPOS64_T uSizeRead ; |
@@ -896,7 +896,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, | |||
896 | { | 896 | { |
897 | uLong acc = 0; | 897 | uLong acc = 0; |
898 | 898 | ||
899 | // since lSeek now points to after the extra field we need to move back | 899 | /* since lSeek now points to after the extra field we need to move back */ |
900 | lSeek -= file_info.size_file_extra; | 900 | lSeek -= file_info.size_file_extra; |
901 | 901 | ||
902 | if (lSeek!=0) | 902 | if (lSeek!=0) |
@@ -1525,10 +1525,10 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) { | |||
1525 | file_in_zip64_read_info_s* pfile_in_zip_read_info; | 1525 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
1526 | s=(unz64_s*)file; | 1526 | s=(unz64_s*)file; |
1527 | if (file==NULL) | 1527 | if (file==NULL) |
1528 | return 0; //UNZ_PARAMERROR; | 1528 | return 0; /* UNZ_PARAMERROR; */ |
1529 | pfile_in_zip_read_info=s->pfile_in_zip_read; | 1529 | pfile_in_zip_read_info=s->pfile_in_zip_read; |
1530 | if (pfile_in_zip_read_info==NULL) | 1530 | if (pfile_in_zip_read_info==NULL) |
1531 | return 0; //UNZ_PARAMERROR; | 1531 | return 0; /* UNZ_PARAMERROR; */ |
1532 | return pfile_in_zip_read_info->pos_in_zipfile + | 1532 | return pfile_in_zip_read_info->pos_in_zipfile + |
1533 | pfile_in_zip_read_info->byte_before_the_zipfile; | 1533 | pfile_in_zip_read_info->byte_before_the_zipfile; |
1534 | } | 1534 | } |
@@ -1697,7 +1697,7 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) { | |||
1697 | if (err!=BZ_OK) | 1697 | if (err!=BZ_OK) |
1698 | break; | 1698 | break; |
1699 | #endif | 1699 | #endif |
1700 | } // end Z_BZIP2ED | 1700 | } /* end Z_BZIP2ED */ |
1701 | else | 1701 | else |
1702 | { | 1702 | { |
1703 | ZPOS64_T uTotalOutBefore,uTotalOutAfter; | 1703 | ZPOS64_T uTotalOutBefore,uTotalOutAfter; |
@@ -1940,7 +1940,7 @@ extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) { | |||
1940 | unz64_s* s; | 1940 | unz64_s* s; |
1941 | 1941 | ||
1942 | if (file==NULL) | 1942 | if (file==NULL) |
1943 | return 0; //UNZ_PARAMERROR; | 1943 | return 0; /* UNZ_PARAMERROR; */ |
1944 | s=(unz64_s*)file; | 1944 | s=(unz64_s*)file; |
1945 | if (!s->current_file_ok) | 1945 | if (!s->current_file_ok) |
1946 | return 0; | 1946 | return 0; |
@@ -1954,7 +1954,7 @@ extern uLong ZEXPORT unzGetOffset(unzFile file) { | |||
1954 | ZPOS64_T offset64; | 1954 | ZPOS64_T offset64; |
1955 | 1955 | ||
1956 | if (file==NULL) | 1956 | if (file==NULL) |
1957 | return 0; //UNZ_PARAMERROR; | 1957 | return 0; /* UNZ_PARAMERROR; */ |
1958 | offset64 = unzGetOffset64(file); | 1958 | offset64 = unzGetOffset64(file); |
1959 | return (uLong)offset64; | 1959 | return (uLong)offset64; |
1960 | } | 1960 | } |
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c index 93d2612..103f325 100644 --- a/contrib/minizip/zip.c +++ b/contrib/minizip/zip.c | |||
@@ -52,7 +52,7 @@ | |||
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #ifndef Z_BUFSIZE | 54 | #ifndef Z_BUFSIZE |
55 | #define Z_BUFSIZE (64*1024) //(16384) | 55 | #define Z_BUFSIZE (64*1024) /* (16384) */ |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #ifndef Z_MAXFILENAMEINZIP | 58 | #ifndef Z_MAXFILENAMEINZIP |
@@ -71,7 +71,7 @@ | |||
71 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ | 71 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ |
72 | 72 | ||
73 | 73 | ||
74 | // NOT sure that this work on ALL platform | 74 | /* NOT sure that this work on ALL platform */ |
75 | #define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32)) | 75 | #define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32)) |
76 | 76 | ||
77 | #ifndef SEEK_CUR | 77 | #ifndef SEEK_CUR |
@@ -125,16 +125,16 @@ typedef struct linkedlist_data_s | |||
125 | } linkedlist_data; | 125 | } linkedlist_data; |
126 | 126 | ||
127 | 127 | ||
128 | // zipAlreadyThere() set functions for a set of zero-terminated strings, and | 128 | /* zipAlreadyThere() set functions for a set of zero-terminated strings, and |
129 | // a block_t type for reading the central directory datablocks. | 129 | // a block_t type for reading the central directory datablocks. */ |
130 | typedef char *set_key_t; | 130 | typedef char *set_key_t; |
131 | #define set_cmp(a, b) strcmp(a, b) | 131 | #define set_cmp(a, b) strcmp(a, b) |
132 | #define set_drop(s, k) set_free(s, k) | 132 | #define set_drop(s, k) set_free(s, k) |
133 | #include "skipset.h" | 133 | #include "skipset.h" |
134 | typedef struct { | 134 | typedef struct { |
135 | unsigned char *next; // next byte in datablock data | 135 | unsigned char *next; /* next byte in datablock data */ |
136 | size_t left; // number of bytes left in data (at least) | 136 | size_t left; /* number of bytes left in data (at least) */ |
137 | linkedlist_datablock_internal *node; // current datablock | 137 | linkedlist_datablock_internal *node; /* current datablock */ |
138 | } block_t; | 138 | } block_t; |
139 | 139 | ||
140 | 140 | ||
@@ -189,9 +189,9 @@ typedef struct | |||
189 | char *globalcomment; | 189 | char *globalcomment; |
190 | #endif | 190 | #endif |
191 | 191 | ||
192 | // Support for zipAlreadyThere(). | 192 | /* Support for zipAlreadyThere(). */ |
193 | set_t set; // set for detecting name collisions | 193 | set_t set; /* set for detecting name collisions */ |
194 | block_t block; // block for reading the central directory | 194 | block_t block; /* block for reading the central directory */ |
195 | 195 | ||
196 | } zip64_internal; | 196 | } zip64_internal; |
197 | 197 | ||
@@ -283,7 +283,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) | |||
283 | return ZIP_OK; | 283 | return ZIP_OK; |
284 | } | 284 | } |
285 | 285 | ||
286 | // zipAlreadyThere() operations. "set" in the zip internal structure keeps the | 286 | /* zipAlreadyThere() operations. "set" in the zip internal structure keeps the |
287 | // set of names that are in the under-construction central directory so far. A | 287 | // set of names that are in the under-construction central directory so far. A |
288 | // skipset provides ~O(log n) time insertion and searching. Central directory | 288 | // skipset provides ~O(log n) time insertion and searching. Central directory |
289 | // records, stored in a linked list of allocated memory datablocks, is read | 289 | // records, stored in a linked list of allocated memory datablocks, is read |
@@ -295,81 +295,81 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) | |||
295 | // datablocks. | 295 | // datablocks. |
296 | 296 | ||
297 | // Initialize *block to the head of list. This should only be called once the | 297 | // Initialize *block to the head of list. This should only be called once the |
298 | // list has at least some data in it, i.e. list->first_block is not NULL. | 298 | // list has at least some data in it, i.e. list->first_block is not NULL. */ |
299 | local void block_init(block_t *block, linkedlist_data *list) { | 299 | local void block_init(block_t *block, linkedlist_data *list) { |
300 | block->node = list->first_block; | 300 | block->node = list->first_block; |
301 | block->next = block->node->data; | 301 | block->next = block->node->data; |
302 | block->left = block->node->filled_in_this_block; | 302 | block->left = block->node->filled_in_this_block; |
303 | } | 303 | } |
304 | 304 | ||
305 | // Mark *block as bad, with all subsequent reads returning end, even if more | 305 | /* Mark *block as bad, with all subsequent reads returning end, even if more |
306 | // data is added to the datablocks. This is invoked if the central directory is | 306 | // data is added to the datablocks. This is invoked if the central directory is |
307 | // invalid, so there is no longer any point in attempting to interpret it. | 307 | // invalid, so there is no longer any point in attempting to interpret it. */ |
308 | local void block_stop(block_t *block) { | 308 | local void block_stop(block_t *block) { |
309 | block->left = 0; | 309 | block->left = 0; |
310 | block->next = NULL; | 310 | block->next = NULL; |
311 | } | 311 | } |
312 | 312 | ||
313 | // Return true if *block has reached the end of the data in the datablocks. | 313 | /* Return true if *block has reached the end of the data in the datablocks. */ |
314 | local int block_end(block_t *block) { | 314 | local int block_end(block_t *block) { |
315 | linkedlist_datablock_internal *node = block->node; | 315 | linkedlist_datablock_internal *node = block->node; |
316 | if (node == NULL) | 316 | if (node == NULL) |
317 | // This block was previously terminated with extreme prejudice. | 317 | /* This block was previously terminated with extreme prejudice. */ |
318 | return 1; | 318 | return 1; |
319 | if (block->next < node->data + node->filled_in_this_block) | 319 | if (block->next < node->data + node->filled_in_this_block) |
320 | // There are more bytes to read in the current datablock. | 320 | /* There are more bytes to read in the current datablock. */ |
321 | return 0; | 321 | return 0; |
322 | while (node->next_datablock != NULL) { | 322 | while (node->next_datablock != NULL) { |
323 | if (node->filled_in_this_block != 0) | 323 | if (node->filled_in_this_block != 0) |
324 | // There are some bytes in a later datablock. | 324 | /* There are some bytes in a later datablock. */ |
325 | return 0; | 325 | return 0; |
326 | node = node->next_datablock; | 326 | node = node->next_datablock; |
327 | } | 327 | } |
328 | // Reached the end of the list of datablocks. There's nothing. | 328 | /* Reached the end of the list of datablocks. There's nothing. */ |
329 | return 1; | 329 | return 1; |
330 | } | 330 | } |
331 | 331 | ||
332 | // Return one byte from *block, or -1 if the end is reached. | 332 | /* Return one byte from *block, or -1 if the end is reached. */ |
333 | local int block_get(block_t *block) { | 333 | local int block_get(block_t *block) { |
334 | while (block->left == 0) { | 334 | while (block->left == 0) { |
335 | if (block->node == NULL) | 335 | if (block->node == NULL) |
336 | // We've been marked bad. Return end. | 336 | /* We've been marked bad. Return end. */ |
337 | return -1; | 337 | return -1; |
338 | // Update left in case more was filled in since we were last here. | 338 | /* Update left in case more was filled in since we were last here. */ |
339 | block->left = block->node->filled_in_this_block - | 339 | block->left = block->node->filled_in_this_block - |
340 | (block->next - block->node->data); | 340 | (block->next - block->node->data); |
341 | if (block->left != 0) | 341 | if (block->left != 0) |
342 | // There was indeed more data appended in the current datablock. | 342 | /* There was indeed more data appended in the current datablock. */ |
343 | break; | 343 | break; |
344 | if (block->node->next_datablock == NULL) | 344 | if (block->node->next_datablock == NULL) |
345 | // No more data here, and there is no next datablock. At the end. | 345 | /* No more data here, and there is no next datablock. At the end. */ |
346 | return -1; | 346 | return -1; |
347 | // Try the next datablock for more data. | 347 | /* Try the next datablock for more data. */ |
348 | block->node = block->node->next_datablock; | 348 | block->node = block->node->next_datablock; |
349 | block->next = block->node->data; | 349 | block->next = block->node->data; |
350 | block->left = block->node->filled_in_this_block; | 350 | block->left = block->node->filled_in_this_block; |
351 | } | 351 | } |
352 | // We have a byte to return. | 352 | /* We have a byte to return. */ |
353 | block->left--; | 353 | block->left--; |
354 | return *block->next++; | 354 | return *block->next++; |
355 | } | 355 | } |
356 | 356 | ||
357 | // Return a 16-bit unsigned little-endian value from block, or a negative value | 357 | /* Return a 16-bit unsigned little-endian value from block, or a negative value |
358 | // if the end is reached. | 358 | // if the end is reached. */ |
359 | local long block_get2(block_t *block) { | 359 | local long block_get2(block_t *block) { |
360 | long got = block_get(block); | 360 | long got = block_get(block); |
361 | return got | ((unsigned long)block_get(block) << 8); | 361 | return got | ((unsigned long)block_get(block) << 8); |
362 | } | 362 | } |
363 | 363 | ||
364 | // Read up to len bytes from block into buf. Return the number of bytes read. | 364 | /* Read up to len bytes from block into buf. Return the number of bytes read. */ |
365 | local size_t block_read(block_t *block, unsigned char *buf, size_t len) { | 365 | local size_t block_read(block_t *block, unsigned char *buf, size_t len) { |
366 | size_t need = len; | 366 | size_t need = len; |
367 | while (need) { | 367 | while (need) { |
368 | if (block->left == 0) { | 368 | if (block->left == 0) { |
369 | // Get a byte to update and step through the linked list as needed. | 369 | /* Get a byte to update and step through the linked list as needed. */ |
370 | int got = block_get(block); | 370 | int got = block_get(block); |
371 | if (got == -1) | 371 | if (got == -1) |
372 | // Reached the end. | 372 | /* Reached the end. */ |
373 | break; | 373 | break; |
374 | *buf++ = (unsigned char)got; | 374 | *buf++ = (unsigned char)got; |
375 | need--; | 375 | need--; |
@@ -382,11 +382,11 @@ local size_t block_read(block_t *block, unsigned char *buf, size_t len) { | |||
382 | buf += take; | 382 | buf += take; |
383 | need -= take; | 383 | need -= take; |
384 | } | 384 | } |
385 | return len - need; // return the number of bytes copied | 385 | return len - need; /* return the number of bytes copied */ |
386 | } | 386 | } |
387 | 387 | ||
388 | // Skip n bytes in block. Return 0 on success or -1 if there are less than n | 388 | /* Skip n bytes in block. Return 0 on success or -1 if there are less than n |
389 | // bytes to the end. | 389 | // bytes to the end. */ |
390 | local int block_skip(block_t *block, size_t n) { | 390 | local int block_skip(block_t *block, size_t n) { |
391 | while (n > block->left) { | 391 | while (n > block->left) { |
392 | n -= block->left; | 392 | n -= block->left; |
@@ -401,103 +401,103 @@ local int block_skip(block_t *block, size_t n) { | |||
401 | return 0; | 401 | return 0; |
402 | } | 402 | } |
403 | 403 | ||
404 | // Process the next central directory record at *block. Return the allocated, | 404 | /* Process the next central directory record at *block. Return the allocated, |
405 | // zero-terminated file name, or NULL for end of input or invalid data. If | 405 | // zero-terminated file name, or NULL for end of input or invalid data. If |
406 | // invalid, *block is marked bad. This uses *set for the allocation of memory. | 406 | // invalid, *block is marked bad. This uses *set for the allocation of memory. */ |
407 | local char *block_central_name(block_t *block, set_t *set) { | 407 | local char *block_central_name(block_t *block, set_t *set) { |
408 | char *name = NULL; | 408 | char *name = NULL; |
409 | for (;;) { | 409 | for (;;) { |
410 | if (block_end(block)) | 410 | if (block_end(block)) |
411 | // At the end of the central directory (so far). | 411 | /* At the end of the central directory (so far). */ |
412 | return NULL; | 412 | return NULL; |
413 | 413 | ||
414 | // Check for a central directory record signature. | 414 | /* Check for a central directory record signature. */ |
415 | if (block_get2(block) != (CENTRALHEADERMAGIC & 0xffff) || | 415 | if (block_get2(block) != (CENTRALHEADERMAGIC & 0xffff) || |
416 | block_get2(block) != (CENTRALHEADERMAGIC >> 16)) | 416 | block_get2(block) != (CENTRALHEADERMAGIC >> 16)) |
417 | // Incorrect signature. | 417 | /* Incorrect signature. */ |
418 | break; | 418 | break; |
419 | 419 | ||
420 | // Go through the remaining fixed-length portion of the record, | 420 | /* Go through the remaining fixed-length portion of the record, |
421 | // extracting the lengths of the three variable-length fields. | 421 | // extracting the lengths of the three variable-length fields. */ |
422 | block_skip(block, 24); | 422 | block_skip(block, 24); |
423 | unsigned flen = block_get2(block); // file name length | 423 | unsigned flen = block_get2(block); /* file name length */ |
424 | unsigned xlen = block_get2(block); // extra field length | 424 | unsigned xlen = block_get2(block); /* extra field length */ |
425 | unsigned clen = block_get2(block); // comment field length | 425 | unsigned clen = block_get2(block); /* comment field length */ |
426 | if (block_skip(block, 12) == -1) | 426 | if (block_skip(block, 12) == -1) |
427 | // Premature end of the record. | 427 | /* Premature end of the record. */ |
428 | break; | 428 | break; |
429 | 429 | ||
430 | // Extract the name and skip over the extra and comment fields. | 430 | /* Extract the name and skip over the extra and comment fields. */ |
431 | name = set_alloc(set, NULL, flen + 1); | 431 | name = set_alloc(set, NULL, flen + 1); |
432 | if (block_read(block, (unsigned char *)name, flen) < flen || | 432 | if (block_read(block, (unsigned char *)name, flen) < flen || |
433 | block_skip(block, xlen + clen) == -1) | 433 | block_skip(block, xlen + clen) == -1) |
434 | // Premature end of the record. | 434 | /* Premature end of the record. */ |
435 | break; | 435 | break; |
436 | 436 | ||
437 | // Check for embedded nuls in the name. | 437 | /* Check for embedded nuls in the name. */ |
438 | if (memchr(name, 0, flen) != NULL) { | 438 | if (memchr(name, 0, flen) != NULL) { |
439 | // This name can never match the zero-terminated name provided to | 439 | /* This name can never match the zero-terminated name provided to |
440 | // zipAlreadyThere(), so we discard it and go back to get another | 440 | // zipAlreadyThere(), so we discard it and go back to get another |
441 | // name. (Who the heck is putting nuls inside their zip file entry | 441 | // name. (Who the heck is putting nuls inside their zip file entry |
442 | // names anyway?) | 442 | // names anyway?) */ |
443 | set_free(set, name); | 443 | set_free(set, name); |
444 | continue; | 444 | continue; |
445 | } | 445 | } |
446 | 446 | ||
447 | // All good. Return the zero-terminated file name. | 447 | /* All good. Return the zero-terminated file name. */ |
448 | name[flen] = 0; | 448 | name[flen] = 0; |
449 | return name; | 449 | return name; |
450 | } | 450 | } |
451 | 451 | ||
452 | // Invalid signature or premature end of the central directory record. | 452 | /* Invalid signature or premature end of the central directory record. |
453 | // Abandon trying to process the central directory. | 453 | // Abandon trying to process the central directory. */ |
454 | set_free(set, name); | 454 | set_free(set, name); |
455 | block_stop(block); | 455 | block_stop(block); |
456 | return NULL; | 456 | return NULL; |
457 | } | 457 | } |
458 | 458 | ||
459 | // Return 0 if name is not in the central directory so far, 1 if it is, -1 if | 459 | /* Return 0 if name is not in the central directory so far, 1 if it is, -1 if |
460 | // the central directory is invalid, -2 if out of memory, or ZIP_PARAMERROR if | 460 | // the central directory is invalid, -2 if out of memory, or ZIP_PARAMERROR if |
461 | // file is NULL. | 461 | // file is NULL. */ |
462 | extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) { | 462 | extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) { |
463 | zip64_internal *zip = file; | 463 | zip64_internal *zip = file; |
464 | if (zip == NULL) | 464 | if (zip == NULL) |
465 | return ZIP_PARAMERROR; | 465 | return ZIP_PARAMERROR; |
466 | if (zip->central_dir.first_block == NULL) | 466 | if (zip->central_dir.first_block == NULL) |
467 | // No central directory yet, so no, name isn't there. | 467 | /* No central directory yet, so no, name isn't there. */ |
468 | return 0; | 468 | return 0; |
469 | if (setjmp(zip->set.env)) { | 469 | if (setjmp(zip->set.env)) { |
470 | // Memory allocation failure. | 470 | /* Memory allocation failure. */ |
471 | set_end(&zip->set); | 471 | set_end(&zip->set); |
472 | return -2; | 472 | return -2; |
473 | } | 473 | } |
474 | if (!set_ok(&zip->set)) { | 474 | if (!set_ok(&zip->set)) { |
475 | // This is the first time here with some central directory content. We | 475 | /* This is the first time here with some central directory content. We |
476 | // construct this set of names only on demand. Prepare set and block. | 476 | // construct this set of names only on demand. Prepare set and block. */ |
477 | set_start(&zip->set); | 477 | set_start(&zip->set); |
478 | block_init(&zip->block, &zip->central_dir); | 478 | block_init(&zip->block, &zip->central_dir); |
479 | } | 479 | } |
480 | 480 | ||
481 | // Update the set of names from the current central directory contents. | 481 | /* Update the set of names from the current central directory contents. |
482 | // This reads any new central directory records since the last time we were | 482 | // This reads any new central directory records since the last time we were |
483 | // here. | 483 | // here. */ |
484 | for (;;) { | 484 | for (;;) { |
485 | char *there = block_central_name(&zip->block, &zip->set); | 485 | char *there = block_central_name(&zip->block, &zip->set); |
486 | if (there == NULL) { | 486 | if (there == NULL) { |
487 | if (zip->block.next == NULL) | 487 | if (zip->block.next == NULL) |
488 | // The central directory is invalid. | 488 | /* The central directory is invalid. */ |
489 | return -1; | 489 | return -1; |
490 | break; | 490 | break; |
491 | } | 491 | } |
492 | 492 | ||
493 | // Add there to the set. | 493 | /* Add there to the set. */ |
494 | if (set_insert(&zip->set, there)) | 494 | if (set_insert(&zip->set, there)) |
495 | // There's already a duplicate in the central directory! We'll just | 495 | /* There's already a duplicate in the central directory! We'll just |
496 | // let this be and carry on. | 496 | // let this be and carry on. */ |
497 | set_free(&zip->set, there); | 497 | set_free(&zip->set, there); |
498 | } | 498 | } |
499 | 499 | ||
500 | // Return true if name is in the central directory. | 500 | /* Return true if name is in the central directory. */ |
501 | size_t len = strlen(name); | 501 | size_t len = strlen(name); |
502 | char *copy = set_alloc(&zip->set, NULL, len + 1); | 502 | char *copy = set_alloc(&zip->set, NULL, len + 1); |
503 | strcpy(copy, name); | 503 | strcpy(copy, name); |
@@ -792,7 +792,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib | |||
792 | 792 | ||
793 | for (i=(int)uReadSize-3; (i--)>0;) | 793 | for (i=(int)uReadSize-3; (i--)>0;) |
794 | { | 794 | { |
795 | // Signature "0x07064b50" Zip64 end of central directory locator | 795 | /* Signature "0x07064b50" Zip64 end of central directory locator */ |
796 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) | 796 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) |
797 | { | 797 | { |
798 | uPosFound = uReadPos+(unsigned)i; | 798 | uPosFound = uReadPos+(unsigned)i; |
@@ -840,7 +840,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib | |||
840 | if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) | 840 | if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) |
841 | return 0; | 841 | return 0; |
842 | 842 | ||
843 | if (uL != 0x06064b50) // signature of 'Zip64 end of central directory' | 843 | if (uL != 0x06064b50) /* signature of 'Zip64 end of central directory' */ |
844 | return 0; | 844 | return 0; |
845 | 845 | ||
846 | return relativeOffset; | 846 | return relativeOffset; |
@@ -869,7 +869,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) { | |||
869 | 869 | ||
870 | int hasZIP64Record = 0; | 870 | int hasZIP64Record = 0; |
871 | 871 | ||
872 | // check first if we find a ZIP64 record | 872 | /* check first if we find a ZIP64 record */ |
873 | central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream); | 873 | central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream); |
874 | if(central_pos > 0) | 874 | if(central_pos > 0) |
875 | { | 875 | { |
@@ -935,13 +935,13 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) { | |||
935 | if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK) | 935 | if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK) |
936 | err=ZIP_ERRNO; | 936 | err=ZIP_ERRNO; |
937 | 937 | ||
938 | // TODO.. | 938 | /* TODO.. |
939 | // read the comment from the standard central header. | 939 | // read the comment from the standard central header. */ |
940 | size_comment = 0; | 940 | size_comment = 0; |
941 | } | 941 | } |
942 | else | 942 | else |
943 | { | 943 | { |
944 | // Read End of central Directory info | 944 | /* Read End of central Directory info */ |
945 | if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) | 945 | if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) |
946 | err=ZIP_ERRNO; | 946 | err=ZIP_ERRNO; |
947 | 947 | ||
@@ -1084,7 +1084,7 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo | |||
1084 | ziinit.number_entry = 0; | 1084 | ziinit.number_entry = 0; |
1085 | ziinit.add_position_when_writing_offset = 0; | 1085 | ziinit.add_position_when_writing_offset = 0; |
1086 | init_linkedlist(&(ziinit.central_dir)); | 1086 | init_linkedlist(&(ziinit.central_dir)); |
1087 | memset(&ziinit.set, 0, sizeof(set_t)); // make sure set appears dormant | 1087 | memset(&ziinit.set, 0, sizeof(set_t)); /* make sure set appears dormant */ |
1088 | 1088 | ||
1089 | 1089 | ||
1090 | 1090 | ||
@@ -1100,7 +1100,7 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo | |||
1100 | ziinit.globalcomment = NULL; | 1100 | ziinit.globalcomment = NULL; |
1101 | if (append == APPEND_STATUS_ADDINZIP) | 1101 | if (append == APPEND_STATUS_ADDINZIP) |
1102 | { | 1102 | { |
1103 | // Read and Cache Central Directory Records | 1103 | /* Read and Cache Central Directory Records */ |
1104 | err = LoadCentralDirectoryRecord(&ziinit); | 1104 | err = LoadCentralDirectoryRecord(&ziinit); |
1105 | } | 1105 | } |
1106 | 1106 | ||
@@ -1184,7 +1184,7 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s | |||
1184 | if (err==ZIP_OK) | 1184 | if (err==ZIP_OK) |
1185 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); | 1185 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); |
1186 | 1186 | ||
1187 | // CRC / Compressed size / Uncompressed size will be filled in later and rewritten later | 1187 | /* CRC / Compressed size / Uncompressed size will be filled in later and rewritten later */ |
1188 | if (err==ZIP_OK) | 1188 | if (err==ZIP_OK) |
1189 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ | 1189 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ |
1190 | if (err==ZIP_OK) | 1190 | if (err==ZIP_OK) |
@@ -1228,13 +1228,13 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s | |||
1228 | 1228 | ||
1229 | if ((err==ZIP_OK) && (zi->ci.zip64)) | 1229 | if ((err==ZIP_OK) && (zi->ci.zip64)) |
1230 | { | 1230 | { |
1231 | // write the Zip64 extended info | 1231 | /* write the Zip64 extended info */ |
1232 | short HeaderID = 1; | 1232 | short HeaderID = 1; |
1233 | short DataSize = 16; | 1233 | short DataSize = 16; |
1234 | ZPOS64_T CompressedSize = 0; | 1234 | ZPOS64_T CompressedSize = 0; |
1235 | ZPOS64_T UncompressedSize = 0; | 1235 | ZPOS64_T UncompressedSize = 0; |
1236 | 1236 | ||
1237 | // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) | 1237 | /* Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) */ |
1238 | zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream); | 1238 | zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream); |
1239 | 1239 | ||
1240 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2); | 1240 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2); |
@@ -1284,14 +1284,14 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c | |||
1284 | return ZIP_PARAMERROR; | 1284 | return ZIP_PARAMERROR; |
1285 | #endif | 1285 | #endif |
1286 | 1286 | ||
1287 | // The filename and comment length must fit in 16 bits. | 1287 | /* The filename and comment length must fit in 16 bits. */ |
1288 | if ((filename!=NULL) && (strlen(filename)>0xffff)) | 1288 | if ((filename!=NULL) && (strlen(filename)>0xffff)) |
1289 | return ZIP_PARAMERROR; | 1289 | return ZIP_PARAMERROR; |
1290 | if ((comment!=NULL) && (strlen(comment)>0xffff)) | 1290 | if ((comment!=NULL) && (strlen(comment)>0xffff)) |
1291 | return ZIP_PARAMERROR; | 1291 | return ZIP_PARAMERROR; |
1292 | // The extra field length must fit in 16 bits. If the member also requires | 1292 | /* The extra field length must fit in 16 bits. If the member also requires |
1293 | // a Zip64 extra block, that will also need to fit within that 16-bit | 1293 | // a Zip64 extra block, that will also need to fit within that 16-bit |
1294 | // length, but that will be checked for later. | 1294 | // length, but that will be checked for later. */ |
1295 | if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff)) | 1295 | if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff)) |
1296 | return ZIP_PARAMERROR; | 1296 | return ZIP_PARAMERROR; |
1297 | 1297 | ||
@@ -1343,7 +1343,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c | |||
1343 | zi->ci.pos_local_header = ZTELL64(zi->z_filefunc,zi->filestream); | 1343 | zi->ci.pos_local_header = ZTELL64(zi->z_filefunc,zi->filestream); |
1344 | 1344 | ||
1345 | zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment; | 1345 | zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment; |
1346 | zi->ci.size_centralExtraFree = 32; // Extra space we have reserved in case we need to add ZIP64 extra info data | 1346 | zi->ci.size_centralExtraFree = 32; /* Extra space we have reserved in case we need to add ZIP64 extra info data */ |
1347 | 1347 | ||
1348 | zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree); | 1348 | zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree); |
1349 | 1349 | ||
@@ -1438,7 +1438,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c | |||
1438 | else if(zi->ci.method == Z_BZIP2ED) | 1438 | else if(zi->ci.method == Z_BZIP2ED) |
1439 | { | 1439 | { |
1440 | #ifdef HAVE_BZIP2 | 1440 | #ifdef HAVE_BZIP2 |
1441 | // Init BZip stuff here | 1441 | /* Init BZip stuff here */ |
1442 | zi->ci.bstream.bzalloc = 0; | 1442 | zi->ci.bstream.bzalloc = 0; |
1443 | zi->ci.bstream.bzfree = 0; | 1443 | zi->ci.bstream.bzfree = 0; |
1444 | zi->ci.bstream.opaque = (voidpf)0; | 1444 | zi->ci.bstream.opaque = (voidpf)0; |
@@ -1640,7 +1640,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i | |||
1640 | if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) | 1640 | if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) |
1641 | { | 1641 | { |
1642 | uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32; | 1642 | uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32; |
1643 | // uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32; | 1643 | /* uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32; */ |
1644 | err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN); | 1644 | err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN); |
1645 | 1645 | ||
1646 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ; | 1646 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ; |
@@ -1698,7 +1698,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i | |||
1698 | zi->ci.pos_in_buffered_data += copy_this; | 1698 | zi->ci.pos_in_buffered_data += copy_this; |
1699 | } | 1699 | } |
1700 | } | 1700 | } |
1701 | }// while(...) | 1701 | }/* while(...) */ |
1702 | } | 1702 | } |
1703 | 1703 | ||
1704 | return err; | 1704 | return err; |
@@ -1804,7 +1804,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si | |||
1804 | compressed_size += zi->ci.crypt_header_size; | 1804 | compressed_size += zi->ci.crypt_header_size; |
1805 | # endif | 1805 | # endif |
1806 | 1806 | ||
1807 | // update Current Item crc and sizes, | 1807 | /* update Current Item crc and sizes, */ |
1808 | if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff) | 1808 | if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff) |
1809 | { | 1809 | { |
1810 | /*version Made by*/ | 1810 | /*version Made by*/ |
@@ -1822,7 +1822,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si | |||
1822 | else | 1822 | else |
1823 | zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/ | 1823 | zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/ |
1824 | 1824 | ||
1825 | /// set internal file attributes field | 1825 | /* set internal file attributes field */ |
1826 | if (zi->ci.stream.data_type == Z_ASCII) | 1826 | if (zi->ci.stream.data_type == Z_ASCII) |
1827 | zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); | 1827 | zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); |
1828 | 1828 | ||
@@ -1831,15 +1831,15 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si | |||
1831 | else | 1831 | else |
1832 | zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/ | 1832 | zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/ |
1833 | 1833 | ||
1834 | // Add ZIP64 extra info field for uncompressed size | 1834 | /* Add ZIP64 extra info field for uncompressed size */ |
1835 | if(uncompressed_size >= 0xffffffff) | 1835 | if(uncompressed_size >= 0xffffffff) |
1836 | datasize += 8; | 1836 | datasize += 8; |
1837 | 1837 | ||
1838 | // Add ZIP64 extra info field for compressed size | 1838 | /* Add ZIP64 extra info field for compressed size */ |
1839 | if(compressed_size >= 0xffffffff) | 1839 | if(compressed_size >= 0xffffffff) |
1840 | datasize += 8; | 1840 | datasize += 8; |
1841 | 1841 | ||
1842 | // Add ZIP64 extra info field for relative offset to local file header of current file | 1842 | /* Add ZIP64 extra info field for relative offset to local file header of current file */ |
1843 | if(zi->ci.pos_local_header >= 0xffffffff) | 1843 | if(zi->ci.pos_local_header >= 0xffffffff) |
1844 | datasize += 8; | 1844 | datasize += 8; |
1845 | 1845 | ||
@@ -1849,16 +1849,16 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si | |||
1849 | 1849 | ||
1850 | if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree) | 1850 | if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree) |
1851 | { | 1851 | { |
1852 | // we cannot write more data to the buffer that we have room for. | 1852 | /* we cannot write more data to the buffer that we have room for. */ |
1853 | return ZIP_BADZIPFILE; | 1853 | return ZIP_BADZIPFILE; |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | p = zi->ci.central_header + zi->ci.size_centralheader; | 1856 | p = zi->ci.central_header + zi->ci.size_centralheader; |
1857 | 1857 | ||
1858 | // Add Extra Information Header for 'ZIP64 information' | 1858 | /* Add Extra Information Header for 'ZIP64 information' */ |
1859 | zip64local_putValue_inmemory(p, 0x0001, 2); // HeaderID | 1859 | zip64local_putValue_inmemory(p, 0x0001, 2); /* HeaderID */ |
1860 | p += 2; | 1860 | p += 2; |
1861 | zip64local_putValue_inmemory(p, datasize, 2); // DataSize | 1861 | zip64local_putValue_inmemory(p, datasize, 2); /* DataSize */ |
1862 | p += 2; | 1862 | p += 2; |
1863 | 1863 | ||
1864 | if(uncompressed_size >= 0xffffffff) | 1864 | if(uncompressed_size >= 0xffffffff) |
@@ -1879,13 +1879,13 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si | |||
1879 | p += 8; | 1879 | p += 8; |
1880 | } | 1880 | } |
1881 | 1881 | ||
1882 | // Update how much extra free space we got in the memory buffer | 1882 | /* Update how much extra free space we got in the memory buffer |
1883 | // and increase the centralheader size so the new ZIP64 fields are included | 1883 | // and increase the centralheader size so the new ZIP64 fields are included |
1884 | // ( 4 below is the size of HeaderID and DataSize field ) | 1884 | // ( 4 below is the size of HeaderID and DataSize field ) */ |
1885 | zi->ci.size_centralExtraFree -= datasize + 4; | 1885 | zi->ci.size_centralExtraFree -= datasize + 4; |
1886 | zi->ci.size_centralheader += datasize + 4; | 1886 | zi->ci.size_centralheader += datasize + 4; |
1887 | 1887 | ||
1888 | // Update the extra info size field | 1888 | /* Update the extra info size field */ |
1889 | zi->ci.size_centralExtra += datasize + 4; | 1889 | zi->ci.size_centralExtra += datasize + 4; |
1890 | zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2); | 1890 | zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2); |
1891 | } | 1891 | } |
@@ -1897,7 +1897,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si | |||
1897 | 1897 | ||
1898 | if (err==ZIP_OK) | 1898 | if (err==ZIP_OK) |
1899 | { | 1899 | { |
1900 | // Update the LocalFileHeader with the new values. | 1900 | /* Update the LocalFileHeader with the new values. */ |
1901 | 1901 | ||
1902 | ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); | 1902 | ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); |
1903 | 1903 | ||
@@ -1911,7 +1911,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si | |||
1911 | { | 1911 | { |
1912 | if(zi->ci.pos_zip64extrainfo > 0) | 1912 | if(zi->ci.pos_zip64extrainfo > 0) |
1913 | { | 1913 | { |
1914 | // Update the size in the ZIP64 extended field. | 1914 | /* Update the size in the ZIP64 extended field. */ |
1915 | if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0) | 1915 | if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0) |
1916 | err = ZIP_ERRNO; | 1916 | err = ZIP_ERRNO; |
1917 | 1917 | ||
@@ -1922,7 +1922,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si | |||
1922 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8); | 1922 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8); |
1923 | } | 1923 | } |
1924 | else | 1924 | else |
1925 | err = ZIP_BADZIPFILE; // Caller passed zip64 = 0, so no room for zip64 info -> fatal | 1925 | err = ZIP_BADZIPFILE; /* Caller passed zip64 = 0, so no room for zip64 info -> fatal */ |
1926 | } | 1926 | } |
1927 | else | 1927 | else |
1928 | { | 1928 | { |
@@ -1976,7 +1976,7 @@ local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_ | |||
1976 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4); | 1976 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4); |
1977 | 1977 | ||
1978 | if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */ | 1978 | if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */ |
1979 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); // why ZPOS64_T of this ? | 1979 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); /* why ZPOS64_T of this ? */ |
1980 | 1980 | ||
1981 | if (err==ZIP_OK) /* version made by */ | 1981 | if (err==ZIP_OK) /* version made by */ |
1982 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); | 1982 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); |
@@ -2023,7 +2023,7 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr | |||
2023 | { | 2023 | { |
2024 | { | 2024 | { |
2025 | if(zi->number_entry >= 0xFFFF) | 2025 | if(zi->number_entry >= 0xFFFF) |
2026 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record | 2026 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); /* use value in ZIP64 record */ |
2027 | else | 2027 | else |
2028 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); | 2028 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); |
2029 | } | 2029 | } |
@@ -2032,7 +2032,7 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr | |||
2032 | if (err==ZIP_OK) /* total number of entries in the central dir */ | 2032 | if (err==ZIP_OK) /* total number of entries in the central dir */ |
2033 | { | 2033 | { |
2034 | if(zi->number_entry >= 0xFFFF) | 2034 | if(zi->number_entry >= 0xFFFF) |
2035 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record | 2035 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); /* use value in ZIP64 record */ |
2036 | else | 2036 | else |
2037 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); | 2037 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); |
2038 | } | 2038 | } |
@@ -2112,7 +2112,7 @@ extern int ZEXPORT zipClose(zipFile file, const char* global_comment) { | |||
2112 | } | 2112 | } |
2113 | free_linkedlist(&(zi->central_dir)); | 2113 | free_linkedlist(&(zi->central_dir)); |
2114 | 2114 | ||
2115 | set_end(&zi->set); // set was zeroed, so this is safe | 2115 | set_end(&zi->set); /* set was zeroed, so this is safe */ |
2116 | 2116 | ||
2117 | pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; | 2117 | pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; |
2118 | if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF) | 2118 | if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF) |
@@ -2162,13 +2162,13 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea | |||
2162 | header = *(short*)p; | 2162 | header = *(short*)p; |
2163 | dataSize = *(((short*)p)+1); | 2163 | dataSize = *(((short*)p)+1); |
2164 | 2164 | ||
2165 | if( header == sHeader ) // Header found. | 2165 | if( header == sHeader ) /* Header found. */ |
2166 | { | 2166 | { |
2167 | p += dataSize + 4; // skip it. do not copy to temp buffer | 2167 | p += dataSize + 4; /* skip it. do not copy to temp buffer */ |
2168 | } | 2168 | } |
2169 | else | 2169 | else |
2170 | { | 2170 | { |
2171 | // Extra Info block should not be removed, So copy it to the temp buffer. | 2171 | /* Extra Info block should not be removed, So copy it to the temp buffer. */ |
2172 | memcpy(pTmp, p, dataSize + 4); | 2172 | memcpy(pTmp, p, dataSize + 4); |
2173 | p += dataSize + 4; | 2173 | p += dataSize + 4; |
2174 | size += dataSize + 4; | 2174 | size += dataSize + 4; |
@@ -2178,14 +2178,14 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea | |||
2178 | 2178 | ||
2179 | if(size < *dataLen) | 2179 | if(size < *dataLen) |
2180 | { | 2180 | { |
2181 | // clean old extra info block. | 2181 | /* clean old extra info block. */ |
2182 | memset(pData,0, *dataLen); | 2182 | memset(pData,0, *dataLen); |
2183 | 2183 | ||
2184 | // copy the new extra info block over the old | 2184 | /* copy the new extra info block over the old */ |
2185 | if(size > 0) | 2185 | if(size > 0) |
2186 | memcpy(pData, pNewHeader, size); | 2186 | memcpy(pData, pNewHeader, size); |
2187 | 2187 | ||
2188 | // set the new extra info size | 2188 | /* set the new extra info size */ |
2189 | *dataLen = size; | 2189 | *dataLen = size; |
2190 | 2190 | ||
2191 | retVal = ZIP_OK; | 2191 | retVal = ZIP_OK; |
diff --git a/contrib/minizip/zip.h b/contrib/minizip/zip.h index 1f7f0b2..9526eac 100644 --- a/contrib/minizip/zip.h +++ b/contrib/minizip/zip.h | |||
@@ -44,7 +44,7 @@ | |||
44 | extern "C" { | 44 | extern "C" { |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | //#define HAVE_BZIP2 | 47 | /* #define HAVE_BZIP2 */ |
48 | 48 | ||
49 | #ifndef _ZLIB_H | 49 | #ifndef _ZLIB_H |
50 | #include "zlib.h" | 50 | #include "zlib.h" |