Navit SVN

/work/compile/navit/src/navit/intl_cmake/printf-parse.h

00001 /* Parse printf format string.
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_PARSE_H
00020 #define _PRINTF_PARSE_H
00021 
00022 #include "printf-args.h"
00023 
00024 
00025 /* Flags */
00026 #define FLAG_GROUP       1      /* ' flag */
00027 #define FLAG_LEFT        2      /* - flag */
00028 #define FLAG_SHOWSIGN    4      /* + flag */
00029 #define FLAG_SPACE       8      /* space flag */
00030 #define FLAG_ALT        16      /* # flag */
00031 #define FLAG_ZERO       32
00032 
00033 /* arg_index value indicating that no argument is consumed.  */
00034 #define ARG_NONE        (~(size_t)0)
00035 
00036 /* A parsed directive.  */
00037 typedef struct
00038 {
00039   const char* dir_start;
00040   const char* dir_end;
00041   int flags;
00042   const char* width_start;
00043   const char* width_end;
00044   size_t width_arg_index;
00045   const char* precision_start;
00046   const char* precision_end;
00047   size_t precision_arg_index;
00048   char conversion; /* d i o u x X f e E g G c s p n U % but not C S */
00049   size_t arg_index;
00050 }
00051 char_directive;
00052 
00053 /* A parsed format string.  */
00054 typedef struct
00055 {
00056   size_t count;
00057   char_directive *dir;
00058   size_t max_width_length;
00059   size_t max_precision_length;
00060 }
00061 char_directives;
00062 
00063 
00064 /* Parses the format string.  Fills in the number N of directives, and fills
00065    in directives[0], ..., directives[N-1], and sets directives[N].dir_start
00066    to the end of the format string.  Also fills in the arg_type fields of the
00067    arguments and the needed count of arguments.  */
00068 #ifdef STATIC
00069 STATIC
00070 #else
00071 extern
00072 #endif
00073 int printf_parse (const char *format, char_directives *d, arguments *a);
00074 
00075 #endif /* _PRINTF_PARSE_H */