]>
Commit | Line | Data |
---|---|---|
6d248857 | 1 | /* Description of GNU message catalog format: general file layout. |
dff8da6b | 2 | Copyright (C) 1995-2024 Free Software Foundation, Inc. |
c84142e8 | 3 | |
6d248857 WN |
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. | |
c84142e8 | 8 | |
6d248857 | 9 | This program is distributed in the hope that it will be useful, |
c84142e8 | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
6d248857 WN |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU Lesser General Public License for more details. | |
c84142e8 | 13 | |
6d248857 | 14 | You should have received a copy of the GNU Lesser General Public License |
5a82c748 | 15 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
24906b43 RM |
16 | |
17 | #ifndef _GETTEXT_H | |
18 | #define _GETTEXT_H 1 | |
19 | ||
0555fcce | 20 | #include <limits.h> |
24906b43 RM |
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 | |
083dc54a | 30 | #define MO_REVISION_NUMBER_WITH_SYSDEP_I 1 |
24906b43 RM |
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 | |
4a4d50f3 UD |
35 | as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work |
36 | when cross-compiling. */ | |
24906b43 RM |
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; | |
3172f58f | 77 | |
083dc54a | 78 | /* The following are only used in .mo files with major revision 0 or 1. */ |
3172f58f | 79 | |
24906b43 RM |
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; | |
3172f58f | 84 | /* Offset of table with start offsets of translated strings. */ |
24906b43 | 85 | nls_uint32 trans_tab_offset; |
3172f58f | 86 | /* Size of hash table. */ |
24906b43 | 87 | nls_uint32 hash_tab_size; |
3172f58f | 88 | /* Offset of first hash table entry. */ |
24906b43 | 89 | nls_uint32 hash_tab_offset; |
3172f58f UD |
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; | |
24906b43 RM |
103 | }; |
104 | ||
3172f58f | 105 | /* Descriptor for static string contained in the binary .mo file. */ |
24906b43 RM |
106 | struct string_desc |
107 | { | |
3172f58f | 108 | /* Length of addressed string, not including the trailing NUL. */ |
24906b43 RM |
109 | nls_uint32 length; |
110 | /* Offset of string in file. */ | |
111 | nls_uint32 offset; | |
112 | }; | |
113 | ||
3172f58f UD |
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 | ||
6d248857 WN |
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 | ||
3172f58f UD |
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. */ | |
6d248857 | 141 | struct segment_pair segments[1]; |
3172f58f UD |
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 | ||
24906b43 RM |
148 | /* @@ begin of epilog @@ */ |
149 | ||
150 | #endif /* gettext.h */ |