printf-args.h

00001 /* Decomposed printf argument list.
00002    Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU Lesser General Public License as published by
00006    the Free Software Foundation; either version 2.1, or (at your option)
00007    any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public License along
00015    with this program; if not, write to the Free Software Foundation,
00016    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00017 
00018 #ifndef _PRINTF_ARGS_H
00019 #define _PRINTF_ARGS_H
00020 
00021 /* Get size_t.  */
00022 #include <stddef.h>
00023 
00024 /* Get wchar_t.  */
00025 #ifdef HAVE_WCHAR_T
00026 # include <stddef.h>
00027 #endif
00028 
00029 /* Get wint_t.  */
00030 #ifdef HAVE_WINT_T
00031 # include <wchar.h>
00032 #endif
00033 
00034 /* Get va_list.  */
00035 #include <stdarg.h>
00036 
00037 
00038 /* Argument types */
00039 typedef enum
00040 {
00041   TYPE_NONE,
00042   TYPE_SCHAR,
00043   TYPE_UCHAR,
00044   TYPE_SHORT,
00045   TYPE_USHORT,
00046   TYPE_INT,
00047   TYPE_UINT,
00048   TYPE_LONGINT,
00049   TYPE_ULONGINT,
00050 #ifdef HAVE_LONG_LONG
00051   TYPE_LONGLONGINT,
00052   TYPE_ULONGLONGINT,
00053 #endif
00054   TYPE_DOUBLE,
00055 #ifdef HAVE_LONG_DOUBLE
00056   TYPE_LONGDOUBLE,
00057 #endif
00058   TYPE_CHAR,
00059 #ifdef HAVE_WINT_T
00060   TYPE_WIDE_CHAR,
00061 #endif
00062   TYPE_STRING,
00063 #ifdef HAVE_WCHAR_T
00064   TYPE_WIDE_STRING,
00065 #endif
00066   TYPE_POINTER,
00067   TYPE_COUNT_SCHAR_POINTER,
00068   TYPE_COUNT_SHORT_POINTER,
00069   TYPE_COUNT_INT_POINTER,
00070   TYPE_COUNT_LONGINT_POINTER
00071 #ifdef HAVE_LONG_LONG
00072 , TYPE_COUNT_LONGLONGINT_POINTER
00073 #endif
00074 } arg_type;
00075 
00076 /* Polymorphic argument */
00077 typedef struct
00078 {
00079   arg_type type;
00080   union
00081   {
00082     signed char                 a_schar;
00083     unsigned char               a_uchar;
00084     short                       a_short;
00085     unsigned short              a_ushort;
00086     int                         a_int;
00087     unsigned int                a_uint;
00088     long int                    a_longint;
00089     unsigned long int           a_ulongint;
00090 #ifdef HAVE_LONG_LONG
00091     long long int               a_longlongint;
00092     unsigned long long int      a_ulonglongint;
00093 #endif
00094     float                       a_float;
00095     double                      a_double;
00096 #ifdef HAVE_LONG_DOUBLE
00097     long double                 a_longdouble;
00098 #endif
00099     int                         a_char;
00100 #ifdef HAVE_WINT_T
00101     wint_t                      a_wide_char;
00102 #endif
00103     const char*                 a_string;
00104 #ifdef HAVE_WCHAR_T
00105     const wchar_t*              a_wide_string;
00106 #endif
00107     void*                       a_pointer;
00108     signed char *               a_count_schar_pointer;
00109     short *                     a_count_short_pointer;
00110     int *                       a_count_int_pointer;
00111     long int *                  a_count_longint_pointer;
00112 #ifdef HAVE_LONG_LONG
00113     long long int *             a_count_longlongint_pointer;
00114 #endif
00115   }
00116   a;
00117 }
00118 argument;
00119 
00120 typedef struct
00121 {
00122   size_t count;
00123   argument *arg;
00124 }
00125 arguments;
00126 
00127 
00128 /* Fetch the arguments, putting them into a. */
00129 #ifdef STATIC
00130 STATIC
00131 #else
00132 extern
00133 #endif
00134 int printf_fetchargs (va_list args, arguments *a);
00135 
00136 #endif /* _PRINTF_ARGS_H */

Generated on Mon Feb 5 10:54:28 2007 for WvStreams by  doxygen 1.5.1