~ubuntu-branches/ubuntu/breezy/gettext/breezy

« back to all changes in this revision

Viewing changes to gettext-tools/src/message.h

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2004-03-14 17:40:02 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040314174002-p1ad5ldve1hqzhye
Tags: 0.14.1-2
* Added libexpat1-dev to Build-Depends, for glade support.
* Added libc0.1-dev to Build-Depends, for GNU/kFreeBSD.
* Removed special-casing of knetbsd-gnu in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GNU gettext - internationalization aids
 
2
   Copyright (C) 1995-1998, 2000-2003 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 2, or (at your option)
 
9
   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, write to the Free SoftwareFoundation,
 
18
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
19
 
 
20
#ifndef _MESSAGE_H
 
21
#define _MESSAGE_H
 
22
 
 
23
#include "str-list.h"
 
24
#include "pos.h"
 
25
#include "hash.h"
 
26
 
 
27
#include <stdbool.h>
 
28
 
 
29
 
 
30
#ifdef __cplusplus
 
31
extern "C" {
 
32
#endif
 
33
 
 
34
 
 
35
/* According to Sun's Uniforum proposal the default message domain is
 
36
   named 'messages'.  */
 
37
#define MESSAGE_DOMAIN_DEFAULT "messages"
 
38
 
 
39
 
 
40
/* Kinds of format strings.  */
 
41
enum format_type
 
42
{
 
43
  format_c,
 
44
  format_objc,
 
45
  format_sh,
 
46
  format_python,
 
47
  format_lisp,
 
48
  format_elisp,
 
49
  format_librep,
 
50
  format_smalltalk,
 
51
  format_java,
 
52
  format_csharp,
 
53
  format_awk,
 
54
  format_pascal,
 
55
  format_ycp,
 
56
  format_tcl,
 
57
  format_perl,
 
58
  format_perl_brace,
 
59
  format_php,
 
60
  format_gcc_internal,
 
61
  format_qt
 
62
};
 
63
#define NFORMATS 19     /* Number of format_type enum values.  */
 
64
extern DLL_VARIABLE const char *const format_language[NFORMATS];
 
65
extern DLL_VARIABLE const char *const format_language_pretty[NFORMATS];
 
66
 
 
67
/* Is current msgid a format string?  */
 
68
enum is_format
 
69
{
 
70
  undecided,
 
71
  yes,
 
72
  no,
 
73
  yes_according_to_context,
 
74
  possible,
 
75
  impossible
 
76
};
 
77
 
 
78
extern bool
 
79
       possible_format_p (enum is_format);
 
80
 
 
81
 
 
82
/* Is current msgid wrappable?  */
 
83
#if 0
 
84
enum is_wrap
 
85
{
 
86
  undecided,
 
87
  yes,
 
88
  no
 
89
};
 
90
#else /* HACK - C's enum concept is so stupid */
 
91
#define is_wrap is_format
 
92
#endif
 
93
 
 
94
 
 
95
typedef struct message_ty message_ty;
 
96
struct message_ty
 
97
{
 
98
  /* The msgid string.  */
 
99
  const char *msgid;
 
100
 
 
101
  /* The msgid's plural, if present.  */
 
102
  const char *msgid_plural;
 
103
 
 
104
  /* The msgstr strings.  */
 
105
  const char *msgstr;
 
106
  /* The number of bytes in msgstr, including the terminating NUL.  */
 
107
  size_t msgstr_len;
 
108
 
 
109
  /* Position in the source PO file.  */
 
110
  lex_pos_ty pos;
 
111
 
 
112
  /* Plain comments (#) appearing before the message.  */
 
113
  string_list_ty *comment;
 
114
 
 
115
  /* Extracted comments (#.) appearing before the message.  */
 
116
  string_list_ty *comment_dot;
 
117
 
 
118
  /* File position comments (#:) appearing before the message, one for
 
119
     each unique file position instance, sorted by file name and then
 
120
     by line.  */
 
121
  size_t filepos_count;
 
122
  lex_pos_ty *filepos;
 
123
 
 
124
  /* Informations from special comments (e.g. generated by msgmerge).  */
 
125
  bool is_fuzzy;
 
126
  enum is_format is_format[NFORMATS];
 
127
 
 
128
  /* Do we want the string to be wrapped in the emitted PO file?  */
 
129
  enum is_wrap do_wrap;
 
130
 
 
131
  /* If set the message is obsolete and while writing out it should be
 
132
     commented out.  */
 
133
  bool obsolete;
 
134
 
 
135
  /* Used for checking that messages have been used, in the msgcmp,
 
136
     msgmerge, msgcomm and msgcat programs.  */
 
137
  int used;
 
138
 
 
139
  /* Used for looking up the target message, in the msgcat program.  */
 
140
  message_ty *tmp;
 
141
 
 
142
  /* Used for combining alternative translations, in the msgcat program.  */
 
143
  int alternative_count;
 
144
  struct altstr
 
145
    {
 
146
      const char *msgstr;
 
147
      size_t msgstr_len;
 
148
      const char *msgstr_end;
 
149
      string_list_ty *comment;
 
150
      string_list_ty *comment_dot;
 
151
      char *id;
 
152
    }
 
153
    *alternative;
 
154
};
 
155
 
 
156
extern message_ty *
 
157
       message_alloc (const char *msgid, const char *msgid_plural,
 
158
                      const char *msgstr, size_t msgstr_len,
 
159
                      const lex_pos_ty *pp);
 
160
extern void
 
161
       message_free (message_ty *mp);
 
162
extern void
 
163
       message_comment_append (message_ty *mp, const char *comment);
 
164
extern void
 
165
       message_comment_dot_append (message_ty *mp, const char *comment);
 
166
extern void
 
167
       message_comment_filepos (message_ty *mp, const char *name, size_t line);
 
168
extern message_ty *
 
169
       message_copy (message_ty *mp);
 
170
 
 
171
 
 
172
typedef struct message_list_ty message_list_ty;
 
173
struct message_list_ty
 
174
{
 
175
  message_ty **item;
 
176
  size_t nitems;
 
177
  size_t nitems_max;
 
178
  bool use_hashtable;
 
179
  hash_table htable;    /* Table mapping msgid to 'message_ty *'.  */
 
180
};
 
181
 
 
182
/* Create a fresh message list.
 
183
   If USE_HASHTABLE is true, a hash table will be used to speed up
 
184
   message_list_search().  USE_HASHTABLE can only be set to true if it is
 
185
   known that the message list will not contain duplicate msgids.  */
 
186
extern message_list_ty *
 
187
       message_list_alloc (bool use_hashtable);
 
188
extern void
 
189
       message_list_free (message_list_ty *mlp);
 
190
extern void
 
191
       message_list_append (message_list_ty *mlp, message_ty *mp);
 
192
extern void
 
193
       message_list_prepend (message_list_ty *mlp, message_ty *mp);
 
194
extern void
 
195
       message_list_delete_nth (message_list_ty *mlp, size_t n);
 
196
typedef bool message_predicate_ty (const message_ty *mp);
 
197
extern void
 
198
       message_list_remove_if_not (message_list_ty *mlp,
 
199
                                   message_predicate_ty *predicate);
 
200
/* Recompute the hash table of a message list after the msgids changed.  */
 
201
extern bool
 
202
       message_list_msgids_changed (message_list_ty *mlp);
 
203
extern message_ty *
 
204
       message_list_search (message_list_ty *mlp, const char *msgid);
 
205
extern message_ty *
 
206
       message_list_search_fuzzy (message_list_ty *mlp, const char *msgid);
 
207
 
 
208
 
 
209
typedef struct message_list_list_ty message_list_list_ty;
 
210
struct message_list_list_ty
 
211
{
 
212
  message_list_ty **item;
 
213
  size_t nitems;
 
214
  size_t nitems_max;
 
215
};
 
216
 
 
217
extern message_list_list_ty *
 
218
       message_list_list_alloc (void);
 
219
extern void
 
220
       message_list_list_free (message_list_list_ty *mllp);
 
221
extern void
 
222
       message_list_list_append (message_list_list_ty *mllp,
 
223
                                 message_list_ty *mlp);
 
224
extern void
 
225
       message_list_list_append_list (message_list_list_ty *mllp,
 
226
                                      message_list_list_ty *mllp2);
 
227
extern message_ty *
 
228
       message_list_list_search (message_list_list_ty *mllp,
 
229
                                 const char *msgid);
 
230
extern message_ty *
 
231
       message_list_list_search_fuzzy (message_list_list_ty *mllp,
 
232
                                       const char *msgid);
 
233
 
 
234
 
 
235
typedef struct msgdomain_ty msgdomain_ty;
 
236
struct msgdomain_ty
 
237
{
 
238
  const char *domain;
 
239
  message_list_ty *messages;
 
240
};
 
241
 
 
242
extern msgdomain_ty *
 
243
       msgdomain_alloc (const char *domain, bool use_hashtable);
 
244
extern void
 
245
       msgdomain_free (msgdomain_ty *mdp);
 
246
 
 
247
 
 
248
typedef struct msgdomain_list_ty msgdomain_list_ty;
 
249
struct msgdomain_list_ty
 
250
{
 
251
  msgdomain_ty **item;
 
252
  size_t nitems;
 
253
  size_t nitems_max;
 
254
  bool use_hashtable;
 
255
  const char *encoding;         /* canonicalized encoding or NULL if unknown */
 
256
};
 
257
 
 
258
extern msgdomain_list_ty *
 
259
       msgdomain_list_alloc (bool use_hashtable);
 
260
extern void
 
261
       msgdomain_list_free (msgdomain_list_ty *mdlp);
 
262
extern void
 
263
       msgdomain_list_append (msgdomain_list_ty *mdlp, msgdomain_ty *mdp);
 
264
extern void
 
265
       msgdomain_list_append_list (msgdomain_list_ty *mdlp,
 
266
                                   msgdomain_list_ty *mdlp2);
 
267
extern message_list_ty *
 
268
       msgdomain_list_sublist (msgdomain_list_ty *mdlp, const char *domain,
 
269
                               bool create);
 
270
extern message_ty *
 
271
       msgdomain_list_search (msgdomain_list_ty *mdlp, const char *msgid);
 
272
extern message_ty *
 
273
       msgdomain_list_search_fuzzy (msgdomain_list_ty *mdlp, const char *msgid);
 
274
 
 
275
 
 
276
#ifdef __cplusplus
 
277
}
 
278
#endif
 
279
 
 
280
 
 
281
#endif /* message.h */