Blame gettext-runtime/intl/printf-args.h

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