1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *  * Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 *  * Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in
12 *    the documentation and/or other materials provided with the
13 *    distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28#ifndef _WCHAR_H_
29#define _WCHAR_H_
30
31#include <sys/cdefs.h>
32#include <stdio.h>
33
34#include <stdarg.h>
35#include <stddef.h>
36#include <time.h>
37
38#include <machine/wchar_limits.h>
39
40__BEGIN_DECLS
41
42typedef __WINT_TYPE__  wint_t;
43typedef struct {
44  uint8_t __seq[4];
45#ifdef __LP64__
46  char __reserved[4];
47#endif
48} mbstate_t;
49
50enum {
51    WC_TYPE_INVALID = 0,
52    WC_TYPE_ALNUM,
53    WC_TYPE_ALPHA,
54    WC_TYPE_BLANK,
55    WC_TYPE_CNTRL,
56    WC_TYPE_DIGIT,
57    WC_TYPE_GRAPH,
58    WC_TYPE_LOWER,
59    WC_TYPE_PRINT,
60    WC_TYPE_PUNCT,
61    WC_TYPE_SPACE,
62    WC_TYPE_UPPER,
63    WC_TYPE_XDIGIT,
64    WC_TYPE_MAX
65};
66
67typedef long wctype_t;
68
69#define  WEOF        ((wint_t)(-1))
70
71extern wint_t            btowc(int);
72extern int               fwprintf(FILE *, const wchar_t *, ...);
73extern int               fwscanf(FILE *, const wchar_t *, ...);
74extern int               iswalnum(wint_t);
75extern int               iswalpha(wint_t);
76extern int               iswblank(wint_t);
77extern int               iswcntrl(wint_t);
78extern int               iswdigit(wint_t);
79extern int               iswgraph(wint_t);
80extern int               iswlower(wint_t);
81extern int               iswprint(wint_t);
82extern int               iswpunct(wint_t);
83extern int               iswspace(wint_t);
84extern int               iswupper(wint_t);
85extern int               iswxdigit(wint_t);
86extern int               iswctype(wint_t, wctype_t);
87extern wint_t            fgetwc(FILE *);
88extern wchar_t          *fgetws(wchar_t *, int, FILE *);
89extern wint_t            fputwc(wchar_t, FILE *);
90extern int               fputws(const wchar_t *, FILE *);
91extern int               fwide(FILE *, int);
92extern wint_t            getwc(FILE *);
93extern wint_t            getwchar(void);
94extern int               mbsinit(const mbstate_t *);
95extern size_t            mbrlen(const char *, size_t, mbstate_t *);
96extern size_t            mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
97extern size_t mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*);
98extern size_t mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*);
99extern size_t            mbstowcs(wchar_t *, const char *, size_t);
100extern wint_t            putwc(wchar_t, FILE *);
101extern wint_t            putwchar(wchar_t);
102extern int               swprintf(wchar_t *, size_t, const wchar_t *, ...);
103extern int               swscanf(const wchar_t *, const wchar_t *, ...);
104extern wint_t            towlower(wint_t);
105extern wint_t            towupper(wint_t);
106extern wint_t            ungetwc(wint_t, FILE *);
107extern int vfwprintf(FILE*, const wchar_t*, va_list);
108extern int vfwscanf(FILE*, const wchar_t*, va_list);
109extern int vswprintf(wchar_t*, size_t, const wchar_t*, va_list);
110extern int vswscanf(const wchar_t*, const wchar_t*, va_list);
111extern int vwprintf(const wchar_t*, va_list);
112extern int vwscanf(const wchar_t*, va_list);
113extern size_t            wcrtomb(char *, wchar_t, mbstate_t *);
114extern int               wcscasecmp(const wchar_t *, const wchar_t *);
115extern wchar_t          *wcscat(wchar_t *, const wchar_t *);
116extern wchar_t          *wcschr(const wchar_t *, wchar_t);
117extern int               wcscmp(const wchar_t *, const wchar_t *);
118extern int               wcscoll(const wchar_t *, const wchar_t *);
119extern wchar_t          *wcscpy(wchar_t *, const wchar_t *);
120extern size_t            wcscspn(const wchar_t *, const wchar_t *);
121extern size_t            wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *) __LIBC_ABI_PUBLIC__;
122extern size_t            wcslen(const wchar_t *);
123extern int               wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
124extern wchar_t          *wcsncat(wchar_t *, const wchar_t *, size_t);
125extern int               wcsncmp(const wchar_t *, const wchar_t *, size_t);
126extern wchar_t          *wcsncpy(wchar_t *, const wchar_t *, size_t);
127extern size_t wcsnrtombs(char*, const wchar_t**, size_t, size_t, mbstate_t*);
128extern wchar_t          *wcspbrk(const wchar_t *, const wchar_t *);
129extern wchar_t          *wcsrchr(const wchar_t *, wchar_t);
130extern size_t wcsrtombs(char*, const wchar_t**, size_t, mbstate_t*);
131extern size_t            wcsspn(const wchar_t *, const wchar_t *);
132extern wchar_t          *wcsstr(const wchar_t *, const wchar_t *);
133extern double wcstod(const wchar_t*, wchar_t**) __NDK_FPABI__;
134extern float wcstof(const wchar_t*, wchar_t**) __NDK_FPABI__;
135extern wchar_t* wcstok(wchar_t*, const wchar_t*, wchar_t**);
136extern long wcstol(const wchar_t*, wchar_t**, int);
137extern long long wcstoll(const wchar_t*, wchar_t**, int);
138extern long double wcstold(const wchar_t*, wchar_t**) __NDK_FPABI__;
139extern unsigned long wcstoul(const wchar_t*, wchar_t**, int);
140extern unsigned long long wcstoull(const wchar_t*, wchar_t**, int);
141extern int               wcswidth(const wchar_t *, size_t);
142extern size_t            wcsxfrm(wchar_t *, const wchar_t *, size_t);
143extern int               wctob(wint_t);
144extern wctype_t          wctype(const char *);
145extern int               wcwidth(wchar_t);
146extern wchar_t          *wmemchr(const wchar_t *, wchar_t, size_t);
147extern int               wmemcmp(const wchar_t *, const wchar_t *, size_t);
148extern wchar_t          *wmemcpy(wchar_t *, const wchar_t *, size_t);
149extern wchar_t          *wmemmove(wchar_t *, const wchar_t *, size_t);
150extern wchar_t          *wmemset(wchar_t *, wchar_t, size_t);
151extern int               wprintf(const wchar_t *, ...);
152extern int               wscanf(const wchar_t *, ...);
153
154extern long long          wcstoll_l(const wchar_t *, wchar_t **, int, locale_t);
155extern unsigned long long wcstoull_l(const wchar_t *, wchar_t **, int, locale_t);
156extern long double        wcstold_l(const wchar_t *, wchar_t **, locale_t ) __NDK_FPABI__;
157
158extern int    wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
159extern size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t);
160
161extern size_t wcslcat(wchar_t*, const wchar_t*, size_t);
162extern size_t wcslcpy(wchar_t*, const wchar_t*, size_t);
163
164typedef void *wctrans_t;
165extern wint_t towctrans(wint_t, wctrans_t);
166extern wctrans_t wctrans(const char*);
167
168#if __POSIX_VISIBLE >= 200809
169wchar_t* wcsdup(const wchar_t*);
170size_t wcsnlen(const wchar_t*, size_t);
171#endif
172
173__END_DECLS
174
175#endif /* _WCHAR_H_ */
176