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