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