Blame gettext-tools/gnulib-lib/printf-args.h

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