1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef _PRINTF_PARSE_H
19 #define _PRINTF_PARSE_H
20
21
22
23
24
25 #if HAVE_FEATURES_H
26 # include <features.h>
27 #endif
28
29 #include "printf-args.h"
30
31
32
33 #define FLAG_GROUP 1
34 #define FLAG_LEFT 2
35 #define FLAG_SHOWSIGN 4
36 #define FLAG_SPACE 8
37 #define FLAG_ALT 16
38 #define FLAG_ZERO 32
39 #if __GLIBC__ >= 2 && !defined __UCLIBC__
40 # define FLAG_LOCALIZED 64
41 #endif
42
43
44 #define ARG_NONE (~(size_t)0)
45
46
47
48
49
50 #define N_DIRECT_ALLOC_DIRECTIVES 7
51
52
53 typedef struct
54 {
55 const char* dir_start;
56 const char* dir_end;
57 int flags;
58 const char* width_start;
59 const char* width_end;
60 size_t width_arg_index;
61 const char* precision_start;
62 const char* precision_end;
63 size_t precision_arg_index;
64 char conversion;
65 size_t arg_index;
66 }
67 char_directive;
68
69
70 typedef struct
71 {
72 size_t count;
73 char_directive *dir;
74 size_t max_width_length;
75 size_t max_precision_length;
76 char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
77 }
78 char_directives;
79
80 #if ENABLE_UNISTDIO
81
82
83 typedef struct
84 {
85 const uint8_t* dir_start;
86 const uint8_t* dir_end;
87 int flags;
88 const uint8_t* width_start;
89 const uint8_t* width_end;
90 size_t width_arg_index;
91 const uint8_t* precision_start;
92 const uint8_t* precision_end;
93 size_t precision_arg_index;
94 uint8_t conversion;
95 size_t arg_index;
96 }
97 u8_directive;
98
99
100 typedef struct
101 {
102 size_t count;
103 u8_directive *dir;
104 size_t max_width_length;
105 size_t max_precision_length;
106 u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
107 }
108 u8_directives;
109
110
111 typedef struct
112 {
113 const uint16_t* dir_start;
114 const uint16_t* dir_end;
115 int flags;
116 const uint16_t* width_start;
117 const uint16_t* width_end;
118 size_t width_arg_index;
119 const uint16_t* precision_start;
120 const uint16_t* precision_end;
121 size_t precision_arg_index;
122 uint16_t conversion;
123 size_t arg_index;
124 }
125 u16_directive;
126
127
128 typedef struct
129 {
130 size_t count;
131 u16_directive *dir;
132 size_t max_width_length;
133 size_t max_precision_length;
134 u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
135 }
136 u16_directives;
137
138
139 typedef struct
140 {
141 const uint32_t* dir_start;
142 const uint32_t* dir_end;
143 int flags;
144 const uint32_t* width_start;
145 const uint32_t* width_end;
146 size_t width_arg_index;
147 const uint32_t* precision_start;
148 const uint32_t* precision_end;
149 size_t precision_arg_index;
150 uint32_t conversion;
151 size_t arg_index;
152 }
153 u32_directive;
154
155
156 typedef struct
157 {
158 size_t count;
159 u32_directive *dir;
160 size_t max_width_length;
161 size_t max_precision_length;
162 u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
163 }
164 u32_directives;
165
166 #endif
167
168
169
170
171
172
173 #if ENABLE_UNISTDIO
174 extern int
175 ulc_printf_parse (const char *format, char_directives *d, arguments *a);
176 extern int
177 u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
178 extern int
179 u16_printf_parse (const uint16_t *format, u16_directives *d,
180 arguments *a);
181 extern int
182 u32_printf_parse (const uint32_t *format, u32_directives *d,
183 arguments *a);
184 #else
185 # ifdef STATIC
186 STATIC
187 # else
188 extern
189 # endif
190 int printf_parse (const char *format, char_directives *d, arguments *a);
191 #endif
192
193 #endif