annotate lib/xvasprintf.h @ 9309:bbbbbf4cd1c5

Change copyright notice from GPLv2+ to GPLv3+.
author Bruno Haible <bruno@clisp.org>
date Sun, 07 Oct 2007 19:14:58 +0200
parents 4ec84f742938
children c4fa39bf5223
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5218
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* vasprintf and asprintf with out-of-memory checking.
8386
4ec84f742938 Convert tabs in the middle of preprocessor directives.
Bruno Haible <bruno@clisp.org>
parents: 6880
diff changeset
2 Copyright (C) 2002-2004, 2006-2007 Free Software Foundation, Inc.
5218
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8386
diff changeset
4 This program is free software: you can redistribute it and/or modify
5218
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8386
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8386
diff changeset
7 (at your option) any later version.
5218
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8386
diff changeset
14 You should have received a copy of the GNU General Public License
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8386
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
5218
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #ifndef _XVASPRINTF_H
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 #define _XVASPRINTF_H
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 /* Get va_list. */
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <stdarg.h>
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #ifndef __attribute__
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 /* This feature is available in gcc versions 2.5 and later. */
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 # define __attribute__(Spec) /* empty */
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 # endif
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 /* The __-protected variants of `format' and `printf' attributes
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 # define __format__ format
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 # define __printf__ printf
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 # endif
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #endif
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35
8386
4ec84f742938 Convert tabs in the middle of preprocessor directives.
Bruno Haible <bruno@clisp.org>
parents: 6880
diff changeset
36 #ifdef __cplusplus
5218
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 extern "C" {
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 #endif
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39
6880
4c57482eb676 Fix the comment fix.
Bruno Haible <bruno@clisp.org>
parents: 6879
diff changeset
40 /* Write formatted output to a string dynamically allocated with malloc(),
4c57482eb676 Fix the comment fix.
Bruno Haible <bruno@clisp.org>
parents: 6879
diff changeset
41 and return it. Upon [ENOMEM] memory allocation error, call xalloc_die.
5218
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 On some other error
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 - [EOVERFLOW] resulting string length is > INT_MAX,
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 - [EINVAL] invalid format string,
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 - [EILSEQ] error during conversion between wide and multibyte characters,
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 return NULL. */
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 extern char *xasprintf (const char *format, ...)
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 __attribute__ ((__format__ (__printf__, 1, 2)));
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 extern char *xvasprintf (const char *format, va_list args)
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 __attribute__ ((__format__ (__printf__, 1, 0)));
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51
8386
4ec84f742938 Convert tabs in the middle of preprocessor directives.
Bruno Haible <bruno@clisp.org>
parents: 6880
diff changeset
52 #ifdef __cplusplus
5218
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 }
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 #endif
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55
f96c64693f86 New module 'xvasprintf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 #endif /* _XVASPRINTF_H */