1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 2003 Matthias Clasen
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 * Modified by the GLib Team and others 2003. See the AUTHORS
20 * file for a list of people on the GLib Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GLib at ftp://ftp.gtk.org/pub/gtk/.
30 #include "vasnprintf.h"
33 int _g_gnulib_printf (char const *format, ...)
38 va_start (args, format);
39 retval = _g_gnulib_vprintf (format, args);
45 int _g_gnulib_fprintf (FILE *file, char const *format, ...)
50 va_start (args, format);
51 retval = _g_gnulib_vfprintf (file, format, args);
57 int _g_gnulib_sprintf (char *string, char const *format, ...)
62 va_start (args, format);
63 retval = _g_gnulib_vsprintf (string, format, args);
69 int _g_gnulib_snprintf (char *string, size_t n, char const *format, ...)
74 va_start (args, format);
75 retval = _g_gnulib_vsnprintf (string, n, format, args);
81 int _g_gnulib_vprintf (char const *format, va_list args)
83 return _g_gnulib_vfprintf (stdout, format, args);
86 int _g_gnulib_vfprintf (FILE *file, char const *format, va_list args)
89 size_t length, rlength;
91 result = vasnprintf (NULL, &length, format, args);
95 rlength = fwrite (result, 1, length, file);
101 int _g_gnulib_vsprintf (char *string, char const *format, va_list args)
106 result = vasnprintf (NULL, &length, format, args);
110 memcpy (string, result, length + 1);
116 int _g_gnulib_vsnprintf (char *string, size_t n, char const *format, va_list args)
121 result = vasnprintf (NULL, &length, format, args);
127 memcpy (string, result, MIN(length + 1, n));
136 int _g_gnulib_vasprintf (char **result, char const *format, va_list args)
140 *result = vasnprintf (NULL, &length, format, args);