You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gmo.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* Description of GNU message catalog format: general file layout.
  2. Copyright (C) 1995, 1997, 2000-2002, 2004 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  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. #define MO_REVISION_NUMBER_WITH_SYSDEP_I 1
  25. /* The following contortions are an attempt to use the C preprocessor
  26. to determine an unsigned integral type that is 32 bits wide. An
  27. alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
  28. as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work
  29. when cross-compiling. */
  30. #if __STDC__
  31. # define UINT_MAX_32_BITS 4294967295U
  32. #else
  33. # define UINT_MAX_32_BITS 0xFFFFFFFF
  34. #endif
  35. /* If UINT_MAX isn't defined, assume it's a 32-bit type.
  36. This should be valid for all systems GNU cares about because
  37. that doesn't include 16-bit systems, and only modern systems
  38. (that certainly have <limits.h>) have 64+-bit integral types. */
  39. #ifndef UINT_MAX
  40. # define UINT_MAX UINT_MAX_32_BITS
  41. #endif
  42. #if UINT_MAX == UINT_MAX_32_BITS
  43. typedef unsigned nls_uint32;
  44. #else
  45. # if USHRT_MAX == UINT_MAX_32_BITS
  46. typedef unsigned short nls_uint32;
  47. # else
  48. # if ULONG_MAX == UINT_MAX_32_BITS
  49. typedef unsigned long nls_uint32;
  50. # else
  51. /* The following line is intended to throw an error. Using #error is
  52. not portable enough. */
  53. "Cannot determine unsigned 32-bit data type."
  54. # endif
  55. # endif
  56. #endif
  57. /* Header for binary .mo file format. */
  58. struct mo_file_header
  59. {
  60. /* The magic number. */
  61. nls_uint32 magic;
  62. /* The revision number of the file format. */
  63. nls_uint32 revision;
  64. /* The following are only used in .mo files with major revision 0 or 1. */
  65. /* The number of strings pairs. */
  66. nls_uint32 nstrings;
  67. /* Offset of table with start offsets of original strings. */
  68. nls_uint32 orig_tab_offset;
  69. /* Offset of table with start offsets of translated strings. */
  70. nls_uint32 trans_tab_offset;
  71. /* Size of hash table. */
  72. nls_uint32 hash_tab_size;
  73. /* Offset of first hash table entry. */
  74. nls_uint32 hash_tab_offset;
  75. /* The following are only used in .mo files with minor revision >= 1. */
  76. /* The number of system dependent segments. */
  77. nls_uint32 n_sysdep_segments;
  78. /* Offset of table describing system dependent segments. */
  79. nls_uint32 sysdep_segments_offset;
  80. /* The number of system dependent strings pairs. */
  81. nls_uint32 n_sysdep_strings;
  82. /* Offset of table with start offsets of original sysdep strings. */
  83. nls_uint32 orig_sysdep_tab_offset;
  84. /* Offset of table with start offsets of translated sysdep strings. */
  85. nls_uint32 trans_sysdep_tab_offset;
  86. };
  87. /* Descriptor for static string contained in the binary .mo file. */
  88. struct string_desc
  89. {
  90. /* Length of addressed string, not including the trailing NUL. */
  91. nls_uint32 length;
  92. /* Offset of string in file. */
  93. nls_uint32 offset;
  94. };
  95. /* The following are only used in .mo files with minor revision >= 1. */
  96. /* Descriptor for system dependent string segment. */
  97. struct sysdep_segment
  98. {
  99. /* Length of addressed string, including the trailing NUL. */
  100. nls_uint32 length;
  101. /* Offset of string in file. */
  102. nls_uint32 offset;
  103. };
  104. /* Descriptor for system dependent string. */
  105. struct sysdep_string
  106. {
  107. /* Offset of static string segments in file. */
  108. nls_uint32 offset;
  109. /* Alternating sequence of static and system dependent segments.
  110. The last segment is a static segment, including the trailing NUL. */
  111. struct segment_pair
  112. {
  113. /* Size of static segment. */
  114. nls_uint32 segsize;
  115. /* Reference to system dependent string segment, or ~0 at the end. */
  116. nls_uint32 sysdepref;
  117. } 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 */