• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _LOCALE_IMPL_H
2 #define _LOCALE_IMPL_H
3 
4 #define __NEED_locale_t
5 
6 #include <locale.h>
7 #include <stdlib.h>
8 #include "libc.h"
9 #include "pthread_impl.h"
10 #include "../include/features.h"
11 
12 #define LOCALE_NAME_MAX 23
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 };
20 
21 extern hidden const struct __locale_map __c_dot_utf8;
22 extern hidden const struct __locale_struct __c_locale;
23 extern hidden const struct __locale_struct __c_dot_utf8_locale;
24 
25 hidden const struct __locale_map *__get_locale(int, const char *);
26 hidden const char *__mo_lookup(const void *, size_t, const char *);
27 hidden const char *__lctrans(const char *, const struct __locale_map *);
28 hidden const char *__lctrans_cur(const char *);
29 hidden const char *__lctrans_impl(const char *, const struct __locale_map *);
30 hidden int __loc_is_allocated(locale_t);
31 hidden char *__gettextdomain(void);
32 
33 #define LOC_MAP_FAILED ((const struct __locale_map *)-1)
34 
35 #define LCTRANS(msg, lc, loc) __lctrans(msg, (loc)->cat[(lc)])
36 #define LCTRANS_CUR(msg) __lctrans_cur(msg)
37 
38 #define C_LOCALE ((locale_t)&__c_locale)
39 #define UTF8_LOCALE ((locale_t)&__c_dot_utf8_locale)
40 
41 #define CURRENT_LOCALE ((locale_t)&__c_locale)
42 
43 #define CURRENT_UTF8 (!!((locale_t)&__c_dot_utf8_locale)->cat[LC_CTYPE])
44 
45 #undef MB_CUR_MAX
46 #define MB_CUR_MAX (CURRENT_UTF8 ? 4 : 1)
47 
48 #endif
49