pkg-monitoring-plugins/gl/printf-args.h

151 lines
3.8 KiB
C
Raw Permalink Normal View History

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