Back to index

cell-binutils  2.17cvs20070401
gmo.h
Go to the documentation of this file.
00001 /* Description of GNU message catalog format: general file layout.
00002    Copyright (C) 1995, 1997, 2000-2002 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify it
00005    under the terms of the GNU Library General Public License as published
00006    by the Free Software Foundation; either version 2, or (at your option)
00007    any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public
00015    License along with this program; if not, write to the Free Software
00016    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
00017    USA.  */
00018 
00019 #ifndef _GETTEXT_H
00020 #define _GETTEXT_H 1
00021 
00022 #include <limits.h>
00023 
00024 /* @@ end of prolog @@ */
00025 
00026 /* The magic number of the GNU message catalog format.  */
00027 #define _MAGIC 0x950412de
00028 #define _MAGIC_SWAPPED 0xde120495
00029 
00030 /* Revision number of the currently used .mo (binary) file format.  */
00031 #define MO_REVISION_NUMBER 0
00032 
00033 /* The following contortions are an attempt to use the C preprocessor
00034    to determine an unsigned integral type that is 32 bits wide.  An
00035    alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
00036    as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work
00037    when cross-compiling.  */
00038 
00039 #if __STDC__
00040 # define UINT_MAX_32_BITS 4294967295U
00041 #else
00042 # define UINT_MAX_32_BITS 0xFFFFFFFF
00043 #endif
00044 
00045 /* If UINT_MAX isn't defined, assume it's a 32-bit type.
00046    This should be valid for all systems GNU cares about because
00047    that doesn't include 16-bit systems, and only modern systems
00048    (that certainly have <limits.h>) have 64+-bit integral types.  */
00049 
00050 #ifndef UINT_MAX
00051 # define UINT_MAX UINT_MAX_32_BITS
00052 #endif
00053 
00054 #if UINT_MAX == UINT_MAX_32_BITS
00055 typedef unsigned nls_uint32;
00056 #else
00057 # if USHRT_MAX == UINT_MAX_32_BITS
00058 typedef unsigned short nls_uint32;
00059 # else
00060 #  if ULONG_MAX == UINT_MAX_32_BITS
00061 typedef unsigned long nls_uint32;
00062 #  else
00063   /* The following line is intended to throw an error.  Using #error is
00064      not portable enough.  */
00065   "Cannot determine unsigned 32-bit data type."
00066 #  endif
00067 # endif
00068 #endif
00069 
00070 
00071 /* Header for binary .mo file format.  */
00072 struct mo_file_header
00073 {
00074   /* The magic number.  */
00075   nls_uint32 magic;
00076   /* The revision number of the file format.  */
00077   nls_uint32 revision;
00078 
00079   /* The following are only used in .mo files with major revision 0.  */
00080 
00081   /* The number of strings pairs.  */
00082   nls_uint32 nstrings;
00083   /* Offset of table with start offsets of original strings.  */
00084   nls_uint32 orig_tab_offset;
00085   /* Offset of table with start offsets of translated strings.  */
00086   nls_uint32 trans_tab_offset;
00087   /* Size of hash table.  */
00088   nls_uint32 hash_tab_size;
00089   /* Offset of first hash table entry.  */
00090   nls_uint32 hash_tab_offset;
00091 
00092   /* The following are only used in .mo files with minor revision >= 1.  */
00093 
00094   /* The number of system dependent segments.  */
00095   nls_uint32 n_sysdep_segments;
00096   /* Offset of table describing system dependent segments.  */
00097   nls_uint32 sysdep_segments_offset;
00098   /* The number of system dependent strings pairs.  */
00099   nls_uint32 n_sysdep_strings;
00100   /* Offset of table with start offsets of original sysdep strings.  */
00101   nls_uint32 orig_sysdep_tab_offset;
00102   /* Offset of table with start offsets of translated sysdep strings.  */
00103   nls_uint32 trans_sysdep_tab_offset;
00104 };
00105 
00106 /* Descriptor for static string contained in the binary .mo file.  */
00107 struct string_desc
00108 {
00109   /* Length of addressed string, not including the trailing NUL.  */
00110   nls_uint32 length;
00111   /* Offset of string in file.  */
00112   nls_uint32 offset;
00113 };
00114 
00115 /* The following are only used in .mo files with minor revision >= 1.  */
00116 
00117 /* Descriptor for system dependent string segment.  */
00118 struct sysdep_segment
00119 {
00120   /* Length of addressed string, including the trailing NUL.  */
00121   nls_uint32 length;
00122   /* Offset of string in file.  */
00123   nls_uint32 offset;
00124 };
00125 
00126 /* Descriptor for system dependent string.  */
00127 struct sysdep_string
00128 {
00129   /* Offset of static string segments in file.  */
00130   nls_uint32 offset;
00131   /* Alternating sequence of static and system dependent segments.
00132      The last segment is a static segment, including the trailing NUL.  */
00133   struct segment_pair
00134   {
00135     /* Size of static segment.  */
00136     nls_uint32 segsize;
00137     /* Reference to system dependent string segment, or ~0 at the end.  */
00138     nls_uint32 sysdepref;
00139   } segments[1];
00140 };
00141 
00142 /* Marker for the end of the segments[] array.  This has the value 0xFFFFFFFF,
00143    regardless whether 'int' is 16 bit, 32 bit, or 64 bit.  */
00144 #define SEGMENTS_END ((nls_uint32) ~0)
00145 
00146 /* @@ begin of epilog @@ */
00147 
00148 #endif /* gettext.h  */