• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/src/
1/* Reading PO files.
2   Copyright (C) 1995-1998, 2000-2003, 2005-2006 Free Software Foundation, Inc.
3   This file was written by Bruno Haible <haible@clisp.cons.org>.
4
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 3 of the License, or
8   (at your option) any later version.
9
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.
14
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18#ifndef _READ_CATALOG_H
19#define _READ_CATALOG_H
20
21#include "message.h"
22#include "read-catalog-abstract.h"
23
24#include <stdbool.h>
25#include <stdio.h>
26
27
28/* For including this file in C++ mode.  */
29#ifdef __cplusplus
30# define this thiss
31#endif
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37
38/* The following pair of structures cooperate to create a derived class from
39   class abstract_catalog_reader_ty.  (See read-catalog-abstract.h for an
40   explanation.)  It implements the default behaviour of reading a PO file
41   and converting it to an 'msgdomain_list_ty *'.  */
42
43/* Forward declaration.  */
44struct default_catalog_reader_ty;
45
46
47typedef struct default_catalog_reader_class_ty default_catalog_reader_class_ty;
48struct default_catalog_reader_class_ty
49{
50  /* Methods inherited from superclass.  */
51  struct abstract_catalog_reader_class_ty super;
52
53  /* How to change the current domain.  */
54  void (*set_domain) (struct default_catalog_reader_ty *pop, char *name);
55
56  /* How to add a message to the list.  */
57  void (*add_message) (struct default_catalog_reader_ty *pop,
58		       char *msgctxt,
59		       char *msgid, lex_pos_ty *msgid_pos, char *msgid_plural,
60		       char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos,
61		       char *prev_msgctxt,
62		       char *prev_msgid,
63		       char *prev_msgid_plural,
64		       bool force_fuzzy, bool obsolete);
65
66  /* How to modify a new message before adding it to the list.  */
67  void (*frob_new_message) (struct default_catalog_reader_ty *pop,
68			    message_ty *mp,
69			    const lex_pos_ty *msgid_pos,
70			    const lex_pos_ty *msgstr_pos);
71};
72
73
74#define DEFAULT_CATALOG_READER_TY \
75  ABSTRACT_CATALOG_READER_TY						\
76									\
77  /* If true, pay attention to comments and filepos comments.  */	\
78  bool handle_comments;							\
79									\
80  /* If true, remember comments for file name and line number for each	\
81     msgid, if present in the reference input.  */			\
82  bool handle_filepos_comments;						\
83									\
84  /* If false, domain directives lead to an error messsage.  */		\
85  bool allow_domain_directives;						\
86									\
87  /* If false, duplicate msgids in the same domain and file generate an	\
88     error.  If true, such msgids are allowed; the caller should treat	\
89     them appropriately.  */						\
90  bool allow_duplicates;						\
91									\
92  /* If true, allow duplicates if they have the same translation.  */	\
93  bool allow_duplicates_if_same_msgstr;					\
94									\
95  /* List of messages already appeared in the current file.  */		\
96  msgdomain_list_ty *mdlp;						\
97									\
98  /* Name of domain we are currently examining.  */			\
99  const char *domain;							\
100									\
101  /* List of messages belonging to the current domain.  */		\
102  message_list_ty *mlp;							\
103									\
104  /* Accumulate comments for next message directive.  */		\
105  string_list_ty *comment;						\
106  string_list_ty *comment_dot;						\
107									\
108  /* Accumulate filepos comments for the next message directive.  */	\
109  size_t filepos_count;							\
110  lex_pos_ty *filepos;							\
111									\
112  /* Flags transported in special comments.  */				\
113  bool is_fuzzy;							\
114  enum is_format is_format[NFORMATS];					\
115  enum is_wrap do_wrap;							\
116
117typedef struct default_catalog_reader_ty default_catalog_reader_ty;
118struct default_catalog_reader_ty
119{
120  DEFAULT_CATALOG_READER_TY
121};
122
123extern void default_constructor (abstract_catalog_reader_ty *that);
124extern void default_destructor (abstract_catalog_reader_ty *that);
125extern void default_parse_brief (abstract_catalog_reader_ty *that);
126extern void default_parse_debrief (abstract_catalog_reader_ty *that);
127extern void default_directive_domain (abstract_catalog_reader_ty *that,
128				      char *name);
129extern void default_directive_message (abstract_catalog_reader_ty *that,
130				       char *msgctxt,
131				       char *msgid,
132				       lex_pos_ty *msgid_pos,
133				       char *msgid_plural,
134				       char *msgstr, size_t msgstr_len,
135				       lex_pos_ty *msgstr_pos,
136				       char *prev_msgctxt,
137				       char *prev_msgid,
138				       char *prev_msgid_plural,
139				       bool force_fuzzy, bool obsolete);
140extern void default_comment (abstract_catalog_reader_ty *that, const char *s);
141extern void default_comment_dot (abstract_catalog_reader_ty *that,
142				 const char *s);
143extern void default_comment_filepos (abstract_catalog_reader_ty *that,
144				     const char *name, size_t line);
145extern void default_comment_special (abstract_catalog_reader_ty *that,
146				     const char *s);
147extern void default_set_domain (default_catalog_reader_ty *this, char *name);
148extern void default_add_message (default_catalog_reader_ty *this,
149				 char *msgctxt,
150				 char *msgid,
151				 lex_pos_ty *msgid_pos,
152				 char *msgid_plural,
153				 char *msgstr, size_t msgstr_len,
154				 lex_pos_ty *msgstr_pos,
155				 char *prev_msgctxt,
156				 char *prev_msgid,
157				 char *prev_msgid_plural,
158				 bool force_fuzzy, bool obsolete);
159
160/* Allocate a fresh default_catalog_reader_ty (or derived class) instance and
161   call its constructor.  */
162extern default_catalog_reader_ty *
163       default_catalog_reader_alloc (default_catalog_reader_class_ty *method_table);
164
165
166/* If nonzero, remember comments for file name and line number for each
167   msgid, if present in the reference input.  Defaults to true.  */
168extern DLL_VARIABLE int line_comment;
169
170/* If false, duplicate msgids in the same domain and file generate an error.
171   If true, such msgids are allowed; the caller should treat them
172   appropriately.  Defaults to false.  */
173extern DLL_VARIABLE bool allow_duplicates;
174
175/* Read the input file from a stream.  Returns a list of messages.  */
176extern msgdomain_list_ty *
177       read_catalog_stream (FILE *fp,
178			    const char *real_filename,
179			    const char *logical_filename,
180			    catalog_input_format_ty input_syntax);
181
182/* Read the input file with the name INPUT_NAME.  The ending .po is added
183   if necessary.  If INPUT_NAME is not an absolute file name and the file is
184   not found, the list of directories in "dir-list.h" is searched.  Returns
185   a list of messages.  */
186extern msgdomain_list_ty *
187       read_catalog_file (const char *input_name,
188			  catalog_input_format_ty input_syntax);
189
190
191#ifdef __cplusplus
192}
193#endif
194
195
196#endif /* _READ_CATALOG_H */
197