1 #ifndef _LOCALE_IMPL_H 2 #define _LOCALE_IMPL_H 3 4 #include <locale.h> 5 #include <stdlib.h> 6 #include "libc.h" 7 #include "pthread_impl.h" 8 9 #define LOCALE_NAME_MAX 23 10 #define VALID 2 11 #define INVALID 1 12 #define ICU_VALID 3 13 14 struct __locale_map { 15 const void *map; 16 size_t map_size; 17 char name[LOCALE_NAME_MAX+1]; 18 const struct __locale_map *next; 19 char flag; 20 }; 21 22 extern hidden volatile int __locale_lock[1]; 23 24 extern hidden const struct __locale_map __c_dot_utf8; 25 extern hidden const struct __locale_struct __c_locale; 26 extern hidden const struct __locale_struct __c_dot_utf8_locale; 27 28 hidden const struct __locale_map *__get_locale(int, const char *); 29 hidden const char *__mo_lookup(const void *, size_t, const char *); 30 hidden const char *__lctrans(const char *, const struct __locale_map *); 31 hidden const char *__lctrans_cur(const char *); 32 hidden const char *__lctrans_impl(const char *, const struct __locale_map *); 33 hidden int __loc_is_allocated(locale_t); 34 hidden char *__gettextdomain(void); 35 36 #ifdef FEATURE_ICU_LOCALE 37 typedef enum { 38 ICU_UC = 0, 39 ICU_I18N, 40 } ICU_SO_TYPE; 41 42 typedef uint16_t u_char; 43 44 hidden void *get_icu_handle(ICU_SO_TYPE type, const char *symbol_name); 45 hidden void get_icu_symbol(ICU_SO_TYPE type, void **icu_symbol_handle, const char *symbol_name); 46 hidden char *get_valid_icu_locale_name(const char *name); 47 hidden void *icu_unum_open(char *icu_locale_name, int *cur_status); 48 hidden void icu_unum_close(void *fmt); 49 hidden double icu_parse_double(void *fmt, u_char *ustr, int32_t *parse_pos, int *cur_status); 50 51 #define ICU_SYMBOL(name) #name"_72" 52 typedef void *(*f_icu18n_unum_open)(int, void *, int32_t, const char *, void *, void *); 53 typedef void (*f_icu18n_unum_close)(void *); 54 typedef void *(*f_icu18n_u_str_from_utf8)(u_char *, int32_t, int32_t *, const char *, int32_t, int *); 55 typedef void *(*f_icu18n_u_str_from_utf32)(u_char *, int32_t, int32_t *, const wchar_t *, int32_t, int *); 56 typedef double (*f_icu18n_unum_parse_double)(void *, u_char *, int32_t, int32_t *, int *); 57 typedef int32_t(*f_icu18n_unum_get_symbol)(const void *, int, u_char *, int32_t, int *); 58 typedef char *(*f_icuuc_u_austrncpy)(char *, const u_char *, int32_t); 59 60 struct icu_opt_func { 61 f_icu18n_unum_open unum_open; 62 f_icu18n_unum_close unum_close; 63 f_icu18n_u_str_from_utf8 u_str_from_utf8; 64 f_icu18n_unum_parse_double unum_parse_double; 65 f_icu18n_u_str_from_utf32 u_strFrom_utf32; 66 f_icu18n_unum_get_symbol unum_get_symbol; 67 f_icuuc_u_austrncpy u_austrncpy; 68 }; 69 extern hidden struct icu_opt_func g_icu_opt_func; 70 71 #define DLSYM_ICU_SUCC 0 72 #define DLSYM_ICU_FAIL 1 73 #define ICU_ERROR (-1) 74 #endif 75 76 #define LOC_MAP_FAILED ((const struct __locale_map *)-1) 77 78 #define LCTRANS(msg, lc, loc) __lctrans(msg, (loc)->cat[(lc)]) 79 #define LCTRANS_CUR(msg) __lctrans_cur(msg) 80 81 #define C_LOCALE ((locale_t)&__c_locale) 82 #define UTF8_LOCALE ((locale_t)&__c_dot_utf8_locale) 83 84 #define CURRENT_LOCALE (__pthread_self()->locale) 85 86 #define CURRENT_UTF8 (!!__pthread_self()->locale->cat[LC_CTYPE]) 87 88 #undef MB_CUR_MAX 89 #define MB_CUR_MAX (CURRENT_UTF8 ? 4 : 1) 90 91 #endif 92