2 Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
3 This file was written by Bruno Haible <haible@clisp.cons.org>.
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. */
23 #include "read-po-abstract.h"
29 /* For including this file in C++ mode. */
39 /* The following pair of structures cooperate to create a derived class from
40 class abstract_po_reader_ty. (See read-po-abstract.h for an explanation.)
41 It implements the default behaviour of reading a PO file and converting it
42 to an 'msgdomain_list_ty *'. */
44 /* Forward declaration. */
45 struct default_po_reader_ty
;
48 typedef struct default_po_reader_class_ty default_po_reader_class_ty
;
49 struct default_po_reader_class_ty
51 /* Methods inherited from superclass. */
52 struct abstract_po_reader_class_ty super
;
54 /* How to change the current domain. */
55 void (*set_domain
) (struct default_po_reader_ty
*pop
, char *name
);
57 /* How to add a message to the list. */
58 void (*add_message
) (struct default_po_reader_ty
*pop
,
59 char *msgid
, lex_pos_ty
*msgid_pos
, char *msgid_plural
,
60 char *msgstr
, size_t msgstr_len
, lex_pos_ty
*msgstr_pos
,
61 bool force_fuzzy
, bool obsolete
);
63 /* How to modify a new message before adding it to the list. */
64 void (*frob_new_message
) (struct default_po_reader_ty
*pop
, message_ty
*mp
,
65 const lex_pos_ty
*msgid_pos
,
66 const lex_pos_ty
*msgstr_pos
);
70 #define DEFAULT_PO_READER_TY \
71 ABSTRACT_PO_READER_TY \
73 /* If true, pay attention to comments and filepos comments. */ \
74 bool handle_comments; \
76 /* If true, remember comments for file name and line number for each \
77 msgid, if present in the reference input. */ \
78 bool handle_filepos_comments; \
80 /* If false, domain directives lead to an error messsage. */ \
81 bool allow_domain_directives; \
83 /* If false, duplicate msgids in the same domain and file generate an \
84 error. If true, such msgids are allowed; the caller should treat \
85 them appropriately. */ \
86 bool allow_duplicates; \
88 /* If true, allow duplicates if they have the same translation. */ \
89 bool allow_duplicates_if_same_msgstr; \
91 /* List of messages already appeared in the current file. */ \
92 msgdomain_list_ty *mdlp; \
94 /* Name of domain we are currently examining. */ \
97 /* List of messages belonging to the current domain. */ \
98 message_list_ty *mlp; \
100 /* Accumulate comments for next message directive. */ \
101 string_list_ty *comment; \
102 string_list_ty *comment_dot; \
104 /* Accumulate filepos comments for the next message directive. */ \
105 size_t filepos_count; \
106 lex_pos_ty *filepos; \
108 /* Flags transported in special comments. */ \
110 enum is_format is_format[NFORMATS]; \
111 enum is_wrap do_wrap; \
113 typedef struct default_po_reader_ty default_po_reader_ty;
114 struct default_po_reader_ty
119 extern void default_constructor (abstract_po_reader_ty
*that
);
120 extern void default_destructor (abstract_po_reader_ty
*that
);
121 extern void default_parse_brief (abstract_po_reader_ty
*that
);
122 extern void default_parse_debrief (abstract_po_reader_ty
*that
);
123 extern void default_directive_domain (abstract_po_reader_ty
*that
, char *name
);
124 extern void default_directive_message (abstract_po_reader_ty
*that
,
126 lex_pos_ty
*msgid_pos
,
128 char *msgstr
, size_t msgstr_len
,
129 lex_pos_ty
*msgstr_pos
,
130 bool force_fuzzy
, bool obsolete
);
131 extern void default_comment (abstract_po_reader_ty
*that
, const char *s
);
132 extern void default_comment_dot (abstract_po_reader_ty
*that
, const char *s
);
133 extern void default_comment_filepos (abstract_po_reader_ty
*that
,
134 const char *name
, size_t line
);
135 extern void default_comment_special (abstract_po_reader_ty
*that
,
137 extern void default_set_domain (default_po_reader_ty
*this, char *name
);
138 extern void default_add_message (default_po_reader_ty
*this,
140 lex_pos_ty
*msgid_pos
,
142 char *msgstr
, size_t msgstr_len
,
143 lex_pos_ty
*msgstr_pos
,
144 bool force_fuzzy
, bool obsolete
);
146 /* Allocate a fresh default_po_reader_ty (or derived class) instance and
147 call its constructor. */
148 extern default_po_reader_ty
*
149 default_po_reader_alloc (default_po_reader_class_ty
*method_table
);
152 /* If nonzero, remember comments for file name and line number for each
153 msgid, if present in the reference input. Defaults to true. */
154 extern DLL_VARIABLE
int line_comment
;
156 /* If false, duplicate msgids in the same domain and file generate an error.
157 If true, such msgids are allowed; the caller should treat them
158 appropriately. Defaults to false. */
159 extern DLL_VARIABLE
bool allow_duplicates
;
161 /* Expected syntax of the input files. */
162 extern DLL_VARIABLE input_syntax_ty input_syntax
;
164 /* Read the input file from a stream. Returns a list of messages. */
165 extern msgdomain_list_ty
*read_po (FILE *fp
, const char *real_filename
,
166 const char *logical_filename
);
168 /* Read the input file with the name INPUT_NAME. The ending .po is added
169 if necessary. If INPUT_NAME is not an absolute file name and the file is
170 not found, the list of directories in "dir-list.h" is searched. Returns
171 a list of messages. */
172 extern msgdomain_list_ty
*read_po_file (const char *input_name
);
180 #endif /* _READ_PO_H */