Mercurial > hg-old > index.cgi
comparison lib/printf-parse.h @ 421:3c2e1f24cc7d 3.0-beta2
Added generated files for release
author | lost@l-w.ca |
---|---|
date | Sun, 19 Sep 2010 01:33:24 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
420:7366deedfa85 | 421:3c2e1f24cc7d |
---|---|
1 /* Parse printf format string. | |
2 Copyright (C) 1999, 2002-2003, 2005, 2007, 2009-2010 Free Software | |
3 Foundation, Inc. | |
4 | |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 3, or (at your option) | |
8 any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License along | |
16 with this program; if not, write to the Free Software Foundation, | |
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
18 | |
19 #ifndef _PRINTF_PARSE_H | |
20 #define _PRINTF_PARSE_H | |
21 | |
22 /* This file can be parametrized with the following macros: | |
23 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. | |
24 STATIC Set to 'static' to declare the function static. */ | |
25 | |
26 #include "printf-args.h" | |
27 | |
28 | |
29 /* Flags */ | |
30 #define FLAG_GROUP 1 /* ' flag */ | |
31 #define FLAG_LEFT 2 /* - flag */ | |
32 #define FLAG_SHOWSIGN 4 /* + flag */ | |
33 #define FLAG_SPACE 8 /* space flag */ | |
34 #define FLAG_ALT 16 /* # flag */ | |
35 #define FLAG_ZERO 32 | |
36 | |
37 /* arg_index value indicating that no argument is consumed. */ | |
38 #define ARG_NONE (~(size_t)0) | |
39 | |
40 /* xxx_directive: A parsed directive. | |
41 xxx_directives: A parsed format string. */ | |
42 | |
43 /* A parsed directive. */ | |
44 typedef struct | |
45 { | |
46 const char* dir_start; | |
47 const char* dir_end; | |
48 int flags; | |
49 const char* width_start; | |
50 const char* width_end; | |
51 size_t width_arg_index; | |
52 const char* precision_start; | |
53 const char* precision_end; | |
54 size_t precision_arg_index; | |
55 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 */ | |
56 size_t arg_index; | |
57 } | |
58 char_directive; | |
59 | |
60 /* A parsed format string. */ | |
61 typedef struct | |
62 { | |
63 size_t count; | |
64 char_directive *dir; | |
65 size_t max_width_length; | |
66 size_t max_precision_length; | |
67 } | |
68 char_directives; | |
69 | |
70 #if ENABLE_UNISTDIO | |
71 | |
72 /* A parsed directive. */ | |
73 typedef struct | |
74 { | |
75 const uint8_t* dir_start; | |
76 const uint8_t* dir_end; | |
77 int flags; | |
78 const uint8_t* width_start; | |
79 const uint8_t* width_end; | |
80 size_t width_arg_index; | |
81 const uint8_t* precision_start; | |
82 const uint8_t* precision_end; | |
83 size_t precision_arg_index; | |
84 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 */ | |
85 size_t arg_index; | |
86 } | |
87 u8_directive; | |
88 | |
89 /* A parsed format string. */ | |
90 typedef struct | |
91 { | |
92 size_t count; | |
93 u8_directive *dir; | |
94 size_t max_width_length; | |
95 size_t max_precision_length; | |
96 } | |
97 u8_directives; | |
98 | |
99 /* A parsed directive. */ | |
100 typedef struct | |
101 { | |
102 const uint16_t* dir_start; | |
103 const uint16_t* dir_end; | |
104 int flags; | |
105 const uint16_t* width_start; | |
106 const uint16_t* width_end; | |
107 size_t width_arg_index; | |
108 const uint16_t* precision_start; | |
109 const uint16_t* precision_end; | |
110 size_t precision_arg_index; | |
111 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 */ | |
112 size_t arg_index; | |
113 } | |
114 u16_directive; | |
115 | |
116 /* A parsed format string. */ | |
117 typedef struct | |
118 { | |
119 size_t count; | |
120 u16_directive *dir; | |
121 size_t max_width_length; | |
122 size_t max_precision_length; | |
123 } | |
124 u16_directives; | |
125 | |
126 /* A parsed directive. */ | |
127 typedef struct | |
128 { | |
129 const uint32_t* dir_start; | |
130 const uint32_t* dir_end; | |
131 int flags; | |
132 const uint32_t* width_start; | |
133 const uint32_t* width_end; | |
134 size_t width_arg_index; | |
135 const uint32_t* precision_start; | |
136 const uint32_t* precision_end; | |
137 size_t precision_arg_index; | |
138 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 */ | |
139 size_t arg_index; | |
140 } | |
141 u32_directive; | |
142 | |
143 /* A parsed format string. */ | |
144 typedef struct | |
145 { | |
146 size_t count; | |
147 u32_directive *dir; | |
148 size_t max_width_length; | |
149 size_t max_precision_length; | |
150 } | |
151 u32_directives; | |
152 | |
153 #endif | |
154 | |
155 | |
156 /* Parses the format string. Fills in the number N of directives, and fills | |
157 in directives[0], ..., directives[N-1], and sets directives[N].dir_start | |
158 to the end of the format string. Also fills in the arg_type fields of the | |
159 arguments and the needed count of arguments. */ | |
160 #if ENABLE_UNISTDIO | |
161 extern int | |
162 ulc_printf_parse (const char *format, char_directives *d, arguments *a); | |
163 extern int | |
164 u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a); | |
165 extern int | |
166 u16_printf_parse (const uint16_t *format, u16_directives *d, | |
167 arguments *a); | |
168 extern int | |
169 u32_printf_parse (const uint32_t *format, u32_directives *d, | |
170 arguments *a); | |
171 #else | |
172 # ifdef STATIC | |
173 STATIC | |
174 # else | |
175 extern | |
176 # endif | |
177 int printf_parse (const char *format, char_directives *d, arguments *a); | |
178 #endif | |
179 | |
180 #endif /* _PRINTF_PARSE_H */ |