2
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
* DEALINGS IN THE SOFTWARE.
29
#include <X11/Xfuncproto.h>
31
#ifndef _X_RESTRICT_KYWD
32
# if defined(restrict) /* assume autoconf set it correctly */ || \
33
(defined(__STDC__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */
34
# define _X_RESTRICT_KYWD restrict
35
# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
36
# define _X_RESTRICT_KYWD __restrict__
38
# define _X_RESTRICT_KYWD
43
* These functions provide a portable implementation of the common (but not
44
* yet universal) asprintf & vasprintf routines to allocate a buffer big
45
* enough to sprintf the arguments to. The XNF variants terminate the server
46
* if the allocation fails.
47
* The buffer allocated is returned in the pointer provided in the first
48
* argument. The return value is the size of the allocated buffer, or -1
51
extern _X_EXPORT int Xasprintf (char **ret,
52
const char * _X_RESTRICT_KYWD fmt,
53
...) _X_ATTRIBUTE_PRINTF(2,3);
54
extern _X_EXPORT int Xvasprintf (char **ret,
55
const char * _X_RESTRICT_KYWD fmt,
56
va_list va) _X_ATTRIBUTE_PRINTF(2,0);
57
extern _X_EXPORT int XNFasprintf (char **ret,
58
const char * _X_RESTRICT_KYWD fmt,
59
...) _X_ATTRIBUTE_PRINTF(2,3);
60
extern _X_EXPORT int XNFvasprintf (char **ret,
61
const char * _X_RESTRICT_KYWD fmt,
62
va_list va) _X_ATTRIBUTE_PRINTF(2,0);
64
#if !defined(HAVE_ASPRINTF) && !defined(HAVE_VASPRINTF)
65
# define asprintf Xasprintf
66
# define vasprintf Xvasprintf
69
#endif /* XPRINTF_H */