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-2011 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, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
21 #ifndef _PRINTF_PARSE_H
22 #define _PRINTF_PARSE_H
24 /* This file can be parametrized with the following macros:
25 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
26 STATIC Set to 'static' to declare the function static. */
29 # include <features.h> /* for __GLIBC__, __UCLIBC__ */
32 #include "printf-args.h"
36 #define FLAG_GROUP 1 /* ' flag */
37 #define FLAG_LEFT 2 /* - flag */
38 #define FLAG_SHOWSIGN 4 /* + flag */
39 #define FLAG_SPACE 8 /* space flag */
40 #define FLAG_ALT 16 /* # flag */
42 #if __GLIBC__ >= 2 && !defined __UCLIBC__
43 # define FLAG_LOCALIZED 64 /* I flag, uses localized digits */
46 /* arg_index value indicating that no argument is consumed. */
47 #define ARG_NONE (~(size_t)0)
49 /* xxx_directive: A parsed directive.
50 xxx_directives: A parsed format string. */
52 /* Number of directly allocated directives (no malloc() needed). */
53 #define N_DIRECT_ALLOC_DIRECTIVES 7
55 /* A parsed directive. */
58 const char* dir_start
;
61 const char* width_start
;
62 const char* width_end
;
63 size_t width_arg_index
;
64 const char* precision_start
;
65 const char* precision_end
;
66 size_t precision_arg_index
;
67 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 */
72 /* A parsed format string. */
77 size_t max_width_length
;
78 size_t max_precision_length
;
79 char_directive direct_alloc_dir
[N_DIRECT_ALLOC_DIRECTIVES
];
85 /* A parsed directive. */
88 const uint8_t* dir_start
;
89 const uint8_t* dir_end
;
91 const uint8_t* width_start
;
92 const uint8_t* width_end
;
93 size_t width_arg_index
;
94 const uint8_t* precision_start
;
95 const uint8_t* precision_end
;
96 size_t precision_arg_index
;
97 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 */
102 /* A parsed format string. */
107 size_t max_width_length
;
108 size_t max_precision_length
;
109 u8_directive direct_alloc_dir
[N_DIRECT_ALLOC_DIRECTIVES
];
113 /* A parsed directive. */
116 const uint16_t* dir_start
;
117 const uint16_t* dir_end
;
119 const uint16_t* width_start
;
120 const uint16_t* width_end
;
121 size_t width_arg_index
;
122 const uint16_t* precision_start
;
123 const uint16_t* precision_end
;
124 size_t precision_arg_index
;
125 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 */
130 /* A parsed format string. */
135 size_t max_width_length
;
136 size_t max_precision_length
;
137 u16_directive direct_alloc_dir
[N_DIRECT_ALLOC_DIRECTIVES
];
141 /* A parsed directive. */
144 const uint32_t* dir_start
;
145 const uint32_t* dir_end
;
147 const uint32_t* width_start
;
148 const uint32_t* width_end
;
149 size_t width_arg_index
;
150 const uint32_t* precision_start
;
151 const uint32_t* precision_end
;
152 size_t precision_arg_index
;
153 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 */
158 /* A parsed format string. */
163 size_t max_width_length
;
164 size_t max_precision_length
;
165 u32_directive direct_alloc_dir
[N_DIRECT_ALLOC_DIRECTIVES
];
172 /* Parses the format string. Fills in the number N of directives, and fills
173 in directives[0], ..., directives[N-1], and sets directives[N].dir_start
174 to the end of the format string. Also fills in the arg_type fields of the
175 arguments and the needed count of arguments. */
178 ulc_printf_parse (const char *format
, char_directives
*d
, arguments
*a
);
180 u8_printf_parse (const uint8_t *format
, u8_directives
*d
, arguments
*a
);
182 u16_printf_parse (const uint16_t *format
, u16_directives
*d
,
185 u32_printf_parse (const uint32_t *format
, u32_directives
*d
,
193 int printf_parse (const char *format
, char_directives
*d
, arguments
*a
);
196 #endif /* _PRINTF_PARSE_H */