]> git.cworth.org Git - tar/blob - gnu/printf-parse.h
upstream: Fix extraction of device nodes.
[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, 2009-2010 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 #include "printf-args.h"
29
30
31 /* Flags */
32 #define FLAG_GROUP       1      /* ' flag */
33 #define FLAG_LEFT        2      /* - flag */
34 #define FLAG_SHOWSIGN    4      /* + flag */
35 #define FLAG_SPACE       8      /* space flag */
36 #define FLAG_ALT        16      /* # flag */
37 #define FLAG_ZERO       32
38
39 /* arg_index value indicating that no argument is consumed.  */
40 #define ARG_NONE        (~(size_t)0)
41
42 /* xxx_directive: A parsed directive.
43    xxx_directives: A parsed format string.  */
44
45 /* A parsed directive.  */
46 typedef struct
47 {
48   const char* dir_start;
49   const char* dir_end;
50   int flags;
51   const char* width_start;
52   const char* width_end;
53   size_t width_arg_index;
54   const char* precision_start;
55   const char* precision_end;
56   size_t precision_arg_index;
57   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 */
58   size_t arg_index;
59 }
60 char_directive;
61
62 /* A parsed format string.  */
63 typedef struct
64 {
65   size_t count;
66   char_directive *dir;
67   size_t max_width_length;
68   size_t max_precision_length;
69 }
70 char_directives;
71
72 #if ENABLE_UNISTDIO
73
74 /* A parsed directive.  */
75 typedef struct
76 {
77   const uint8_t* dir_start;
78   const uint8_t* dir_end;
79   int flags;
80   const uint8_t* width_start;
81   const uint8_t* width_end;
82   size_t width_arg_index;
83   const uint8_t* precision_start;
84   const uint8_t* precision_end;
85   size_t precision_arg_index;
86   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 */
87   size_t arg_index;
88 }
89 u8_directive;
90
91 /* A parsed format string.  */
92 typedef struct
93 {
94   size_t count;
95   u8_directive *dir;
96   size_t max_width_length;
97   size_t max_precision_length;
98 }
99 u8_directives;
100
101 /* A parsed directive.  */
102 typedef struct
103 {
104   const uint16_t* dir_start;
105   const uint16_t* dir_end;
106   int flags;
107   const uint16_t* width_start;
108   const uint16_t* width_end;
109   size_t width_arg_index;
110   const uint16_t* precision_start;
111   const uint16_t* precision_end;
112   size_t precision_arg_index;
113   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 */
114   size_t arg_index;
115 }
116 u16_directive;
117
118 /* A parsed format string.  */
119 typedef struct
120 {
121   size_t count;
122   u16_directive *dir;
123   size_t max_width_length;
124   size_t max_precision_length;
125 }
126 u16_directives;
127
128 /* A parsed directive.  */
129 typedef struct
130 {
131   const uint32_t* dir_start;
132   const uint32_t* dir_end;
133   int flags;
134   const uint32_t* width_start;
135   const uint32_t* width_end;
136   size_t width_arg_index;
137   const uint32_t* precision_start;
138   const uint32_t* precision_end;
139   size_t precision_arg_index;
140   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 */
141   size_t arg_index;
142 }
143 u32_directive;
144
145 /* A parsed format string.  */
146 typedef struct
147 {
148   size_t count;
149   u32_directive *dir;
150   size_t max_width_length;
151   size_t max_precision_length;
152 }
153 u32_directives;
154
155 #endif
156
157
158 /* Parses the format string.  Fills in the number N of directives, and fills
159    in directives[0], ..., directives[N-1], and sets directives[N].dir_start
160    to the end of the format string.  Also fills in the arg_type fields of the
161    arguments and the needed count of arguments.  */
162 #if ENABLE_UNISTDIO
163 extern int
164        ulc_printf_parse (const char *format, char_directives *d, arguments *a);
165 extern int
166        u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
167 extern int
168        u16_printf_parse (const uint16_t *format, u16_directives *d,
169                          arguments *a);
170 extern int
171        u32_printf_parse (const uint32_t *format, u32_directives *d,
172                          arguments *a);
173 #else
174 # ifdef STATIC
175 STATIC
176 # else
177 extern
178 # endif
179 int printf_parse (const char *format, char_directives *d, arguments *a);
180 #endif
181
182 #endif /* _PRINTF_PARSE_H */