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