]> pd.if.org Git - pdclib/blob - includes/locale.h
Some cleanup.
[pdclib] / includes / locale.h
1 // ----------------------------------------------------------------------------
2 // $Id$
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
7 // Localization
8 // ----------------------------------------------------------------------------
9
10 #ifndef __LOCALE_H
11 #define __LOCALE_H __LOCALE_H
12
13 // ----------------------------------------------------------------------------
14 // DEFINES
15
16 #define NULL 0
17
18 // Locale categories
19 #define LC_COLLATE   1 // affects strcoll() and strxfrm()
20 #define LC_CTYPE     2 // affects ctype.h
21 #define LC_MONETARY  4 // affects monetary aspect of localeconv()
22 #define LC_NUMERIC   8 // affects numeric aspect of localeconv()
23 #define LC_TIME     16 // affects strftime()
24 #define LC_ALL      31 // affects all of the above
25
26 // ----------------------------------------------------------------------------
27 // TYPEDEFS
28
29 // TODO: Detailed documentation of grouping formats and field values
30
31 struct lconv
32 {
33     // LC_NUMERIC
34     char * decimal_point;      // decimal point
35     char * grouping;           // grouping
36     char * thousands_sep;      // grouping string
37
38     // LC_MONETARY
39     char * mon_decimal_point;  // decimal point
40     char * mon_grouping;       // grouping
41     char * mon_thousands_sep;  // grouping string
42     char * negative_sign;      // negative sign
43     char * positive_sign;      // positive sign
44     char * currency_symbol;    // currency symbol
45     char frac_digits;          // after-point digits
46     // negative values
47     char n_cs_precedes;        // currency symbol preceding value?
48     char n_sep_by_space;       // currency symbol seperated by space?
49     char n_sign_posn;          // sign position
50     // positive values
51     char p_cs_precedes;        // currency symbol preceding value?
52     char p_sep_by_space;       // currency symbol seperated by space?
53     char p_sign_posn;          // sign position?
54
55     // for international monetary values
56     char * int_curr_symbol;    // international currency symbol (ISO 4217)
57     char int_frac_digits;      // after-point digits
58     // negative values
59     char int_n_cs_precedes;    // currency symbol preceding value?
60     char int_n_sep_by_space;   // currency symbol seperated by space?
61     char int_n_sign_posn;      // sign position?
62     // positive values
63     char int_p_cs_precedes;    // currency symbol preceding value?
64     char int_p_sep_by_space;   // currency symbol seperated by space?
65     char int_p_sign_posn;      // sign position?
66 };
67
68 // ----------------------------------------------------------------------------
69 // FUNCTIONS
70
71 // Returns a (pointer to a) lconv structure holding the values for the current
72 // locale. The structure must not be changed; values might become outdated with
73 // later calls to setlocale() changing LC_NUMERIC, LC_MONETARY or LC_ALL.
74 struct lconv * localeconv( void );
75
76 // Categories are selected by OR'ing the LC_* defines from this header. The
77 // function sets the current locale to that defined by locale_name, and returns
78 // the name of the new locale (if it was set successfully) or a null pointer
79 // (if unsuccessful). At startup, the current locale is "C" by default. A null
80 // pointer as locale_name leaves the locale unchanged, an empty string sets it
81 // to the "native" locale.
82 char * setlocale( int categories, const char * locale_name );
83
84 #endif // __LOCALE_H