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