1*5a08728eSmatthew /* $OpenBSD: wchar.h,v 1.23 2012/06/06 16:58:02 matthew Exp $ */ 2bc92a556Sespie /* $NetBSD: wchar.h,v 1.16 2003/03/07 07:11:35 tshiozak Exp $ */ 3bc92a556Sespie 4bc92a556Sespie /*- 5bc92a556Sespie * Copyright (c)1999 Citrus Project, 6bc92a556Sespie * All rights reserved. 7bc92a556Sespie * 8bc92a556Sespie * Redistribution and use in source and binary forms, with or without 9bc92a556Sespie * modification, are permitted provided that the following conditions 10bc92a556Sespie * are met: 11bc92a556Sespie * 1. Redistributions of source code must retain the above copyright 12bc92a556Sespie * notice, this list of conditions and the following disclaimer. 13bc92a556Sespie * 2. Redistributions in binary form must reproduce the above copyright 14bc92a556Sespie * notice, this list of conditions and the following disclaimer in the 15bc92a556Sespie * documentation and/or other materials provided with the distribution. 16bc92a556Sespie * 17bc92a556Sespie * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18bc92a556Sespie * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19bc92a556Sespie * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20bc92a556Sespie * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21bc92a556Sespie * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22bc92a556Sespie * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23bc92a556Sespie * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24bc92a556Sespie * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25bc92a556Sespie * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26bc92a556Sespie * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27bc92a556Sespie * SUCH DAMAGE. 28bc92a556Sespie */ 29bc92a556Sespie 30bc92a556Sespie /*- 31bc92a556Sespie * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. 32bc92a556Sespie * All rights reserved. 33bc92a556Sespie * 34bc92a556Sespie * This code is derived from software contributed to The NetBSD Foundation 35bc92a556Sespie * by Julian Coleman. 36bc92a556Sespie * 37bc92a556Sespie * Redistribution and use in source and binary forms, with or without 38bc92a556Sespie * modification, are permitted provided that the following conditions 39bc92a556Sespie * are met: 40bc92a556Sespie * 1. Redistributions of source code must retain the above copyright 41bc92a556Sespie * notice, this list of conditions and the following disclaimer. 42bc92a556Sespie * 2. Redistributions in binary form must reproduce the above copyright 43bc92a556Sespie * notice, this list of conditions and the following disclaimer in the 44bc92a556Sespie * documentation and/or other materials provided with the distribution. 45bc92a556Sespie * 46bc92a556Sespie * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 47bc92a556Sespie * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 48bc92a556Sespie * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 49bc92a556Sespie * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 50bc92a556Sespie * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 51bc92a556Sespie * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 52bc92a556Sespie * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 53bc92a556Sespie * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 54bc92a556Sespie * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 55bc92a556Sespie * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 56bc92a556Sespie * POSSIBILITY OF SUCH DAMAGE. 57bc92a556Sespie */ 58bc92a556Sespie 59bc92a556Sespie #ifndef _WCHAR_H_ 60bc92a556Sespie #define _WCHAR_H_ 61bc92a556Sespie 62bc92a556Sespie #include <sys/cdefs.h> 63c916d948Smillert #include <sys/_types.h> 64bc92a556Sespie 65bc92a556Sespie #ifndef NULL 66bc92a556Sespie #ifdef __GNUG__ 67bc92a556Sespie #define NULL __null 68c4ff7beeSjsg #elif defined(__cplusplus) 69c4ff7beeSjsg #define NULL 0L 70bc92a556Sespie #else 710c2a5da7Smiod #define NULL ((void *)0) 72bc92a556Sespie #endif 73bc92a556Sespie #endif 74bc92a556Sespie 75bc92a556Sespie #include <stdio.h> /* for FILE* */ 76bc92a556Sespie 77c916d948Smillert #if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus) 78c916d948Smillert #define _WCHAR_T_DEFINED_ 79c916d948Smillert typedef __wchar_t wchar_t; 80bc92a556Sespie #endif 81bc92a556Sespie 82c916d948Smillert #ifndef _MBSTATE_T_DEFINED_ 83c916d948Smillert #define _MBSTATE_T_DEFINED_ 84c916d948Smillert typedef __mbstate_t mbstate_t; 85561d433dSespie #endif 86561d433dSespie 87c916d948Smillert #ifndef _WINT_T_DEFINED_ 88c916d948Smillert #define _WINT_T_DEFINED_ 89c916d948Smillert typedef __wint_t wint_t; 90bc92a556Sespie #endif 91bc92a556Sespie 92c916d948Smillert #ifndef _SIZE_T_DEFINED_ 93c916d948Smillert #define _SIZE_T_DEFINED_ 94c916d948Smillert typedef __size_t size_t; 95bc92a556Sespie #endif 96bc92a556Sespie 97bc92a556Sespie #ifndef WEOF 98bc92a556Sespie #define WEOF ((wint_t)-1) 99bc92a556Sespie #endif 100bc92a556Sespie 101ff74d4c2Skettenis #ifndef WCHAR_MIN 102ff74d4c2Skettenis #define WCHAR_MIN (-0x7fffffff - 1) 103ff74d4c2Skettenis #endif 104ff74d4c2Skettenis #ifndef WCHAR_MAX 105ff74d4c2Skettenis #define WCHAR_MAX 0x7fffffff 106ff74d4c2Skettenis #endif 107ff74d4c2Skettenis 108bc92a556Sespie __BEGIN_DECLS 109561d433dSespie wint_t btowc(int); 110561d433dSespie size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict); 111561d433dSespie size_t mbrtowc(wchar_t * __restrict, const char * __restrict, size_t, 112561d433dSespie mbstate_t * __restrict); 113561d433dSespie int mbsinit(const mbstate_t *); 114561d433dSespie size_t mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, 115561d433dSespie mbstate_t * __restrict); 116561d433dSespie size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict); 117bc92a556Sespie wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict); 118bc92a556Sespie wchar_t *wcschr(const wchar_t *, wchar_t); 119bc92a556Sespie int wcscmp(const wchar_t *, const wchar_t *); 120bc92a556Sespie int wcscoll(const wchar_t *, const wchar_t *); 121bc92a556Sespie wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict); 122bc92a556Sespie size_t wcscspn(const wchar_t *, const wchar_t *); 123bc92a556Sespie size_t wcslen(const wchar_t *); 124bc92a556Sespie wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict, 125bc92a556Sespie size_t); 126bc92a556Sespie int wcsncmp(const wchar_t *, const wchar_t *, size_t); 127bc92a556Sespie wchar_t *wcsncpy(wchar_t * __restrict , const wchar_t * __restrict, 128bc92a556Sespie size_t); 129bc92a556Sespie wchar_t *wcspbrk(const wchar_t *, const wchar_t *); 130bc92a556Sespie wchar_t *wcsrchr(const wchar_t *, wchar_t); 131561d433dSespie size_t wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t, 132561d433dSespie mbstate_t * __restrict); 133bc92a556Sespie size_t wcsspn(const wchar_t *, const wchar_t *); 134bc92a556Sespie wchar_t *wcsstr(const wchar_t *, const wchar_t *); 135bc92a556Sespie wchar_t *wcstok(wchar_t * __restrict, const wchar_t * __restrict, 136bc92a556Sespie wchar_t ** __restrict); 13738311d31Sespie size_t wcsxfrm(wchar_t *, const wchar_t *, size_t); 138bc92a556Sespie wchar_t *wcswcs(const wchar_t *, const wchar_t *); 139bc92a556Sespie wchar_t *wmemchr(const wchar_t *, wchar_t, size_t); 140bc92a556Sespie int wmemcmp(const wchar_t *, const wchar_t *, size_t); 141bc92a556Sespie wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, 142bc92a556Sespie size_t); 143bc92a556Sespie wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t); 144bc92a556Sespie wchar_t *wmemset(wchar_t *, wchar_t, size_t); 145bc92a556Sespie 146bc92a556Sespie size_t wcslcat(wchar_t *, const wchar_t *, size_t); 147bc92a556Sespie size_t wcslcpy(wchar_t *, const wchar_t *, size_t); 14838311d31Sespie int wcswidth(const wchar_t *, size_t); 149561d433dSespie int wctob(wint_t); 15038311d31Sespie int wcwidth(wchar_t); 15138311d31Sespie 15238311d31Sespie double wcstod(const wchar_t * __restrict, wchar_t ** __restrict); 15338311d31Sespie long int wcstol(const wchar_t * __restrict, wchar_t ** __restrict, int base); 15438311d31Sespie unsigned long int wcstoul(const wchar_t * __restrict, wchar_t ** __restrict, 15538311d31Sespie int base); 15638311d31Sespie 157e4bf39f1Smillert #if __POSIX_VISIBLE >= 200809 1582dcf140dSnicm wchar_t *wcsdup(const wchar_t *); 15942569c7dSespie int wcscasecmp(const wchar_t *, const wchar_t *); 16042569c7dSespie int wcsncasecmp(const wchar_t *, const wchar_t *, size_t); 161*5a08728eSmatthew 162*5a08728eSmatthew size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, 163*5a08728eSmatthew size_t, mbstate_t * __restrict); 164*5a08728eSmatthew size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t, 165*5a08728eSmatthew size_t, mbstate_t * __restrict); 16642569c7dSespie #endif 16742569c7dSespie 168416b788cSkettenis #if __ISO_C_VISIBLE >= 1999 169416b788cSkettenis float wcstof(const wchar_t * __restrict, wchar_t ** __restrict); 170416b788cSkettenis long double wcstold(const wchar_t * __restrict, wchar_t ** __restrict); 1710b5b2ca2Sstsp size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t *__restrict, 1720b5b2ca2Sstsp const struct tm *__restrict); 173416b788cSkettenis #endif 174416b788cSkettenis 175ad6d987cSmillert #if (defined(__GNUC__) && __GNUC__ >= 2 && !defined(__STRICT_ANSI__)) || \ 176ad6d987cSmillert __ISO_C_VISIBLE >= 1999 17738311d31Sespie /* LONGLONG */ 17838311d31Sespie long long int wcstoll(const wchar_t * __restrict, 17938311d31Sespie wchar_t ** __restrict, int base); 18038311d31Sespie /* LONGLONG */ 18138311d31Sespie unsigned long long int wcstoull(const wchar_t * __restrict, 18238311d31Sespie wchar_t ** __restrict, int base); 18338311d31Sespie #endif 184c2fb3212Sespie 185c2fb3212Sespie wint_t ungetwc(wint_t, FILE *); 186c2fb3212Sespie wint_t fgetwc(FILE *); 187c2fb3212Sespie wchar_t *fgetws(wchar_t * __restrict, int, FILE * __restrict); 188c2fb3212Sespie wint_t getwc(FILE *); 189c2fb3212Sespie wint_t getwchar(void); 190c2fb3212Sespie wint_t fputwc(wchar_t, FILE *); 191c2fb3212Sespie int fputws(const wchar_t * __restrict, FILE * __restrict); 192c2fb3212Sespie wint_t putwc(wchar_t, FILE *); 193c2fb3212Sespie wint_t putwchar(wchar_t); 194c2fb3212Sespie 195c2fb3212Sespie int fwide(FILE *, int); 196c2fb3212Sespie 19725963022Sstsp int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...); 19825963022Sstsp int swprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict, ...); 19925963022Sstsp int vfwprintf(FILE * __restrict, const wchar_t * __restrict, __va_list); 20025963022Sstsp int vswprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict, 20125963022Sstsp __va_list); 20225963022Sstsp int vwprintf(const wchar_t * __restrict, __va_list); 20325963022Sstsp int wprintf(const wchar_t * __restrict, ...); 20425963022Sstsp 2052d31a56bSstsp int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...); 2062d31a56bSstsp int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...); 2072d31a56bSstsp int vfwscanf(FILE * __restrict, const wchar_t * __restrict, __va_list); 2082d31a56bSstsp int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict, __va_list); 2092d31a56bSstsp int vwscanf(const wchar_t * __restrict, __va_list); 2102d31a56bSstsp int wscanf(const wchar_t * __restrict, ...); 2112d31a56bSstsp 212c2fb3212Sespie #define getwc(f) fgetwc(f) 213c2fb3212Sespie #define getwchar() getwc(stdin) 214c2fb3212Sespie #define putwc(wc, f) fputwc((wc), (f)) 215c2fb3212Sespie #define putwchar(wc) putwc((wc), stdout) 216bc92a556Sespie __END_DECLS 217bc92a556Sespie 218bc92a556Sespie #endif /* !_WCHAR_H_ */ 219