*: fix places where we were still using malloc/realloc
[oweals/busybox.git] / include / unicode.h
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Licensed under the GPL version 2, see the file LICENSE in this tarball.
4  */
5 #ifndef UNICODE_H
6 #define UNICODE_H 1
7
8 enum {
9         UNICODE_UNKNOWN = 0,
10         UNICODE_OFF = 1,
11         UNICODE_ON = 2,
12 };
13
14 #if !ENABLE_FEATURE_ASSUME_UNICODE
15
16 # define bb_mbstrlen(string) strlen(string)
17 # define unicode_status UNICODE_OFF
18 # define init_unicode() ((void)0)
19
20 #else
21
22 size_t bb_mbstrlen(const char *string) FAST_FUNC;
23
24 # if ENABLE_LOCALE_SUPPORT
25
26 #  include <wchar.h>
27 #  include <wctype.h>
28 extern uint8_t unicode_status;
29 void init_unicode(void) FAST_FUNC;
30
31 # else
32
33 /* Crude "locale support" which knows only C and Unicode locales */
34
35 #  if !ENABLE_FEATURE_CHECK_UNICODE_IN_ENV
36 #   define unicode_status UNICODE_ON
37 #   define init_unicode() ((void)0)
38 #  else
39 extern uint8_t unicode_status;
40 void init_unicode(void) FAST_FUNC;
41 #  endif
42
43 #  undef MB_CUR_MAX
44 #  define MB_CUR_MAX 6
45
46 /* Prevent name collisions */
47 #  define wint_t    bb_wint_t
48 #  define mbstate_t bb_mbstate_t
49 #  define mbstowcs  bb_mbstowcs
50 #  define wcstombs  bb_wcstombs
51 #  define wcrtomb   bb_wcrtomb
52 #  define iswspace  bb_iswspace
53 #  define iswalnum  bb_iswalnum
54 #  define iswpunct  bb_iswpunct
55
56 typedef int32_t wint_t;
57 typedef struct {
58         char bogus;
59 } mbstate_t;
60
61 size_t mbstowcs(wchar_t *dest, const char *src, size_t n) FAST_FUNC;
62 size_t wcstombs(char *dest, const wchar_t *src, size_t n) FAST_FUNC;
63 size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps) FAST_FUNC;
64 int iswspace(wint_t wc) FAST_FUNC;
65 int iswalnum(wint_t wc) FAST_FUNC;
66 int iswpunct(wint_t wc) FAST_FUNC;
67
68 # endif /* !LOCALE_SUPPORT */
69
70 #endif /* FEATURE_ASSUME_UNICODE */
71
72 #endif