1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Parse printf format string.
4 Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2014 Free Software
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, see <http://www.gnu.org/licenses/>. */
20 #ifndef _PRINTF_PARSE_H
21 #define _PRINTF_PARSE_H
23 /* This file can be parametrized with the following macros:
24 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
25 STATIC Set to 'static' to declare the function static. */
28 # include <features.h> /* for __GLIBC__, __UCLIBC__ */
31 #include "printf-args.h"
35 #define FLAG_GROUP 1 /* ' flag */
36 #define FLAG_LEFT 2 /* - flag */
37 #define FLAG_SHOWSIGN 4 /* + flag */
38 #define FLAG_SPACE 8 /* space flag */
39 #define FLAG_ALT 16 /* # flag */
41 #if __GLIBC__ >= 2 && !defined __UCLIBC__
42 # define FLAG_LOCALIZED 64 /* I flag, uses localized digits */
45 /* arg_index value indicating that no argument is consumed. */
46 #define ARG_NONE (~(size_t)0)
48 /* xxx_directive: A parsed directive.
49 xxx_directives: A parsed format string. */
51 /* Number of directly allocated directives (no malloc() needed). */
52 #define N_DIRECT_ALLOC_DIRECTIVES 7
54 /* A parsed directive. */
57 const char* dir_start;
60 const char* width_start;
61 const char* width_end;
62 size_t width_arg_index;
63 const char* precision_start;
64 const char* precision_end;
65 size_t precision_arg_index;
66 char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
71 /* A parsed format string. */
76 size_t max_width_length;
77 size_t max_precision_length;
78 char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
84 /* A parsed directive. */
87 const uint8_t* dir_start;
88 const uint8_t* dir_end;
90 const uint8_t* width_start;
91 const uint8_t* width_end;
92 size_t width_arg_index;
93 const uint8_t* precision_start;
94 const uint8_t* precision_end;
95 size_t precision_arg_index;
96 uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
101 /* A parsed format string. */
106 size_t max_width_length;
107 size_t max_precision_length;
108 u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
112 /* A parsed directive. */
115 const uint16_t* dir_start;
116 const uint16_t* dir_end;
118 const uint16_t* width_start;
119 const uint16_t* width_end;
120 size_t width_arg_index;
121 const uint16_t* precision_start;
122 const uint16_t* precision_end;
123 size_t precision_arg_index;
124 uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
129 /* A parsed format string. */
134 size_t max_width_length;
135 size_t max_precision_length;
136 u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
140 /* A parsed directive. */
143 const uint32_t* dir_start;
144 const uint32_t* dir_end;
146 const uint32_t* width_start;
147 const uint32_t* width_end;
148 size_t width_arg_index;
149 const uint32_t* precision_start;
150 const uint32_t* precision_end;
151 size_t precision_arg_index;
152 uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
157 /* A parsed format string. */
162 size_t max_width_length;
163 size_t max_precision_length;
164 u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
171 /* Parses the format string. Fills in the number N of directives, and fills
172 in directives[0], ..., directives[N-1], and sets directives[N].dir_start
173 to the end of the format string. Also fills in the arg_type fields of the
174 arguments and the needed count of arguments. */
177 ulc_printf_parse (const char *format, char_directives *d, arguments *a);
179 u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
181 u16_printf_parse (const uint16_t *format, u16_directives *d,
184 u32_printf_parse (const uint32_t *format, u32_directives *d,
192 int printf_parse (const char *format, char_directives *d, arguments *a);
195 #endif /* _PRINTF_PARSE_H */