Blame gl/printf-args.h

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