PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pg_locale.h
Go to the documentation of this file.
1 /*-----------------------------------------------------------------------
2  *
3  * PostgreSQL locale utilities
4  *
5  * src/include/utils/pg_locale.h
6  *
7  * Copyright (c) 2002-2017, PostgreSQL Global Development Group
8  *
9  *-----------------------------------------------------------------------
10  */
11 
12 #ifndef _PG_LOCALE_
13 #define _PG_LOCALE_
14 
15 #if defined(LOCALE_T_IN_XLOCALE) || defined(WCSTOMBS_L_IN_XLOCALE)
16 #include <xlocale.h>
17 #endif
18 
19 #include "utils/guc.h"
20 
21 
22 /* GUC settings */
23 extern char *locale_messages;
24 extern char *locale_monetary;
25 extern char *locale_numeric;
26 extern char *locale_time;
27 
28 /* lc_time localization cache */
29 extern char *localized_abbrev_days[];
30 extern char *localized_full_days[];
31 extern char *localized_abbrev_months[];
32 extern char *localized_full_months[];
33 
34 
35 extern bool check_locale_messages(char **newval, void **extra, GucSource source);
36 extern void assign_locale_messages(const char *newval, void *extra);
37 extern bool check_locale_monetary(char **newval, void **extra, GucSource source);
38 extern void assign_locale_monetary(const char *newval, void *extra);
39 extern bool check_locale_numeric(char **newval, void **extra, GucSource source);
40 extern void assign_locale_numeric(const char *newval, void *extra);
41 extern bool check_locale_time(char **newval, void **extra, GucSource source);
42 extern void assign_locale_time(const char *newval, void *extra);
43 
44 extern bool check_locale(int category, const char *locale, char **canonname);
45 extern char *pg_perm_setlocale(int category, const char *locale);
46 extern void check_strxfrm_bug(void);
47 
48 extern bool lc_collate_is_c(Oid collation);
49 extern bool lc_ctype_is_c(Oid collation);
50 
51 /*
52  * Return the POSIX lconv struct (contains number/money formatting
53  * information) with locale information for all categories.
54  */
55 extern struct lconv *PGLC_localeconv(void);
56 
57 extern void cache_locale_time(void);
58 
59 
60 /*
61  * We define our own wrapper around locale_t so we can keep the same
62  * function signatures for all builds, while not having to create a
63  * fake version of the standard type locale_t in the global namespace.
64  * The fake version of pg_locale_t can be checked for truth; that's
65  * about all it will be needed for.
66  */
67 #ifdef HAVE_LOCALE_T
68 typedef locale_t pg_locale_t;
69 #else
70 typedef int pg_locale_t;
71 #endif
72 
74 
75 /* These functions convert from/to libc's wchar_t, *not* pg_wchar_t */
76 #ifdef USE_WIDE_UPPER_LOWER
77 extern size_t wchar2char(char *to, const wchar_t *from, size_t tolen,
79 extern size_t char2wchar(wchar_t *to, size_t tolen,
80  const char *from, size_t fromlen, pg_locale_t locale);
81 #endif
82 
83 #endif /* _PG_LOCALE_ */
char * pg_perm_setlocale(int category, const char *locale)
Definition: pg_locale.c:145
bool check_locale_monetary(char **newval, void **extra, GucSource source)
Definition: pg_locale.c:301
bool lc_collate_is_c(Oid collation)
Definition: pg_locale.c:1122
#define locale_t
Definition: win32.h:333
char * locale_time
Definition: pg_locale.c:85
bool check_locale_numeric(char **newval, void **extra, GucSource source)
Definition: pg_locale.c:313
bool check_locale_messages(char **newval, void **extra, GucSource source)
Definition: pg_locale.c:347
struct lconv * PGLC_localeconv(void)
Definition: pg_locale.c:477
unsigned int Oid
Definition: postgres_ext.h:31
GucSource
Definition: guc.h:105
int pg_locale_t
Definition: pg_locale.h:70
bool check_locale(int category, const char *locale, char **canonname)
Definition: pg_locale.c:258
void assign_locale_monetary(const char *newval, void *extra)
Definition: pg_locale.c:307
bool lc_ctype_is_c(Oid collation)
Definition: pg_locale.c:1172
void assign_locale_messages(const char *newval, void *extra)
Definition: pg_locale.c:370
char * locale_monetary
Definition: pg_locale.c:83
pg_locale_t pg_newlocale_from_collation(Oid collid)
Definition: pg_locale.c:1259
char * localized_full_days[]
Definition: pg_locale.c:89
bool check_locale_time(char **newval, void **extra, GucSource source)
Definition: pg_locale.c:325
char * locale_messages
Definition: pg_locale.c:82
void cache_locale_time(void)
Definition: pg_locale.c:780
void check_strxfrm_bug(void)
Definition: pg_locale.c:987
char * localized_full_months[]
Definition: pg_locale.c:91
void assign_locale_numeric(const char *newval, void *extra)
Definition: pg_locale.c:319
#define newval
char * locale_numeric
Definition: pg_locale.c:84
void assign_locale_time(const char *newval, void *extra)
Definition: pg_locale.c:331
static char * locale
Definition: initdb.c:121
char * localized_abbrev_days[]
Definition: pg_locale.c:88
char * localized_abbrev_months[]
Definition: pg_locale.c:90