No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / src / message.h
blobe9b6aed9470986e1e2ef57231a958a841482f98d
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)
9 any later version.
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. */
20 #ifndef _MESSAGE_H
21 #define _MESSAGE_H
23 #include "str-list.h"
24 #include "pos.h"
25 #include "hash.h"
27 #include <stdbool.h>
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
35 /* According to Sun's Uniforum proposal the default message domain is
36 named 'messages'. */
37 #define MESSAGE_DOMAIN_DEFAULT "messages"
40 /* Kinds of format strings. */
41 enum format_type
43 format_c,
44 format_objc,
45 format_sh,
46 format_python,
47 format_lisp,
48 format_elisp,
49 format_librep,
50 format_scheme,
51 format_smalltalk,
52 format_java,
53 format_csharp,
54 format_awk,
55 format_pascal,
56 format_ycp,
57 format_tcl,
58 format_perl,
59 format_perl_brace,
60 format_php,
61 format_gcc_internal,
62 format_qt
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? */
69 enum is_format
71 undecided,
72 yes,
73 no,
74 yes_according_to_context,
75 possible,
76 impossible
79 extern bool
80 possible_format_p (enum is_format);
83 /* Is current msgid wrappable? */
84 #if 0
85 enum is_wrap
87 undecided,
88 yes,
91 #else /* HACK - C's enum concept is so stupid */
92 #define is_wrap is_format
93 #endif
96 typedef struct message_ty message_ty;
97 struct message_ty
99 /* The msgid string. */
100 const char *msgid;
102 /* The msgid's plural, if present. */
103 const char *msgid_plural;
105 /* The msgstr strings. */
106 const char *msgstr;
107 /* The number of bytes in msgstr, including the terminating NUL. */
108 size_t msgstr_len;
110 /* Position in the source PO file. */
111 lex_pos_ty pos;
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
121 by line. */
122 size_t filepos_count;
123 lex_pos_ty *filepos;
125 /* Informations from special comments (e.g. generated by msgmerge). */
126 bool is_fuzzy;
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
133 commented out. */
134 bool obsolete;
136 /* Used for checking that messages have been used, in the msgcmp,
137 msgmerge, msgcomm and msgcat programs. */
138 int used;
140 /* Used for looking up the target message, in the msgcat program. */
141 message_ty *tmp;
143 /* Used for combining alternative translations, in the msgcat program. */
144 int alternative_count;
145 struct altstr
147 const char *msgstr;
148 size_t msgstr_len;
149 const char *msgstr_end;
150 string_list_ty *comment;
151 string_list_ty *comment_dot;
152 char *id;
154 *alternative;
157 extern message_ty *
158 message_alloc (const char *msgid, const char *msgid_plural,
159 const char *msgstr, size_t msgstr_len,
160 const lex_pos_ty *pp);
161 extern void
162 message_free (message_ty *mp);
163 extern void
164 message_comment_append (message_ty *mp, const char *comment);
165 extern void
166 message_comment_dot_append (message_ty *mp, const char *comment);
167 extern void
168 message_comment_filepos (message_ty *mp, const char *name, size_t line);
169 extern message_ty *
170 message_copy (message_ty *mp);
173 typedef struct message_list_ty message_list_ty;
174 struct message_list_ty
176 message_ty **item;
177 size_t nitems;
178 size_t nitems_max;
179 bool use_hashtable;
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);
189 extern void
190 message_list_free (message_list_ty *mlp);
191 extern void
192 message_list_append (message_list_ty *mlp, message_ty *mp);
193 extern void
194 message_list_prepend (message_list_ty *mlp, message_ty *mp);
195 extern void
196 message_list_insert_at (message_list_ty *mlp, size_t n, message_ty *mp);
197 extern void
198 message_list_delete_nth (message_list_ty *mlp, size_t n);
199 typedef bool message_predicate_ty (const message_ty *mp);
200 extern void
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. */
204 extern bool
205 message_list_msgids_changed (message_list_ty *mlp);
206 extern message_ty *
207 message_list_search (message_list_ty *mlp, const char *msgid);
208 extern message_ty *
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;
216 size_t nitems;
217 size_t nitems_max;
220 extern message_list_list_ty *
221 message_list_list_alloc (void);
222 extern void
223 message_list_list_free (message_list_list_ty *mllp);
224 extern void
225 message_list_list_append (message_list_list_ty *mllp,
226 message_list_ty *mlp);
227 extern void
228 message_list_list_append_list (message_list_list_ty *mllp,
229 message_list_list_ty *mllp2);
230 extern message_ty *
231 message_list_list_search (message_list_list_ty *mllp,
232 const char *msgid);
233 extern message_ty *
234 message_list_list_search_fuzzy (message_list_list_ty *mllp,
235 const char *msgid);
238 typedef struct msgdomain_ty msgdomain_ty;
239 struct msgdomain_ty
241 const char *domain;
242 message_list_ty *messages;
245 extern msgdomain_ty *
246 msgdomain_alloc (const char *domain, bool use_hashtable);
247 extern void
248 msgdomain_free (msgdomain_ty *mdp);
251 typedef struct msgdomain_list_ty msgdomain_list_ty;
252 struct msgdomain_list_ty
254 msgdomain_ty **item;
255 size_t nitems;
256 size_t nitems_max;
257 bool use_hashtable;
258 const char *encoding; /* canonicalized encoding or NULL if unknown */
261 extern msgdomain_list_ty *
262 msgdomain_list_alloc (bool use_hashtable);
263 extern void
264 msgdomain_list_free (msgdomain_list_ty *mdlp);
265 extern void
266 msgdomain_list_append (msgdomain_list_ty *mdlp, msgdomain_ty *mdp);
267 extern void
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,
272 bool create);
273 extern message_ty *
274 msgdomain_list_search (msgdomain_list_ty *mdlp, const char *msgid);
275 extern message_ty *
276 msgdomain_list_search_fuzzy (msgdomain_list_ty *mdlp, const char *msgid);
279 #ifdef __cplusplus
281 #endif
284 #endif /* message.h */