Navit SVN

/work/compile/navit/src/navit/intl_cmake/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 it
00005    under the terms of the GNU Library General Public License as published
00006    by the Free Software Foundation; either version 2, 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 GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public
00015    License along with this program; if not, write to the Free Software
00016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00017    USA.  */
00018 
00019 #ifndef _PRINTF_ARGS_H
00020 #define _PRINTF_ARGS_H
00021 
00022 /* Get size_t.  */
00023 #include <stddef.h>
00024 
00025 /* Get wchar_t.  */
00026 #ifdef HAVE_WCHAR_T
00027 # include <stddef.h>
00028 #endif
00029 
00030 /* Get wint_t.  */
00031 #ifdef HAVE_WINT_T
00032 # include <wchar.h>
00033 #endif
00034 
00035 /* Get va_list.  */
00036 #include <stdarg.h>
00037 
00038 
00039 /* Argument types */
00040 typedef enum
00041 {
00042   TYPE_NONE,
00043   TYPE_SCHAR,
00044   TYPE_UCHAR,
00045   TYPE_SHORT,
00046   TYPE_USHORT,
00047   TYPE_INT,
00048   TYPE_UINT,
00049   TYPE_LONGINT,
00050   TYPE_ULONGINT,
00051 #ifdef HAVE_LONG_LONG
00052   TYPE_LONGLONGINT,
00053   TYPE_ULONGLONGINT,
00054 #endif
00055   TYPE_DOUBLE,
00056 #ifdef HAVE_LONG_DOUBLE
00057   TYPE_LONGDOUBLE,
00058 #endif
00059   TYPE_CHAR,
00060 #ifdef HAVE_WINT_T
00061   TYPE_WIDE_CHAR,
00062 #endif
00063   TYPE_STRING,
00064 #ifdef HAVE_WCHAR_T
00065   TYPE_WIDE_STRING,
00066 #endif
00067   TYPE_POINTER,
00068   TYPE_COUNT_SCHAR_POINTER,
00069   TYPE_COUNT_SHORT_POINTER,
00070   TYPE_COUNT_INT_POINTER,
00071   TYPE_COUNT_LONGINT_POINTER
00072 #ifdef HAVE_LONG_LONG
00073 , TYPE_COUNT_LONGLONGINT_POINTER
00074 #endif
00075 } arg_type;
00076 
00077 /* Polymorphic argument */
00078 typedef struct
00079 {
00080   arg_type type;
00081   union
00082   {
00083     signed char                 a_schar;
00084     unsigned char               a_uchar;
00085     short                       a_short;
00086     unsigned short              a_ushort;
00087     int                         a_int;
00088     unsigned int                a_uint;
00089     long int                    a_longint;
00090     unsigned long int           a_ulongint;
00091 #ifdef HAVE_LONG_LONG
00092     long long int               a_longlongint;
00093     unsigned long long int      a_ulonglongint;
00094 #endif
00095     float                       a_float;
00096     double                      a_double;
00097 #ifdef HAVE_LONG_DOUBLE
00098     long double                 a_longdouble;
00099 #endif
00100     int                         a_char;
00101 #ifdef HAVE_WINT_T
00102     wint_t                      a_wide_char;
00103 #endif
00104     const char*                 a_string;
00105 #ifdef HAVE_WCHAR_T
00106     const wchar_t*              a_wide_string;
00107 #endif
00108     void*                       a_pointer;
00109     signed char *               a_count_schar_pointer;
00110     short *                     a_count_short_pointer;
00111     int *                       a_count_int_pointer;
00112     long int *                  a_count_longint_pointer;
00113 #ifdef HAVE_LONG_LONG
00114     long long int *             a_count_longlongint_pointer;
00115 #endif
00116   }
00117   a;
00118 }
00119 argument;
00120 
00121 typedef struct
00122 {
00123   size_t count;
00124   argument *arg;
00125 }
00126 arguments;
00127 
00128 
00129 /* Fetch the arguments, putting them into a. */
00130 #ifdef STATIC
00131 STATIC
00132 #else
00133 extern
00134 #endif
00135 int printf_fetchargs (va_list args, arguments *a);
00136 
00137 #endif /* _PRINTF_ARGS_H */