1 /* GNU gettext - internationalization aids
2 Copyright (C) 1995-1998, 2000-2004 Free Software Foundation, Inc.
4 This file was written by Peter Miller <millerp@canb.auug.org.au>
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 2, or (at your option)
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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free SoftwareFoundation,
18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
35 /* According to Sun's Uniforum proposal the default message domain is
37 #define MESSAGE_DOMAIN_DEFAULT "messages"
40 /* Kinds of format strings. */
64 #define NFORMATS 20 /* Number of format_type enum values. */
65 extern DLL_VARIABLE
const char *const format_language
[NFORMATS
];
66 extern DLL_VARIABLE
const char *const format_language_pretty
[NFORMATS
];
68 /* Is current msgid a format string? */
74 yes_according_to_context
,
80 possible_format_p (enum is_format
);
83 /* Is current msgid wrappable? */
91 #else /* HACK - C's enum concept is so stupid */
92 #define is_wrap is_format
96 typedef struct message_ty message_ty
;
99 /* The msgid string. */
102 /* The msgid's plural, if present. */
103 const char *msgid_plural
;
105 /* The msgstr strings. */
107 /* The number of bytes in msgstr, including the terminating NUL. */
110 /* Position in the source PO file. */
113 /* Plain comments (#) appearing before the message. */
114 string_list_ty
*comment
;
116 /* Extracted comments (#.) appearing before the message. */
117 string_list_ty
*comment_dot
;
119 /* File position comments (#:) appearing before the message, one for
120 each unique file position instance, sorted by file name and then
122 size_t filepos_count
;
125 /* Informations from special comments (e.g. generated by msgmerge). */
127 enum is_format is_format
[NFORMATS
];
129 /* Do we want the string to be wrapped in the emitted PO file? */
130 enum is_wrap do_wrap
;
132 /* If set the message is obsolete and while writing out it should be
136 /* Used for checking that messages have been used, in the msgcmp,
137 msgmerge, msgcomm and msgcat programs. */
140 /* Used for looking up the target message, in the msgcat program. */
143 /* Used for combining alternative translations, in the msgcat program. */
144 int alternative_count
;
149 const char *msgstr_end
;
150 string_list_ty
*comment
;
151 string_list_ty
*comment_dot
;
158 message_alloc (const char *msgid
, const char *msgid_plural
,
159 const char *msgstr
, size_t msgstr_len
,
160 const lex_pos_ty
*pp
);
162 message_free (message_ty
*mp
);
164 message_comment_append (message_ty
*mp
, const char *comment
);
166 message_comment_dot_append (message_ty
*mp
, const char *comment
);
168 message_comment_filepos (message_ty
*mp
, const char *name
, size_t line
);
170 message_copy (message_ty
*mp
);
173 typedef struct message_list_ty message_list_ty
;
174 struct message_list_ty
180 hash_table htable
; /* Table mapping msgid to 'message_ty *'. */
183 /* Create a fresh message list.
184 If USE_HASHTABLE is true, a hash table will be used to speed up
185 message_list_search(). USE_HASHTABLE can only be set to true if it is
186 known that the message list will not contain duplicate msgids. */
187 extern message_list_ty
*
188 message_list_alloc (bool use_hashtable
);
190 message_list_free (message_list_ty
*mlp
);
192 message_list_append (message_list_ty
*mlp
, message_ty
*mp
);
194 message_list_prepend (message_list_ty
*mlp
, message_ty
*mp
);
196 message_list_insert_at (message_list_ty
*mlp
, size_t n
, message_ty
*mp
);
198 message_list_delete_nth (message_list_ty
*mlp
, size_t n
);
199 typedef bool message_predicate_ty (const message_ty
*mp
);
201 message_list_remove_if_not (message_list_ty
*mlp
,
202 message_predicate_ty
*predicate
);
203 /* Recompute the hash table of a message list after the msgids changed. */
205 message_list_msgids_changed (message_list_ty
*mlp
);
207 message_list_search (message_list_ty
*mlp
, const char *msgid
);
209 message_list_search_fuzzy (message_list_ty
*mlp
, const char *msgid
);
212 typedef struct message_list_list_ty message_list_list_ty
;
213 struct message_list_list_ty
215 message_list_ty
**item
;
220 extern message_list_list_ty
*
221 message_list_list_alloc (void);
223 message_list_list_free (message_list_list_ty
*mllp
);
225 message_list_list_append (message_list_list_ty
*mllp
,
226 message_list_ty
*mlp
);
228 message_list_list_append_list (message_list_list_ty
*mllp
,
229 message_list_list_ty
*mllp2
);
231 message_list_list_search (message_list_list_ty
*mllp
,
234 message_list_list_search_fuzzy (message_list_list_ty
*mllp
,
238 typedef struct msgdomain_ty msgdomain_ty
;
242 message_list_ty
*messages
;
245 extern msgdomain_ty
*
246 msgdomain_alloc (const char *domain
, bool use_hashtable
);
248 msgdomain_free (msgdomain_ty
*mdp
);
251 typedef struct msgdomain_list_ty msgdomain_list_ty
;
252 struct msgdomain_list_ty
258 const char *encoding
; /* canonicalized encoding or NULL if unknown */
261 extern msgdomain_list_ty
*
262 msgdomain_list_alloc (bool use_hashtable
);
264 msgdomain_list_free (msgdomain_list_ty
*mdlp
);
266 msgdomain_list_append (msgdomain_list_ty
*mdlp
, msgdomain_ty
*mdp
);
268 msgdomain_list_append_list (msgdomain_list_ty
*mdlp
,
269 msgdomain_list_ty
*mdlp2
);
270 extern message_list_ty
*
271 msgdomain_list_sublist (msgdomain_list_ty
*mdlp
, const char *domain
,
274 msgdomain_list_search (msgdomain_list_ty
*mdlp
, const char *msgid
);
276 msgdomain_list_search_fuzzy (msgdomain_list_ty
*mdlp
, const char *msgid
);
284 #endif /* message.h */