xref: /openbsd-src/gnu/usr.bin/binutils/intl/gettext.h (revision d2201f2f89f0be1a0be6f7568000ed297414a06d)
1*d2201f2fSdrahn /* Internal header for GNU gettext internationalization functions.
2f7cc78ecSespie    Copyright (C) 1995, 1997 Free Software Foundation, Inc.
3f7cc78ecSespie 
4f7cc78ecSespie    This program is free software; you can redistribute it and/or modify
5f7cc78ecSespie    it under the terms of the GNU General Public License as published by
6f7cc78ecSespie    the Free Software Foundation; either version 2, or (at your option)
7f7cc78ecSespie    any later version.
8f7cc78ecSespie 
9f7cc78ecSespie    This program is distributed in the hope that it will be useful,
10f7cc78ecSespie    but WITHOUT ANY WARRANTY; without even the implied warranty of
11f7cc78ecSespie    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12f7cc78ecSespie    GNU General Public License for more details.
13f7cc78ecSespie 
14f7cc78ecSespie    You should have received a copy of the GNU Library General Public
15f7cc78ecSespie    License along with the GNU C Library; see the file COPYING.LIB.  If not,
16f7cc78ecSespie    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17f7cc78ecSespie    Boston, MA 02111-1307, USA.  */
18f7cc78ecSespie 
19f7cc78ecSespie #ifndef _GETTEXT_H
20f7cc78ecSespie #define _GETTEXT_H 1
21f7cc78ecSespie 
22f7cc78ecSespie #include <stdio.h>
23f7cc78ecSespie 
24f7cc78ecSespie #if HAVE_LIMITS_H || _LIBC
25f7cc78ecSespie # include <limits.h>
26f7cc78ecSespie #endif
27f7cc78ecSespie 
28f7cc78ecSespie /* @@ end of prolog @@ */
29f7cc78ecSespie 
30f7cc78ecSespie /* The magic number of the GNU message catalog format.  */
31f7cc78ecSespie #define _MAGIC 0x950412de
32f7cc78ecSespie #define _MAGIC_SWAPPED 0xde120495
33f7cc78ecSespie 
34f7cc78ecSespie /* Revision number of the currently used .mo (binary) file format.  */
35f7cc78ecSespie #define MO_REVISION_NUMBER 0
36f7cc78ecSespie 
37f7cc78ecSespie /* The following contortions are an attempt to use the C preprocessor
38f7cc78ecSespie    to determine an unsigned integral type that is 32 bits wide.  An
39f7cc78ecSespie    alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
40f7cc78ecSespie    doing that would require that the configure script compile and *run*
41f7cc78ecSespie    the resulting executable.  Locally running cross-compiled executables
42f7cc78ecSespie    is usually not possible.  */
43f7cc78ecSespie 
44f7cc78ecSespie #if __STDC__
45f7cc78ecSespie # define UINT_MAX_32_BITS 4294967295U
46f7cc78ecSespie #else
47f7cc78ecSespie # define UINT_MAX_32_BITS 0xFFFFFFFF
48f7cc78ecSespie #endif
49f7cc78ecSespie 
50f7cc78ecSespie /* If UINT_MAX isn't defined, assume it's a 32-bit type.
51f7cc78ecSespie    This should be valid for all systems GNU cares about because
52f7cc78ecSespie    that doesn't include 16-bit systems, and only modern systems
53f7cc78ecSespie    (that certainly have <limits.h>) have 64+-bit integral types.  */
54f7cc78ecSespie 
55f7cc78ecSespie #ifndef UINT_MAX
56f7cc78ecSespie # define UINT_MAX UINT_MAX_32_BITS
57f7cc78ecSespie #endif
58f7cc78ecSespie 
59f7cc78ecSespie #if UINT_MAX == UINT_MAX_32_BITS
60f7cc78ecSespie typedef unsigned nls_uint32;
61f7cc78ecSespie #else
62f7cc78ecSespie # if USHRT_MAX == UINT_MAX_32_BITS
63f7cc78ecSespie typedef unsigned short nls_uint32;
64f7cc78ecSespie # else
65f7cc78ecSespie #  if ULONG_MAX == UINT_MAX_32_BITS
66f7cc78ecSespie typedef unsigned long nls_uint32;
67f7cc78ecSespie #  else
68f7cc78ecSespie   /* The following line is intended to throw an error.  Using #error is
69f7cc78ecSespie      not portable enough.  */
70f7cc78ecSespie   "Cannot determine unsigned 32-bit data type."
71f7cc78ecSespie #  endif
72f7cc78ecSespie # endif
73f7cc78ecSespie #endif
74f7cc78ecSespie 
75f7cc78ecSespie 
76f7cc78ecSespie /* Header for binary .mo file format.  */
77f7cc78ecSespie struct mo_file_header
78f7cc78ecSespie {
79f7cc78ecSespie   /* The magic number.  */
80f7cc78ecSespie   nls_uint32 magic;
81f7cc78ecSespie   /* The revision number of the file format.  */
82f7cc78ecSespie   nls_uint32 revision;
83f7cc78ecSespie   /* The number of strings pairs.  */
84f7cc78ecSespie   nls_uint32 nstrings;
85f7cc78ecSespie   /* Offset of table with start offsets of original strings.  */
86f7cc78ecSespie   nls_uint32 orig_tab_offset;
87f7cc78ecSespie   /* Offset of table with start offsets of translation strings.  */
88f7cc78ecSespie   nls_uint32 trans_tab_offset;
89f7cc78ecSespie   /* Size of hashing table.  */
90f7cc78ecSespie   nls_uint32 hash_tab_size;
91f7cc78ecSespie   /* Offset of first hashing entry.  */
92f7cc78ecSespie   nls_uint32 hash_tab_offset;
93f7cc78ecSespie };
94f7cc78ecSespie 
95f7cc78ecSespie struct string_desc
96f7cc78ecSespie {
97f7cc78ecSespie   /* Length of addressed string.  */
98f7cc78ecSespie   nls_uint32 length;
99f7cc78ecSespie   /* Offset of string in file.  */
100f7cc78ecSespie   nls_uint32 offset;
101f7cc78ecSespie };
102f7cc78ecSespie 
103f7cc78ecSespie /* @@ begin of epilog @@ */
104f7cc78ecSespie 
105f7cc78ecSespie #endif	/* gettext.h  */
106