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