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