loadinfo.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Copyright (C) 1996-2019 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program 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
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef _LOADINFO_H
  15. #define _LOADINFO_H 1
  16. /* Declarations of locale dependent catalog lookup functions.
  17. Implemented in
  18. localealias.c Possibly replace a locale name by another.
  19. explodename.c Split a locale name into its various fields.
  20. l10nflist.c Generate a list of filenames of possible message catalogs.
  21. finddomain.c Find and open the relevant message catalogs.
  22. The main function _nl_find_domain() in finddomain.c is declared
  23. in gettextP.h.
  24. */
  25. #ifndef LIBINTL_DLL_EXPORTED
  26. # define LIBINTL_DLL_EXPORTED
  27. #endif
  28. /* Tell the compiler when a conditional or integer expression is
  29. almost always true or almost always false. */
  30. #ifndef HAVE_BUILTIN_EXPECT
  31. # define __builtin_expect(expr, val) (expr)
  32. #endif
  33. /* Separator in PATH like lists of pathnames. */
  34. #if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
  35. /* Win32, OS/2, DOS */
  36. # define PATH_SEPARATOR ';'
  37. #else
  38. /* Unix */
  39. # define PATH_SEPARATOR ':'
  40. #endif
  41. /* Encoding of locale name parts. */
  42. #define XPG_NORM_CODESET 1
  43. #define XPG_CODESET 2
  44. #define XPG_TERRITORY 4
  45. #define XPG_MODIFIER 8
  46. struct loaded_l10nfile
  47. {
  48. const char *filename;
  49. int decided;
  50. const void *data;
  51. struct loaded_l10nfile *next;
  52. struct loaded_l10nfile *successor[1];
  53. };
  54. /* Normalize codeset name. There is no standard for the codeset
  55. names. Normalization allows the user to use any of the common
  56. names. The return value is dynamically allocated and has to be
  57. freed by the caller. */
  58. extern const char *_nl_normalize_codeset (const char *codeset,
  59. size_t name_len);
  60. /* Lookup a locale dependent file.
  61. *L10NFILE_LIST denotes a pool of lookup results of locale dependent
  62. files of the same kind, sorted in decreasing order of ->filename.
  63. DIRLIST and DIRLIST_LEN are an argz list of directories in which to
  64. look, containing at least one directory (i.e. DIRLIST_LEN > 0).
  65. MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER
  66. are the pieces of the locale name, as produced by _nl_explode_name().
  67. FILENAME is the filename suffix.
  68. The return value is the lookup result, either found in *L10NFILE_LIST,
  69. or - if DO_ALLOCATE is nonzero - freshly allocated, or possibly NULL.
  70. If the return value is non-NULL, it is added to *L10NFILE_LIST, and
  71. its ->next field denotes the chaining inside *L10NFILE_LIST, and
  72. furthermore its ->successor[] field contains a list of other lookup
  73. results from which this lookup result inherits. */
  74. extern struct loaded_l10nfile *
  75. _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
  76. const char *dirlist, size_t dirlist_len, int mask,
  77. const char *language, const char *territory,
  78. const char *codeset, const char *normalized_codeset,
  79. const char *modifier,
  80. const char *filename, int do_allocate);
  81. /* Lookup the real locale name for a locale alias NAME, or NULL if
  82. NAME is not a locale alias (but possibly a real locale name).
  83. The return value is statically allocated and must not be freed. */
  84. /* Part of the libintl ABI only for the sake of the gettext.m4 macro. */
  85. extern LIBINTL_DLL_EXPORTED const char *_nl_expand_alias (const char *name);
  86. /* Split a locale name NAME into its pieces: language, modifier,
  87. territory, codeset.
  88. NAME gets destructively modified: NUL bytes are inserted here and
  89. there. *LANGUAGE gets assigned NAME. Each of *MODIFIER, *TERRITORY,
  90. *CODESET gets assigned either a pointer into the old NAME string, or
  91. NULL. *NORMALIZED_CODESET gets assigned the expanded *CODESET, if it
  92. is different from *CODESET; this one is dynamically allocated and has
  93. to be freed by the caller.
  94. The return value is a bitmask, where each bit corresponds to one
  95. filled-in value:
  96. XPG_MODIFIER for *MODIFIER,
  97. XPG_TERRITORY for *TERRITORY,
  98. XPG_CODESET for *CODESET,
  99. XPG_NORM_CODESET for *NORMALIZED_CODESET.
  100. */
  101. extern int _nl_explode_name (char *name, const char **language,
  102. const char **modifier, const char **territory,
  103. const char **codeset,
  104. const char **normalized_codeset);
  105. #endif /* loadinfo.h */