]> git.ipfire.org Git - thirdparty/glibc.git/blob - intl/gmo.h
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / intl / gmo.h
1 /* Description of GNU message catalog format: general file layout.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17 #ifndef _GETTEXT_H
18 #define _GETTEXT_H 1
19
20 #include <limits.h>
21
22 /* @@ end of prolog @@ */
23
24 /* The magic number of the GNU message catalog format. */
25 #define _MAGIC 0x950412de
26 #define _MAGIC_SWAPPED 0xde120495
27
28 /* Revision number of the currently used .mo (binary) file format. */
29 #define MO_REVISION_NUMBER 0
30 #define MO_REVISION_NUMBER_WITH_SYSDEP_I 1
31
32 /* The following contortions are an attempt to use the C preprocessor
33 to determine an unsigned integral type that is 32 bits wide. An
34 alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
35 as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work
36 when cross-compiling. */
37
38 #if __STDC__
39 # define UINT_MAX_32_BITS 4294967295U
40 #else
41 # define UINT_MAX_32_BITS 0xFFFFFFFF
42 #endif
43
44 /* If UINT_MAX isn't defined, assume it's a 32-bit type.
45 This should be valid for all systems GNU cares about because
46 that doesn't include 16-bit systems, and only modern systems
47 (that certainly have <limits.h>) have 64+-bit integral types. */
48
49 #ifndef UINT_MAX
50 # define UINT_MAX UINT_MAX_32_BITS
51 #endif
52
53 #if UINT_MAX == UINT_MAX_32_BITS
54 typedef unsigned nls_uint32;
55 #else
56 # if USHRT_MAX == UINT_MAX_32_BITS
57 typedef unsigned short nls_uint32;
58 # else
59 # if ULONG_MAX == UINT_MAX_32_BITS
60 typedef unsigned long nls_uint32;
61 # else
62 /* The following line is intended to throw an error. Using #error is
63 not portable enough. */
64 "Cannot determine unsigned 32-bit data type."
65 # endif
66 # endif
67 #endif
68
69
70 /* Header for binary .mo file format. */
71 struct mo_file_header
72 {
73 /* The magic number. */
74 nls_uint32 magic;
75 /* The revision number of the file format. */
76 nls_uint32 revision;
77
78 /* The following are only used in .mo files with major revision 0 or 1. */
79
80 /* The number of strings pairs. */
81 nls_uint32 nstrings;
82 /* Offset of table with start offsets of original strings. */
83 nls_uint32 orig_tab_offset;
84 /* Offset of table with start offsets of translated strings. */
85 nls_uint32 trans_tab_offset;
86 /* Size of hash table. */
87 nls_uint32 hash_tab_size;
88 /* Offset of first hash table entry. */
89 nls_uint32 hash_tab_offset;
90
91 /* The following are only used in .mo files with minor revision >= 1. */
92
93 /* The number of system dependent segments. */
94 nls_uint32 n_sysdep_segments;
95 /* Offset of table describing system dependent segments. */
96 nls_uint32 sysdep_segments_offset;
97 /* The number of system dependent strings pairs. */
98 nls_uint32 n_sysdep_strings;
99 /* Offset of table with start offsets of original sysdep strings. */
100 nls_uint32 orig_sysdep_tab_offset;
101 /* Offset of table with start offsets of translated sysdep strings. */
102 nls_uint32 trans_sysdep_tab_offset;
103 };
104
105 /* Descriptor for static string contained in the binary .mo file. */
106 struct string_desc
107 {
108 /* Length of addressed string, not including the trailing NUL. */
109 nls_uint32 length;
110 /* Offset of string in file. */
111 nls_uint32 offset;
112 };
113
114 /* The following are only used in .mo files with minor revision >= 1. */
115
116 /* Descriptor for system dependent string segment. */
117 struct sysdep_segment
118 {
119 /* Length of addressed string, including the trailing NUL. */
120 nls_uint32 length;
121 /* Offset of string in file. */
122 nls_uint32 offset;
123 };
124
125 /* Pair of a static and a system dependent segment, in struct sysdep_string. */
126 struct segment_pair
127 {
128 /* Size of static segment. */
129 nls_uint32 segsize;
130 /* Reference to system dependent string segment, or ~0 at the end. */
131 nls_uint32 sysdepref;
132 };
133
134 /* Descriptor for system dependent string. */
135 struct sysdep_string
136 {
137 /* Offset of static string segments in file. */
138 nls_uint32 offset;
139 /* Alternating sequence of static and system dependent segments.
140 The last segment is a static segment, including the trailing NUL. */
141 struct segment_pair segments[1];
142 };
143
144 /* Marker for the end of the segments[] array. This has the value 0xFFFFFFFF,
145 regardless whether 'int' is 16 bit, 32 bit, or 64 bit. */
146 #define SEGMENTS_END ((nls_uint32) ~0)
147
148 /* @@ begin of epilog @@ */
149
150 #endif /* gettext.h */