locale.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* Copyright (C) 1991,92,95-99,2000,01,02 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, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. /*
  16. * ISO C99 Standard: 7.11 Localization <locale.h>
  17. */
  18. #ifndef _LOCALE_H
  19. #define _LOCALE_H 1
  20. #include <features.h>
  21. #define __need_NULL
  22. #include <stddef.h>
  23. #include <bits/uClibc_locale.h>
  24. __BEGIN_DECLS
  25. /* These are the possibilities for the first argument to setlocale.
  26. The code assumes that the lowest LC_* symbol has the value zero. */
  27. #define LC_CTYPE __LC_CTYPE
  28. #define LC_NUMERIC __LC_NUMERIC
  29. #define LC_TIME __LC_TIME
  30. #define LC_COLLATE __LC_COLLATE
  31. #define LC_MONETARY __LC_MONETARY
  32. #define LC_MESSAGES __LC_MESSAGES
  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. #define LC_ALL __LC_ALL
  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. __BEGIN_NAMESPACE_STD
  109. /* Set and/or return the current locale. */
  110. extern char *setlocale (int __category, __const char *__locale) __THROW;
  111. /* Return the numeric/monetary information for the current locale. */
  112. extern struct lconv *localeconv (void) __THROW;
  113. __END_NAMESPACE_STD
  114. #if defined(__USE_GNU) && 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. typedef __locale_t locale_t;
  127. /* Return a reference to a data structure representing a set of locale
  128. datasets. Unlike for the CATEGORY parameter for `setlocale' the
  129. CATEGORY_MASK parameter here uses a single bit for each category,
  130. made by OR'ing together LC_*_MASK bits above. */
  131. extern __locale_t newlocale (int __category_mask, __const char *__locale,
  132. __locale_t __base) __THROW;
  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 L_newlocale
  144. #warning mask defines for extra locale categories
  145. #endif /* L_newlocale - uClibc note */
  146. #ifdef LC_PAPER
  147. # define LC_PAPER_MASK (1 << __LC_PAPER)
  148. # define LC_NAME_MASK (1 << __LC_NAME)
  149. # define LC_ADDRESS_MASK (1 << __LC_ADDRESS)
  150. # define LC_TELEPHONE_MASK (1 << __LC_TELEPHONE)
  151. # define LC_MEASUREMENT_MASK (1 << __LC_MEASUREMENT)
  152. # define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION)
  153. # define LC_ALL_MASK (LC_CTYPE_MASK \
  154. | LC_NUMERIC_MASK \
  155. | LC_TIME_MASK \
  156. | LC_COLLATE_MASK \
  157. | LC_MONETARY_MASK \
  158. | LC_MESSAGES_MASK \
  159. | LC_PAPER_MASK \
  160. | LC_NAME_MASK \
  161. | LC_ADDRESS_MASK \
  162. | LC_TELEPHONE_MASK \
  163. | LC_MEASUREMENT_MASK \
  164. | LC_IDENTIFICATION_MASK \
  165. )
  166. #else /* LC_PAPER */
  167. # define LC_ALL_MASK (LC_CTYPE_MASK \
  168. | LC_NUMERIC_MASK \
  169. | LC_TIME_MASK \
  170. | LC_COLLATE_MASK \
  171. | LC_MONETARY_MASK \
  172. | LC_MESSAGES_MASK \
  173. )
  174. #endif /* LC_PAPER */
  175. /* Return a duplicate of the set of locale in DATASET. All usage
  176. counters are increased if necessary. */
  177. extern __locale_t duplocale (__locale_t __dataset) __THROW;
  178. /* Free the data associated with a locale dataset previously returned
  179. by a call to `setlocale_r'. */
  180. extern void freelocale (__locale_t __dataset) __THROW;
  181. /* Switch the current thread's locale to DATASET.
  182. If DATASET is null, instead just return the current setting.
  183. The special value LC_GLOBAL_LOCALE is the initial setting
  184. for all threads and can also be installed any time, meaning
  185. the thread uses the global settings controlled by `setlocale'. */
  186. extern __locale_t uselocale (__locale_t __dataset) __THROW;
  187. /* This value can be passed to `uselocale' and may be returned by it.
  188. Passing this value to any other function has undefined behavior. */
  189. # define LC_GLOBAL_LOCALE ((__locale_t) -1L)
  190. extern __locale_t __newlocale (int __category_mask, __const char *__locale,
  191. __locale_t __base) __THROW;
  192. extern __locale_t __duplocale (__locale_t __dataset) __THROW;
  193. extern void __freelocale (__locale_t __dataset) __THROW;
  194. extern __locale_t __uselocale (__locale_t __dataset) __THROW;
  195. #endif
  196. __END_DECLS
  197. #endif /* locale.h */