gmo.h 4.7 KB

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