195a4049aSTakuya SHIOZAKI /*- 2eebd9d53SWarner Losh * SPDX-License-Identifier: (BSD-2-Clause) 3e58eb3c4SPedro F. Giffuni * 495a4049aSTakuya SHIOZAKI * Copyright (c)1999 Citrus Project, 595a4049aSTakuya SHIOZAKI * All rights reserved. 695a4049aSTakuya SHIOZAKI * 795a4049aSTakuya SHIOZAKI * Redistribution and use in source and binary forms, with or without 895a4049aSTakuya SHIOZAKI * modification, are permitted provided that the following conditions 995a4049aSTakuya SHIOZAKI * are met: 1095a4049aSTakuya SHIOZAKI * 1. Redistributions of source code must retain the above copyright 1195a4049aSTakuya SHIOZAKI * notice, this list of conditions and the following disclaimer. 1295a4049aSTakuya SHIOZAKI * 2. Redistributions in binary form must reproduce the above copyright 1395a4049aSTakuya SHIOZAKI * notice, this list of conditions and the following disclaimer in the 1495a4049aSTakuya SHIOZAKI * documentation and/or other materials provided with the distribution. 1595a4049aSTakuya SHIOZAKI * 1695a4049aSTakuya SHIOZAKI * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1795a4049aSTakuya SHIOZAKI * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1895a4049aSTakuya SHIOZAKI * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1995a4049aSTakuya SHIOZAKI * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2095a4049aSTakuya SHIOZAKI * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2195a4049aSTakuya SHIOZAKI * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2295a4049aSTakuya SHIOZAKI * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2395a4049aSTakuya SHIOZAKI * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2495a4049aSTakuya SHIOZAKI * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2595a4049aSTakuya SHIOZAKI * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2695a4049aSTakuya SHIOZAKI * SUCH DAMAGE. 2795a4049aSTakuya SHIOZAKI */ 2895a4049aSTakuya SHIOZAKI 2995a4049aSTakuya SHIOZAKI /*- 3095a4049aSTakuya SHIOZAKI * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. 3195a4049aSTakuya SHIOZAKI * All rights reserved. 3295a4049aSTakuya SHIOZAKI * 3395a4049aSTakuya SHIOZAKI * This code is derived from software contributed to The NetBSD Foundation 3495a4049aSTakuya SHIOZAKI * by Julian Coleman. 3595a4049aSTakuya SHIOZAKI * 3695a4049aSTakuya SHIOZAKI * Redistribution and use in source and binary forms, with or without 3795a4049aSTakuya SHIOZAKI * modification, are permitted provided that the following conditions 3895a4049aSTakuya SHIOZAKI * are met: 3995a4049aSTakuya SHIOZAKI * 1. Redistributions of source code must retain the above copyright 4095a4049aSTakuya SHIOZAKI * notice, this list of conditions and the following disclaimer. 4195a4049aSTakuya SHIOZAKI * 2. Redistributions in binary form must reproduce the above copyright 4295a4049aSTakuya SHIOZAKI * notice, this list of conditions and the following disclaimer in the 4395a4049aSTakuya SHIOZAKI * documentation and/or other materials provided with the distribution. 4495a4049aSTakuya SHIOZAKI * 4595a4049aSTakuya SHIOZAKI * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 4695a4049aSTakuya SHIOZAKI * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 4795a4049aSTakuya SHIOZAKI * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 4895a4049aSTakuya SHIOZAKI * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 4995a4049aSTakuya SHIOZAKI * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 5095a4049aSTakuya SHIOZAKI * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 5195a4049aSTakuya SHIOZAKI * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 5295a4049aSTakuya SHIOZAKI * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 5395a4049aSTakuya SHIOZAKI * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 5495a4049aSTakuya SHIOZAKI * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 5595a4049aSTakuya SHIOZAKI * POSSIBILITY OF SUCH DAMAGE. 56115fef56SDavid E. O'Brien * 57115fef56SDavid E. O'Brien * $NetBSD: wchar.h,v 1.8 2000/12/22 05:31:42 itojun Exp $ 5895a4049aSTakuya SHIOZAKI */ 5995a4049aSTakuya SHIOZAKI 6095a4049aSTakuya SHIOZAKI #ifndef _WCHAR_H_ 6195a4049aSTakuya SHIOZAKI #define _WCHAR_H_ 6295a4049aSTakuya SHIOZAKI 6395a4049aSTakuya SHIOZAKI #include <sys/cdefs.h> 6412eb46c8SMarcel Moolenaar #include <sys/_null.h> 65abbd8902SMike Barcroft #include <sys/_types.h> 66287365ffSAlexander Kabaev #include <machine/_limits.h> 67de6c9c9dSTim J. Robbins #include <_ctype.h> 68e74101e4STim J. Robbins 69abbd8902SMike Barcroft #ifndef _MBSTATE_T_DECLARED 70abbd8902SMike Barcroft typedef __mbstate_t mbstate_t; 71abbd8902SMike Barcroft #define _MBSTATE_T_DECLARED 7295a4049aSTakuya SHIOZAKI #endif 7395a4049aSTakuya SHIOZAKI 74abbd8902SMike Barcroft #ifndef _SIZE_T_DECLARED 75abbd8902SMike Barcroft typedef __size_t size_t; 76abbd8902SMike Barcroft #define _SIZE_T_DECLARED 7795a4049aSTakuya SHIOZAKI #endif 7895a4049aSTakuya SHIOZAKI 797e3327beSEd Schouten #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE 807e3327beSEd Schouten #ifndef _VA_LIST_DECLARED 817e3327beSEd Schouten typedef __va_list va_list; 827e3327beSEd Schouten #define _VA_LIST_DECLARED 837e3327beSEd Schouten #endif 847e3327beSEd Schouten #endif 857e3327beSEd Schouten 869a1a7924STim J. Robbins #ifndef __cplusplus 87abbd8902SMike Barcroft #ifndef _WCHAR_T_DECLARED 880a4c54d6STijl Coosemans typedef ___wchar_t wchar_t; 89abbd8902SMike Barcroft #define _WCHAR_T_DECLARED 909a1a7924STim J. Robbins #endif 919a1a7924STim J. Robbins #endif 929a1a7924STim J. Robbins 93abbd8902SMike Barcroft #ifndef _WINT_T_DECLARED 94abbd8902SMike Barcroft typedef __wint_t wint_t; 95abbd8902SMike Barcroft #define _WINT_T_DECLARED 969a1a7924STim J. Robbins #endif 979a1a7924STim J. Robbins 9874dc547eSAndrew Turner #define WCHAR_MIN __WCHAR_MIN 9974dc547eSAndrew Turner #define WCHAR_MAX __WCHAR_MAX 100287365ffSAlexander Kabaev 10195a4049aSTakuya SHIOZAKI #ifndef WEOF 10295a4049aSTakuya SHIOZAKI #define WEOF ((wint_t)-1) 10395a4049aSTakuya SHIOZAKI #endif 10495a4049aSTakuya SHIOZAKI 105c9e7ce2fSDavid Chisnall #ifndef _STDFILE_DECLARED 106c9e7ce2fSDavid Chisnall #define _STDFILE_DECLARED 107c9e7ce2fSDavid Chisnall typedef struct __sFILE FILE; 108c9e7ce2fSDavid Chisnall #endif 10947794211STim J. Robbins struct tm; 1105207d0c8STim J. Robbins 11195a4049aSTakuya SHIOZAKI __BEGIN_DECLS 112*b53d7aa8SKyle Evans size_t wcslen(const wchar_t *) __pure; 113*b53d7aa8SKyle Evans __END_DECLS 114*b53d7aa8SKyle Evans 115*b53d7aa8SKyle Evans #if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 116*b53d7aa8SKyle Evans #include <ssp/wchar.h> 117*b53d7aa8SKyle Evans #endif 118*b53d7aa8SKyle Evans 119*b53d7aa8SKyle Evans __BEGIN_DECLS 120babfb08bSTim J. Robbins wint_t btowc(int); 121c9e7ce2fSDavid Chisnall wint_t fgetwc(FILE *); 122e74101e4STim J. Robbins wchar_t * 123c9e7ce2fSDavid Chisnall fgetws(wchar_t * __restrict, int, FILE * __restrict); 124c9e7ce2fSDavid Chisnall wint_t fputwc(wchar_t, FILE *); 125c9e7ce2fSDavid Chisnall int fputws(const wchar_t * __restrict, FILE * __restrict); 126c9e7ce2fSDavid Chisnall int fwide(FILE *, int); 127c9e7ce2fSDavid Chisnall int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...); 128c9e7ce2fSDavid Chisnall int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...); 129c9e7ce2fSDavid Chisnall wint_t getwc(FILE *); 130e74101e4STim J. Robbins wint_t getwchar(void); 131bb28f3c2SWarner Losh size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict); 132bb28f3c2SWarner Losh size_t mbrtowc(wchar_t * __restrict, const char * __restrict, size_t, 133bb28f3c2SWarner Losh mbstate_t * __restrict); 134bb28f3c2SWarner Losh int mbsinit(const mbstate_t *); 135bb28f3c2SWarner Losh size_t mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, 136bb28f3c2SWarner Losh mbstate_t * __restrict); 137c9e7ce2fSDavid Chisnall wint_t putwc(wchar_t, FILE *); 138e74101e4STim J. Robbins wint_t putwchar(wchar_t); 139c5604d0aSTim J. Robbins int swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict, 140c5604d0aSTim J. Robbins ...); 1411f4ff850STim J. Robbins int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...); 142c9e7ce2fSDavid Chisnall wint_t ungetwc(wint_t, FILE *); 143c9e7ce2fSDavid Chisnall int vfwprintf(FILE * __restrict, const wchar_t * __restrict, 144c5604d0aSTim J. Robbins __va_list); 145c5604d0aSTim J. Robbins int vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict, 146c5604d0aSTim J. Robbins __va_list); 147c5604d0aSTim J. Robbins int vwprintf(const wchar_t * __restrict, __va_list); 148bb28f3c2SWarner Losh size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict); 149bb28f3c2SWarner Losh wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict); 150affcb871STim J. Robbins wchar_t *wcschr(const wchar_t *, wchar_t) __pure; 151affcb871STim J. Robbins int wcscmp(const wchar_t *, const wchar_t *) __pure; 152fd4f1dd9STim J. Robbins int wcscoll(const wchar_t *, const wchar_t *); 153bb28f3c2SWarner Losh wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict); 154affcb871STim J. Robbins size_t wcscspn(const wchar_t *, const wchar_t *) __pure; 15547794211STim J. Robbins size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict, 15647794211STim J. Robbins const struct tm * __restrict); 157bb28f3c2SWarner Losh wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict, 158bb28f3c2SWarner Losh size_t); 159affcb871STim J. Robbins int wcsncmp(const wchar_t *, const wchar_t *, size_t) __pure; 160bb28f3c2SWarner Losh wchar_t *wcsncpy(wchar_t * __restrict , const wchar_t * __restrict, size_t); 161affcb871STim J. Robbins wchar_t *wcspbrk(const wchar_t *, const wchar_t *) __pure; 162affcb871STim J. Robbins wchar_t *wcsrchr(const wchar_t *, wchar_t) __pure; 163bb28f3c2SWarner Losh size_t wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t, 164bb28f3c2SWarner Losh mbstate_t * __restrict); 165affcb871STim J. Robbins size_t wcsspn(const wchar_t *, const wchar_t *) __pure; 166affcb871STim J. Robbins wchar_t *wcsstr(const wchar_t * __restrict, const wchar_t * __restrict) 167affcb871STim J. Robbins __pure; 168fd4f1dd9STim J. Robbins size_t wcsxfrm(wchar_t * __restrict, const wchar_t * __restrict, size_t); 169e9fb7011STim J. Robbins int wctob(wint_t); 17003b716c4STim J. Robbins double wcstod(const wchar_t * __restrict, wchar_t ** __restrict); 1719ad39134STim J. Robbins wchar_t *wcstok(wchar_t * __restrict, const wchar_t * __restrict, 1729ad39134STim J. Robbins wchar_t ** __restrict); 1735fd17624STim J. Robbins long wcstol(const wchar_t * __restrict, wchar_t ** __restrict, int); 1745fd17624STim J. Robbins unsigned long 1755fd17624STim J. Robbins wcstoul(const wchar_t * __restrict, wchar_t ** __restrict, int); 176affcb871STim J. Robbins wchar_t *wmemchr(const wchar_t *, wchar_t, size_t) __pure; 177affcb871STim J. Robbins int wmemcmp(const wchar_t *, const wchar_t *, size_t) __pure; 178babfb08bSTim J. Robbins wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t); 179babfb08bSTim J. Robbins wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t); 180ee37f64cSKonstantin Belousov #if __BSD_VISIBLE 181ee37f64cSKonstantin Belousov wchar_t *wmempcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t); 182ee37f64cSKonstantin Belousov #endif 183babfb08bSTim J. Robbins wchar_t *wmemset(wchar_t *, wchar_t, size_t); 184c5604d0aSTim J. Robbins int wprintf(const wchar_t * __restrict, ...); 1851f4ff850STim J. Robbins int wscanf(const wchar_t * __restrict, ...); 18671f9b420STim J. Robbins 18784bb9aaaSTim J. Robbins #ifndef _STDSTREAM_DECLARED 188c9e7ce2fSDavid Chisnall extern FILE *__stdinp; 189c9e7ce2fSDavid Chisnall extern FILE *__stdoutp; 190c9e7ce2fSDavid Chisnall extern FILE *__stderrp; 19184bb9aaaSTim J. Robbins #define _STDSTREAM_DECLARED 19284bb9aaaSTim J. Robbins #endif 19384bb9aaaSTim J. Robbins 19484bb9aaaSTim J. Robbins #define getwc(fp) fgetwc(fp) 19584bb9aaaSTim J. Robbins #define getwchar() fgetwc(__stdinp) 196f05d1a46STim J. Robbins #define putwc(wc, fp) fputwc(wc, fp) 19784bb9aaaSTim J. Robbins #define putwchar(wc) fputwc(wc, __stdoutp) 19884bb9aaaSTim J. Robbins 19911de8366STim J. Robbins #if __ISO_C_VISIBLE >= 1999 200c9e7ce2fSDavid Chisnall int vfwscanf(FILE * __restrict, const wchar_t * __restrict, 20111de8366STim J. Robbins __va_list); 20211de8366STim J. Robbins int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict, 20311de8366STim J. Robbins __va_list); 20411de8366STim J. Robbins int vwscanf(const wchar_t * __restrict, __va_list); 205542bd65fSTim J. Robbins float wcstof(const wchar_t * __restrict, wchar_t ** __restrict); 206542bd65fSTim J. Robbins long double 207542bd65fSTim J. Robbins wcstold(const wchar_t * __restrict, wchar_t ** __restrict); 20811de8366STim J. Robbins #ifdef __LONG_LONG_SUPPORTED 20911de8366STim J. Robbins /* LONGLONG */ 21011de8366STim J. Robbins long long 21111de8366STim J. Robbins wcstoll(const wchar_t * __restrict, wchar_t ** __restrict, int); 21211de8366STim J. Robbins /* LONGLONG */ 21311de8366STim J. Robbins unsigned long long 21411de8366STim J. Robbins wcstoull(const wchar_t * __restrict, wchar_t ** __restrict, int); 21511de8366STim J. Robbins #endif 21611de8366STim J. Robbins #endif /* __ISO_C_VISIBLE >= 1999 */ 21711de8366STim J. Robbins 21871f9b420STim J. Robbins #if __XSI_VISIBLE 21971f9b420STim J. Robbins int wcswidth(const wchar_t *, size_t); 22071f9b420STim J. Robbins int wcwidth(wchar_t); 221de6c9c9dSTim J. Robbins #define wcwidth(_c) __wcwidth(_c) 22271f9b420STim J. Robbins #endif 2237ca9f09dSTim J. Robbins 224448f5f73SJilles Tjoelker #if __POSIX_VISIBLE >= 200809 2251949a347STim J. Robbins size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, 2261949a347STim J. Robbins size_t, mbstate_t * __restrict); 2279240031aSJohn Baldwin FILE *open_wmemstream(wchar_t **, size_t *); 2285eb167d3SDavid Schultz wchar_t *wcpcpy(wchar_t * __restrict, const wchar_t * __restrict); 2295eb167d3SDavid Schultz wchar_t *wcpncpy(wchar_t * __restrict, const wchar_t * __restrict, size_t); 230544048ecSDavid Schultz wchar_t *wcsdup(const wchar_t *) __malloc_like; 23169099ba2SDavid Schultz int wcscasecmp(const wchar_t *, const wchar_t *); 23269099ba2SDavid Schultz int wcsncasecmp(const wchar_t *, const wchar_t *, size_t n); 23369099ba2SDavid Schultz size_t wcsnlen(const wchar_t *, size_t) __pure; 2341949a347STim J. Robbins size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t, 2351949a347STim J. Robbins size_t, mbstate_t * __restrict); 23669099ba2SDavid Schultz #endif 23769099ba2SDavid Schultz 23869099ba2SDavid Schultz #if __BSD_VISIBLE 239c9e7ce2fSDavid Chisnall wchar_t *fgetwln(FILE * __restrict, size_t * __restrict); 2407ca9f09dSTim J. Robbins size_t wcslcat(wchar_t *, const wchar_t *, size_t); 2417ca9f09dSTim J. Robbins size_t wcslcpy(wchar_t *, const wchar_t *, size_t); 2427ca9f09dSTim J. Robbins #endif 243a8ed63bbSDavid Chisnall 2443ac9d659SDavid Chisnall #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) 245a8ed63bbSDavid Chisnall #include <xlocale/_wchar.h> 246a8ed63bbSDavid Chisnall #endif 24795a4049aSTakuya SHIOZAKI __END_DECLS 24895a4049aSTakuya SHIOZAKI 24995a4049aSTakuya SHIOZAKI #endif /* !_WCHAR_H_ */ 250