Back to index

tetex-bin  3.0
vasnprintf.h
Go to the documentation of this file.
00001 /* vsprintf with automatic memory allocation.
00002    Copyright (C) 2002-2003 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify it
00005    under the terms of the GNU Library General Public License as published
00006    by the Free Software Foundation; either version 2, or (at your option)
00007    any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public
00015    License along with this program; if not, write to the Free Software
00016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00017    USA.  */
00018 
00019 #ifndef _VASNPRINTF_H
00020 #define _VASNPRINTF_H
00021 
00022 /* Get va_list.  */
00023 #include <stdarg.h>
00024 
00025 /* Get size_t.  */
00026 #include <stddef.h>
00027 
00028 #ifndef __attribute__
00029 /* This feature is available in gcc versions 2.5 and later.  */
00030 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
00031 #  define __attribute__(Spec) /* empty */
00032 # endif
00033 /* The __-protected variants of `format' and `printf' attributes
00034    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
00035 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
00036 #  define __format__ format
00037 #  define __printf__ printf
00038 # endif
00039 #endif
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 /* Write formatted output to a string dynamically allocated with malloc().
00046    You can pass a preallocated buffer for the result in RESULTBUF and its
00047    size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
00048    If successful, return the address of the string (this may be = RESULTBUF
00049    if no dynamic memory allocation was necessary) and set *LENGTHP to the
00050    number of resulting bytes, excluding the trailing NUL.  Upon error, set
00051    errno and return NULL.  */
00052 extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
00053        __attribute__ ((__format__ (__printf__, 3, 4)));
00054 extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
00055        __attribute__ ((__format__ (__printf__, 3, 0)));
00056 
00057 #ifdef __cplusplus
00058 }
00059 #endif
00060 
00061 #endif /* _VASNPRINTF_H */