1
/* Public API for GNU gettext PO files - contained in libgettextpo.
2
Copyright (C) 2003 Free Software Foundation, Inc.
3
Written by Bruno Haible <bruno@clisp.org>, 2003.
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. */
20
#define _GETTEXT_PO_H 1
27
/* ================================= Types ================================= */
29
/* A po_file_t represents the contents of a PO file. */
30
typedef struct po_file *po_file_t;
32
/* A po_message_iterator_t represents an iterator through a domain of a
34
typedef struct po_message_iterator *po_message_iterator_t;
36
/* A po_message_t represents a message in a PO file. */
37
typedef struct po_message *po_message_t;
40
The memory allocations performed by these functions use xmalloc(),
41
therefore will cause a program exit if memory is exhausted.
42
The memory allocated by po_file_read, and implicitly returned through
43
the po_message_* functions, lasts until freed with po_file_free. */
46
/* ============================= po_file_t API ============================= */
48
/* Read a PO file into memory.
49
Return its contents. Upon failure, return NULL and set errno. */
50
extern po_file_t po_file_read (const char *filename);
52
/* Free a PO file from memory. */
53
extern void po_file_free (po_file_t file);
55
/* Return the names of the domains covered by a PO file in memory. */
56
extern const char * const * po_file_domains (po_file_t file);
59
/* =========================== Header entry API ============================ */
61
/* Return the header entry of a domain of a PO file in memory.
62
The domain NULL denotes the default domain.
63
Return NULL if there is no header entry. */
64
extern const char * po_file_domain_header (po_file_t file, const char *domain);
66
/* Return the value of a field in a header entry.
67
The return value is either a freshly allocated string, to be freed by the
69
extern char * po_header_field (const char *header, const char *field);
72
/* ======================= po_message_iterator_t API ======================= */
74
/* Create an iterator for traversing a domain of a PO file in memory.
75
The domain NULL denotes the default domain. */
76
extern po_message_iterator_t po_message_iterator (po_file_t file, const char *domain);
78
/* Free an iterator. */
79
extern void po_message_iterator_free (po_message_iterator_t iterator);
81
/* Return the next message, and advance the iterator.
82
Return NULL at the end of the message list. */
83
extern po_message_t po_next_message (po_message_iterator_t iterator);
86
/* =========================== po_message_t API ============================ */
88
/* Return the msgid (untranslated English string) of a message. */
89
extern const char * po_message_msgid (po_message_t message);
91
/* Return the msgid_plural (untranslated English plural string) of a message,
92
or NULL for a message without plural. */
93
extern const char * po_message_msgid_plural (po_message_t message);
95
/* Return the msgstr (translation) of a message.
96
Return the empty string for an untranslated message. */
97
extern const char * po_message_msgstr (po_message_t message);
99
/* Return the msgstr[index] for a message with plural handling, or
100
NULL when the index is out of range or for a message without plural. */
101
extern const char * po_message_msgstr_plural (po_message_t message, int index);
103
/* Return true if the message is marked obsolete. */
104
extern int po_message_is_obsolete (po_message_t message);
106
/* Return true if the message is marked fuzzy. */
107
extern int po_message_is_fuzzy (po_message_t message);
109
/* Return true if the message is marked as being a format string of the given
110
type (e.g. "c-format"). */
111
extern int po_message_is_format (po_message_t message, const char *format_type);
118
#endif /* _GETTEXT_PO_H */