Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* -*- buffer-read-only: t -*- vi: set ro: */ 00002 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 00003 /* vsprintf with automatic memory allocation. 00004 Copyright (C) 2002-2004, 2007-2011 Free Software Foundation, Inc. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3, or (at your option) 00009 any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License along 00017 with this program; if not, write to the Free Software Foundation, 00018 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 00019 00020 #ifndef _VASNPRINTF_H 00021 #define _VASNPRINTF_H 00022 00023 /* Get va_list. */ 00024 #include <stdarg.h> 00025 00026 /* Get size_t. */ 00027 #include <stddef.h> 00028 00029 #ifndef __attribute__ 00030 /* The __attribute__ feature is available in gcc versions 2.5 and later. 00031 The __-protected variants of the attributes 'format' and 'printf' are 00032 accepted by gcc versions 2.6.4 (effectively 2.7) and later. 00033 We enable __attribute__ only if these are supported too, because 00034 gnulib and libintl do '#define printf __printf__' when they override 00035 the 'printf' function. */ 00036 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 00037 # define __attribute__(Spec) /* empty */ 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 00053 When dynamic memory allocation occurs, the preallocated buffer is left 00054 alone (with possibly modified contents). This makes it possible to use 00055 a statically allocated or stack-allocated buffer, like this: 00056 00057 char buf[100]; 00058 size_t len = sizeof (buf); 00059 char *output = vasnprintf (buf, &len, format, args); 00060 if (output == NULL) 00061 ... error handling ...; 00062 else 00063 { 00064 ... use the output string ...; 00065 if (output != buf) 00066 free (output); 00067 } 00068 */ 00069 #if REPLACE_VASNPRINTF 00070 # define asnprintf rpl_asnprintf 00071 # define vasnprintf rpl_vasnprintf 00072 #endif 00073 extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) 00074 __attribute__ ((__format__ (__printf__, 3, 4))); 00075 extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) 00076 __attribute__ ((__format__ (__printf__, 3, 0))); 00077 00078 #ifdef __cplusplus 00079 } 00080 #endif 00081 00082 #endif /* _VASNPRINTF_H */