1/* -*- buffer-read-only: t -*- vi: set ro: */ 2/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 3#line 1 4/* vsprintf with automatic memory allocation. 5 Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 3, or (at your option) 10 any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License along 18 with this program; if not, write to the Free Software Foundation, 19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 20 21#ifndef _VASNPRINTF_H 22#define _VASNPRINTF_H 23 24/* Get va_list. */ 25#include <stdarg.h> 26 27/* Get size_t. */ 28#include <stddef.h> 29 30#ifndef __attribute__ 31/* This feature is available in gcc versions 2.5 and later. */ 32# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) 33# define __attribute__(Spec) /* empty */ 34# endif 35/* The __-protected variants of `format' and `printf' attributes 36 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ 37# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 38# define __format__ format 39# define __printf__ printf 40# endif 41#endif 42 43#ifdef __cplusplus 44extern "C" { 45#endif 46 47/* Write formatted output to a string dynamically allocated with malloc(). 48 You can pass a preallocated buffer for the result in RESULTBUF and its 49 size in *LENGTHP; otherwise you pass RESULTBUF = NULL. 50 If successful, return the address of the string (this may be = RESULTBUF 51 if no dynamic memory allocation was necessary) and set *LENGTHP to the 52 number of resulting bytes, excluding the trailing NUL. Upon error, set 53 errno and return NULL. 54 55 When dynamic memory allocation occurs, the preallocated buffer is left 56 alone (with possibly modified contents). This makes it possible to use 57 a statically allocated or stack-allocated buffer, like this: 58 59 char buf[100]; 60 size_t len = sizeof (buf); 61 char *output = vasnprintf (buf, &len, format, args); 62 if (output == NULL) 63 ... error handling ...; 64 else 65 { 66 ... use the output string ...; 67 if (output != buf) 68 free (output); 69 } 70 */ 71#if REPLACE_VASNPRINTF 72# define asnprintf rpl_asnprintf 73# define vasnprintf rpl_vasnprintf 74#endif 75extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) 76 __attribute__ ((__format__ (__printf__, 3, 4))); 77extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) 78 __attribute__ ((__format__ (__printf__, 3, 0))); 79 80#ifdef __cplusplus 81} 82#endif 83 84#endif /* _VASNPRINTF_H */ 85