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