annotate lib/printf-parse.h @ 423:079d43b6967b 3.0-beta2 3.0-beta2

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