Blame glib/gnulib/printf-args.h

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