Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / src / po-lex.h
1 /* GNU gettext - internationalization aids
2    Copyright (C) 1995-1998, 2000-2006, 2012, 2015 Free Software
3    Foundation, Inc.
4
5    This file was written by Peter Miller <millerp@canb.auug.org.au>
6
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 #ifndef _PO_LEX_H
21 #define _PO_LEX_H
22
23 #include <sys/types.h>
24 #include <stdio.h>
25 #include <stdbool.h>
26 #include "error.h"
27 #include "error-progname.h"
28 #include "xerror.h"
29 #include "pos.h"
30
31 #ifndef __attribute__
32 /* This feature is available in gcc versions 2.5 and later.  */
33 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
34 #  define __attribute__(Spec) /* empty */
35 # endif
36 /* The __-protected variants of 'format' and 'printf' attributes
37    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
38 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
39 #  define __format__ format
40 #  define __printf__ printf
41 # endif
42 #endif
43
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49
50 /* Lexical analyzer for reading PO files.  */
51
52
53 /* Global variables from po-lex.c.  */
54
55 /* Current position within the PO file.  */
56 extern DLL_VARIABLE lex_pos_ty gram_pos;
57 extern DLL_VARIABLE int gram_pos_column;
58
59 /* Number of parse errors within a PO file that cause the program to
60    terminate.  Cf. error_message_count, declared in <error.h>.  */
61 extern DLL_VARIABLE unsigned int gram_max_allowed_errors;
62
63 /* True if obsolete entries shall be considered as valid.  */
64 extern DLL_VARIABLE bool pass_obsolete_entries;
65
66
67 /* Prepare lexical analysis.  */
68 extern void lex_start (FILE *fp, const char *real_filename,
69                        const char *logical_filename);
70
71 /* Terminate lexical analysis.  */
72 extern void lex_end (void);
73
74 /* Return the next token in the PO file.  The return codes are defined
75    in "po-gram-gen2.h".  Associated data is put in 'po_gram_lval.  */
76 extern int po_gram_lex (void);
77
78 /* po_gram_lex() can return comments as COMMENT.  Switch this on or off.  */
79 extern void po_lex_pass_comments (bool flag);
80
81 /* po_gram_lex() can return obsolete entries as if they were normal entries.
82    Switch this on or off.  */
83 extern void po_lex_pass_obsolete_entries (bool flag);
84
85 extern void po_gram_error (const char *fmt, ...)
86        __attribute__ ((__format__ (__printf__, 1, 2)));
87 extern void po_gram_error_at_line (const lex_pos_ty *pos, const char *fmt, ...)
88        __attribute__ ((__format__ (__printf__, 2, 3)));
89
90
91 /* Contains information about the definition of one translation.  */
92 struct msgstr_def
93 {
94   char *msgstr;
95   size_t msgstr_len;
96 };
97
98
99 #ifdef __cplusplus
100 }
101 #endif
102
103
104 #endif