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