Blame lib/printf-args.h

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