Back to index

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