2
Copyright (C) 2001-2004 Free Software Foundation, Inc.
3
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2, or (at your option)
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software Foundation,
17
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24
#include "pos.h" /* Get lex_pos_ty. */
25
#include "message.h" /* Get NFORMATS. */
33
/* This structure describes a format string parser for a language. */
34
struct formatstring_parser
36
/* Parse the given string as a format string.
37
If translated is true, some extensions available only to msgstr but not
38
to msgid strings are recognized.
39
Return a freshly allocated structure describing
40
1. the argument types/names needed for the format string,
41
2. the total number of format directives.
42
Return NULL if the string is not a valid format string. In this case,
43
also set *invalid_reason to an error message explaining why. */
44
void * (*parse) (const char *string, bool translated, char **invalid_reason);
46
/* Free a format string descriptor, returned by parse(). */
47
void (*free) (void *descr);
49
/* Return the number of format directives.
50
A string that can be output literally has 0 format directives. */
51
int (*get_number_of_directives) (void *descr);
53
/* Verify that the argument types/names in msgid_descr and those in
54
msgstr_descr are the same (if equality=true), or (if equality=false)
55
that those of msgid_descr extend those of msgstr_descr (i.e.
56
msgstr_descr may omit some of the arguments of msgid_descr).
57
If not, signal an error using
58
error_with_progname = false;
59
error_at_line (0, 0, pos->file_name, pos->line_number, ...);
60
error_with_progname = true;
61
(but only if noisy=true) and return true. Otherwise return false. */
62
bool (*check) (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr, bool equality, bool noisy, const char *pretty_msgstr);
65
/* Format string parsers, each defined in its own file. */
66
extern DLL_VARIABLE struct formatstring_parser formatstring_c;
67
extern DLL_VARIABLE struct formatstring_parser formatstring_objc;
68
extern DLL_VARIABLE struct formatstring_parser formatstring_sh;
69
extern DLL_VARIABLE struct formatstring_parser formatstring_python;
70
extern DLL_VARIABLE struct formatstring_parser formatstring_lisp;
71
extern DLL_VARIABLE struct formatstring_parser formatstring_elisp;
72
extern DLL_VARIABLE struct formatstring_parser formatstring_librep;
73
extern DLL_VARIABLE struct formatstring_parser formatstring_smalltalk;
74
extern DLL_VARIABLE struct formatstring_parser formatstring_java;
75
extern DLL_VARIABLE struct formatstring_parser formatstring_csharp;
76
extern DLL_VARIABLE struct formatstring_parser formatstring_awk;
77
extern DLL_VARIABLE struct formatstring_parser formatstring_pascal;
78
extern DLL_VARIABLE struct formatstring_parser formatstring_ycp;
79
extern DLL_VARIABLE struct formatstring_parser formatstring_tcl;
80
extern DLL_VARIABLE struct formatstring_parser formatstring_perl;
81
extern DLL_VARIABLE struct formatstring_parser formatstring_perl_brace;
82
extern DLL_VARIABLE struct formatstring_parser formatstring_php;
83
extern DLL_VARIABLE struct formatstring_parser formatstring_gcc_internal;
84
extern DLL_VARIABLE struct formatstring_parser formatstring_qt;
86
/* Table of all format string parsers. */
87
extern DLL_VARIABLE struct formatstring_parser *formatstring_parsers[NFORMATS];
89
/* Returns an array of the ISO C 99 <inttypes.h> format directives and other
90
format flags or directives with a system dependent expansion contained in
91
the argument string. *intervalsp is assigned to a freshly allocated array
92
of intervals (startpos pointing to '<', endpos to the character after '>'),
93
and *lengthp is assigned to the number of intervals in this array. */
100
get_sysdep_c_format_directives (const char *string, bool translated,
101
struct interval **intervalsp, size_t *lengthp);
109
#endif /* _FORMAT_H */