Blame gl/printf-args.h

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