xref: /netbsd/external/gpl2/xcvs/dist/lib/printf-args.h (revision a7c91847)
1*a7c91847Schristos /* Decomposed printf argument list.
2*a7c91847Schristos    Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
3*a7c91847Schristos 
4*a7c91847Schristos    This program is free software; you can redistribute it and/or modify
5*a7c91847Schristos    it under the terms of the GNU General Public License as published by
6*a7c91847Schristos    the Free Software Foundation; either version 2, or (at your option)
7*a7c91847Schristos    any later version.
8*a7c91847Schristos 
9*a7c91847Schristos    This program is distributed in the hope that it will be useful,
10*a7c91847Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
11*a7c91847Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*a7c91847Schristos    GNU General Public License for more details.
13*a7c91847Schristos 
14*a7c91847Schristos    You should have received a copy of the GNU General Public License along
15*a7c91847Schristos    with this program; if not, write to the Free Software Foundation,
16*a7c91847Schristos    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17*a7c91847Schristos 
18*a7c91847Schristos #ifndef _PRINTF_ARGS_H
19*a7c91847Schristos #define _PRINTF_ARGS_H
20*a7c91847Schristos 
21*a7c91847Schristos /* Get size_t.  */
22*a7c91847Schristos #include <stddef.h>
23*a7c91847Schristos 
24*a7c91847Schristos /* Get wchar_t.  */
25*a7c91847Schristos #ifdef HAVE_WCHAR_T
26*a7c91847Schristos # include <stddef.h>
27*a7c91847Schristos #endif
28*a7c91847Schristos 
29*a7c91847Schristos /* Get wint_t.  */
30*a7c91847Schristos #ifdef HAVE_WINT_T
31*a7c91847Schristos # include <wchar.h>
32*a7c91847Schristos #endif
33*a7c91847Schristos 
34*a7c91847Schristos /* Get va_list.  */
35*a7c91847Schristos #include <stdarg.h>
36*a7c91847Schristos 
37*a7c91847Schristos 
38*a7c91847Schristos /* Argument types */
39*a7c91847Schristos typedef enum
40*a7c91847Schristos {
41*a7c91847Schristos   TYPE_NONE,
42*a7c91847Schristos   TYPE_SCHAR,
43*a7c91847Schristos   TYPE_UCHAR,
44*a7c91847Schristos   TYPE_SHORT,
45*a7c91847Schristos   TYPE_USHORT,
46*a7c91847Schristos   TYPE_INT,
47*a7c91847Schristos   TYPE_UINT,
48*a7c91847Schristos   TYPE_LONGINT,
49*a7c91847Schristos   TYPE_ULONGINT,
50*a7c91847Schristos #ifdef HAVE_LONG_LONG
51*a7c91847Schristos   TYPE_LONGLONGINT,
52*a7c91847Schristos   TYPE_ULONGLONGINT,
53*a7c91847Schristos #endif
54*a7c91847Schristos   TYPE_DOUBLE,
55*a7c91847Schristos #ifdef HAVE_LONG_DOUBLE
56*a7c91847Schristos   TYPE_LONGDOUBLE,
57*a7c91847Schristos #endif
58*a7c91847Schristos   TYPE_CHAR,
59*a7c91847Schristos #ifdef HAVE_WINT_T
60*a7c91847Schristos   TYPE_WIDE_CHAR,
61*a7c91847Schristos #endif
62*a7c91847Schristos   TYPE_STRING,
63*a7c91847Schristos #ifdef HAVE_WCHAR_T
64*a7c91847Schristos   TYPE_WIDE_STRING,
65*a7c91847Schristos #endif
66*a7c91847Schristos   TYPE_POINTER,
67*a7c91847Schristos   TYPE_COUNT_SCHAR_POINTER,
68*a7c91847Schristos   TYPE_COUNT_SHORT_POINTER,
69*a7c91847Schristos   TYPE_COUNT_INT_POINTER,
70*a7c91847Schristos   TYPE_COUNT_LONGINT_POINTER
71*a7c91847Schristos #ifdef HAVE_LONG_LONG
72*a7c91847Schristos , TYPE_COUNT_LONGLONGINT_POINTER
73*a7c91847Schristos #endif
74*a7c91847Schristos } arg_type;
75*a7c91847Schristos 
76*a7c91847Schristos /* Polymorphic argument */
77*a7c91847Schristos typedef struct
78*a7c91847Schristos {
79*a7c91847Schristos   arg_type type;
80*a7c91847Schristos   union
81*a7c91847Schristos   {
82*a7c91847Schristos     signed char			a_schar;
83*a7c91847Schristos     unsigned char		a_uchar;
84*a7c91847Schristos     short			a_short;
85*a7c91847Schristos     unsigned short		a_ushort;
86*a7c91847Schristos     int				a_int;
87*a7c91847Schristos     unsigned int		a_uint;
88*a7c91847Schristos     long int			a_longint;
89*a7c91847Schristos     unsigned long int		a_ulongint;
90*a7c91847Schristos #ifdef HAVE_LONG_LONG
91*a7c91847Schristos     long long int		a_longlongint;
92*a7c91847Schristos     unsigned long long int	a_ulonglongint;
93*a7c91847Schristos #endif
94*a7c91847Schristos     float			a_float;
95*a7c91847Schristos     double			a_double;
96*a7c91847Schristos #ifdef HAVE_LONG_DOUBLE
97*a7c91847Schristos     long double			a_longdouble;
98*a7c91847Schristos #endif
99*a7c91847Schristos     int				a_char;
100*a7c91847Schristos #ifdef HAVE_WINT_T
101*a7c91847Schristos     wint_t			a_wide_char;
102*a7c91847Schristos #endif
103*a7c91847Schristos     const char*			a_string;
104*a7c91847Schristos #ifdef HAVE_WCHAR_T
105*a7c91847Schristos     const wchar_t*		a_wide_string;
106*a7c91847Schristos #endif
107*a7c91847Schristos     void*			a_pointer;
108*a7c91847Schristos     signed char *		a_count_schar_pointer;
109*a7c91847Schristos     short *			a_count_short_pointer;
110*a7c91847Schristos     int *			a_count_int_pointer;
111*a7c91847Schristos     long int *			a_count_longint_pointer;
112*a7c91847Schristos #ifdef HAVE_LONG_LONG
113*a7c91847Schristos     long long int *		a_count_longlongint_pointer;
114*a7c91847Schristos #endif
115*a7c91847Schristos   }
116*a7c91847Schristos   a;
117*a7c91847Schristos }
118*a7c91847Schristos argument;
119*a7c91847Schristos 
120*a7c91847Schristos typedef struct
121*a7c91847Schristos {
122*a7c91847Schristos   size_t count;
123*a7c91847Schristos   argument *arg;
124*a7c91847Schristos }
125*a7c91847Schristos arguments;
126*a7c91847Schristos 
127*a7c91847Schristos 
128*a7c91847Schristos /* Fetch the arguments, putting them into a. */
129*a7c91847Schristos #ifdef STATIC
130*a7c91847Schristos STATIC
131*a7c91847Schristos #else
132*a7c91847Schristos extern
133*a7c91847Schristos #endif
134*a7c91847Schristos int printf_fetchargs (va_list args, arguments *a);
135*a7c91847Schristos 
136*a7c91847Schristos #endif /* _PRINTF_ARGS_H */
137