xref: /openbsd-src/gnu/usr.bin/texinfo/intl/wprintf-parse.h (revision a1acfa9b69ad64eb720639240c8438f11107dc85)
1*a1acfa9bSespie /* Parse printf format string.
2*a1acfa9bSespie    Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
3*a1acfa9bSespie 
4*a1acfa9bSespie    This program is free software; you can redistribute it and/or modify it
5*a1acfa9bSespie    under the terms of the GNU Library General Public License as published
6*a1acfa9bSespie    by the Free Software Foundation; either version 2, or (at your option)
7*a1acfa9bSespie    any later version.
8*a1acfa9bSespie 
9*a1acfa9bSespie    This program is distributed in the hope that it will be useful,
10*a1acfa9bSespie    but WITHOUT ANY WARRANTY; without even the implied warranty of
11*a1acfa9bSespie    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12*a1acfa9bSespie    Library General Public License for more details.
13*a1acfa9bSespie 
14*a1acfa9bSespie    You should have received a copy of the GNU Library General Public
15*a1acfa9bSespie    License along with this program; if not, write to the Free Software
16*a1acfa9bSespie    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17*a1acfa9bSespie    USA.  */
18*a1acfa9bSespie 
19*a1acfa9bSespie #ifndef _WPRINTF_PARSE_H
20*a1acfa9bSespie #define _WPRINTF_PARSE_H
21*a1acfa9bSespie 
22*a1acfa9bSespie #include "printf-args.h"
23*a1acfa9bSespie 
24*a1acfa9bSespie 
25*a1acfa9bSespie /* Flags */
26*a1acfa9bSespie #define FLAG_GROUP	 1	/* ' flag */
27*a1acfa9bSespie #define FLAG_LEFT	 2	/* - flag */
28*a1acfa9bSespie #define FLAG_SHOWSIGN	 4	/* + flag */
29*a1acfa9bSespie #define FLAG_SPACE	 8	/* space flag */
30*a1acfa9bSespie #define FLAG_ALT	16	/* # flag */
31*a1acfa9bSespie #define FLAG_ZERO	32
32*a1acfa9bSespie 
33*a1acfa9bSespie /* arg_index value indicating that no argument is consumed.  */
34*a1acfa9bSespie #define ARG_NONE	(~(size_t)0)
35*a1acfa9bSespie 
36*a1acfa9bSespie /* A parsed directive.  */
37*a1acfa9bSespie typedef struct
38*a1acfa9bSespie {
39*a1acfa9bSespie   const wchar_t* dir_start;
40*a1acfa9bSespie   const wchar_t* dir_end;
41*a1acfa9bSespie   int flags;
42*a1acfa9bSespie   const wchar_t* width_start;
43*a1acfa9bSespie   const wchar_t* width_end;
44*a1acfa9bSespie   size_t width_arg_index;
45*a1acfa9bSespie   const wchar_t* precision_start;
46*a1acfa9bSespie   const wchar_t* precision_end;
47*a1acfa9bSespie   size_t precision_arg_index;
48*a1acfa9bSespie   wchar_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */
49*a1acfa9bSespie   size_t arg_index;
50*a1acfa9bSespie }
51*a1acfa9bSespie wchar_t_directive;
52*a1acfa9bSespie 
53*a1acfa9bSespie /* A parsed format string.  */
54*a1acfa9bSespie typedef struct
55*a1acfa9bSespie {
56*a1acfa9bSespie   size_t count;
57*a1acfa9bSespie   wchar_t_directive *dir;
58*a1acfa9bSespie   size_t max_width_length;
59*a1acfa9bSespie   size_t max_precision_length;
60*a1acfa9bSespie }
61*a1acfa9bSespie wchar_t_directives;
62*a1acfa9bSespie 
63*a1acfa9bSespie 
64*a1acfa9bSespie /* Parses the format string.  Fills in the number N of directives, and fills
65*a1acfa9bSespie    in directives[0], ..., directives[N-1], and sets directives[N].dir_start
66*a1acfa9bSespie    to the end of the format string.  Also fills in the arg_type fields of the
67*a1acfa9bSespie    arguments and the needed count of arguments.  */
68*a1acfa9bSespie #ifdef STATIC
69*a1acfa9bSespie STATIC
70*a1acfa9bSespie #else
71*a1acfa9bSespie extern
72*a1acfa9bSespie #endif
73*a1acfa9bSespie int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a);
74*a1acfa9bSespie 
75*a1acfa9bSespie #endif /* _WPRINTF_PARSE_H */
76