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