diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2013-03-22 18:32:37 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2013-03-22 18:32:37 -0700 |
commit | b06dee43696b5057ee8e1b9700655ad9e7d89669 (patch) | |
tree | 2c2faf2573f390a54dce9cdbda5e5e9747af087f | |
parent | dd5d0940e93f2196a7791b1bf052d68309a7d45f (diff) | |
download | zlib-b06dee43696b5057ee8e1b9700655ad9e7d89669.tar.gz zlib-b06dee43696b5057ee8e1b9700655ad9e7d89669.tar.bz2 zlib-b06dee43696b5057ee8e1b9700655ad9e7d89669.zip |
Add gzvprintf() as an undocumented function in zlib.
The function is only available if stdarg.h is available.
-rw-r--r-- | gzwrite.c | 19 | ||||
-rw-r--r-- | zconf.h | 6 | ||||
-rw-r--r-- | zconf.h.cmakein | 6 | ||||
-rw-r--r-- | zconf.h.in | 6 | ||||
-rw-r--r-- | zlib.h | 6 |
5 files changed, 36 insertions, 7 deletions
@@ -307,12 +307,11 @@ int ZEXPORT gzputs(file, str) | |||
307 | #include <stdarg.h> | 307 | #include <stdarg.h> |
308 | 308 | ||
309 | /* -- see zlib.h -- */ | 309 | /* -- see zlib.h -- */ |
310 | int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) | 310 | int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) |
311 | { | 311 | { |
312 | int size, len; | 312 | int size, len; |
313 | gz_statep state; | 313 | gz_statep state; |
314 | z_streamp strm; | 314 | z_streamp strm; |
315 | va_list va; | ||
316 | 315 | ||
317 | /* get internal structure */ | 316 | /* get internal structure */ |
318 | if (file == NULL) | 317 | if (file == NULL) |
@@ -342,25 +341,20 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) | |||
342 | /* do the printf() into the input buffer, put length in len */ | 341 | /* do the printf() into the input buffer, put length in len */ |
343 | size = (int)(state->size); | 342 | size = (int)(state->size); |
344 | state->in[size - 1] = 0; | 343 | state->in[size - 1] = 0; |
345 | va_start(va, format); | ||
346 | #ifdef NO_vsnprintf | 344 | #ifdef NO_vsnprintf |
347 | # ifdef HAS_vsprintf_void | 345 | # ifdef HAS_vsprintf_void |
348 | (void)vsprintf((char *)(state->in), format, va); | 346 | (void)vsprintf((char *)(state->in), format, va); |
349 | va_end(va); | ||
350 | for (len = 0; len < size; len++) | 347 | for (len = 0; len < size; len++) |
351 | if (state->in[len] == 0) break; | 348 | if (state->in[len] == 0) break; |
352 | # else | 349 | # else |
353 | len = vsprintf((char *)(state->in), format, va); | 350 | len = vsprintf((char *)(state->in), format, va); |
354 | va_end(va); | ||
355 | # endif | 351 | # endif |
356 | #else | 352 | #else |
357 | # ifdef HAS_vsnprintf_void | 353 | # ifdef HAS_vsnprintf_void |
358 | (void)vsnprintf((char *)(state->in), size, format, va); | 354 | (void)vsnprintf((char *)(state->in), size, format, va); |
359 | va_end(va); | ||
360 | len = strlen((char *)(state->in)); | 355 | len = strlen((char *)(state->in)); |
361 | # else | 356 | # else |
362 | len = vsnprintf((char *)(state->in), size, format, va); | 357 | len = vsnprintf((char *)(state->in), size, format, va); |
363 | va_end(va); | ||
364 | # endif | 358 | # endif |
365 | #endif | 359 | #endif |
366 | 360 | ||
@@ -375,6 +369,17 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) | |||
375 | return len; | 369 | return len; |
376 | } | 370 | } |
377 | 371 | ||
372 | int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) | ||
373 | { | ||
374 | va_list va; | ||
375 | int ret; | ||
376 | |||
377 | va_start(va, format); | ||
378 | ret = gzvprintf(file, format, va); | ||
379 | va_end(va); | ||
380 | return ret; | ||
381 | } | ||
382 | |||
378 | #else /* !STDC && !Z_HAVE_STDARG_H */ | 383 | #else /* !STDC && !Z_HAVE_STDARG_H */ |
379 | 384 | ||
380 | /* -- see zlib.h -- */ | 385 | /* -- see zlib.h -- */ |
@@ -427,6 +427,12 @@ typedef uLong FAR uLongf; | |||
427 | # endif | 427 | # endif |
428 | #endif | 428 | #endif |
429 | 429 | ||
430 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) | ||
431 | # ifndef Z_SOLO | ||
432 | # include <stdarg.h> /* for va_list */ | ||
433 | # endif | ||
434 | #endif | ||
435 | |||
430 | #ifdef _WIN32 | 436 | #ifdef _WIN32 |
431 | # ifndef Z_SOLO | 437 | # ifndef Z_SOLO |
432 | # include <stddef.h> /* for wchar_t */ | 438 | # include <stddef.h> /* for wchar_t */ |
diff --git a/zconf.h.cmakein b/zconf.h.cmakein index 8f1956c..028be15 100644 --- a/zconf.h.cmakein +++ b/zconf.h.cmakein | |||
@@ -429,6 +429,12 @@ typedef uLong FAR uLongf; | |||
429 | # endif | 429 | # endif |
430 | #endif | 430 | #endif |
431 | 431 | ||
432 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) | ||
433 | # ifndef Z_SOLO | ||
434 | # include <stdarg.h> /* for va_list */ | ||
435 | # endif | ||
436 | #endif | ||
437 | |||
432 | #ifdef _WIN32 | 438 | #ifdef _WIN32 |
433 | # ifndef Z_SOLO | 439 | # ifndef Z_SOLO |
434 | # include <stddef.h> /* for wchar_t */ | 440 | # include <stddef.h> /* for wchar_t */ |
@@ -427,6 +427,12 @@ typedef uLong FAR uLongf; | |||
427 | # endif | 427 | # endif |
428 | #endif | 428 | #endif |
429 | 429 | ||
430 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) | ||
431 | # ifndef Z_SOLO | ||
432 | # include <stdarg.h> /* for va_list */ | ||
433 | # endif | ||
434 | #endif | ||
435 | |||
430 | #ifdef _WIN32 | 436 | #ifdef _WIN32 |
431 | # ifndef Z_SOLO | 437 | # ifndef Z_SOLO |
432 | # include <stddef.h> /* for wchar_t */ | 438 | # include <stddef.h> /* for wchar_t */ |
@@ -1753,6 +1753,12 @@ ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); | |||
1753 | ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, | 1753 | ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, |
1754 | const char *mode)); | 1754 | const char *mode)); |
1755 | #endif | 1755 | #endif |
1756 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) | ||
1757 | # ifndef Z_SOLO | ||
1758 | ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, const char *format, | ||
1759 | va_list va)); | ||
1760 | # endif | ||
1761 | #endif | ||
1756 | 1762 | ||
1757 | #ifdef __cplusplus | 1763 | #ifdef __cplusplus |
1758 | } | 1764 | } |