aboutsummaryrefslogtreecommitdiff
path: root/gzlib.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2023-04-14 01:42:03 -0700
committerMark Adler <madler@alumni.caltech.edu>2023-04-15 21:17:31 -0700
commite9d5486e6635141f589e110fd789648aa08e9544 (patch)
treea78b9ccd92b05af7cd5776b688d9c3eb3a81a40a /gzlib.c
parent5799c14c8526bf1aaa130c021982f831d155b46d (diff)
downloadzlib-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 'gzlib.c')
-rw-r--r--gzlib.c97
1 files changed, 20 insertions, 77 deletions
diff --git a/gzlib.c b/gzlib.c
index 55da46a..2b446c4 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -15,10 +15,6 @@
15#endif 15#endif
16#endif 16#endif
17 17
18/* Local functions */
19local void gz_reset OF((gz_statep));
20local gzFile gz_open OF((const void *, int, const char *));
21
22#if defined UNDER_CE 18#if defined UNDER_CE
23 19
24/* Map the Windows error number in ERROR to a locale-dependent error message 20/* Map the Windows error number in ERROR to a locale-dependent error message
@@ -30,9 +26,7 @@ local gzFile gz_open OF((const void *, int, const char *));
30 26
31 The gz_strwinerror function does not change the current setting of 27 The gz_strwinerror function does not change the current setting of
32 GetLastError. */ 28 GetLastError. */
33char ZLIB_INTERNAL *gz_strwinerror(error) 29char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
34 DWORD error;
35{
36 static char buf[1024]; 30 static char buf[1024];
37 31
38 wchar_t *msgbuf; 32 wchar_t *msgbuf;
@@ -72,9 +66,7 @@ char ZLIB_INTERNAL *gz_strwinerror(error)
72#endif /* UNDER_CE */ 66#endif /* UNDER_CE */
73 67
74/* Reset gzip file state */ 68/* Reset gzip file state */
75local void gz_reset(state) 69local void gz_reset(gz_statep state) {
76 gz_statep state;
77{
78 state->x.have = 0; /* no output data available */ 70 state->x.have = 0; /* no output data available */
79 if (state->mode == GZ_READ) { /* for reading ... */ 71 if (state->mode == GZ_READ) { /* for reading ... */
80 state->eof = 0; /* not at end of file */ 72 state->eof = 0; /* not at end of file */
@@ -90,11 +82,7 @@ local void gz_reset(state)
90} 82}
91 83
92/* Open a gzip file either by name or file descriptor. */ 84/* Open a gzip file either by name or file descriptor. */
93local gzFile gz_open(path, fd, mode) 85local gzFile gz_open(const void *path, int fd, const char *mode) {
94 const void *path;
95 int fd;
96 const char *mode;
97{
98 gz_statep state; 86 gz_statep state;
99 z_size_t len; 87 z_size_t len;
100 int oflag; 88 int oflag;
@@ -269,26 +257,17 @@ local gzFile gz_open(path, fd, mode)
269} 257}
270 258
271/* -- see zlib.h -- */ 259/* -- see zlib.h -- */
272gzFile ZEXPORT gzopen(path, mode) 260gzFile ZEXPORT gzopen(const char *path, const char *mode) {
273 const char *path;
274 const char *mode;
275{
276 return gz_open(path, -1, mode); 261 return gz_open(path, -1, mode);
277} 262}
278 263
279/* -- see zlib.h -- */ 264/* -- see zlib.h -- */
280gzFile ZEXPORT gzopen64(path, mode) 265gzFile ZEXPORT gzopen64(const char *path, const char *mode) {
281 const char *path;
282 const char *mode;
283{
284 return gz_open(path, -1, mode); 266 return gz_open(path, -1, mode);
285} 267}
286 268
287/* -- see zlib.h -- */ 269/* -- see zlib.h -- */
288gzFile ZEXPORT gzdopen(fd, mode) 270gzFile ZEXPORT gzdopen(int fd, const char *mode) {
289 int fd;
290 const char *mode;
291{
292 char *path; /* identifier for error messages */ 271 char *path; /* identifier for error messages */
293 gzFile gz; 272 gzFile gz;
294 273
@@ -306,19 +285,13 @@ gzFile ZEXPORT gzdopen(fd, mode)
306 285
307/* -- see zlib.h -- */ 286/* -- see zlib.h -- */
308#ifdef WIDECHAR 287#ifdef WIDECHAR
309gzFile ZEXPORT gzopen_w(path, mode) 288gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) {
310 const wchar_t *path;
311 const char *mode;
312{
313 return gz_open(path, -2, mode); 289 return gz_open(path, -2, mode);
314} 290}
315#endif 291#endif
316 292
317/* -- see zlib.h -- */ 293/* -- see zlib.h -- */
318int ZEXPORT gzbuffer(file, size) 294int ZEXPORT gzbuffer(gzFile file, unsigned size) {
319 gzFile file;
320 unsigned size;
321{
322 gz_statep state; 295 gz_statep state;
323 296
324 /* get internal structure and check integrity */ 297 /* get internal structure and check integrity */
@@ -342,9 +315,7 @@ int ZEXPORT gzbuffer(file, size)
342} 315}
343 316
344/* -- see zlib.h -- */ 317/* -- see zlib.h -- */
345int ZEXPORT gzrewind(file) 318int ZEXPORT gzrewind(gzFile file) {
346 gzFile file;
347{
348 gz_statep state; 319 gz_statep state;
349 320
350 /* get internal structure */ 321 /* get internal structure */
@@ -365,11 +336,7 @@ int ZEXPORT gzrewind(file)
365} 336}
366 337
367/* -- see zlib.h -- */ 338/* -- see zlib.h -- */
368z_off64_t ZEXPORT gzseek64(file, offset, whence) 339z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
369 gzFile file;
370 z_off64_t offset;
371 int whence;
372{
373 unsigned n; 340 unsigned n;
374 z_off64_t ret; 341 z_off64_t ret;
375 gz_statep state; 342 gz_statep state;
@@ -442,11 +409,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
442} 409}
443 410
444/* -- see zlib.h -- */ 411/* -- see zlib.h -- */
445z_off_t ZEXPORT gzseek(file, offset, whence) 412z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
446 gzFile file;
447 z_off_t offset;
448 int whence;
449{
450 z_off64_t ret; 413 z_off64_t ret;
451 414
452 ret = gzseek64(file, (z_off64_t)offset, whence); 415 ret = gzseek64(file, (z_off64_t)offset, whence);
@@ -454,9 +417,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence)
454} 417}
455 418
456/* -- see zlib.h -- */ 419/* -- see zlib.h -- */
457z_off64_t ZEXPORT gztell64(file) 420z_off64_t ZEXPORT gztell64(gzFile file) {
458 gzFile file;
459{
460 gz_statep state; 421 gz_statep state;
461 422
462 /* get internal structure and check integrity */ 423 /* get internal structure and check integrity */
@@ -471,9 +432,7 @@ z_off64_t ZEXPORT gztell64(file)
471} 432}
472 433
473/* -- see zlib.h -- */ 434/* -- see zlib.h -- */
474z_off_t ZEXPORT gztell(file) 435z_off_t ZEXPORT gztell(gzFile file) {
475 gzFile file;
476{
477 z_off64_t ret; 436 z_off64_t ret;
478 437
479 ret = gztell64(file); 438 ret = gztell64(file);
@@ -481,9 +440,7 @@ z_off_t ZEXPORT gztell(file)
481} 440}
482 441
483/* -- see zlib.h -- */ 442/* -- see zlib.h -- */
484z_off64_t ZEXPORT gzoffset64(file) 443z_off64_t ZEXPORT gzoffset64(gzFile file) {
485 gzFile file;
486{
487 z_off64_t offset; 444 z_off64_t offset;
488 gz_statep state; 445 gz_statep state;
489 446
@@ -504,9 +461,7 @@ z_off64_t ZEXPORT gzoffset64(file)
504} 461}
505 462
506/* -- see zlib.h -- */ 463/* -- see zlib.h -- */
507z_off_t ZEXPORT gzoffset(file) 464z_off_t ZEXPORT gzoffset(gzFile file) {
508 gzFile file;
509{
510 z_off64_t ret; 465 z_off64_t ret;
511 466
512 ret = gzoffset64(file); 467 ret = gzoffset64(file);
@@ -514,9 +469,7 @@ z_off_t ZEXPORT gzoffset(file)
514} 469}
515 470
516/* -- see zlib.h -- */ 471/* -- see zlib.h -- */
517int ZEXPORT gzeof(file) 472int ZEXPORT gzeof(gzFile file) {
518 gzFile file;
519{
520 gz_statep state; 473 gz_statep state;
521 474
522 /* get internal structure and check integrity */ 475 /* get internal structure and check integrity */
@@ -531,10 +484,7 @@ int ZEXPORT gzeof(file)
531} 484}
532 485
533/* -- see zlib.h -- */ 486/* -- see zlib.h -- */
534const char * ZEXPORT gzerror(file, errnum) 487const char * ZEXPORT gzerror(gzFile file, int *errnum) {
535 gzFile file;
536 int *errnum;
537{
538 gz_statep state; 488 gz_statep state;
539 489
540 /* get internal structure and check integrity */ 490 /* get internal structure and check integrity */
@@ -552,9 +502,7 @@ const char * ZEXPORT gzerror(file, errnum)
552} 502}
553 503
554/* -- see zlib.h -- */ 504/* -- see zlib.h -- */
555void ZEXPORT gzclearerr(file) 505void ZEXPORT gzclearerr(gzFile file) {
556 gzFile file;
557{
558 gz_statep state; 506 gz_statep state;
559 507
560 /* get internal structure and check integrity */ 508 /* get internal structure and check integrity */
@@ -578,11 +526,7 @@ void ZEXPORT gzclearerr(file)
578 memory). Simply save the error message as a static string. If there is an 526 memory). Simply save the error message as a static string. If there is an
579 allocation failure constructing the error message, then convert the error to 527 allocation failure constructing the error message, then convert the error to
580 out of memory. */ 528 out of memory. */
581void ZLIB_INTERNAL gz_error(state, err, msg) 529void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
582 gz_statep state;
583 int err;
584 const char *msg;
585{
586 /* free previously allocated message and clear */ 530 /* free previously allocated message and clear */
587 if (state->msg != NULL) { 531 if (state->msg != NULL) {
588 if (state->err != Z_MEM_ERROR) 532 if (state->err != Z_MEM_ERROR)
@@ -624,8 +568,7 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
624 available) -- we need to do this to cover cases where 2's complement not 568 available) -- we need to do this to cover cases where 2's complement not
625 used, since C standard permits 1's complement and sign-bit representations, 569 used, since C standard permits 1's complement and sign-bit representations,
626 otherwise we could just use ((unsigned)-1) >> 1 */ 570 otherwise we could just use ((unsigned)-1) >> 1 */
627unsigned ZLIB_INTERNAL gz_intmax() 571unsigned ZLIB_INTERNAL gz_intmax(void) {
628{
629 unsigned p, q; 572 unsigned p, q;
630 573
631 p = 1; 574 p = 1;