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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 USA. */ 18 19 #ifndef _PRINTF_ARGS_H 20 #define _PRINTF_ARGS_H 21 22 /* Get size_t. */ 23 #include <stddef.h> 24 25 /* Get wchar_t. */ 26 #ifdef HAVE_WCHAR_T 27 # include <stddef.h> 28 #endif 29 30 /* Get wint_t. */ 31 #ifdef HAVE_WINT_T 32 # include <wchar.h> 33 #endif 34 35 /* Get va_list. */ 36 #include <stdarg.h> 37 38 39 /* Argument types */ 40 typedef enum 41 { 42 TYPE_NONE, 43 TYPE_SCHAR, 44 TYPE_UCHAR, 45 TYPE_SHORT, 46 TYPE_USHORT, 47 TYPE_INT, 48 TYPE_UINT, 49 TYPE_LONGINT, 50 TYPE_ULONGINT, 51 #ifdef HAVE_LONG_LONG 52 TYPE_LONGLONGINT, 53 TYPE_ULONGLONGINT, 54 #endif 55 TYPE_DOUBLE, 56 #ifdef HAVE_LONG_DOUBLE 57 TYPE_LONGDOUBLE, 58 #endif 59 TYPE_CHAR, 60 #ifdef HAVE_WINT_T 61 TYPE_WIDE_CHAR, 62 #endif 63 TYPE_STRING, 64 #ifdef HAVE_WCHAR_T 65 TYPE_WIDE_STRING, 66 #endif 67 TYPE_POINTER, 68 TYPE_COUNT_SCHAR_POINTER, 69 TYPE_COUNT_SHORT_POINTER, 70 TYPE_COUNT_INT_POINTER, 71 TYPE_COUNT_LONGINT_POINTER 72 #ifdef HAVE_LONG_LONG 73 , TYPE_COUNT_LONGLONGINT_POINTER 74 #endif 75 } arg_type; 76 77 /* Polymorphic argument */ 78 typedef struct 79 { 80 arg_type type; 81 union 82 { 83 signed char a_schar; 84 unsigned char a_uchar; 85 short a_short; 86 unsigned short a_ushort; 87 int a_int; 88 unsigned int a_uint; 89 long int a_longint; 90 unsigned long int a_ulongint; 91 #ifdef HAVE_LONG_LONG 92 long long int a_longlongint; 93 unsigned long long int a_ulonglongint; 94 #endif 95 float a_float; 96 double a_double; 97 #ifdef HAVE_LONG_DOUBLE 98 long double a_longdouble; 99 #endif 100 int a_char; 101 #ifdef HAVE_WINT_T 102 wint_t a_wide_char; 103 #endif 104 const char* a_string; 105 #ifdef HAVE_WCHAR_T 106 const wchar_t* a_wide_string; 107 #endif 108 void* a_pointer; 109 signed char * a_count_schar_pointer; 110 short * a_count_short_pointer; 111 int * a_count_int_pointer; 112 long int * a_count_longint_pointer; 113 #ifdef HAVE_LONG_LONG 114 long long int * a_count_longlongint_pointer; 115 #endif 116 } 117 a; 118 } 119 argument; 120 121 typedef struct 122 { 123 size_t count; 124 argument *arg; 125 } 126 arguments; 127 128 129 /* Fetch the arguments, putting them into a. */ 130 #ifdef STATIC 131 STATIC 132 #else 133 extern 134 #endif 135 int printf_fetchargs (va_list args, arguments *a); 136 137 #endif /* _PRINTF_ARGS_H */ 138