xref: /freebsd/include/locale.h (revision 3c87aa1d3dc1d8dad3efad322852a8e1e76dee55)
159deaec5SRodney W. Grimes /*
259deaec5SRodney W. Grimes  * Copyright (c) 1991, 1993
359deaec5SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
459deaec5SRodney W. Grimes  *
559deaec5SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
659deaec5SRodney W. Grimes  * modification, are permitted provided that the following conditions
759deaec5SRodney W. Grimes  * are met:
859deaec5SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
959deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
1059deaec5SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
1159deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
1259deaec5SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
13f2556687SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
1459deaec5SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
1559deaec5SRodney W. Grimes  *    without specific prior written permission.
1659deaec5SRodney W. Grimes  *
1759deaec5SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1859deaec5SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1959deaec5SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2059deaec5SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2159deaec5SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2259deaec5SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2359deaec5SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2459deaec5SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2559deaec5SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2659deaec5SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2759deaec5SRodney W. Grimes  * SUCH DAMAGE.
2859deaec5SRodney W. Grimes  *
2959deaec5SRodney W. Grimes  *	@(#)locale.h	8.1 (Berkeley) 6/2/93
30bb28f3c2SWarner Losh  * $FreeBSD$
3159deaec5SRodney W. Grimes  */
3259deaec5SRodney W. Grimes 
3359deaec5SRodney W. Grimes #ifndef _LOCALE_H_
3459deaec5SRodney W. Grimes #define _LOCALE_H_
3559deaec5SRodney W. Grimes 
3612eb46c8SMarcel Moolenaar #include <sys/_null.h>
3712eb46c8SMarcel Moolenaar 
3859deaec5SRodney W. Grimes struct lconv {
3959deaec5SRodney W. Grimes 	char	*decimal_point;
4059deaec5SRodney W. Grimes 	char	*thousands_sep;
4159deaec5SRodney W. Grimes 	char	*grouping;
4259deaec5SRodney W. Grimes 	char	*int_curr_symbol;
4359deaec5SRodney W. Grimes 	char	*currency_symbol;
4459deaec5SRodney W. Grimes 	char	*mon_decimal_point;
4559deaec5SRodney W. Grimes 	char	*mon_thousands_sep;
4659deaec5SRodney W. Grimes 	char	*mon_grouping;
4759deaec5SRodney W. Grimes 	char	*positive_sign;
4859deaec5SRodney W. Grimes 	char	*negative_sign;
4959deaec5SRodney W. Grimes 	char	int_frac_digits;
5059deaec5SRodney W. Grimes 	char	frac_digits;
5159deaec5SRodney W. Grimes 	char	p_cs_precedes;
5259deaec5SRodney W. Grimes 	char	p_sep_by_space;
5359deaec5SRodney W. Grimes 	char	n_cs_precedes;
5459deaec5SRodney W. Grimes 	char	n_sep_by_space;
5559deaec5SRodney W. Grimes 	char	p_sign_posn;
5659deaec5SRodney W. Grimes 	char	n_sign_posn;
57f4da1a75STim J. Robbins 	char	int_p_cs_precedes;
58f4da1a75STim J. Robbins 	char	int_n_cs_precedes;
59f4da1a75STim J. Robbins 	char	int_p_sep_by_space;
60f4da1a75STim J. Robbins 	char	int_n_sep_by_space;
61f4da1a75STim J. Robbins 	char	int_p_sign_posn;
62f4da1a75STim J. Robbins 	char	int_n_sign_posn;
6359deaec5SRodney W. Grimes };
6459deaec5SRodney W. Grimes 
6559deaec5SRodney W. Grimes #define	LC_ALL		0
6659deaec5SRodney W. Grimes #define	LC_COLLATE	1
6759deaec5SRodney W. Grimes #define	LC_CTYPE	2
6859deaec5SRodney W. Grimes #define	LC_MONETARY	3
6959deaec5SRodney W. Grimes #define	LC_NUMERIC	4
7059deaec5SRodney W. Grimes #define	LC_TIME		5
710b5e953bSAndrey A. Chernov #define	LC_MESSAGES	6
7259deaec5SRodney W. Grimes 
730b5e953bSAndrey A. Chernov #define	_LC_LAST	7		/* marks end */
7459deaec5SRodney W. Grimes 
7559deaec5SRodney W. Grimes #include <sys/cdefs.h>
7659deaec5SRodney W. Grimes 
7759deaec5SRodney W. Grimes __BEGIN_DECLS
78bb28f3c2SWarner Losh struct lconv	*localeconv(void);
79bb28f3c2SWarner Losh char		*setlocale(int, const char *);
8059deaec5SRodney W. Grimes __END_DECLS
8159deaec5SRodney W. Grimes 
82*3c87aa1dSDavid Chisnall #if __POSIX_VISIBLE >= 200809
83*3c87aa1dSDavid Chisnall 
84*3c87aa1dSDavid Chisnall #define LC_COLLATE_MASK  (1<<0)
85*3c87aa1dSDavid Chisnall #define LC_CTYPE_MASK    (1<<1)
86*3c87aa1dSDavid Chisnall #define LC_MESSAGES_MASK (1<<2)
87*3c87aa1dSDavid Chisnall #define LC_MONETARY_MASK (1<<3)
88*3c87aa1dSDavid Chisnall #define LC_NUMERIC_MASK  (1<<4)
89*3c87aa1dSDavid Chisnall #define LC_TIME_MASK     (1<<5)
90*3c87aa1dSDavid Chisnall #define LC_ALL_MASK      (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | \
91*3c87aa1dSDavid Chisnall 		LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
92*3c87aa1dSDavid Chisnall 
93*3c87aa1dSDavid Chisnall #define LC_GLOBAL_LOCALE ((locale_t)-1)
94*3c87aa1dSDavid Chisnall 
95*3c87aa1dSDavid Chisnall __BEGIN_DECLS
96*3c87aa1dSDavid Chisnall 
97*3c87aa1dSDavid Chisnall typedef struct _xlocale *locale_t;
98*3c87aa1dSDavid Chisnall /**
99*3c87aa1dSDavid Chisnall  * Creates a new locale.
100*3c87aa1dSDavid Chisnall  */
101*3c87aa1dSDavid Chisnall locale_t	 newlocale(int mask, const char *locale, locale_t base);
102*3c87aa1dSDavid Chisnall 
103*3c87aa1dSDavid Chisnall /**
104*3c87aa1dSDavid Chisnall  * Returns an identical duplicate of the passed locale.  The returned locale
105*3c87aa1dSDavid Chisnall  * must be freed with freelocale().  The returned locale will share components
106*3c87aa1dSDavid Chisnall  * with the original.
107*3c87aa1dSDavid Chisnall  */
108*3c87aa1dSDavid Chisnall locale_t	 duplocale(locale_t base);
109*3c87aa1dSDavid Chisnall /*
110*3c87aa1dSDavid Chisnall  * Free a locale_t.  This is quite a poorly named function.  It actually
111*3c87aa1dSDavid Chisnall  * disclaims a reference to a locale_t, rather than freeing it.
112*3c87aa1dSDavid Chisnall  */
113*3c87aa1dSDavid Chisnall int	 freelocale(locale_t loc);
114*3c87aa1dSDavid Chisnall 
115*3c87aa1dSDavid Chisnall /*
116*3c87aa1dSDavid Chisnall  * Returns the name of the locale for a particular component of a locale_t.
117*3c87aa1dSDavid Chisnall  */
118*3c87aa1dSDavid Chisnall const char	*querylocale(int mask, locale_t loc);
119*3c87aa1dSDavid Chisnall 
120*3c87aa1dSDavid Chisnall /*
121*3c87aa1dSDavid Chisnall  * Installs the specified locale_t as this thread's locale.
122*3c87aa1dSDavid Chisnall  */
123*3c87aa1dSDavid Chisnall locale_t	 uselocale(locale_t loc);
124*3c87aa1dSDavid Chisnall 
125*3c87aa1dSDavid Chisnall __END_DECLS
126*3c87aa1dSDavid Chisnall 
127*3c87aa1dSDavid Chisnall #endif /* __POSIX_VISIBLE >= 200809 */
128*3c87aa1dSDavid Chisnall 
129*3c87aa1dSDavid Chisnall 
13059deaec5SRodney W. Grimes #endif /* _LOCALE_H_ */
131