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