gmo.h 4.7 KB

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