Back to index

courier  0.68.2
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, 2004, 2006 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 #define MO_REVISION_NUMBER_WITH_SYSDEP_I 1
00033 
00034 /* The following contortions are an attempt to use the C preprocessor
00035    to determine an unsigned integral type that is 32 bits wide.  An
00036    alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
00037    as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work
00038    when cross-compiling.  */
00039 
00040 #if __STDC__
00041 # define UINT_MAX_32_BITS 4294967295U
00042 #else
00043 # define UINT_MAX_32_BITS 0xFFFFFFFF
00044 #endif
00045 
00046 /* If UINT_MAX isn't defined, assume it's a 32-bit type.
00047    This should be valid for all systems GNU cares about because
00048    that doesn't include 16-bit systems, and only modern systems
00049    (that certainly have <limits.h>) have 64+-bit integral types.  */
00050 
00051 #ifndef UINT_MAX
00052 # define UINT_MAX UINT_MAX_32_BITS
00053 #endif
00054 
00055 #if UINT_MAX == UINT_MAX_32_BITS
00056 typedef unsigned nls_uint32;
00057 #else
00058 # if USHRT_MAX == UINT_MAX_32_BITS
00059 typedef unsigned short nls_uint32;
00060 # else
00061 #  if ULONG_MAX == UINT_MAX_32_BITS
00062 typedef unsigned long nls_uint32;
00063 #  else
00064   /* The following line is intended to throw an error.  Using #error is
00065      not portable enough.  */
00066   "Cannot determine unsigned 32-bit data type."
00067 #  endif
00068 # endif
00069 #endif
00070 
00071 
00072 /* Header for binary .mo file format.  */
00073 struct mo_file_header
00074 {
00075   /* The magic number.  */
00076   nls_uint32 magic;
00077   /* The revision number of the file format.  */
00078   nls_uint32 revision;
00079 
00080   /* The following are only used in .mo files with major revision 0 or 1.  */
00081 
00082   /* The number of strings pairs.  */
00083   nls_uint32 nstrings;
00084   /* Offset of table with start offsets of original strings.  */
00085   nls_uint32 orig_tab_offset;
00086   /* Offset of table with start offsets of translated strings.  */
00087   nls_uint32 trans_tab_offset;
00088   /* Size of hash table.  */
00089   nls_uint32 hash_tab_size;
00090   /* Offset of first hash table entry.  */
00091   nls_uint32 hash_tab_offset;
00092 
00093   /* The following are only used in .mo files with minor revision >= 1.  */
00094 
00095   /* The number of system dependent segments.  */
00096   nls_uint32 n_sysdep_segments;
00097   /* Offset of table describing system dependent segments.  */
00098   nls_uint32 sysdep_segments_offset;
00099   /* The number of system dependent strings pairs.  */
00100   nls_uint32 n_sysdep_strings;
00101   /* Offset of table with start offsets of original sysdep strings.  */
00102   nls_uint32 orig_sysdep_tab_offset;
00103   /* Offset of table with start offsets of translated sysdep strings.  */
00104   nls_uint32 trans_sysdep_tab_offset;
00105 };
00106 
00107 /* Descriptor for static string contained in the binary .mo file.  */
00108 struct string_desc
00109 {
00110   /* Length of addressed string, not including the trailing NUL.  */
00111   nls_uint32 length;
00112   /* Offset of string in file.  */
00113   nls_uint32 offset;
00114 };
00115 
00116 /* The following are only used in .mo files with minor revision >= 1.  */
00117 
00118 /* Descriptor for system dependent string segment.  */
00119 struct sysdep_segment
00120 {
00121   /* Length of addressed string, including the trailing NUL.  */
00122   nls_uint32 length;
00123   /* Offset of string in file.  */
00124   nls_uint32 offset;
00125 };
00126 
00127 /* Pair of a static and a system dependent segment, in struct sysdep_string.  */
00128 struct segment_pair
00129 {
00130   /* Size of static segment.  */
00131   nls_uint32 segsize;
00132   /* Reference to system dependent string segment, or ~0 at the end.  */
00133   nls_uint32 sysdepref;
00134 };
00135 
00136 /* Descriptor for system dependent string.  */
00137 struct sysdep_string
00138 {
00139   /* Offset of static string segments in file.  */
00140   nls_uint32 offset;
00141   /* Alternating sequence of static and system dependent segments.
00142      The last segment is a static segment, including the trailing NUL.  */
00143   struct segment_pair segments[1];
00144 };
00145 
00146 /* Marker for the end of the segments[] array.  This has the value 0xFFFFFFFF,
00147    regardless whether 'int' is 16 bit, 32 bit, or 64 bit.  */
00148 #define SEGMENTS_END ((nls_uint32) ~0)
00149 
00150 /* @@ begin of epilog @@ */
00151 
00152 #endif /* gettext.h  */