localeinfo.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* localeinfo.h -- declarations for internal libc locale interfaces
  2. Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #ifndef _LOCALEINFO_H
  17. #define _LOCALEINFO_H 1
  18. #include <stddef.h>
  19. #include <limits.h>
  20. #include <time.h>
  21. #include <sys/types.h>
  22. #include <locale.h>
  23. #include <langinfo.h>
  24. //#include "../intl/loadinfo.h" /* For loaded_l10nfile definition. */
  25. /* Magic number at the beginning of a locale data file for CATEGORY. */
  26. #define LIMAGIC(category) (0x960617de ^ (category))
  27. /* Two special weight constants for the collation data. */
  28. #define FORWARD_CHAR ((wchar_t) 0xfffffffd)
  29. #define ELLIPSIS_CHAR ((wchar_t) 0xfffffffe)
  30. #define IGNORE_CHAR ((wchar_t) 0xffffffff)
  31. /* We use a special value for the usage counter in `locale_data' to
  32. signal that this data must never be removed anymore. */
  33. #define MAX_USAGE_COUNT (UINT_MAX - 1)
  34. #define UNDELETABLE UINT_MAX
  35. /* Structure describing locale data in core for a category. */
  36. struct locale_data
  37. {
  38. const char *name;
  39. const char *filedata; /* Region mapping the file data. */
  40. off_t filesize; /* Size of the file (and the region). */
  41. int mmaped; /* If nonzero the data is mmaped. */
  42. unsigned int usage_count; /* Counter for users. */
  43. unsigned int nstrings; /* Number of strings below. */
  44. union locale_data_value
  45. {
  46. const wchar_t *wstr;
  47. const char *string;
  48. unsigned int word;
  49. }
  50. values[0]; /* Items, usually pointers into `filedata'. */
  51. };
  52. /* We know three kinds of collation sorting rules. */
  53. enum coll_sort_rule
  54. {
  55. illegal_0__,
  56. sort_forward,
  57. sort_backward,
  58. illegal_3__,
  59. sort_position,
  60. sort_forward_position,
  61. sort_backward_position,
  62. sort_mask
  63. };
  64. /* We can map the types of the entries into a few categories. */
  65. enum value_type
  66. {
  67. none,
  68. string,
  69. stringarray,
  70. byte,
  71. bytearray,
  72. word,
  73. stringlist
  74. };
  75. /* Structure to access `era' information from LC_TIME. */
  76. struct era_entry
  77. {
  78. u_int32_t direction; /* Contains '+' or '-'. */
  79. int32_t offset;
  80. int32_t start_date[3];
  81. int32_t stop_date[3];
  82. const char name_fmt[0];
  83. };
  84. /* For each category declare the variable for the current locale data. */
  85. #define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
  86. extern struct locale_data *_nl_current_##category;
  87. #include "categories.c"
  88. #undef DEFINE_CATEGORY
  89. extern const char _nl_category_names[LC_ALL + 1][16];
  90. extern const size_t _nl_category_name_sizes[LC_ALL + 1];
  91. extern struct locale_data * *const _nl_current[LC_ALL + 1];
  92. /* Name of the standard locales. */
  93. extern const char _nl_C_name[];
  94. extern const char _nl_POSIX_name[];
  95. /* Extract the current CATEGORY locale's string for ITEM. */
  96. #define _NL_CURRENT(category, item) \
  97. (_nl_current_##category->values[_NL_ITEM_INDEX (item)].string)
  98. /* Extract the current CATEGORY locale's word for ITEM. */
  99. #define _NL_CURRENT_WORD(category, item) \
  100. (_nl_current_##category->values[_NL_ITEM_INDEX (item)].word)
  101. /* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY. */
  102. #define _NL_CURRENT_DEFINE(category) \
  103. extern struct locale_data _nl_C_##category; \
  104. struct locale_data *_nl_current_##category = &_nl_C_##category
  105. /* Load the locale data for CATEGORY from the file specified by *NAME.
  106. If *NAME is "", use environment variables as specified by POSIX,
  107. and fill in *NAME with the actual name used. The directories
  108. listed in LOCALE_PATH are searched for the locale files. */
  109. extern struct locale_data *_nl_find_locale (const char *locale_path,
  110. size_t locale_path_len,
  111. int category, const char **name);
  112. /* Try to load the file described by FILE. */
  113. //extern void _nl_load_locale (struct loaded_l10nfile *file, int category);
  114. /* Free all resource. */
  115. extern void _nl_unload_locale (struct locale_data *locale);
  116. /* Free the locale and give back all memory if the usage count is one. */
  117. extern void _nl_remove_locale (int locale, struct locale_data *data);
  118. /* Return `era' entry which corresponds to TP. Used in strftime. */
  119. extern struct era_entry *_nl_get_era_entry (const struct tm *tp);
  120. /* Return `alt_digit' which corresponds to NUMBER. Used in strftime. */
  121. extern const char *_nl_get_alt_digit (unsigned int number);
  122. /* Global variables for LC_COLLATE category data. */
  123. extern const u_int32_t *__collate_table;
  124. extern const u_int32_t *__collate_extra;
  125. extern const u_int32_t *__collate_element_hash;
  126. extern const char *__collate_element_strings;
  127. extern const wchar_t *__collate_element_values;
  128. extern const u_int32_t *__collate_symbol_hash;
  129. extern const char *__collate_symbol_strings;
  130. extern const u_int32_t *__collate_symbol_classes;
  131. #endif /* localeinfo.h */