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