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