Blame gnulib-tests/printf-args.h

Packit 709fb3
/* Decomposed printf argument list.
Packit 709fb3
   Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2017 Free Software
Packit 709fb3
   Foundation, Inc.
Packit 709fb3
Packit 709fb3
   This program is free software; you can redistribute it and/or modify
Packit 709fb3
   it under the terms of the GNU General Public License as published by
Packit 709fb3
   the Free Software Foundation; either version 3, or (at your option)
Packit 709fb3
   any later version.
Packit 709fb3
Packit 709fb3
   This program is distributed in the hope that it will be useful,
Packit 709fb3
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 709fb3
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 709fb3
   GNU General Public License for more details.
Packit 709fb3
Packit 709fb3
   You should have received a copy of the GNU General Public License along
Packit 709fb3
   with this program; if not, see <http://www.gnu.org/licenses/>.  */
Packit 709fb3
Packit 709fb3
#ifndef _PRINTF_ARGS_H
Packit 709fb3
#define _PRINTF_ARGS_H
Packit 709fb3
Packit 709fb3
/* This file can be parametrized with the following macros:
Packit 709fb3
     ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions.
Packit 709fb3
     PRINTF_FETCHARGS   Name of the function to be declared.
Packit 709fb3
     STATIC             Set to 'static' to declare the function static.  */
Packit 709fb3
Packit 709fb3
/* Default parameters.  */
Packit 709fb3
#ifndef PRINTF_FETCHARGS
Packit 709fb3
# define PRINTF_FETCHARGS printf_fetchargs
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
/* Get size_t.  */
Packit 709fb3
#include <stddef.h>
Packit 709fb3
Packit 709fb3
/* Get wchar_t.  */
Packit 709fb3
#if HAVE_WCHAR_T
Packit 709fb3
# include <stddef.h>
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
/* Get wint_t.  */
Packit 709fb3
#if HAVE_WINT_T
Packit 709fb3
# include <wchar.h>
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
/* Get va_list.  */
Packit 709fb3
#include <stdarg.h>
Packit 709fb3
Packit 709fb3
Packit 709fb3
/* Argument types */
Packit 709fb3
typedef enum
Packit 709fb3
{
Packit 709fb3
  TYPE_NONE,
Packit 709fb3
  TYPE_SCHAR,
Packit 709fb3
  TYPE_UCHAR,
Packit 709fb3
  TYPE_SHORT,
Packit 709fb3
  TYPE_USHORT,
Packit 709fb3
  TYPE_INT,
Packit 709fb3
  TYPE_UINT,
Packit 709fb3
  TYPE_LONGINT,
Packit 709fb3
  TYPE_ULONGINT,
Packit 709fb3
#if HAVE_LONG_LONG_INT
Packit 709fb3
  TYPE_LONGLONGINT,
Packit 709fb3
  TYPE_ULONGLONGINT,
Packit 709fb3
#endif
Packit 709fb3
  TYPE_DOUBLE,
Packit 709fb3
  TYPE_LONGDOUBLE,
Packit 709fb3
  TYPE_CHAR,
Packit 709fb3
#if HAVE_WINT_T
Packit 709fb3
  TYPE_WIDE_CHAR,
Packit 709fb3
#endif
Packit 709fb3
  TYPE_STRING,
Packit 709fb3
#if HAVE_WCHAR_T
Packit 709fb3
  TYPE_WIDE_STRING,
Packit 709fb3
#endif
Packit 709fb3
  TYPE_POINTER,
Packit 709fb3
  TYPE_COUNT_SCHAR_POINTER,
Packit 709fb3
  TYPE_COUNT_SHORT_POINTER,
Packit 709fb3
  TYPE_COUNT_INT_POINTER,
Packit 709fb3
  TYPE_COUNT_LONGINT_POINTER
Packit 709fb3
#if HAVE_LONG_LONG_INT
Packit 709fb3
, TYPE_COUNT_LONGLONGINT_POINTER
Packit 709fb3
#endif
Packit 709fb3
#if ENABLE_UNISTDIO
Packit 709fb3
  /* The unistdio extensions.  */
Packit 709fb3
, TYPE_U8_STRING
Packit 709fb3
, TYPE_U16_STRING
Packit 709fb3
, TYPE_U32_STRING
Packit 709fb3
#endif
Packit 709fb3
} arg_type;
Packit 709fb3
Packit 709fb3
/* Polymorphic argument */
Packit 709fb3
typedef struct
Packit 709fb3
{
Packit 709fb3
  arg_type type;
Packit 709fb3
  union
Packit 709fb3
  {
Packit 709fb3
    signed char                 a_schar;
Packit 709fb3
    unsigned char               a_uchar;
Packit 709fb3
    short                       a_short;
Packit 709fb3
    unsigned short              a_ushort;
Packit 709fb3
    int                         a_int;
Packit 709fb3
    unsigned int                a_uint;
Packit 709fb3
    long int                    a_longint;
Packit 709fb3
    unsigned long int           a_ulongint;
Packit 709fb3
#if HAVE_LONG_LONG_INT
Packit 709fb3
    long long int               a_longlongint;
Packit 709fb3
    unsigned long long int      a_ulonglongint;
Packit 709fb3
#endif
Packit 709fb3
    float                       a_float;
Packit 709fb3
    double                      a_double;
Packit 709fb3
    long double                 a_longdouble;
Packit 709fb3
    int                         a_char;
Packit 709fb3
#if HAVE_WINT_T
Packit 709fb3
    wint_t                      a_wide_char;
Packit 709fb3
#endif
Packit 709fb3
    const char*                 a_string;
Packit 709fb3
#if HAVE_WCHAR_T
Packit 709fb3
    const wchar_t*              a_wide_string;
Packit 709fb3
#endif
Packit 709fb3
    void*                       a_pointer;
Packit 709fb3
    signed char *               a_count_schar_pointer;
Packit 709fb3
    short *                     a_count_short_pointer;
Packit 709fb3
    int *                       a_count_int_pointer;
Packit 709fb3
    long int *                  a_count_longint_pointer;
Packit 709fb3
#if HAVE_LONG_LONG_INT
Packit 709fb3
    long long int *             a_count_longlongint_pointer;
Packit 709fb3
#endif
Packit 709fb3
#if ENABLE_UNISTDIO
Packit 709fb3
    /* The unistdio extensions.  */
Packit 709fb3
    const uint8_t *             a_u8_string;
Packit 709fb3
    const uint16_t *            a_u16_string;
Packit 709fb3
    const uint32_t *            a_u32_string;
Packit 709fb3
#endif
Packit 709fb3
  }
Packit 709fb3
  a;
Packit 709fb3
}
Packit 709fb3
argument;
Packit 709fb3
Packit 709fb3
/* Number of directly allocated arguments (no malloc() needed).  */
Packit 709fb3
#define N_DIRECT_ALLOC_ARGUMENTS 7
Packit 709fb3
Packit 709fb3
typedef struct
Packit 709fb3
{
Packit 709fb3
  size_t count;
Packit 709fb3
  argument *arg;
Packit 709fb3
  argument direct_alloc_arg[N_DIRECT_ALLOC_ARGUMENTS];
Packit 709fb3
}
Packit 709fb3
arguments;
Packit 709fb3
Packit 709fb3
Packit 709fb3
/* Fetch the arguments, putting them into a. */
Packit 709fb3
#ifdef STATIC
Packit 709fb3
STATIC
Packit 709fb3
#else
Packit 709fb3
extern
Packit 709fb3
#endif
Packit 709fb3
int PRINTF_FETCHARGS (va_list args, arguments *a);
Packit 709fb3
Packit 709fb3
#endif /* _PRINTF_ARGS_H */