1 /* Parse printf format string.
2 Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 #ifndef _PRINTF_PARSE_H
19 #define _PRINTF_PARSE_H
21 #include "printf-args.h"
25 #define FLAG_GROUP 1 /* ' flag */
26 #define FLAG_LEFT 2 /* - flag */
27 #define FLAG_SHOWSIGN 4 /* + flag */
28 #define FLAG_SPACE 8 /* space flag */
29 #define FLAG_ALT 16 /* # flag */
32 /* arg_index value indicating that no argument is consumed. */
33 #define ARG_NONE (~(size_t)0)
35 /* A parsed directive. */
38 const char* dir_start
;
41 const char* width_start
;
42 const char* width_end
;
43 size_t width_arg_index
;
44 const char* precision_start
;
45 const char* precision_end
;
46 size_t precision_arg_index
;
47 char conversion
; /* d i o u x X f e E g G c s p n U % but not C S */
52 /* A parsed format string. */
57 size_t max_width_length
;
58 size_t max_precision_length
;
63 /* Parses the format string. Fills in the number N of directives, and fills
64 in directives[0], ..., directives[N-1], and sets directives[N].dir_start
65 to the end of the format string. Also fills in the arg_type fields of the
66 arguments and the needed count of arguments. */
72 int printf_parse (const char *format
, char_directives
*d
, arguments
*a
);
74 #endif /* _PRINTF_PARSE_H */