PIPS
printf-args.h
Go to the documentation of this file.
1 /* Decomposed printf argument list.
2  Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2014 Free Software
3  Foundation, Inc.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 3, or (at your option)
8  any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, see <http://www.gnu.org/licenses/>. */
17 
18 #ifndef _PRINTF_ARGS_H
19 #define _PRINTF_ARGS_H
20 
21 /* This file can be parametrized with the following macros:
22  ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
23  PRINTF_FETCHARGS Name of the function to be declared.
24  STATIC Set to 'static' to declare the function static. */
25 
26 /* Default parameters. */
27 #ifndef PRINTF_FETCHARGS
28 # define PRINTF_FETCHARGS printf_fetchargs
29 #endif
30 
31 /* Get size_t. */
32 #include <stddef.h>
33 
34 /* Get wchar_t. */
35 #if HAVE_WCHAR_T
36 # include <stddef.h>
37 #endif
38 
39 /* Get wint_t. */
40 #if HAVE_WINT_T
41 # include <wchar.h>
42 #endif
43 
44 /* Get va_list. */
45 #include <stdarg.h>
46 
47 
48 /* Argument types */
49 typedef enum
50 {
60 #if HAVE_LONG_LONG_INT
61  TYPE_LONGLONGINT,
62  TYPE_ULONGLONGINT,
63 #endif
67 #if HAVE_WINT_T
68  TYPE_WIDE_CHAR,
69 #endif
71 #if HAVE_WCHAR_T
72  TYPE_WIDE_STRING,
73 #endif
79 #if HAVE_LONG_LONG_INT
80 , TYPE_COUNT_LONGLONGINT_POINTER
81 #endif
82 #if ENABLE_UNISTDIO
83  /* The unistdio extensions. */
84 , TYPE_U8_STRING
85 , TYPE_U16_STRING
86 , TYPE_U32_STRING
87 #endif
89 
90 /* Polymorphic argument */
91 typedef struct
92 {
94  union
95  {
96  signed char a_schar;
97  unsigned char a_uchar;
98  short a_short;
99  unsigned short a_ushort;
100  int a_int;
101  unsigned int a_uint;
102  long int a_longint;
103  unsigned long int a_ulongint;
104 #if HAVE_LONG_LONG_INT
105  long long int a_longlongint;
106  unsigned long long int a_ulonglongint;
107 #endif
108  float a_float;
109  double a_double;
110  long double a_longdouble;
111  int a_char;
112 #if HAVE_WINT_T
113  wint_t a_wide_char;
114 #endif
115  const char* a_string;
116 #if HAVE_WCHAR_T
117  const wchar_t* a_wide_string;
118 #endif
119  void* a_pointer;
120  signed char * a_count_schar_pointer;
124 #if HAVE_LONG_LONG_INT
125  long long int * a_count_longlongint_pointer;
126 #endif
127 #if ENABLE_UNISTDIO
128  /* The unistdio extensions. */
129  const uint8_t * a_u8_string;
130  const uint16_t * a_u16_string;
131  const uint32_t * a_u32_string;
132 #endif
133  }
134  a;
135 }
136 argument;
137 
138 /* Number of directly allocated arguments (no malloc() needed). */
139 #define N_DIRECT_ALLOC_ARGUMENTS 7
140 
141 typedef struct
142 {
143  size_t count;
146 }
147 arguments;
148 
149 
150 /* Fetch the arguments, putting them into a. */
151 #ifdef STATIC
152 STATIC
153 #else
154 extern
155 #endif
156 int PRINTF_FETCHARGS (va_list args, arguments *a);
157 
158 #endif /* _PRINTF_ARGS_H */
#define N_DIRECT_ALLOC_ARGUMENTS
Number of directly allocated arguments (no malloc() needed).
Definition: printf-args.h:139
arg_type
Get size_t.
Definition: printf-args.h:50
@ TYPE_DOUBLE
Definition: printf-args.h:64
@ TYPE_NONE
Definition: printf-args.h:51
@ TYPE_SHORT
Definition: printf-args.h:54
@ TYPE_CHAR
Definition: printf-args.h:66
@ TYPE_USHORT
Definition: printf-args.h:55
@ TYPE_INT
Definition: printf-args.h:56
@ TYPE_LONGINT
Definition: printf-args.h:58
@ TYPE_COUNT_SCHAR_POINTER
Definition: printf-args.h:75
@ TYPE_POINTER
Definition: printf-args.h:74
@ TYPE_SCHAR
Definition: printf-args.h:52
@ TYPE_LONGDOUBLE
Definition: printf-args.h:65
@ TYPE_COUNT_SHORT_POINTER
Definition: printf-args.h:76
@ TYPE_COUNT_LONGINT_POINTER
Definition: printf-args.h:78
@ TYPE_COUNT_INT_POINTER
Definition: printf-args.h:77
@ TYPE_UINT
Definition: printf-args.h:57
@ TYPE_ULONGINT
Definition: printf-args.h:59
@ TYPE_STRING
Definition: printf-args.h:70
@ TYPE_UCHAR
Definition: printf-args.h:53
#define PRINTF_FETCHARGS
Decomposed printf argument list.
Definition: printf-args.h:28
#define uint32_t
Definition: stdint.in.h:156
#define uint16_t
Definition: stdint.in.h:149
#define uint8_t
Definition: stdint.in.h:142
Polymorphic argument.
Definition: printf-args.h:92
int a_char
Definition: printf-args.h:111
signed char * a_count_schar_pointer
Definition: printf-args.h:120
unsigned int a_uint
Definition: printf-args.h:101
long int * a_count_longint_pointer
Definition: printf-args.h:123
arg_type type
Definition: printf-args.h:93
signed char a_schar
Definition: printf-args.h:96
unsigned long int a_ulongint
Definition: printf-args.h:103
long double a_longdouble
Definition: printf-args.h:110
short a_short
Definition: printf-args.h:98
float a_float
Definition: printf-args.h:108
double a_double
Definition: printf-args.h:109
unsigned short a_ushort
Definition: printf-args.h:99
unsigned char a_uchar
Definition: printf-args.h:97
union argument::@14 a
const char * a_string
Definition: printf-args.h:115
long int a_longint
Definition: printf-args.h:102
void * a_pointer
Definition: printf-args.h:119
short * a_count_short_pointer
Definition: printf-args.h:121
int * a_count_int_pointer
Definition: printf-args.h:122
size_t count
Definition: printf-args.h:143
argument * arg
Definition: printf-args.h:144
#define wint_t
The definitions of _GL_FUNCDECL_RPL etc.
Definition: wchar.in.h:103