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 /gzwrite.c | |
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.
Diffstat (limited to 'gzwrite.c')
-rw-r--r-- | gzwrite.c | 19 |
1 files changed, 12 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 -- */ |