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