blob: 453b6d552a17bf3f59572c4734ae81268ac233a7 [file] [log] [blame]
David 'Digit' Turner70121172010-09-22 18:04:36 +02001/*
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/* wchar_t is required in stdlib.h according to POSIX */
35#define __need___wchar_t
36#include <stddef.h>
37
38#include <stdarg.h>
39#include <time.h>
40#include <malloc.h>
41
42#include <stddef.h>
David 'Digit' Turnerfe8625d2013-07-18 02:13:34 +020043#include <sys/_wchar_limits.h>
David 'Digit' Turner70121172010-09-22 18:04:36 +020044
45/* IMPORTANT: Any code that relies on wide character support is essentially
46 * non-portable and/or broken. the only reason this header exist
47 * is because I'm really a nice guy. However, I'm not nice enough
48 * to provide you with a real implementation. instead wchar_t == char
49 * and all wc functions are stubs to their "normal" equivalent...
50 */
51
52__BEGIN_DECLS
53
Andrew Hsieh7c9e2c62012-12-24 14:14:55 +080054typedef __WINT_TYPE__ wint_t;
David 'Digit' Turner70121172010-09-22 18:04:36 +020055typedef struct { int dummy; } mbstate_t;
56
57typedef enum {
58 WC_TYPE_INVALID = 0,
59 WC_TYPE_ALNUM,
60 WC_TYPE_ALPHA,
61 WC_TYPE_BLANK,
62 WC_TYPE_CNTRL,
63 WC_TYPE_DIGIT,
64 WC_TYPE_GRAPH,
65 WC_TYPE_LOWER,
66 WC_TYPE_PRINT,
67 WC_TYPE_PUNCT,
68 WC_TYPE_SPACE,
69 WC_TYPE_UPPER,
70 WC_TYPE_XDIGIT,
71 WC_TYPE_MAX
72} wctype_t;
73
David 'Digit' Turnerfe8625d2013-07-18 02:13:34 +020074/* WEOF used to be defined as simply -1, which is
David 'Digit' Turnerf85e2432013-07-03 15:54:16 +020075 * invalid (the standard mandates that the expression must have wint_t
David 'Digit' Turnerfe8625d2013-07-18 02:13:34 +020076 * type). Revert to the old broken behaviour is _WCHAR_IS_8BIT is defined.
77 * See http://b.android.com/57267 */
78#ifdef _WCHAR_IS_8BIT
79#define WEOF (-1)
80#else
81#define WEOF ((wint_t)-1)
82#endif
David 'Digit' Turnerf85e2432013-07-03 15:54:16 +020083#ifdef _WCHAR_IS_8BIT
David 'Digit' Turner70121172010-09-22 18:04:36 +020084#define WEOF (-1)
David 'Digit' Turnerf85e2432013-07-03 15:54:16 +020085#else
86#define WEOF ((wint_t)-1)
87#endif
David 'Digit' Turner70121172010-09-22 18:04:36 +020088
89extern wint_t btowc(int);
90extern int fwprintf(FILE *, const wchar_t *, ...);
91extern int fwscanf(FILE *, const wchar_t *, ...);
92extern int iswalnum(wint_t);
93extern int iswalpha(wint_t);
94extern int iswcntrl(wint_t);
95extern int iswdigit(wint_t);
96extern int iswgraph(wint_t);
97extern int iswlower(wint_t);
98extern int iswprint(wint_t);
99extern int iswpunct(wint_t);
100extern int iswspace(wint_t);
101extern int iswupper(wint_t);
102extern int iswxdigit(wint_t);
103extern int iswctype(wint_t, wctype_t);
104extern wint_t fgetwc(FILE *);
105extern wchar_t *fgetws(wchar_t *, int, FILE *);
106extern wint_t fputwc(wchar_t, FILE *);
107extern int fputws(const wchar_t *, FILE *);
108extern int fwide(FILE *, int);
109extern wint_t getwc(FILE *);
110extern wint_t getwchar(void);
111extern int mbsinit(const mbstate_t *);
112extern size_t mbrlen(const char *, size_t, mbstate_t *);
113extern size_t mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
114extern size_t mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *);
115extern size_t mbstowcs(wchar_t *, const char *, size_t);
116extern wint_t putwc(wchar_t, FILE *);
117extern wint_t putwchar(wchar_t);
118extern int swprintf(wchar_t *, size_t, const wchar_t *, ...);
119extern int swscanf(const wchar_t *, const wchar_t *, ...);
120extern wint_t towlower(wint_t);
121extern wint_t towupper(wint_t);
122extern wint_t ungetwc(wint_t, FILE *);
123extern int vfwprintf(FILE *, const wchar_t *, va_list);
124extern int vwprintf(const wchar_t *, va_list);
125extern int vswprintf(wchar_t *, size_t, const wchar_t *, va_list);
126extern size_t wcrtomb(char *, wchar_t, mbstate_t *);
127extern wchar_t *wcscat(wchar_t *, const wchar_t *);
128extern wchar_t *wcschr(const wchar_t *, wchar_t);
129extern int wcscmp(const wchar_t *, const wchar_t *);
130extern int wcscoll(const wchar_t *, const wchar_t *);
131extern wchar_t *wcscpy(wchar_t *, const wchar_t *);
132extern size_t wcscspn(const wchar_t *, const wchar_t *);
133extern size_t wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *);
134extern size_t wcslen(const wchar_t *);
135extern wchar_t *wcsncat(wchar_t *, const wchar_t *, size_t);
136extern int wcsncmp(const wchar_t *, const wchar_t *, size_t);
137extern wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t);
138extern wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
139extern wchar_t *wcsrchr(const wchar_t *, wchar_t);
140extern size_t wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *);
141extern size_t wcsspn(const wchar_t *, const wchar_t *);
142extern wchar_t *wcsstr(const wchar_t *, const wchar_t *);
143extern double wcstod(const wchar_t *, wchar_t **);
144extern wchar_t *wcstok(wchar_t *, const wchar_t *, wchar_t **);
145extern long int wcstol(const wchar_t *, wchar_t **, int);
146extern size_t wcstombs(char *, const wchar_t *, size_t);
147extern unsigned long int wcstoul(const wchar_t *, wchar_t **, int);
148extern wchar_t *wcswcs(const wchar_t *, const wchar_t *);
149extern int wcswidth(const wchar_t *, size_t);
150extern size_t wcsxfrm(wchar_t *, const wchar_t *, size_t);
151extern int wctob(wint_t);
152extern wctype_t wctype(const char *);
153extern int wcwidth(wchar_t);
154extern wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
155extern int wmemcmp(const wchar_t *, const wchar_t *, size_t);
156extern wchar_t *wmemcpy(wchar_t *, const wchar_t *, size_t);
157extern wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
158extern wchar_t *wmemset(wchar_t *, wchar_t, size_t);
159extern int wprintf(const wchar_t *, ...);
160extern int wscanf(const wchar_t *, ...);
161
162/* No really supported. These are just for making libstdc++-v3 happy. */
163typedef void *wctrans_t;
164extern wint_t towctrans(wint_t, wctrans_t);
165extern wctrans_t wctrans (const char *);
166
167__END_DECLS
168
169#endif /* _WCHAR_H_ */