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