Back to index

courier  0.68.2
printf-args.h
Go to the documentation of this file.
00001 /* Decomposed printf argument list.
00002    Copyright (C) 1999, 2002-2003, 2006-2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00017    USA.  */
00018 
00019 #ifndef _PRINTF_ARGS_H
00020 #define _PRINTF_ARGS_H
00021 
00022 /* This file can be parametrized with the following macros:
00023      ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions.
00024      PRINTF_FETCHARGS   Name of the function to be declared.
00025      STATIC             Set to 'static' to declare the function static.  */
00026 
00027 /* Default parameters.  */
00028 #ifndef PRINTF_FETCHARGS
00029 # define PRINTF_FETCHARGS printf_fetchargs
00030 #endif
00031 
00032 /* Get size_t.  */
00033 #include <stddef.h>
00034 
00035 /* Get wchar_t.  */
00036 #if HAVE_WCHAR_T
00037 # include <stddef.h>
00038 #endif
00039 
00040 /* Get wint_t.  */
00041 #if HAVE_WINT_T
00042 # include <wchar.h>
00043 #endif
00044 
00045 /* Get va_list.  */
00046 #include <stdarg.h>
00047 
00048 
00049 /* Argument types */
00050 typedef enum
00051 {
00052   TYPE_NONE,
00053   TYPE_SCHAR,
00054   TYPE_UCHAR,
00055   TYPE_SHORT,
00056   TYPE_USHORT,
00057   TYPE_INT,
00058   TYPE_UINT,
00059   TYPE_LONGINT,
00060   TYPE_ULONGINT,
00061 #if HAVE_LONG_LONG_INT
00062   TYPE_LONGLONGINT,
00063   TYPE_ULONGLONGINT,
00064 #endif
00065   TYPE_DOUBLE,
00066   TYPE_LONGDOUBLE,
00067   TYPE_CHAR,
00068 #if HAVE_WINT_T
00069   TYPE_WIDE_CHAR,
00070 #endif
00071   TYPE_STRING,
00072 #if HAVE_WCHAR_T
00073   TYPE_WIDE_STRING,
00074 #endif
00075   TYPE_POINTER,
00076   TYPE_COUNT_SCHAR_POINTER,
00077   TYPE_COUNT_SHORT_POINTER,
00078   TYPE_COUNT_INT_POINTER,
00079   TYPE_COUNT_LONGINT_POINTER
00080 #if HAVE_LONG_LONG_INT
00081 , TYPE_COUNT_LONGLONGINT_POINTER
00082 #endif
00083 #if ENABLE_UNISTDIO
00084   /* The unistdio extensions.  */
00085 , TYPE_U8_STRING
00086 , TYPE_U16_STRING
00087 , TYPE_U32_STRING
00088 #endif
00089 } arg_type;
00090 
00091 /* Polymorphic argument */
00092 typedef struct
00093 {
00094   arg_type type;
00095   union
00096   {
00097     signed char                 a_schar;
00098     unsigned char               a_uchar;
00099     short                       a_short;
00100     unsigned short              a_ushort;
00101     int                         a_int;
00102     unsigned int                a_uint;
00103     long int                    a_longint;
00104     unsigned long int           a_ulongint;
00105 #if HAVE_LONG_LONG_INT
00106     long long int               a_longlongint;
00107     unsigned long long int      a_ulonglongint;
00108 #endif
00109     float                       a_float;
00110     double                      a_double;
00111     long double                 a_longdouble;
00112     int                         a_char;
00113 #if HAVE_WINT_T
00114     wint_t                      a_wide_char;
00115 #endif
00116     const char*                 a_string;
00117 #if HAVE_WCHAR_T
00118     const wchar_t*              a_wide_string;
00119 #endif
00120     void*                       a_pointer;
00121     signed char *               a_count_schar_pointer;
00122     short *                     a_count_short_pointer;
00123     int *                       a_count_int_pointer;
00124     long int *                  a_count_longint_pointer;
00125 #if HAVE_LONG_LONG_INT
00126     long long int *             a_count_longlongint_pointer;
00127 #endif
00128 #if ENABLE_UNISTDIO
00129     /* The unistdio extensions.  */
00130     const uint8_t *             a_u8_string;
00131     const uint16_t *            a_u16_string;
00132     const uint32_t *            a_u32_string;
00133 #endif
00134   }
00135   a;
00136 }
00137 argument;
00138 
00139 typedef struct
00140 {
00141   size_t count;
00142   argument *arg;
00143 }
00144 arguments;
00145 
00146 
00147 /* Fetch the arguments, putting them into a. */
00148 #ifdef STATIC
00149 STATIC
00150 #else
00151 extern
00152 #endif
00153 int PRINTF_FETCHARGS (va_list args, arguments *a);
00154 
00155 #endif /* _PRINTF_ARGS_H */