xref: /openbsd-src/gnu/usr.bin/texinfo/intl/vasnprintf.h (revision a1acfa9b69ad64eb720639240c8438f11107dc85)
1*a1acfa9bSespie /* vsprintf with automatic memory allocation.
2*a1acfa9bSespie    Copyright (C) 2002-2003 Free Software Foundation, Inc.
3*a1acfa9bSespie 
4*a1acfa9bSespie    This program is free software; you can redistribute it and/or modify it
5*a1acfa9bSespie    under the terms of the GNU Library General Public License as published
6*a1acfa9bSespie    by the Free Software Foundation; either version 2, or (at your option)
7*a1acfa9bSespie    any later version.
8*a1acfa9bSespie 
9*a1acfa9bSespie    This program is distributed in the hope that it will be useful,
10*a1acfa9bSespie    but WITHOUT ANY WARRANTY; without even the implied warranty of
11*a1acfa9bSespie    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12*a1acfa9bSespie    Library General Public License for more details.
13*a1acfa9bSespie 
14*a1acfa9bSespie    You should have received a copy of the GNU Library General Public
15*a1acfa9bSespie    License along with this program; if not, write to the Free Software
16*a1acfa9bSespie    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17*a1acfa9bSespie    USA.  */
18*a1acfa9bSespie 
19*a1acfa9bSespie #ifndef _VASNPRINTF_H
20*a1acfa9bSespie #define _VASNPRINTF_H
21*a1acfa9bSespie 
22*a1acfa9bSespie /* Get va_list.  */
23*a1acfa9bSespie #include <stdarg.h>
24*a1acfa9bSespie 
25*a1acfa9bSespie /* Get size_t.  */
26*a1acfa9bSespie #include <stddef.h>
27*a1acfa9bSespie 
28*a1acfa9bSespie #ifndef __attribute__
29*a1acfa9bSespie /* This feature is available in gcc versions 2.5 and later.  */
30*a1acfa9bSespie # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
31*a1acfa9bSespie #  define __attribute__(Spec) /* empty */
32*a1acfa9bSespie # endif
33*a1acfa9bSespie /* The __-protected variants of `format' and `printf' attributes
34*a1acfa9bSespie    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
35*a1acfa9bSespie # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
36*a1acfa9bSespie #  define __format__ format
37*a1acfa9bSespie #  define __printf__ printf
38*a1acfa9bSespie # endif
39*a1acfa9bSespie #endif
40*a1acfa9bSespie 
41*a1acfa9bSespie #ifdef	__cplusplus
42*a1acfa9bSespie extern "C" {
43*a1acfa9bSespie #endif
44*a1acfa9bSespie 
45*a1acfa9bSespie /* Write formatted output to a string dynamically allocated with malloc().
46*a1acfa9bSespie    You can pass a preallocated buffer for the result in RESULTBUF and its
47*a1acfa9bSespie    size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
48*a1acfa9bSespie    If successful, return the address of the string (this may be = RESULTBUF
49*a1acfa9bSespie    if no dynamic memory allocation was necessary) and set *LENGTHP to the
50*a1acfa9bSespie    number of resulting bytes, excluding the trailing NUL.  Upon error, set
51*a1acfa9bSespie    errno and return NULL.  */
52*a1acfa9bSespie extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
53*a1acfa9bSespie        __attribute__ ((__format__ (__printf__, 3, 4)));
54*a1acfa9bSespie extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
55*a1acfa9bSespie        __attribute__ ((__format__ (__printf__, 3, 0)));
56*a1acfa9bSespie 
57*a1acfa9bSespie #ifdef	__cplusplus
58*a1acfa9bSespie }
59*a1acfa9bSespie #endif
60*a1acfa9bSespie 
61*a1acfa9bSespie #endif /* _VASNPRINTF_H */
62