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