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