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