Import upstream version 1.27
[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-2013 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, see <http://www.gnu.org/licenses/>.  */
19
20 #ifndef _PRINTF_PARSE_H
21 #define _PRINTF_PARSE_H
22
23 /* This file can be parametrized with the following macros:
24      ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions.
25      STATIC             Set to 'static' to declare the function static.  */
26
27 #if HAVE_FEATURES_H
28 # include <features.h> /* for __GLIBC__, __UCLIBC__ */
29 #endif
30
31 #include "printf-args.h"
32
33
34 /* Flags */
35 #define FLAG_GROUP       1      /* ' flag */
36 #define FLAG_LEFT        2      /* - flag */
37 #define FLAG_SHOWSIGN    4      /* + flag */
38 #define FLAG_SPACE       8      /* space flag */
39 #define FLAG_ALT        16      /* # flag */
40 #define FLAG_ZERO       32
41 #if __GLIBC__ >= 2 && !defined __UCLIBC__
42 # define FLAG_LOCALIZED 64      /* I flag, uses localized digits */
43 #endif
44
45 /* arg_index value indicating that no argument is consumed.  */
46 #define ARG_NONE        (~(size_t)0)
47
48 /* xxx_directive: A parsed directive.
49    xxx_directives: A parsed format string.  */
50
51 /* Number of directly allocated directives (no malloc() needed).  */
52 #define N_DIRECT_ALLOC_DIRECTIVES 7
53
54 /* A parsed directive.  */
55 typedef struct
56 {
57   const char* dir_start;
58   const char* dir_end;
59   int flags;
60   const char* width_start;
61   const char* width_end;
62   size_t width_arg_index;
63   const char* precision_start;
64   const char* precision_end;
65   size_t precision_arg_index;
66   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 */
67   size_t arg_index;
68 }
69 char_directive;
70
71 /* A parsed format string.  */
72 typedef struct
73 {
74   size_t count;
75   char_directive *dir;
76   size_t max_width_length;
77   size_t max_precision_length;
78   char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
79 }
80 char_directives;
81
82 #if ENABLE_UNISTDIO
83
84 /* A parsed directive.  */
85 typedef struct
86 {
87   const uint8_t* dir_start;
88   const uint8_t* dir_end;
89   int flags;
90   const uint8_t* width_start;
91   const uint8_t* width_end;
92   size_t width_arg_index;
93   const uint8_t* precision_start;
94   const uint8_t* precision_end;
95   size_t precision_arg_index;
96   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 */
97   size_t arg_index;
98 }
99 u8_directive;
100
101 /* A parsed format string.  */
102 typedef struct
103 {
104   size_t count;
105   u8_directive *dir;
106   size_t max_width_length;
107   size_t max_precision_length;
108   u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
109 }
110 u8_directives;
111
112 /* A parsed directive.  */
113 typedef struct
114 {
115   const uint16_t* dir_start;
116   const uint16_t* dir_end;
117   int flags;
118   const uint16_t* width_start;
119   const uint16_t* width_end;
120   size_t width_arg_index;
121   const uint16_t* precision_start;
122   const uint16_t* precision_end;
123   size_t precision_arg_index;
124   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 */
125   size_t arg_index;
126 }
127 u16_directive;
128
129 /* A parsed format string.  */
130 typedef struct
131 {
132   size_t count;
133   u16_directive *dir;
134   size_t max_width_length;
135   size_t max_precision_length;
136   u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
137 }
138 u16_directives;
139
140 /* A parsed directive.  */
141 typedef struct
142 {
143   const uint32_t* dir_start;
144   const uint32_t* dir_end;
145   int flags;
146   const uint32_t* width_start;
147   const uint32_t* width_end;
148   size_t width_arg_index;
149   const uint32_t* precision_start;
150   const uint32_t* precision_end;
151   size_t precision_arg_index;
152   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 */
153   size_t arg_index;
154 }
155 u32_directive;
156
157 /* A parsed format string.  */
158 typedef struct
159 {
160   size_t count;
161   u32_directive *dir;
162   size_t max_width_length;
163   size_t max_precision_length;
164   u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
165 }
166 u32_directives;
167
168 #endif
169
170
171 /* Parses the format string.  Fills in the number N of directives, and fills
172    in directives[0], ..., directives[N-1], and sets directives[N].dir_start
173    to the end of the format string.  Also fills in the arg_type fields of the
174    arguments and the needed count of arguments.  */
175 #if ENABLE_UNISTDIO
176 extern int
177        ulc_printf_parse (const char *format, char_directives *d, arguments *a);
178 extern int
179        u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
180 extern int
181        u16_printf_parse (const uint16_t *format, u16_directives *d,
182                          arguments *a);
183 extern int
184        u32_printf_parse (const uint32_t *format, u32_directives *d,
185                          arguments *a);
186 #else
187 # ifdef STATIC
188 STATIC
189 # else
190 extern
191 # endif
192 int printf_parse (const char *format, char_directives *d, arguments *a);
193 #endif
194
195 #endif /* _PRINTF_PARSE_H */