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