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