add isl_pw_qpolynomial_upper_bound
[barvinok.git] / lib / printf-parse.h
blobde7fc49b6fbc17d79196cdd59b6eac099ba63624
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 General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
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 /* 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"
28 /* Flags */
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 */
34 #define FLAG_ZERO 32
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. */
43 typedef struct
45 const char* dir_start;
46 const char* dir_end;
47 int flags;
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 */
55 size_t arg_index;
57 char_directive;
59 /* A parsed format string. */
60 typedef struct
62 size_t count;
63 char_directive *dir;
64 size_t max_width_length;
65 size_t max_precision_length;
67 char_directives;
69 #if ENABLE_UNISTDIO
71 /* A parsed directive. */
72 typedef struct
74 const uint8_t* dir_start;
75 const uint8_t* dir_end;
76 int flags;
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 */
84 size_t arg_index;
86 u8_directive;
88 /* A parsed format string. */
89 typedef struct
91 size_t count;
92 u8_directive *dir;
93 size_t max_width_length;
94 size_t max_precision_length;
96 u8_directives;
98 /* A parsed directive. */
99 typedef struct
101 const uint16_t* dir_start;
102 const uint16_t* dir_end;
103 int flags;
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 */
111 size_t arg_index;
113 u16_directive;
115 /* A parsed format string. */
116 typedef struct
118 size_t count;
119 u16_directive *dir;
120 size_t max_width_length;
121 size_t max_precision_length;
123 u16_directives;
125 /* A parsed directive. */
126 typedef struct
128 const uint32_t* dir_start;
129 const uint32_t* dir_end;
130 int flags;
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 */
138 size_t arg_index;
140 u32_directive;
142 /* A parsed format string. */
143 typedef struct
145 size_t count;
146 u32_directive *dir;
147 size_t max_width_length;
148 size_t max_precision_length;
150 u32_directives;
152 #endif
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. */
159 #if ENABLE_UNISTDIO
160 extern int
161 ulc_printf_parse (const char *format, char_directives *d, arguments *a);
162 extern int
163 u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
164 extern int
165 u16_printf_parse (const uint16_t *format, u16_directives *d,
166 arguments *a);
167 extern int
168 u32_printf_parse (const uint32_t *format, u32_directives *d,
169 arguments *a);
170 #else
171 # ifdef STATIC
172 STATIC
173 # else
174 extern
175 # endif
176 int printf_parse (const char *format, char_directives *d, arguments *a);
177 #endif
179 #endif /* _PRINTF_PARSE_H */