implement mo file string lookup for translations
[musl] / src / internal / locale_impl.h
1 #include <locale.h>
2 #include <stdlib.h>
3 #include "libc.h"
4 #include "pthread_impl.h"
5
6 #define LOCALE_NAME_MAX 15
7
8 struct __locale_map {
9         const void *map;
10         size_t map_size;
11         char name[LOCALE_NAME_MAX+1];
12         struct __locale_map *next;
13 };
14
15 int __setlocalecat(locale_t, int, const char *);
16 const char *__mo_lookup(const void *, size_t, const char *);
17 const char *__lctrans(const char *, const struct __locale_map *);
18 const char *__lctrans_cur(const char *);
19
20 #define LCTRANS(msg, lc, loc) __lctrans(msg, (loc)->cat[(lc)-2])
21 #define LCTRANS_CUR(msg) __lctrans_cur(msg)
22
23 #define CURRENT_LOCALE \
24         (libc.uselocale_cnt ? __pthread_self()->locale : &libc.global_locale)
25
26 #define CURRENT_UTF8 \
27         (libc.bytelocale_cnt_minus_1<0 || __pthread_self()->locale->ctype_utf8)
28
29 #undef MB_CUR_MAX
30 #define MB_CUR_MAX (CURRENT_UTF8 ? 4 : 1)