|
Packit |
5b56b6 |
/* vsprintf with automatic memory allocation.
|
|
Packit |
5b56b6 |
Copyright (C) 2002-2003, 2012, 2015 Free Software Foundation, Inc.
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
This program is free software: you can redistribute it and/or modify
|
|
Packit |
5b56b6 |
it under the terms of the GNU Lesser General Public License as published by
|
|
Packit |
5b56b6 |
the Free Software Foundation; either version 2.1 of the License, or
|
|
Packit |
5b56b6 |
(at your option) any later version.
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
This program is distributed in the hope that it will be useful,
|
|
Packit |
5b56b6 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
5b56b6 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
5b56b6 |
GNU Lesser General Public License for more details.
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
5b56b6 |
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
#ifndef _VASPRINTF_H
|
|
Packit |
5b56b6 |
#define _VASPRINTF_H
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
/* Get va_list. */
|
|
Packit |
5b56b6 |
#include <stdarg.h>
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
#ifndef __attribute__
|
|
Packit |
5b56b6 |
/* This feature is available in gcc versions 2.5 and later. */
|
|
Packit |
5b56b6 |
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
|
|
Packit |
5b56b6 |
# define __attribute__(Spec) /* empty */
|
|
Packit |
5b56b6 |
# endif
|
|
Packit |
5b56b6 |
/* The __-protected variants of 'format' and 'printf' attributes
|
|
Packit |
5b56b6 |
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
|
Packit |
5b56b6 |
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
|
Packit |
5b56b6 |
# define __format__ format
|
|
Packit |
5b56b6 |
# define __printf__ printf
|
|
Packit |
5b56b6 |
# endif
|
|
Packit |
5b56b6 |
#endif
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
#ifdef __cplusplus
|
|
Packit |
5b56b6 |
extern "C" {
|
|
Packit |
5b56b6 |
#endif
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
/* Write formatted output to a string dynamically allocated with malloc().
|
|
Packit |
5b56b6 |
If the memory allocation succeeds, store the address of the string in
|
|
Packit |
5b56b6 |
*RESULT and return the number of resulting bytes, excluding the trailing
|
|
Packit |
5b56b6 |
NUL. Upon memory allocation error, or some other error, return -1. */
|
|
Packit |
5b56b6 |
extern int asprintf (char **result, const char *format, ...)
|
|
Packit |
5b56b6 |
__attribute__ ((__format__ (__printf__, 2, 3)));
|
|
Packit |
5b56b6 |
extern int vasprintf (char **result, const char *format, va_list args)
|
|
Packit |
5b56b6 |
__attribute__ ((__format__ (__printf__, 2, 0)));
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
#ifdef __cplusplus
|
|
Packit |
5b56b6 |
}
|
|
Packit |
5b56b6 |
#endif
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
#endif /* _VASPRINTF_H */
|