| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 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 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 34 | #include <stdarg.h> | 
| Elliott Hughes | 0cc0d25 | 2012-10-01 15:12:40 -0700 | [diff] [blame] | 35 | #include <stddef.h> | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 36 | #include <time.h> | 
| Elliott Hughes | b20c244 | 2014-11-06 15:04:08 -0800 | [diff] [blame] | 37 | #include <xlocale.h> | 
| Elliott Hughes | 83c07b5 | 2014-04-21 18:09:46 -0700 | [diff] [blame] | 38 |  | 
|  | 39 | #include <machine/wchar_limits.h> | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 40 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 41 | __BEGIN_DECLS | 
|  | 42 |  | 
| Calin Juravle | eab395e | 2014-04-29 15:48:34 +0100 | [diff] [blame] | 43 | typedef __WINT_TYPE__  wint_t; | 
|  | 44 | typedef struct { | 
| Calin Juravle | 15a6310 | 2014-05-08 14:38:35 +0100 | [diff] [blame] | 45 | uint8_t __seq[4]; | 
|  | 46 | #ifdef __LP64__ | 
|  | 47 | char __reserved[4]; | 
| Calin Juravle | eab395e | 2014-04-29 15:48:34 +0100 | [diff] [blame] | 48 | #endif | 
|  | 49 | } mbstate_t; | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 50 |  | 
| Calin Juravle | 0c47247 | 2014-05-13 12:47:27 +0100 | [diff] [blame] | 51 | enum { | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 52 | WC_TYPE_INVALID = 0, | 
|  | 53 | WC_TYPE_ALNUM, | 
|  | 54 | WC_TYPE_ALPHA, | 
|  | 55 | WC_TYPE_BLANK, | 
|  | 56 | WC_TYPE_CNTRL, | 
|  | 57 | WC_TYPE_DIGIT, | 
|  | 58 | WC_TYPE_GRAPH, | 
|  | 59 | WC_TYPE_LOWER, | 
|  | 60 | WC_TYPE_PRINT, | 
|  | 61 | WC_TYPE_PUNCT, | 
|  | 62 | WC_TYPE_SPACE, | 
|  | 63 | WC_TYPE_UPPER, | 
|  | 64 | WC_TYPE_XDIGIT, | 
|  | 65 | WC_TYPE_MAX | 
| Calin Juravle | 0c47247 | 2014-05-13 12:47:27 +0100 | [diff] [blame] | 66 | }; | 
|  | 67 |  | 
| Calin Juravle | b55f263 | 2014-05-13 13:11:27 +0100 | [diff] [blame] | 68 | typedef long wctype_t; | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 69 |  | 
| David 'Digit' Turner | 50ace4f | 2010-06-16 16:36:41 -0700 | [diff] [blame] | 70 | #define  WEOF        ((wint_t)(-1)) | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 71 |  | 
|  | 72 | extern wint_t            btowc(int); | 
|  | 73 | extern int               fwprintf(FILE *, const wchar_t *, ...); | 
|  | 74 | extern int               fwscanf(FILE *, const wchar_t *, ...); | 
|  | 75 | extern int               iswalnum(wint_t); | 
|  | 76 | extern int               iswalpha(wint_t); | 
| Elliott Hughes | 40b0579 | 2014-04-15 12:04:05 -0700 | [diff] [blame] | 77 | extern int               iswblank(wint_t); | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 78 | extern int               iswcntrl(wint_t); | 
|  | 79 | extern int               iswdigit(wint_t); | 
|  | 80 | extern int               iswgraph(wint_t); | 
|  | 81 | extern int               iswlower(wint_t); | 
|  | 82 | extern int               iswprint(wint_t); | 
|  | 83 | extern int               iswpunct(wint_t); | 
|  | 84 | extern int               iswspace(wint_t); | 
|  | 85 | extern int               iswupper(wint_t); | 
|  | 86 | extern int               iswxdigit(wint_t); | 
|  | 87 | extern int               iswctype(wint_t, wctype_t); | 
|  | 88 | extern wint_t            fgetwc(FILE *); | 
|  | 89 | extern wchar_t          *fgetws(wchar_t *, int, FILE *); | 
|  | 90 | extern wint_t            fputwc(wchar_t, FILE *); | 
|  | 91 | extern int               fputws(const wchar_t *, FILE *); | 
|  | 92 | extern int               fwide(FILE *, int); | 
|  | 93 | extern wint_t            getwc(FILE *); | 
|  | 94 | extern wint_t            getwchar(void); | 
|  | 95 | extern int               mbsinit(const mbstate_t *); | 
|  | 96 | extern size_t            mbrlen(const char *, size_t, mbstate_t *); | 
|  | 97 | extern size_t            mbrtowc(wchar_t *, const char *, size_t, mbstate_t *); | 
| Elliott Hughes | 3d7a0d9 | 2014-04-29 14:46:56 -0700 | [diff] [blame] | 98 | extern size_t mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*); | 
|  | 99 | extern size_t mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*); | 
| Dan Bornstein | 03c643b | 2009-11-10 12:15:33 -0800 | [diff] [blame] | 100 | extern size_t            mbstowcs(wchar_t *, const char *, size_t); | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 101 | extern wint_t            putwc(wchar_t, FILE *); | 
|  | 102 | extern wint_t            putwchar(wchar_t); | 
|  | 103 | extern int               swprintf(wchar_t *, size_t, const wchar_t *, ...); | 
|  | 104 | extern int               swscanf(const wchar_t *, const wchar_t *, ...); | 
|  | 105 | extern wint_t            towlower(wint_t); | 
|  | 106 | extern wint_t            towupper(wint_t); | 
|  | 107 | extern wint_t            ungetwc(wint_t, FILE *); | 
| Elliott Hughes | 01ae00f | 2014-04-29 16:28:56 -0700 | [diff] [blame] | 108 | extern int vfwprintf(FILE*, const wchar_t*, va_list); | 
|  | 109 | extern int vfwscanf(FILE*, const wchar_t*, va_list); | 
|  | 110 | extern int vswprintf(wchar_t*, size_t, const wchar_t*, va_list); | 
|  | 111 | extern int vswscanf(const wchar_t*, const wchar_t*, va_list); | 
|  | 112 | extern int vwprintf(const wchar_t*, va_list); | 
|  | 113 | extern int vwscanf(const wchar_t*, va_list); | 
| Christopher Ferris | 5c7d958 | 2014-11-13 15:48:39 -0800 | [diff] [blame] | 114 | extern wchar_t* wcpcpy (wchar_t*, const wchar_t *); | 
|  | 115 | extern wchar_t* wcpncpy (wchar_t*, const wchar_t *, size_t); | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 116 | extern size_t            wcrtomb(char *, wchar_t, mbstate_t *); | 
| tedbo | 16e02c2 | 2010-11-29 13:15:07 -0800 | [diff] [blame] | 117 | extern int               wcscasecmp(const wchar_t *, const wchar_t *); | 
| Elliott Hughes | b20c244 | 2014-11-06 15:04:08 -0800 | [diff] [blame] | 118 | extern int               wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t); | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 119 | extern wchar_t          *wcscat(wchar_t *, const wchar_t *); | 
|  | 120 | extern wchar_t          *wcschr(const wchar_t *, wchar_t); | 
|  | 121 | extern int               wcscmp(const wchar_t *, const wchar_t *); | 
|  | 122 | extern int               wcscoll(const wchar_t *, const wchar_t *); | 
|  | 123 | extern wchar_t          *wcscpy(wchar_t *, const wchar_t *); | 
|  | 124 | extern size_t            wcscspn(const wchar_t *, const wchar_t *); | 
| Elliott Hughes | d10db82 | 2014-06-19 14:49:30 -0700 | [diff] [blame] | 125 | extern size_t            wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *) __LIBC_ABI_PUBLIC__; | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 126 | extern size_t            wcslen(const wchar_t *); | 
| tedbo | 16e02c2 | 2010-11-29 13:15:07 -0800 | [diff] [blame] | 127 | extern int               wcsncasecmp(const wchar_t *, const wchar_t *, size_t); | 
| Elliott Hughes | b20c244 | 2014-11-06 15:04:08 -0800 | [diff] [blame] | 128 | extern int               wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t); | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 129 | extern wchar_t          *wcsncat(wchar_t *, const wchar_t *, size_t); | 
|  | 130 | extern int               wcsncmp(const wchar_t *, const wchar_t *, size_t); | 
|  | 131 | extern wchar_t          *wcsncpy(wchar_t *, const wchar_t *, size_t); | 
| Elliott Hughes | 3d7a0d9 | 2014-04-29 14:46:56 -0700 | [diff] [blame] | 132 | extern size_t wcsnrtombs(char*, const wchar_t**, size_t, size_t, mbstate_t*); | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 133 | extern wchar_t          *wcspbrk(const wchar_t *, const wchar_t *); | 
|  | 134 | extern wchar_t          *wcsrchr(const wchar_t *, wchar_t); | 
| Elliott Hughes | 3d7a0d9 | 2014-04-29 14:46:56 -0700 | [diff] [blame] | 135 | extern size_t wcsrtombs(char*, const wchar_t**, size_t, mbstate_t*); | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 136 | extern size_t            wcsspn(const wchar_t *, const wchar_t *); | 
|  | 137 | extern wchar_t          *wcsstr(const wchar_t *, const wchar_t *); | 
| Elliott Hughes | 3d7a0d9 | 2014-04-29 14:46:56 -0700 | [diff] [blame] | 138 | extern double wcstod(const wchar_t*, wchar_t**); | 
|  | 139 | extern float wcstof(const wchar_t*, wchar_t**); | 
|  | 140 | extern wchar_t* wcstok(wchar_t*, const wchar_t*, wchar_t**); | 
|  | 141 | extern long wcstol(const wchar_t*, wchar_t**, int); | 
|  | 142 | extern long long wcstoll(const wchar_t*, wchar_t**, int); | 
|  | 143 | extern long double wcstold(const wchar_t*, wchar_t**); | 
|  | 144 | extern unsigned long wcstoul(const wchar_t*, wchar_t**, int); | 
|  | 145 | extern unsigned long long wcstoull(const wchar_t*, wchar_t**, int); | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 146 | extern int               wcswidth(const wchar_t *, size_t); | 
|  | 147 | extern size_t            wcsxfrm(wchar_t *, const wchar_t *, size_t); | 
|  | 148 | extern int               wctob(wint_t); | 
|  | 149 | extern wctype_t          wctype(const char *); | 
|  | 150 | extern int               wcwidth(wchar_t); | 
|  | 151 | extern wchar_t          *wmemchr(const wchar_t *, wchar_t, size_t); | 
|  | 152 | extern int               wmemcmp(const wchar_t *, const wchar_t *, size_t); | 
|  | 153 | extern wchar_t          *wmemcpy(wchar_t *, const wchar_t *, size_t); | 
| Elliott Hughes | 3cfb52a | 2015-02-18 21:29:13 -0800 | [diff] [blame] | 154 | #if defined(__USE_GNU) | 
|  | 155 | extern wchar_t          *wmempcpy(wchar_t *, const wchar_t *, size_t); | 
|  | 156 | #endif | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 157 | extern wchar_t          *wmemmove(wchar_t *, const wchar_t *, size_t); | 
|  | 158 | extern wchar_t          *wmemset(wchar_t *, wchar_t, size_t); | 
|  | 159 | extern int               wprintf(const wchar_t *, ...); | 
|  | 160 | extern int               wscanf(const wchar_t *, ...); | 
|  | 161 |  | 
| Dan Albert | 3c5037f | 2014-09-23 15:32:24 -0700 | [diff] [blame] | 162 | extern long long          wcstoll_l(const wchar_t *, wchar_t **, int, locale_t); | 
|  | 163 | extern unsigned long long wcstoull_l(const wchar_t *, wchar_t **, int, locale_t); | 
| Dan Albert | dfb5ce4 | 2014-07-09 22:51:34 +0000 | [diff] [blame] | 164 | extern long double        wcstold_l(const wchar_t *, wchar_t **, locale_t ); | 
|  | 165 |  | 
|  | 166 | extern int    wcscoll_l(const wchar_t *, const wchar_t *, locale_t); | 
|  | 167 | extern size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t); | 
|  | 168 |  | 
| Elliott Hughes | 53e4329 | 2014-02-24 18:00:43 -0800 | [diff] [blame] | 169 | extern size_t wcslcat(wchar_t*, const wchar_t*, size_t); | 
|  | 170 | extern size_t wcslcpy(wchar_t*, const wchar_t*, size_t); | 
|  | 171 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 172 | typedef void *wctrans_t; | 
| Elliott Hughes | 77e944f | 2014-04-04 17:34:51 -0700 | [diff] [blame] | 173 | extern wint_t towctrans(wint_t, wctrans_t); | 
|  | 174 | extern wctrans_t wctrans(const char*); | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 175 |  | 
| Elliott Hughes | 77e944f | 2014-04-04 17:34:51 -0700 | [diff] [blame] | 176 | #if __POSIX_VISIBLE >= 200809 | 
| Elliott Hughes | 6b841db | 2014-08-20 16:10:49 -0700 | [diff] [blame] | 177 | FILE* open_wmemstream(wchar_t**, size_t*); | 
| Elliott Hughes | eb93ebf | 2013-03-01 18:35:56 -0800 | [diff] [blame] | 178 | wchar_t* wcsdup(const wchar_t*); | 
|  | 179 | size_t wcsnlen(const wchar_t*, size_t); | 
|  | 180 | #endif | 
|  | 181 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 182 | __END_DECLS | 
|  | 183 |  | 
|  | 184 | #endif /* _WCHAR_H_ */ |