locale.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /* Copyright (C) 1991-2021 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library 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. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. /*
  15. * ISO C99 Standard: 7.11 Localization <locale.h>
  16. */
  17. #ifndef _LOCALE_H
  18. #define _LOCALE_H 1
  19. #include <features.h>
  20. #define __need_NULL
  21. #include <stddef.h>
  22. #include <bits/locale.h>
  23. __BEGIN_DECLS
  24. /* These are the possibilities for the first argument to setlocale.
  25. The code assumes that the lowest LC_* symbol has the value zero. */
  26. #define LC_CTYPE __LC_CTYPE
  27. #define LC_NUMERIC __LC_NUMERIC
  28. #define LC_TIME __LC_TIME
  29. #define LC_COLLATE __LC_COLLATE
  30. #define LC_MONETARY __LC_MONETARY
  31. #define LC_MESSAGES __LC_MESSAGES
  32. #define LC_ALL __LC_ALL
  33. #define LC_PAPER __LC_PAPER
  34. #define LC_NAME __LC_NAME
  35. #define LC_ADDRESS __LC_ADDRESS
  36. #define LC_TELEPHONE __LC_TELEPHONE
  37. #define LC_MEASUREMENT __LC_MEASUREMENT
  38. #define LC_IDENTIFICATION __LC_IDENTIFICATION
  39. /* Structure giving information about numeric and monetary notation. */
  40. struct lconv
  41. {
  42. /* Numeric (non-monetary) information. */
  43. char *decimal_point; /* Decimal point character. */
  44. char *thousands_sep; /* Thousands separator. */
  45. /* Each element is the number of digits in each group;
  46. elements with higher indices are farther left.
  47. An element with value CHAR_MAX means that no further grouping is done.
  48. An element with value 0 means that the previous element is used
  49. for all groups farther left. */
  50. char *grouping;
  51. /* Monetary information. */
  52. /* First three chars are a currency symbol from ISO 4217.
  53. Fourth char is the separator. Fifth char is '\0'. */
  54. char *int_curr_symbol;
  55. char *currency_symbol; /* Local currency symbol. */
  56. char *mon_decimal_point; /* Decimal point character. */
  57. char *mon_thousands_sep; /* Thousands separator. */
  58. char *mon_grouping; /* Like `grouping' element (above). */
  59. char *positive_sign; /* Sign for positive values. */
  60. char *negative_sign; /* Sign for negative values. */
  61. char int_frac_digits; /* Int'l fractional digits. */
  62. char frac_digits; /* Local fractional digits. */
  63. /* 1 if currency_symbol precedes a positive value, 0 if succeeds. */
  64. char p_cs_precedes;
  65. /* 1 iff a space separates currency_symbol from a positive value. */
  66. char p_sep_by_space;
  67. /* 1 if currency_symbol precedes a negative value, 0 if succeeds. */
  68. char n_cs_precedes;
  69. /* 1 iff a space separates currency_symbol from a negative value. */
  70. char n_sep_by_space;
  71. /* Positive and negative sign positions:
  72. 0 Parentheses surround the quantity and currency_symbol.
  73. 1 The sign string precedes the quantity and currency_symbol.
  74. 2 The sign string follows the quantity and currency_symbol.
  75. 3 The sign string immediately precedes the currency_symbol.
  76. 4 The sign string immediately follows the currency_symbol. */
  77. char p_sign_posn;
  78. char n_sign_posn;
  79. #ifdef __USE_ISOC99
  80. /* 1 if int_curr_symbol precedes a positive value, 0 if succeeds. */
  81. char int_p_cs_precedes;
  82. /* 1 iff a space separates int_curr_symbol from a positive value. */
  83. char int_p_sep_by_space;
  84. /* 1 if int_curr_symbol precedes a negative value, 0 if succeeds. */
  85. char int_n_cs_precedes;
  86. /* 1 iff a space separates int_curr_symbol from a negative value. */
  87. char int_n_sep_by_space;
  88. /* Positive and negative sign positions:
  89. 0 Parentheses surround the quantity and int_curr_symbol.
  90. 1 The sign string precedes the quantity and int_curr_symbol.
  91. 2 The sign string follows the quantity and int_curr_symbol.
  92. 3 The sign string immediately precedes the int_curr_symbol.
  93. 4 The sign string immediately follows the int_curr_symbol. */
  94. char int_p_sign_posn;
  95. char int_n_sign_posn;
  96. #else
  97. char __int_p_cs_precedes;
  98. char __int_p_sep_by_space;
  99. char __int_n_cs_precedes;
  100. char __int_n_sep_by_space;
  101. char __int_p_sign_posn;
  102. char __int_n_sign_posn;
  103. #endif
  104. };
  105. /* Set and/or return the current locale. */
  106. extern char *setlocale (int __category, const char *__locale) __THROW;
  107. /* Return the numeric/monetary information for the current locale. */
  108. extern struct lconv *localeconv (void) __THROW;
  109. #ifdef __USE_XOPEN2K8
  110. /* POSIX.1-2008 extends the locale interface with functions for
  111. explicit creation and manipulation of 'locale_t' objects
  112. representing locale contexts, and a set of parallel
  113. locale-sensitive text processing functions that take a locale_t
  114. argument. This enables applications to work with data from
  115. multiple locales simultaneously and thread-safely. */
  116. # include <bits/types/locale_t.h>
  117. /* Return a reference to a data structure representing a set of locale
  118. datasets. Unlike for the CATEGORY parameter for `setlocale' the
  119. CATEGORY_MASK parameter here uses a single bit for each category,
  120. made by OR'ing together LC_*_MASK bits above. */
  121. extern locale_t newlocale (int __category_mask, const char *__locale,
  122. locale_t __base) __THROW;
  123. /* These are the bits that can be set in the CATEGORY_MASK argument to
  124. `newlocale'. In the GNU implementation, LC_FOO_MASK has the value
  125. of (1 << LC_FOO), but this is not a part of the interface that
  126. callers can assume will be true. */
  127. # define LC_CTYPE_MASK (1 << __LC_CTYPE)
  128. # define LC_NUMERIC_MASK (1 << __LC_NUMERIC)
  129. # define LC_TIME_MASK (1 << __LC_TIME)
  130. # define LC_COLLATE_MASK (1 << __LC_COLLATE)
  131. # define LC_MONETARY_MASK (1 << __LC_MONETARY)
  132. # define LC_MESSAGES_MASK (1 << __LC_MESSAGES)
  133. # define LC_PAPER_MASK (1 << __LC_PAPER)
  134. # define LC_NAME_MASK (1 << __LC_NAME)
  135. # define LC_ADDRESS_MASK (1 << __LC_ADDRESS)
  136. # define LC_TELEPHONE_MASK (1 << __LC_TELEPHONE)
  137. # define LC_MEASUREMENT_MASK (1 << __LC_MEASUREMENT)
  138. # define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION)
  139. # define LC_ALL_MASK (LC_CTYPE_MASK \
  140. | LC_NUMERIC_MASK \
  141. | LC_TIME_MASK \
  142. | LC_COLLATE_MASK \
  143. | LC_MONETARY_MASK \
  144. | LC_MESSAGES_MASK \
  145. | LC_PAPER_MASK \
  146. | LC_NAME_MASK \
  147. | LC_ADDRESS_MASK \
  148. | LC_TELEPHONE_MASK \
  149. | LC_MEASUREMENT_MASK \
  150. | LC_IDENTIFICATION_MASK \
  151. )
  152. /* Return a duplicate of the set of locale in DATASET. All usage
  153. counters are increased if necessary. */
  154. extern locale_t duplocale (locale_t __dataset) __THROW;
  155. /* Free the data associated with a locale dataset previously returned
  156. by a call to `setlocale_r'. */
  157. extern void freelocale (locale_t __dataset) __THROW;
  158. /* Switch the current thread's locale to DATASET.
  159. If DATASET is null, instead just return the current setting.
  160. The special value LC_GLOBAL_LOCALE is the initial setting
  161. for all threads and can also be installed any time, meaning
  162. the thread uses the global settings controlled by `setlocale'. */
  163. extern locale_t uselocale (locale_t __dataset) __THROW;
  164. /* This value can be passed to `uselocale' and may be returned by it.
  165. Passing this value to any other function has undefined behavior. */
  166. # define LC_GLOBAL_LOCALE ((locale_t) -1L)
  167. #endif
  168. __END_DECLS
  169. #endif /* locale.h */