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