提交 b06dee43 编写于 作者: M Mark Adler

Add gzvprintf() as an undocumented function in zlib.

The function is only available if stdarg.h is available.
上级 dd5d0940
...@@ -307,12 +307,11 @@ int ZEXPORT gzputs(file, str) ...@@ -307,12 +307,11 @@ int ZEXPORT gzputs(file, str)
#include <stdarg.h> #include <stdarg.h>
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
{ {
int size, len; int size, len;
gz_statep state; gz_statep state;
z_streamp strm; z_streamp strm;
va_list va;
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
...@@ -342,25 +341,20 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) ...@@ -342,25 +341,20 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
/* do the printf() into the input buffer, put length in len */ /* do the printf() into the input buffer, put length in len */
size = (int)(state->size); size = (int)(state->size);
state->in[size - 1] = 0; state->in[size - 1] = 0;
va_start(va, format);
#ifdef NO_vsnprintf #ifdef NO_vsnprintf
# ifdef HAS_vsprintf_void # ifdef HAS_vsprintf_void
(void)vsprintf((char *)(state->in), format, va); (void)vsprintf((char *)(state->in), format, va);
va_end(va);
for (len = 0; len < size; len++) for (len = 0; len < size; len++)
if (state->in[len] == 0) break; if (state->in[len] == 0) break;
# else # else
len = vsprintf((char *)(state->in), format, va); len = vsprintf((char *)(state->in), format, va);
va_end(va);
# endif # endif
#else #else
# ifdef HAS_vsnprintf_void # ifdef HAS_vsnprintf_void
(void)vsnprintf((char *)(state->in), size, format, va); (void)vsnprintf((char *)(state->in), size, format, va);
va_end(va);
len = strlen((char *)(state->in)); len = strlen((char *)(state->in));
# else # else
len = vsnprintf((char *)(state->in), size, format, va); len = vsnprintf((char *)(state->in), size, format, va);
va_end(va);
# endif # endif
#endif #endif
...@@ -375,6 +369,17 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) ...@@ -375,6 +369,17 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
return len; return len;
} }
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
{
va_list va;
int ret;
va_start(va, format);
ret = gzvprintf(file, format, va);
va_end(va);
return ret;
}
#else /* !STDC && !Z_HAVE_STDARG_H */ #else /* !STDC && !Z_HAVE_STDARG_H */
/* -- see zlib.h -- */ /* -- see zlib.h -- */
......
...@@ -427,6 +427,12 @@ typedef uLong FAR uLongf; ...@@ -427,6 +427,12 @@ typedef uLong FAR uLongf;
# endif # endif
#endif #endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifndef Z_SOLO
# include <stdarg.h> /* for va_list */
# endif
#endif
#ifdef _WIN32 #ifdef _WIN32
# ifndef Z_SOLO # ifndef Z_SOLO
# include <stddef.h> /* for wchar_t */ # include <stddef.h> /* for wchar_t */
......
...@@ -429,6 +429,12 @@ typedef uLong FAR uLongf; ...@@ -429,6 +429,12 @@ typedef uLong FAR uLongf;
# endif # endif
#endif #endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifndef Z_SOLO
# include <stdarg.h> /* for va_list */
# endif
#endif
#ifdef _WIN32 #ifdef _WIN32
# ifndef Z_SOLO # ifndef Z_SOLO
# include <stddef.h> /* for wchar_t */ # include <stddef.h> /* for wchar_t */
......
...@@ -427,6 +427,12 @@ typedef uLong FAR uLongf; ...@@ -427,6 +427,12 @@ typedef uLong FAR uLongf;
# endif # endif
#endif #endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifndef Z_SOLO
# include <stdarg.h> /* for va_list */
# endif
#endif
#ifdef _WIN32 #ifdef _WIN32
# ifndef Z_SOLO # ifndef Z_SOLO
# include <stddef.h> /* for wchar_t */ # include <stddef.h> /* for wchar_t */
......
...@@ -1753,6 +1753,12 @@ ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); ...@@ -1753,6 +1753,12 @@ ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
const char *mode)); const char *mode));
#endif #endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifndef Z_SOLO
ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, const char *format,
va_list va));
# endif
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册