locale.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /* Copyright (C) 1991,1992,1995-2002,2007,2009 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. <http://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/uClibc_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. #if 0
  34. #define LC_PAPER __LC_PAPER
  35. #define LC_NAME __LC_NAME
  36. #define LC_ADDRESS __LC_ADDRESS
  37. #define LC_TELEPHONE __LC_TELEPHONE
  38. #define LC_MEASUREMENT __LC_MEASUREMENT
  39. #define LC_IDENTIFICATION __LC_IDENTIFICATION
  40. #endif
  41. __BEGIN_NAMESPACE_STD
  42. /* Structure giving information about numeric and monetary notation. */
  43. struct lconv
  44. {
  45. /* Numeric (non-monetary) information. */
  46. char *decimal_point; /* Decimal point character. */
  47. char *thousands_sep; /* Thousands separator. */
  48. /* Each element is the number of digits in each group;
  49. elements with higher indices are farther left.
  50. An element with value CHAR_MAX means that no further grouping is done.
  51. An element with value 0 means that the previous element is used
  52. for all groups farther left. */
  53. char *grouping;
  54. /* Monetary information. */
  55. /* First three chars are a currency symbol from ISO 4217.
  56. Fourth char is the separator. Fifth char is '\0'. */
  57. char *int_curr_symbol;
  58. char *currency_symbol; /* Local currency symbol. */
  59. char *mon_decimal_point; /* Decimal point character. */
  60. char *mon_thousands_sep; /* Thousands separator. */
  61. char *mon_grouping; /* Like `grouping' element (above). */
  62. char *positive_sign; /* Sign for positive values. */
  63. char *negative_sign; /* Sign for negative values. */
  64. char int_frac_digits; /* Int'l fractional digits. */
  65. char frac_digits; /* Local fractional digits. */
  66. /* 1 if currency_symbol precedes a positive value, 0 if succeeds. */
  67. char p_cs_precedes;
  68. /* 1 iff a space separates currency_symbol from a positive value. */
  69. char p_sep_by_space;
  70. /* 1 if currency_symbol precedes a negative value, 0 if succeeds. */
  71. char n_cs_precedes;
  72. /* 1 iff a space separates currency_symbol from a negative value. */
  73. char n_sep_by_space;
  74. /* Positive and negative sign positions:
  75. 0 Parentheses surround the quantity and currency_symbol.
  76. 1 The sign string precedes the quantity and currency_symbol.
  77. 2 The sign string follows the quantity and currency_symbol.
  78. 3 The sign string immediately precedes the currency_symbol.
  79. 4 The sign string immediately follows the currency_symbol. */
  80. char p_sign_posn;
  81. char n_sign_posn;
  82. #ifdef __USE_ISOC99
  83. /* 1 if int_curr_symbol precedes a positive value, 0 if succeeds. */
  84. char int_p_cs_precedes;
  85. /* 1 iff a space separates int_curr_symbol from a positive value. */
  86. char int_p_sep_by_space;
  87. /* 1 if int_curr_symbol precedes a negative value, 0 if succeeds. */
  88. char int_n_cs_precedes;
  89. /* 1 iff a space separates int_curr_symbol from a negative value. */
  90. char int_n_sep_by_space;
  91. /* Positive and negative sign positions:
  92. 0 Parentheses surround the quantity and int_curr_symbol.
  93. 1 The sign string precedes the quantity and int_curr_symbol.
  94. 2 The sign string follows the quantity and int_curr_symbol.
  95. 3 The sign string immediately precedes the int_curr_symbol.
  96. 4 The sign string immediately follows the int_curr_symbol. */
  97. char int_p_sign_posn;
  98. char int_n_sign_posn;
  99. #else
  100. char __int_p_cs_precedes;
  101. char __int_p_sep_by_space;
  102. char __int_n_cs_precedes;
  103. char __int_n_sep_by_space;
  104. char __int_p_sign_posn;
  105. char __int_n_sign_posn;
  106. #endif
  107. };
  108. /* Set and/or return the current locale. */
  109. extern char *setlocale (int __category, const char *__locale) __THROW;
  110. /* Return the numeric/monetary information for the current locale. */
  111. extern struct lconv *localeconv (void) __THROW;
  112. libc_hidden_proto(localeconv)
  113. __END_NAMESPACE_STD
  114. #if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_XLOCALE__
  115. /* The concept of one static locale per category is not very well
  116. thought out. Many applications will need to process its data using
  117. information from several different locales. Another application is
  118. the implementation of the internationalization handling in the
  119. upcoming ISO C++ standard library. To support this another set of
  120. the functions using locale data exist which have an additional
  121. argument.
  122. Attention: all these functions are *not* standardized in any form.
  123. This is a proof-of-concept implementation. */
  124. /* Get locale datatype definition. */
  125. # include <xlocale.h>
  126. /* Return a reference to a data structure representing a set of locale
  127. datasets. Unlike for the CATEGORY parameter for `setlocale' the
  128. CATEGORY_MASK parameter here uses a single bit for each category,
  129. made by OR'ing together LC_*_MASK bits above. */
  130. extern __locale_t newlocale (int __category_mask, const char *__locale,
  131. __locale_t __base) __THROW;
  132. libc_hidden_proto(newlocale)
  133. /* These are the bits that can be set in the CATEGORY_MASK argument to
  134. `newlocale'. In the GNU implementation, LC_FOO_MASK has the value
  135. of (1 << LC_FOO), but this is not a part of the interface that
  136. callers can assume will be true. */
  137. # define LC_CTYPE_MASK (1 << __LC_CTYPE)
  138. # define LC_NUMERIC_MASK (1 << __LC_NUMERIC)
  139. # define LC_TIME_MASK (1 << __LC_TIME)
  140. # define LC_COLLATE_MASK (1 << __LC_COLLATE)
  141. # define LC_MONETARY_MASK (1 << __LC_MONETARY)
  142. # define LC_MESSAGES_MASK (1 << __LC_MESSAGES)
  143. #ifdef LC_PAPER
  144. # define LC_PAPER_MASK (1 << __LC_PAPER)
  145. # define LC_NAME_MASK (1 << __LC_NAME)
  146. # define LC_ADDRESS_MASK (1 << __LC_ADDRESS)
  147. # define LC_TELEPHONE_MASK (1 << __LC_TELEPHONE)
  148. # define LC_MEASUREMENT_MASK (1 << __LC_MEASUREMENT)
  149. # define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION)
  150. # define LC_ALL_MASK (LC_CTYPE_MASK \
  151. | LC_NUMERIC_MASK \
  152. | LC_TIME_MASK \
  153. | LC_COLLATE_MASK \
  154. | LC_MONETARY_MASK \
  155. | LC_MESSAGES_MASK \
  156. | LC_PAPER_MASK \
  157. | LC_NAME_MASK \
  158. | LC_ADDRESS_MASK \
  159. | LC_TELEPHONE_MASK \
  160. | LC_MEASUREMENT_MASK \
  161. | LC_IDENTIFICATION_MASK \
  162. )
  163. #else /* LC_PAPER */
  164. # define LC_ALL_MASK (LC_CTYPE_MASK \
  165. | LC_NUMERIC_MASK \
  166. | LC_TIME_MASK \
  167. | LC_COLLATE_MASK \
  168. | LC_MONETARY_MASK \
  169. | LC_MESSAGES_MASK \
  170. )
  171. #endif /* LC_PAPER */
  172. /* Return a duplicate of the set of locale in DATASET. All usage
  173. counters are increased if necessary. */
  174. extern __locale_t duplocale (__locale_t __dataset) __THROW;
  175. /* Free the data associated with a locale dataset previously returned
  176. by a call to `setlocale_r'. */
  177. extern void freelocale (__locale_t __dataset) __THROW;
  178. /* Switch the current thread's locale to DATASET.
  179. If DATASET is null, instead just return the current setting.
  180. The special value LC_GLOBAL_LOCALE is the initial setting
  181. for all threads and can also be installed any time, meaning
  182. the thread uses the global settings controlled by `setlocale'. */
  183. extern __locale_t uselocale (__locale_t __dataset) __THROW;
  184. libc_hidden_proto(uselocale)
  185. /* This value can be passed to `uselocale' and may be returned by it.
  186. Passing this value to any other function has undefined behavior. */
  187. # define LC_GLOBAL_LOCALE ((__locale_t) -1L)
  188. #endif
  189. __END_DECLS
  190. #endif /* locale.h */