Blame gl/printf-args.h

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