diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2023-04-14 01:42:03 -0700 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2023-04-15 21:17:31 -0700 |
| commit | e9d5486e6635141f589e110fd789648aa08e9544 (patch) | |
| tree | a78b9ccd92b05af7cd5776b688d9c3eb3a81a40a /test | |
| parent | 5799c14c8526bf1aaa130c021982f831d155b46d (diff) | |
| download | zlib-e9d5486e6635141f589e110fd789648aa08e9544.tar.gz zlib-e9d5486e6635141f589e110fd789648aa08e9544.tar.bz2 zlib-e9d5486e6635141f589e110fd789648aa08e9544.zip | |
Remove K&R function definitions from zlib.
C2X has removed K&R definitions from the C function syntax.
Though the standard has not yet been approved, some high-profile
compilers are now issuing warnings when such definitions are
encountered.
Diffstat (limited to 'test')
| -rw-r--r-- | test/example.c | 93 | ||||
| -rw-r--r-- | test/minigzip.c | 172 |
2 files changed, 68 insertions, 197 deletions
diff --git a/test/example.c b/test/example.c index 1470bc8..1c755bc 100644 --- a/test/example.c +++ b/test/example.c | |||
| @@ -34,37 +34,14 @@ static z_const char hello[] = "hello, hello!"; | |||
| 34 | static const char dictionary[] = "hello"; | 34 | static const char dictionary[] = "hello"; |
| 35 | static uLong dictId; /* Adler32 value of the dictionary */ | 35 | static uLong dictId; /* Adler32 value of the dictionary */ |
| 36 | 36 | ||
| 37 | void test_deflate OF((Byte *compr, uLong comprLen)); | ||
| 38 | void test_inflate OF((Byte *compr, uLong comprLen, | ||
| 39 | Byte *uncompr, uLong uncomprLen)); | ||
| 40 | void test_large_deflate OF((Byte *compr, uLong comprLen, | ||
| 41 | Byte *uncompr, uLong uncomprLen)); | ||
| 42 | void test_large_inflate OF((Byte *compr, uLong comprLen, | ||
| 43 | Byte *uncompr, uLong uncomprLen)); | ||
| 44 | void test_flush OF((Byte *compr, uLong *comprLen)); | ||
| 45 | void test_sync OF((Byte *compr, uLong comprLen, | ||
| 46 | Byte *uncompr, uLong uncomprLen)); | ||
| 47 | void test_dict_deflate OF((Byte *compr, uLong comprLen)); | ||
| 48 | void test_dict_inflate OF((Byte *compr, uLong comprLen, | ||
| 49 | Byte *uncompr, uLong uncomprLen)); | ||
| 50 | int main OF((int argc, char *argv[])); | ||
| 51 | |||
| 52 | |||
| 53 | #ifdef Z_SOLO | 37 | #ifdef Z_SOLO |
| 54 | 38 | ||
| 55 | void *myalloc OF((void *, unsigned, unsigned)); | 39 | void *myalloc(void *q, unsigned n, unsigned m) { |
| 56 | void myfree OF((void *, void *)); | ||
| 57 | |||
| 58 | void *myalloc(q, n, m) | ||
| 59 | void *q; | ||
| 60 | unsigned n, m; | ||
| 61 | { | ||
| 62 | (void)q; | 40 | (void)q; |
| 63 | return calloc(n, m); | 41 | return calloc(n, m); |
| 64 | } | 42 | } |
| 65 | 43 | ||
| 66 | void myfree(void *q, void *p) | 44 | void myfree(void *q, void *p) { |
| 67 | { | ||
| 68 | (void)q; | 45 | (void)q; |
| 69 | free(p); | 46 | free(p); |
| 70 | } | 47 | } |
| @@ -77,18 +54,11 @@ static free_func zfree = myfree; | |||
| 77 | static alloc_func zalloc = (alloc_func)0; | 54 | static alloc_func zalloc = (alloc_func)0; |
| 78 | static free_func zfree = (free_func)0; | 55 | static free_func zfree = (free_func)0; |
| 79 | 56 | ||
| 80 | void test_compress OF((Byte *compr, uLong comprLen, | ||
| 81 | Byte *uncompr, uLong uncomprLen)); | ||
| 82 | void test_gzio OF((const char *fname, | ||
| 83 | Byte *uncompr, uLong uncomprLen)); | ||
| 84 | |||
| 85 | /* =========================================================================== | 57 | /* =========================================================================== |
| 86 | * Test compress() and uncompress() | 58 | * Test compress() and uncompress() |
| 87 | */ | 59 | */ |
| 88 | void test_compress(compr, comprLen, uncompr, uncomprLen) | 60 | void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, |
| 89 | Byte *compr, *uncompr; | 61 | uLong uncomprLen) { |
| 90 | uLong comprLen, uncomprLen; | ||
| 91 | { | ||
| 92 | int err; | 62 | int err; |
| 93 | uLong len = (uLong)strlen(hello)+1; | 63 | uLong len = (uLong)strlen(hello)+1; |
| 94 | 64 | ||
| @@ -111,11 +81,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) | |||
| 111 | /* =========================================================================== | 81 | /* =========================================================================== |
| 112 | * Test read/write of .gz files | 82 | * Test read/write of .gz files |
| 113 | */ | 83 | */ |
| 114 | void test_gzio(fname, uncompr, uncomprLen) | 84 | void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) { |
| 115 | const char *fname; /* compressed file name */ | ||
| 116 | Byte *uncompr; | ||
| 117 | uLong uncomprLen; | ||
| 118 | { | ||
| 119 | #ifdef NO_GZCOMPRESS | 85 | #ifdef NO_GZCOMPRESS |
| 120 | fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); | 86 | fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); |
| 121 | #else | 87 | #else |
| @@ -197,10 +163,7 @@ void test_gzio(fname, uncompr, uncomprLen) | |||
| 197 | /* =========================================================================== | 163 | /* =========================================================================== |
| 198 | * Test deflate() with small buffers | 164 | * Test deflate() with small buffers |
| 199 | */ | 165 | */ |
| 200 | void test_deflate(compr, comprLen) | 166 | void test_deflate(Byte *compr, uLong comprLen) { |
| 201 | Byte *compr; | ||
| 202 | uLong comprLen; | ||
| 203 | { | ||
| 204 | z_stream c_stream; /* compression stream */ | 167 | z_stream c_stream; /* compression stream */ |
| 205 | int err; | 168 | int err; |
| 206 | uLong len = (uLong)strlen(hello)+1; | 169 | uLong len = (uLong)strlen(hello)+1; |
| @@ -235,10 +198,8 @@ void test_deflate(compr, comprLen) | |||
| 235 | /* =========================================================================== | 198 | /* =========================================================================== |
| 236 | * Test inflate() with small buffers | 199 | * Test inflate() with small buffers |
| 237 | */ | 200 | */ |
| 238 | void test_inflate(compr, comprLen, uncompr, uncomprLen) | 201 | void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, |
| 239 | Byte *compr, *uncompr; | 202 | uLong uncomprLen) { |
| 240 | uLong comprLen, uncomprLen; | ||
| 241 | { | ||
| 242 | int err; | 203 | int err; |
| 243 | z_stream d_stream; /* decompression stream */ | 204 | z_stream d_stream; /* decompression stream */ |
| 244 | 205 | ||
| @@ -276,10 +237,8 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen) | |||
| 276 | /* =========================================================================== | 237 | /* =========================================================================== |
| 277 | * Test deflate() with large buffers and dynamic change of compression level | 238 | * Test deflate() with large buffers and dynamic change of compression level |
| 278 | */ | 239 | */ |
| 279 | void test_large_deflate(compr, comprLen, uncompr, uncomprLen) | 240 | void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, |
| 280 | Byte *compr, *uncompr; | 241 | uLong uncomprLen) { |
| 281 | uLong comprLen, uncomprLen; | ||
| 282 | { | ||
| 283 | z_stream c_stream; /* compression stream */ | 242 | z_stream c_stream; /* compression stream */ |
| 284 | int err; | 243 | int err; |
| 285 | 244 | ||
| @@ -331,10 +290,8 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) | |||
| 331 | /* =========================================================================== | 290 | /* =========================================================================== |
| 332 | * Test inflate() with large buffers | 291 | * Test inflate() with large buffers |
| 333 | */ | 292 | */ |
| 334 | void test_large_inflate(compr, comprLen, uncompr, uncomprLen) | 293 | void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, |
| 335 | Byte *compr, *uncompr; | 294 | uLong uncomprLen) { |
| 336 | uLong comprLen, uncomprLen; | ||
| 337 | { | ||
| 338 | int err; | 295 | int err; |
| 339 | z_stream d_stream; /* decompression stream */ | 296 | z_stream d_stream; /* decompression stream */ |
| 340 | 297 | ||
| @@ -372,10 +329,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) | |||
| 372 | /* =========================================================================== | 329 | /* =========================================================================== |
| 373 | * Test deflate() with full flush | 330 | * Test deflate() with full flush |
| 374 | */ | 331 | */ |
| 375 | void test_flush(compr, comprLen) | 332 | void test_flush(Byte *compr, uLong *comprLen) { |
| 376 | Byte *compr; | ||
| 377 | uLong *comprLen; | ||
| 378 | { | ||
| 379 | z_stream c_stream; /* compression stream */ | 333 | z_stream c_stream; /* compression stream */ |
| 380 | int err; | 334 | int err; |
| 381 | uInt len = (uInt)strlen(hello)+1; | 335 | uInt len = (uInt)strlen(hello)+1; |
| @@ -410,10 +364,7 @@ void test_flush(compr, comprLen) | |||
| 410 | /* =========================================================================== | 364 | /* =========================================================================== |
| 411 | * Test inflateSync() | 365 | * Test inflateSync() |
| 412 | */ | 366 | */ |
| 413 | void test_sync(compr, comprLen, uncompr, uncomprLen) | 367 | void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { |
| 414 | Byte *compr, *uncompr; | ||
| 415 | uLong comprLen, uncomprLen; | ||
| 416 | { | ||
| 417 | int err; | 368 | int err; |
| 418 | z_stream d_stream; /* decompression stream */ | 369 | z_stream d_stream; /* decompression stream */ |
| 419 | 370 | ||
| @@ -453,10 +404,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) | |||
| 453 | /* =========================================================================== | 404 | /* =========================================================================== |
| 454 | * Test deflate() with preset dictionary | 405 | * Test deflate() with preset dictionary |
| 455 | */ | 406 | */ |
| 456 | void test_dict_deflate(compr, comprLen) | 407 | void test_dict_deflate(Byte *compr, uLong comprLen) { |
| 457 | Byte *compr; | ||
| 458 | uLong comprLen; | ||
| 459 | { | ||
| 460 | z_stream c_stream; /* compression stream */ | 408 | z_stream c_stream; /* compression stream */ |
| 461 | int err; | 409 | int err; |
| 462 | 410 | ||
| @@ -490,10 +438,8 @@ void test_dict_deflate(compr, comprLen) | |||
| 490 | /* =========================================================================== | 438 | /* =========================================================================== |
| 491 | * Test inflate() with a preset dictionary | 439 | * Test inflate() with a preset dictionary |
| 492 | */ | 440 | */ |
| 493 | void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) | 441 | void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, |
| 494 | Byte *compr, *uncompr; | 442 | uLong uncomprLen) { |
| 495 | uLong comprLen, uncomprLen; | ||
| 496 | { | ||
| 497 | int err; | 443 | int err; |
| 498 | z_stream d_stream; /* decompression stream */ | 444 | z_stream d_stream; /* decompression stream */ |
| 499 | 445 | ||
| @@ -541,10 +487,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) | |||
| 541 | * Usage: example [output.gz [input.gz]] | 487 | * Usage: example [output.gz [input.gz]] |
| 542 | */ | 488 | */ |
| 543 | 489 | ||
| 544 | int main(argc, argv) | 490 | int main(int argc, char *argv[]) { |
| 545 | int argc; | ||
| 546 | char *argv[]; | ||
| 547 | { | ||
| 548 | Byte *compr, *uncompr; | 491 | Byte *compr, *uncompr; |
| 549 | uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ | 492 | uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ |
| 550 | uLong uncomprLen = comprLen; | 493 | uLong uncomprLen = comprLen; |
diff --git a/test/minigzip.c b/test/minigzip.c index a649d2b..8a21ddf 100644 --- a/test/minigzip.c +++ b/test/minigzip.c | |||
| @@ -59,7 +59,7 @@ | |||
| 59 | 59 | ||
| 60 | #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) | 60 | #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) |
| 61 | #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ | 61 | #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ |
| 62 | extern int unlink OF((const char *)); | 62 | extern int unlink(const char *); |
| 63 | #endif | 63 | #endif |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| @@ -149,20 +149,12 @@ static void pwinerror (s) | |||
| 149 | # include <unistd.h> /* for unlink() */ | 149 | # include <unistd.h> /* for unlink() */ |
| 150 | #endif | 150 | #endif |
| 151 | 151 | ||
| 152 | void *myalloc OF((void *, unsigned, unsigned)); | 152 | void *myalloc(void *q, unsigned n, unsigned m) { |
| 153 | void myfree OF((void *, void *)); | ||
| 154 | |||
| 155 | void *myalloc(q, n, m) | ||
| 156 | void *q; | ||
| 157 | unsigned n, m; | ||
| 158 | { | ||
| 159 | (void)q; | 153 | (void)q; |
| 160 | return calloc(n, m); | 154 | return calloc(n, m); |
| 161 | } | 155 | } |
| 162 | 156 | ||
| 163 | void myfree(q, p) | 157 | void myfree(void *q, void *p) { |
| 164 | void *q, *p; | ||
| 165 | { | ||
| 166 | (void)q; | 158 | (void)q; |
| 167 | free(p); | 159 | free(p); |
| 168 | } | 160 | } |
| @@ -175,29 +167,7 @@ typedef struct gzFile_s { | |||
| 175 | z_stream strm; | 167 | z_stream strm; |
| 176 | } *gzFile; | 168 | } *gzFile; |
| 177 | 169 | ||
| 178 | gzFile gzopen OF((const char *, const char *)); | 170 | gzFile gz_open(const char *path, int fd, const char *mode) { |
| 179 | gzFile gzdopen OF((int, const char *)); | ||
| 180 | gzFile gz_open OF((const char *, int, const char *)); | ||
| 181 | |||
| 182 | gzFile gzopen(path, mode) | ||
| 183 | const char *path; | ||
| 184 | const char *mode; | ||
| 185 | { | ||
| 186 | return gz_open(path, -1, mode); | ||
| 187 | } | ||
| 188 | |||
| 189 | gzFile gzdopen(fd, mode) | ||
| 190 | int fd; | ||
| 191 | const char *mode; | ||
| 192 | { | ||
| 193 | return gz_open(NULL, fd, mode); | ||
| 194 | } | ||
| 195 | |||
| 196 | gzFile gz_open(path, fd, mode) | ||
| 197 | const char *path; | ||
| 198 | int fd; | ||
| 199 | const char *mode; | ||
| 200 | { | ||
| 201 | gzFile gz; | 171 | gzFile gz; |
| 202 | int ret; | 172 | int ret; |
| 203 | 173 | ||
| @@ -231,13 +201,15 @@ gzFile gz_open(path, fd, mode) | |||
| 231 | return gz; | 201 | return gz; |
| 232 | } | 202 | } |
| 233 | 203 | ||
| 234 | int gzwrite OF((gzFile, const void *, unsigned)); | 204 | gzFile gzopen(const char *path, const char *mode) { |
| 205 | return gz_open(path, -1, mode); | ||
| 206 | } | ||
| 235 | 207 | ||
| 236 | int gzwrite(gz, buf, len) | 208 | gzFile gzdopen(int fd, const char *mode) { |
| 237 | gzFile gz; | 209 | return gz_open(NULL, fd, mode); |
| 238 | const void *buf; | 210 | } |
| 239 | unsigned len; | 211 | |
| 240 | { | 212 | int gzwrite(gzFile gz, const void *buf, unsigned len) { |
| 241 | z_stream *strm; | 213 | z_stream *strm; |
| 242 | unsigned char out[BUFLEN]; | 214 | unsigned char out[BUFLEN]; |
| 243 | 215 | ||
| @@ -255,13 +227,7 @@ int gzwrite(gz, buf, len) | |||
| 255 | return len; | 227 | return len; |
| 256 | } | 228 | } |
| 257 | 229 | ||
| 258 | int gzread OF((gzFile, void *, unsigned)); | 230 | int gzread(gzFile gz, void *buf, unsigned len) { |
| 259 | |||
| 260 | int gzread(gz, buf, len) | ||
| 261 | gzFile gz; | ||
| 262 | void *buf; | ||
| 263 | unsigned len; | ||
| 264 | { | ||
| 265 | int ret; | 231 | int ret; |
| 266 | unsigned got; | 232 | unsigned got; |
| 267 | unsigned char in[1]; | 233 | unsigned char in[1]; |
| @@ -292,11 +258,7 @@ int gzread(gz, buf, len) | |||
| 292 | return len - strm->avail_out; | 258 | return len - strm->avail_out; |
| 293 | } | 259 | } |
| 294 | 260 | ||
| 295 | int gzclose OF((gzFile)); | 261 | int gzclose(gzFile gz) { |
| 296 | |||
| 297 | int gzclose(gz) | ||
| 298 | gzFile gz; | ||
| 299 | { | ||
| 300 | z_stream *strm; | 262 | z_stream *strm; |
| 301 | unsigned char out[BUFLEN]; | 263 | unsigned char out[BUFLEN]; |
| 302 | 264 | ||
| @@ -321,12 +283,7 @@ int gzclose(gz) | |||
| 321 | return Z_OK; | 283 | return Z_OK; |
| 322 | } | 284 | } |
| 323 | 285 | ||
| 324 | const char *gzerror OF((gzFile, int *)); | 286 | const char *gzerror(gzFile gz, int *err) { |
| 325 | |||
| 326 | const char *gzerror(gz, err) | ||
| 327 | gzFile gz; | ||
| 328 | int *err; | ||
| 329 | { | ||
| 330 | *err = gz->err; | 287 | *err = gz->err; |
| 331 | return gz->msg; | 288 | return gz->msg; |
| 332 | } | 289 | } |
| @@ -335,67 +292,20 @@ const char *gzerror(gz, err) | |||
| 335 | 292 | ||
| 336 | static char *prog; | 293 | static char *prog; |
| 337 | 294 | ||
| 338 | void error OF((const char *msg)); | ||
| 339 | void gz_compress OF((FILE *in, gzFile out)); | ||
| 340 | #ifdef USE_MMAP | ||
| 341 | int gz_compress_mmap OF((FILE *in, gzFile out)); | ||
| 342 | #endif | ||
| 343 | void gz_uncompress OF((gzFile in, FILE *out)); | ||
| 344 | void file_compress OF((char *file, char *mode)); | ||
| 345 | void file_uncompress OF((char *file)); | ||
| 346 | int main OF((int argc, char *argv[])); | ||
| 347 | |||
| 348 | /* =========================================================================== | 295 | /* =========================================================================== |
| 349 | * Display error message and exit | 296 | * Display error message and exit |
| 350 | */ | 297 | */ |
| 351 | void error(msg) | 298 | void error(const char *msg) { |
| 352 | const char *msg; | ||
| 353 | { | ||
| 354 | fprintf(stderr, "%s: %s\n", prog, msg); | 299 | fprintf(stderr, "%s: %s\n", prog, msg); |
| 355 | exit(1); | 300 | exit(1); |
| 356 | } | 301 | } |
| 357 | 302 | ||
| 358 | /* =========================================================================== | ||
| 359 | * Compress input to output then close both files. | ||
| 360 | */ | ||
| 361 | |||
| 362 | void gz_compress(in, out) | ||
| 363 | FILE *in; | ||
| 364 | gzFile out; | ||
| 365 | { | ||
| 366 | local char buf[BUFLEN]; | ||
| 367 | int len; | ||
| 368 | int err; | ||
| 369 | |||
| 370 | #ifdef USE_MMAP | ||
| 371 | /* Try first compressing with mmap. If mmap fails (minigzip used in a | ||
| 372 | * pipe), use the normal fread loop. | ||
| 373 | */ | ||
| 374 | if (gz_compress_mmap(in, out) == Z_OK) return; | ||
| 375 | #endif | ||
| 376 | for (;;) { | ||
| 377 | len = (int)fread(buf, 1, sizeof(buf), in); | ||
| 378 | if (ferror(in)) { | ||
| 379 | perror("fread"); | ||
| 380 | exit(1); | ||
| 381 | } | ||
| 382 | if (len == 0) break; | ||
| 383 | |||
| 384 | if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); | ||
| 385 | } | ||
| 386 | fclose(in); | ||
| 387 | if (gzclose(out) != Z_OK) error("failed gzclose"); | ||
| 388 | } | ||
| 389 | |||
| 390 | #ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */ | 303 | #ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */ |
| 391 | 304 | ||
| 392 | /* Try compressing the input file at once using mmap. Return Z_OK if | 305 | /* Try compressing the input file at once using mmap. Return Z_OK if |
| 393 | * if success, Z_ERRNO otherwise. | 306 | * if success, Z_ERRNO otherwise. |
| 394 | */ | 307 | */ |
| 395 | int gz_compress_mmap(in, out) | 308 | int gz_compress_mmap(FILE *in, gzFile out) { |
| 396 | FILE *in; | ||
| 397 | gzFile out; | ||
| 398 | { | ||
| 399 | int len; | 309 | int len; |
| 400 | int err; | 310 | int err; |
| 401 | int ifd = fileno(in); | 311 | int ifd = fileno(in); |
| @@ -425,12 +335,38 @@ int gz_compress_mmap(in, out) | |||
| 425 | #endif /* USE_MMAP */ | 335 | #endif /* USE_MMAP */ |
| 426 | 336 | ||
| 427 | /* =========================================================================== | 337 | /* =========================================================================== |
| 338 | * Compress input to output then close both files. | ||
| 339 | */ | ||
| 340 | |||
| 341 | void gz_compress(FILE *in, gzFile out) { | ||
| 342 | local char buf[BUFLEN]; | ||
| 343 | int len; | ||
| 344 | int err; | ||
| 345 | |||
| 346 | #ifdef USE_MMAP | ||
| 347 | /* Try first compressing with mmap. If mmap fails (minigzip used in a | ||
| 348 | * pipe), use the normal fread loop. | ||
| 349 | */ | ||
| 350 | if (gz_compress_mmap(in, out) == Z_OK) return; | ||
| 351 | #endif | ||
| 352 | for (;;) { | ||
| 353 | len = (int)fread(buf, 1, sizeof(buf), in); | ||
| 354 | if (ferror(in)) { | ||
| 355 | perror("fread"); | ||
| 356 | exit(1); | ||
| 357 | } | ||
| 358 | if (len == 0) break; | ||
| 359 | |||
| 360 | if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); | ||
| 361 | } | ||
| 362 | fclose(in); | ||
| 363 | if (gzclose(out) != Z_OK) error("failed gzclose"); | ||
| 364 | } | ||
| 365 | |||
| 366 | /* =========================================================================== | ||
| 428 | * Uncompress input to output then close both files. | 367 | * Uncompress input to output then close both files. |
| 429 | */ | 368 | */ |
| 430 | void gz_uncompress(in, out) | 369 | void gz_uncompress(gzFile in, FILE *out) { |
| 431 | gzFile in; | ||
| 432 | FILE *out; | ||
| 433 | { | ||
| 434 | local char buf[BUFLEN]; | 370 | local char buf[BUFLEN]; |
| 435 | int len; | 371 | int len; |
| 436 | int err; | 372 | int err; |
| @@ -454,10 +390,7 @@ void gz_uncompress(in, out) | |||
| 454 | * Compress the given file: create a corresponding .gz file and remove the | 390 | * Compress the given file: create a corresponding .gz file and remove the |
| 455 | * original. | 391 | * original. |
| 456 | */ | 392 | */ |
| 457 | void file_compress(file, mode) | 393 | void file_compress(char *file, char *mode) { |
| 458 | char *file; | ||
| 459 | char *mode; | ||
| 460 | { | ||
| 461 | local char outfile[MAX_NAME_LEN]; | 394 | local char outfile[MAX_NAME_LEN]; |
| 462 | FILE *in; | 395 | FILE *in; |
| 463 | gzFile out; | 396 | gzFile out; |
| @@ -493,9 +426,7 @@ void file_compress(file, mode) | |||
| 493 | /* =========================================================================== | 426 | /* =========================================================================== |
| 494 | * Uncompress the given file and remove the original. | 427 | * Uncompress the given file and remove the original. |
| 495 | */ | 428 | */ |
| 496 | void file_uncompress(file) | 429 | void file_uncompress(char *file) { |
| 497 | char *file; | ||
| 498 | { | ||
| 499 | local char buf[MAX_NAME_LEN]; | 430 | local char buf[MAX_NAME_LEN]; |
| 500 | char *infile, *outfile; | 431 | char *infile, *outfile; |
| 501 | FILE *out; | 432 | FILE *out; |
| @@ -553,10 +484,7 @@ void file_uncompress(file) | |||
| 553 | * -1 to -9 : compression level | 484 | * -1 to -9 : compression level |
| 554 | */ | 485 | */ |
| 555 | 486 | ||
| 556 | int main(argc, argv) | 487 | int main(int argc, char *argv[]) { |
| 557 | int argc; | ||
| 558 | char *argv[]; | ||
| 559 | { | ||
| 560 | int copyout = 0; | 488 | int copyout = 0; |
| 561 | int uncompr = 0; | 489 | int uncompr = 0; |
| 562 | gzFile file; | 490 | gzFile file; |
