1
/* Parse printf format string.
2
Copyright (C) 1999, 2002-2003, 2005, 2007 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 Lesser General Public License as published by
6
the Free Software Foundation; either version 2.1, 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 Lesser General Public License for more details.
14
You should have received a copy of the GNU Lesser 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
/* This file can be parametrized with the following macros:
22
ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
23
STATIC Set to 'static' to declare the function static. */
25
#include "printf-args.h"
29
#define FLAG_GROUP 1 /* ' flag */
30
#define FLAG_LEFT 2 /* - flag */
31
#define FLAG_SHOWSIGN 4 /* + flag */
32
#define FLAG_SPACE 8 /* space flag */
33
#define FLAG_ALT 16 /* # flag */
36
/* arg_index value indicating that no argument is consumed. */
37
#define ARG_NONE (~(size_t)0)
39
/* xxx_directive: A parsed directive.
40
xxx_directives: A parsed format string. */
42
/* A parsed directive. */
45
const char* dir_start;
48
const char* width_start;
49
const char* width_end;
50
size_t width_arg_index;
51
const char* precision_start;
52
const char* precision_end;
53
size_t precision_arg_index;
54
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 */
59
/* A parsed format string. */
64
size_t max_width_length;
65
size_t max_precision_length;
71
/* A parsed directive. */
74
const uint8_t* dir_start;
75
const uint8_t* dir_end;
77
const uint8_t* width_start;
78
const uint8_t* width_end;
79
size_t width_arg_index;
80
const uint8_t* precision_start;
81
const uint8_t* precision_end;
82
size_t precision_arg_index;
83
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 */
88
/* A parsed format string. */
93
size_t max_width_length;
94
size_t max_precision_length;
98
/* A parsed directive. */
101
const uint16_t* dir_start;
102
const uint16_t* dir_end;
104
const uint16_t* width_start;
105
const uint16_t* width_end;
106
size_t width_arg_index;
107
const uint16_t* precision_start;
108
const uint16_t* precision_end;
109
size_t precision_arg_index;
110
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 */
115
/* A parsed format string. */
120
size_t max_width_length;
121
size_t max_precision_length;
125
/* A parsed directive. */
128
const uint32_t* dir_start;
129
const uint32_t* dir_end;
131
const uint32_t* width_start;
132
const uint32_t* width_end;
133
size_t width_arg_index;
134
const uint32_t* precision_start;
135
const uint32_t* precision_end;
136
size_t precision_arg_index;
137
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 */
142
/* A parsed format string. */
147
size_t max_width_length;
148
size_t max_precision_length;
155
/* Parses the format string. Fills in the number N of directives, and fills
156
in directives[0], ..., directives[N-1], and sets directives[N].dir_start
157
to the end of the format string. Also fills in the arg_type fields of the
158
arguments and the needed count of arguments. */
161
ulc_printf_parse (const char *format, char_directives *d, arguments *a);
163
u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
165
u16_printf_parse (const uint16_t *format, u16_directives *d,
168
u32_printf_parse (const uint32_t *format, u32_directives *d,
176
int printf_parse (const char *format, char_directives *d, arguments *a);
179
#endif /* _PRINTF_PARSE_H */