Back to index

glibc  2.9
locale.h
Go to the documentation of this file.
00001 /* Copyright (C) 1991,1992,1995-2002,2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 /*
00020  *     ISO C99 Standard: 7.11 Localization       <locale.h>
00021  */
00022 
00023 #ifndef       _LOCALE_H
00024 #define       _LOCALE_H     1
00025 
00026 #include <features.h>
00027 
00028 #define __need_NULL
00029 #include <stddef.h>
00030 #include <bits/locale.h>
00031 
00032 __BEGIN_DECLS
00033 
00034 /* These are the possibilities for the first argument to setlocale.
00035    The code assumes that the lowest LC_* symbol has the value zero.  */
00036 #define LC_CTYPE          __LC_CTYPE
00037 #define LC_NUMERIC        __LC_NUMERIC
00038 #define LC_TIME           __LC_TIME
00039 #define LC_COLLATE        __LC_COLLATE
00040 #define LC_MONETARY       __LC_MONETARY
00041 #define LC_MESSAGES       __LC_MESSAGES
00042 #define       LC_ALL          __LC_ALL
00043 #define LC_PAPER       __LC_PAPER
00044 #define LC_NAME               __LC_NAME
00045 #define LC_ADDRESS     __LC_ADDRESS
00046 #define LC_TELEPHONE   __LC_TELEPHONE
00047 #define LC_MEASUREMENT        __LC_MEASUREMENT
00048 #define LC_IDENTIFICATION __LC_IDENTIFICATION
00049 
00050 
00051 __BEGIN_NAMESPACE_STD
00052 
00053 /* Structure giving information about numeric and monetary notation.  */
00054 struct lconv
00055 {
00056   /* Numeric (non-monetary) information.  */
00057 
00058   char *decimal_point;             /* Decimal point character.  */
00059   char *thousands_sep;             /* Thousands separator.  */
00060   /* Each element is the number of digits in each group;
00061      elements with higher indices are farther left.
00062      An element with value CHAR_MAX means that no further grouping is done.
00063      An element with value 0 means that the previous element is used
00064      for all groups farther left.  */
00065   char *grouping;
00066 
00067   /* Monetary information.  */
00068 
00069   /* First three chars are a currency symbol from ISO 4217.
00070      Fourth char is the separator.  Fifth char is '\0'.  */
00071   char *int_curr_symbol;
00072   char *currency_symbol;    /* Local currency symbol.  */
00073   char *mon_decimal_point;  /* Decimal point character.  */
00074   char *mon_thousands_sep;  /* Thousands separator.  */
00075   char *mon_grouping;              /* Like `grouping' element (above).  */
00076   char *positive_sign;             /* Sign for positive values.  */
00077   char *negative_sign;             /* Sign for negative values.  */
00078   char int_frac_digits;            /* Int'l fractional digits.  */
00079   char frac_digits;         /* Local fractional digits.  */
00080   /* 1 if currency_symbol precedes a positive value, 0 if succeeds.  */
00081   char p_cs_precedes;
00082   /* 1 iff a space separates currency_symbol from a positive value.  */
00083   char p_sep_by_space;
00084   /* 1 if currency_symbol precedes a negative value, 0 if succeeds.  */
00085   char n_cs_precedes;
00086   /* 1 iff a space separates currency_symbol from a negative value.  */
00087   char n_sep_by_space;
00088   /* Positive and negative sign positions:
00089      0 Parentheses surround the quantity and currency_symbol.
00090      1 The sign string precedes the quantity and currency_symbol.
00091      2 The sign string follows the quantity and currency_symbol.
00092      3 The sign string immediately precedes the currency_symbol.
00093      4 The sign string immediately follows the currency_symbol.  */
00094   char p_sign_posn;
00095   char n_sign_posn;
00096 #ifdef __USE_ISOC99
00097   /* 1 if int_curr_symbol precedes a positive value, 0 if succeeds.  */
00098   char int_p_cs_precedes;
00099   /* 1 iff a space separates int_curr_symbol from a positive value.  */
00100   char int_p_sep_by_space;
00101   /* 1 if int_curr_symbol precedes a negative value, 0 if succeeds.  */
00102   char int_n_cs_precedes;
00103   /* 1 iff a space separates int_curr_symbol from a negative value.  */
00104   char int_n_sep_by_space;
00105   /* Positive and negative sign positions:
00106      0 Parentheses surround the quantity and int_curr_symbol.
00107      1 The sign string precedes the quantity and int_curr_symbol.
00108      2 The sign string follows the quantity and int_curr_symbol.
00109      3 The sign string immediately precedes the int_curr_symbol.
00110      4 The sign string immediately follows the int_curr_symbol.  */
00111   char int_p_sign_posn;
00112   char int_n_sign_posn;
00113 #else
00114   char __int_p_cs_precedes;
00115   char __int_p_sep_by_space;
00116   char __int_n_cs_precedes;
00117   char __int_n_sep_by_space;
00118   char __int_p_sign_posn;
00119   char __int_n_sign_posn;
00120 #endif
00121 };
00122 
00123 
00124 /* Set and/or return the current locale.  */
00125 extern char *setlocale (int __category, __const char *__locale) __THROW;
00126 
00127 /* Return the numeric/monetary information for the current locale.  */
00128 extern struct lconv *localeconv (void) __THROW;
00129 
00130 __END_NAMESPACE_STD
00131 
00132 
00133 #ifdef __USE_GNU
00134 /* The concept of one static locale per category is not very well
00135    thought out.  Many applications will need to process its data using
00136    information from several different locales.  Another application is
00137    the implementation of the internationalization handling in the
00138    upcoming ISO C++ standard library.  To support this another set of
00139    the functions using locale data exist which have an additional
00140    argument.
00141 
00142    Attention: all these functions are *not* standardized in any form.
00143    This is a proof-of-concept implementation.  */
00144 
00145 /* Get locale datatype definition.  */
00146 # include <xlocale.h>
00147 
00148 typedef __locale_t locale_t;
00149 
00150 /* Return a reference to a data structure representing a set of locale
00151    datasets.  Unlike for the CATEGORY parameter for `setlocale' the
00152    CATEGORY_MASK parameter here uses a single bit for each category,
00153    made by OR'ing together LC_*_MASK bits above.  */
00154 extern __locale_t newlocale (int __category_mask, __const char *__locale,
00155                           __locale_t __base) __THROW;
00156 
00157 /* These are the bits that can be set in the CATEGORY_MASK argument to
00158    `newlocale'.  In the GNU implementation, LC_FOO_MASK has the value
00159    of (1 << LC_FOO), but this is not a part of the interface that
00160    callers can assume will be true.  */
00161 # define LC_CTYPE_MASK             (1 << __LC_CTYPE)
00162 # define LC_NUMERIC_MASK    (1 << __LC_NUMERIC)
00163 # define LC_TIME_MASK              (1 << __LC_TIME)
00164 # define LC_COLLATE_MASK    (1 << __LC_COLLATE)
00165 # define LC_MONETARY_MASK   (1 << __LC_MONETARY)
00166 # define LC_MESSAGES_MASK   (1 << __LC_MESSAGES)
00167 # define LC_PAPER_MASK             (1 << __LC_PAPER)
00168 # define LC_NAME_MASK              (1 << __LC_NAME)
00169 # define LC_ADDRESS_MASK    (1 << __LC_ADDRESS)
00170 # define LC_TELEPHONE_MASK  (1 << __LC_TELEPHONE)
00171 # define LC_MEASUREMENT_MASK       (1 << __LC_MEASUREMENT)
00172 # define LC_IDENTIFICATION_MASK    (1 << __LC_IDENTIFICATION)
00173 # define LC_ALL_MASK        (LC_CTYPE_MASK \
00174                              | LC_NUMERIC_MASK \
00175                              | LC_TIME_MASK \
00176                              | LC_COLLATE_MASK \
00177                              | LC_MONETARY_MASK \
00178                              | LC_MESSAGES_MASK \
00179                              | LC_PAPER_MASK \
00180                              | LC_NAME_MASK \
00181                              | LC_ADDRESS_MASK \
00182                              | LC_TELEPHONE_MASK \
00183                              | LC_MEASUREMENT_MASK \
00184                              | LC_IDENTIFICATION_MASK \
00185                              )
00186 
00187 /* Return a duplicate of the set of locale in DATASET.  All usage
00188    counters are increased if necessary.  */
00189 extern __locale_t duplocale (__locale_t __dataset) __THROW;
00190 
00191 /* Free the data associated with a locale dataset previously returned
00192    by a call to `setlocale_r'.  */
00193 extern void freelocale (__locale_t __dataset) __THROW;
00194 
00195 /* Switch the current thread's locale to DATASET.
00196    If DATASET is null, instead just return the current setting.
00197    The special value LC_GLOBAL_LOCALE is the initial setting
00198    for all threads and can also be installed any time, meaning
00199    the thread uses the global settings controlled by `setlocale'.  */
00200 extern __locale_t uselocale (__locale_t __dataset) __THROW;
00201 
00202 /* This value can be passed to `uselocale' and may be returned by it.
00203    Passing this value to any other function has undefined behavior.  */
00204 # define LC_GLOBAL_LOCALE   ((__locale_t) -1L)
00205 
00206 #endif
00207 
00208 __END_DECLS
00209 
00210 #endif /* locale.h  */