1 1.46 nia /* $NetBSD: wchar.h,v 1.46 2024/11/01 16:36:58 nia Exp $ */ 2 1.2 itojun 3 1.2 itojun /*- 4 1.2 itojun * Copyright (c)1999 Citrus Project, 5 1.2 itojun * All rights reserved. 6 1.2 itojun * 7 1.2 itojun * Redistribution and use in source and binary forms, with or without 8 1.2 itojun * modification, are permitted provided that the following conditions 9 1.2 itojun * are met: 10 1.2 itojun * 1. Redistributions of source code must retain the above copyright 11 1.2 itojun * notice, this list of conditions and the following disclaimer. 12 1.2 itojun * 2. Redistributions in binary form must reproduce the above copyright 13 1.2 itojun * notice, this list of conditions and the following disclaimer in the 14 1.2 itojun * documentation and/or other materials provided with the distribution. 15 1.2 itojun * 16 1.2 itojun * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 1.2 itojun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 1.2 itojun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 1.2 itojun * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 1.2 itojun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 1.2 itojun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 1.2 itojun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 1.2 itojun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 1.2 itojun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 1.2 itojun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 1.2 itojun * SUCH DAMAGE. 27 1.2 itojun */ 28 1.1 kleink 29 1.1 kleink /*- 30 1.1 kleink * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. 31 1.1 kleink * All rights reserved. 32 1.1 kleink * 33 1.1 kleink * This code is derived from software contributed to The NetBSD Foundation 34 1.1 kleink * by Julian Coleman. 35 1.1 kleink * 36 1.1 kleink * Redistribution and use in source and binary forms, with or without 37 1.1 kleink * modification, are permitted provided that the following conditions 38 1.1 kleink * are met: 39 1.1 kleink * 1. Redistributions of source code must retain the above copyright 40 1.1 kleink * notice, this list of conditions and the following disclaimer. 41 1.1 kleink * 2. Redistributions in binary form must reproduce the above copyright 42 1.1 kleink * notice, this list of conditions and the following disclaimer in the 43 1.1 kleink * documentation and/or other materials provided with the distribution. 44 1.1 kleink * 45 1.1 kleink * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 46 1.1 kleink * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 47 1.1 kleink * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 48 1.1 kleink * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 49 1.1 kleink * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 50 1.1 kleink * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 51 1.1 kleink * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 52 1.1 kleink * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 53 1.1 kleink * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 54 1.1 kleink * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 55 1.1 kleink * POSSIBILITY OF SUCH DAMAGE. 56 1.1 kleink */ 57 1.1 kleink 58 1.1 kleink #ifndef _WCHAR_H_ 59 1.1 kleink #define _WCHAR_H_ 60 1.1 kleink 61 1.2 itojun #include <sys/cdefs.h> 62 1.18 bjh21 #include <sys/featuretest.h> 63 1.20 kleink #include <machine/wchar_limits.h> 64 1.29 tnozaki #include <sys/ansi.h> 65 1.3 itojun #include <sys/null.h> 66 1.1 kleink 67 1.11 yamt #include <stdio.h> /* for FILE* */ 68 1.11 yamt 69 1.28 christos #if defined(_BSD_WCHAR_T_) && !defined(__cplusplus) 70 1.1 kleink typedef _BSD_WCHAR_T_ wchar_t; 71 1.1 kleink #undef _BSD_WCHAR_T_ 72 1.1 kleink #endif 73 1.1 kleink 74 1.5 itojun #ifdef _BSD_MBSTATE_T_ 75 1.5 itojun typedef _BSD_MBSTATE_T_ mbstate_t; 76 1.5 itojun #undef _BSD_MBSTATE_T_ 77 1.5 itojun #endif 78 1.5 itojun 79 1.1 kleink #ifdef _BSD_WINT_T_ 80 1.1 kleink typedef _BSD_WINT_T_ wint_t; 81 1.1 kleink #undef _BSD_WINT_T_ 82 1.1 kleink #endif 83 1.1 kleink 84 1.1 kleink #ifdef _BSD_SIZE_T_ 85 1.1 kleink typedef _BSD_SIZE_T_ size_t; 86 1.1 kleink #undef _BSD_SIZE_T_ 87 1.1 kleink #endif 88 1.2 itojun 89 1.30 joerg #if defined(_POSIX_C_SOURCE) 90 1.30 joerg #ifndef __VA_LIST_DECLARED 91 1.30 joerg typedef __va_list va_list; 92 1.30 joerg #define __VA_LIST_DECLARED 93 1.30 joerg #endif 94 1.30 joerg #endif 95 1.30 joerg 96 1.22 christos struct tm; 97 1.22 christos 98 1.2 itojun __BEGIN_DECLS 99 1.21 perry wint_t btowc(int); 100 1.21 perry size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict); 101 1.21 perry size_t mbrtowc(wchar_t * __restrict, const char * __restrict, size_t, 102 1.21 perry mbstate_t * __restrict); 103 1.21 perry int mbsinit(const mbstate_t *); 104 1.21 perry size_t mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, 105 1.21 perry mbstate_t * __restrict); 106 1.21 perry size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict); 107 1.21 perry wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict); 108 1.21 perry wchar_t *wcschr(const wchar_t *, wchar_t); 109 1.21 perry int wcscmp(const wchar_t *, const wchar_t *); 110 1.21 perry int wcscoll(const wchar_t *, const wchar_t *); 111 1.21 perry wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict); 112 1.21 perry size_t wcscspn(const wchar_t *, const wchar_t *); 113 1.22 christos size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict, 114 1.22 christos const struct tm * __restrict); 115 1.21 perry size_t wcslen(const wchar_t *); 116 1.21 perry wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict, size_t); 117 1.21 perry int wcsncmp(const wchar_t *, const wchar_t *, size_t); 118 1.21 perry wchar_t *wcsncpy(wchar_t * __restrict , const wchar_t * __restrict, size_t); 119 1.42 kamil size_t wcsnlen(const wchar_t *, size_t); 120 1.21 perry wchar_t *wcspbrk(const wchar_t *, const wchar_t *); 121 1.21 perry wchar_t *wcsrchr(const wchar_t *, wchar_t); 122 1.21 perry size_t wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t, 123 1.21 perry mbstate_t * __restrict); 124 1.21 perry size_t wcsspn(const wchar_t *, const wchar_t *); 125 1.21 perry wchar_t *wcsstr(const wchar_t *, const wchar_t *); 126 1.21 perry wchar_t *wcstok(wchar_t * __restrict, const wchar_t * __restrict, 127 1.21 perry wchar_t ** __restrict); 128 1.21 perry size_t wcsxfrm(wchar_t *, const wchar_t *, size_t); 129 1.21 perry wchar_t *wcswcs(const wchar_t *, const wchar_t *); 130 1.21 perry wchar_t *wmemchr(const wchar_t *, wchar_t, size_t); 131 1.21 perry int wmemcmp(const wchar_t *, const wchar_t *, size_t); 132 1.21 perry wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t); 133 1.45 christos wchar_t *wmempcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t); 134 1.21 perry wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t); 135 1.21 perry wchar_t *wmemset(wchar_t *, wchar_t, size_t); 136 1.21 perry 137 1.46 nia /* 138 1.46 nia * IEEE Std 1003.1-2024 (POSIX.1-2024) 139 1.46 nia */ 140 1.46 nia #if (_POSIX_C_SOURCE - 0) >= 202405L || (_XOPEN_SOURCE - 0 >= 800) || \ 141 1.46 nia defined(_NETBSD_SOURCE) 142 1.21 perry size_t wcslcat(wchar_t *, const wchar_t *, size_t); 143 1.21 perry size_t wcslcpy(wchar_t *, const wchar_t *, size_t); 144 1.43 maya #endif 145 1.43 maya 146 1.43 maya #if defined(_NETBSD_SOURCE) || \ 147 1.43 maya (_POSIX_C_SOURCE - 0 >= 200112L) || (_XOPEN_SOURCE - 0) >= 600 148 1.21 perry int wcswidth(const wchar_t *, size_t); 149 1.21 perry int wcwidth(wchar_t); 150 1.43 maya #endif 151 1.21 perry 152 1.43 maya int wctob(wint_t); 153 1.21 perry unsigned long int wcstoul(const wchar_t * __restrict, 154 1.21 perry wchar_t ** __restrict, int); 155 1.21 perry long int wcstol(const wchar_t * __restrict, 156 1.21 perry wchar_t ** __restrict, int); 157 1.21 perry double wcstod(const wchar_t * __restrict, wchar_t ** __restrict); 158 1.17 tshiozak 159 1.44 joerg #if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ 160 1.44 joerg (__cplusplus - 0) >= 201103L || defined(_NETBSD_SOURCE) || \ 161 1.44 joerg (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 162 1.25 tnozaki float wcstof(const wchar_t * __restrict, wchar_t ** __restrict); 163 1.25 tnozaki long double wcstold(const wchar_t * __restrict, wchar_t ** __restrict); 164 1.25 tnozaki 165 1.17 tshiozak /* LONGLONG */ 166 1.21 perry long long int wcstoll(const wchar_t * __restrict, 167 1.21 perry wchar_t ** __restrict, int); 168 1.17 tshiozak /* LONGLONG */ 169 1.21 perry unsigned long long int wcstoull(const wchar_t * __restrict, 170 1.21 perry wchar_t ** __restrict, int); 171 1.17 tshiozak #endif 172 1.11 yamt 173 1.41 christos #if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ 174 1.41 christos defined(_NETBSD_SOURCE) 175 1.41 christos FILE *open_wmemstream(wchar_t **, size_t *); 176 1.41 christos #endif 177 1.41 christos 178 1.21 perry wint_t ungetwc(wint_t, FILE *); 179 1.21 perry wint_t fgetwc(FILE *); 180 1.21 perry wchar_t *fgetws(wchar_t * __restrict, int, FILE * __restrict); 181 1.21 perry wint_t getwc(FILE *); 182 1.21 perry wint_t getwchar(void); 183 1.21 perry wint_t fputwc(wchar_t, FILE *); 184 1.21 perry int fputws(const wchar_t * __restrict, FILE * __restrict); 185 1.21 perry wint_t putwc(wchar_t, FILE *); 186 1.21 perry wint_t putwchar(wchar_t); 187 1.11 yamt 188 1.21 perry int fwide(FILE *, int); 189 1.23 christos 190 1.23 christos wchar_t *fgetwln(FILE * __restrict, size_t * __restrict); 191 1.23 christos int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...); 192 1.23 christos int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...); 193 1.23 christos int swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict, ...); 194 1.23 christos int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...); 195 1.30 joerg int vfwprintf(FILE * __restrict, const wchar_t * __restrict, __va_list); 196 1.23 christos int vswprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict, 197 1.30 joerg __va_list); 198 1.30 joerg int vwprintf(const wchar_t * __restrict, __va_list); 199 1.23 christos int wprintf(const wchar_t * __restrict, ...); 200 1.23 christos int wscanf(const wchar_t * __restrict, ...); 201 1.23 christos #if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) > 199901L || \ 202 1.44 joerg (__cplusplus - 0) >= 201103L || defined(_NETBSD_SOURCE) || \ 203 1.44 joerg (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 204 1.30 joerg int vfwscanf(FILE * __restrict, const wchar_t * __restrict, __va_list); 205 1.23 christos int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict, 206 1.30 joerg __va_list); 207 1.30 joerg int vwscanf(const wchar_t * __restrict, __va_list); 208 1.23 christos #endif 209 1.24 christos #if defined(_NETBSD_SOURCE) 210 1.24 christos struct tinfo; 211 1.24 christos int t_putws(struct tinfo *, const wchar_t *, int, void (*)(wchar_t, void *), 212 1.24 christos void *); 213 1.26 christos wchar_t *wcsdup (const wchar_t *); 214 1.26 christos int wcsncasecmp (const wchar_t *, const wchar_t *, size_t); 215 1.26 christos int wcscasecmp(const wchar_t *, const wchar_t *); 216 1.24 christos #endif 217 1.2 itojun __END_DECLS 218 1.1 kleink 219 1.21 perry #ifndef WEOF 220 1.21 perry #define WEOF ((wint_t)-1) 221 1.21 perry #endif 222 1.21 perry 223 1.21 perry #define getwc(f) fgetwc(f) 224 1.21 perry #define getwchar() getwc(stdin) 225 1.21 perry #define putwc(wc, f) fputwc((wc), (f)) 226 1.21 perry #define putwchar(wc) putwc((wc), stdout) 227 1.21 perry 228 1.31 joerg #if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) 229 1.31 joerg # ifndef __LOCALE_T_DECLARED 230 1.31 joerg typedef struct _locale *locale_t; 231 1.31 joerg # define __LOCALE_T_DECLARED 232 1.31 joerg # endif 233 1.37 joerg __BEGIN_DECLS 234 1.38 joerg size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, 235 1.38 joerg size_t, mbstate_t * __restrict); 236 1.38 joerg size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t, 237 1.38 joerg size_t, mbstate_t * __restrict); 238 1.38 joerg 239 1.34 joerg int wcscoll_l(const wchar_t *, const wchar_t *, locale_t); 240 1.34 joerg size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t); 241 1.34 joerg int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t); 242 1.34 joerg int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t); 243 1.34 joerg 244 1.39 joerg size_t wcsftime_l(wchar_t * __restrict, size_t, const wchar_t * __restrict, 245 1.39 joerg const struct tm * __restrict, locale_t); 246 1.39 joerg 247 1.33 joerg float wcstof_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t); 248 1.33 joerg double wcstod_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t); 249 1.33 joerg long double wcstold_l(const wchar_t * __restrict, wchar_t ** __restrict, 250 1.33 joerg locale_t); 251 1.32 joerg long int wcstol_l(const wchar_t * __restrict, wchar_t ** __restrict, int, 252 1.32 joerg locale_t); 253 1.32 joerg unsigned long int wcstoul_l(const wchar_t * __restrict, 254 1.32 joerg wchar_t ** __restrict, int, locale_t); 255 1.32 joerg /* LONGLONG */ 256 1.32 joerg long long int wcstoll_l(const wchar_t * __restrict, wchar_t ** __restrict, int, 257 1.32 joerg locale_t); 258 1.32 joerg /* LONGLONG */ 259 1.32 joerg unsigned long long int wcstoull_l(const wchar_t * __restrict, 260 1.32 joerg wchar_t ** __restrict, int, locale_t); 261 1.31 joerg int wcwidth_l(wchar_t, locale_t); 262 1.31 joerg int wcswidth_l(const wchar_t *, size_t, locale_t); 263 1.37 joerg __END_DECLS 264 1.34 joerg #endif /* _POSIX_C_SOURCE || _NETBSD_SOURCE */ 265 1.34 joerg 266 1.34 joerg #if defined(_NETBSD_SOURCE) 267 1.37 joerg __BEGIN_DECLS 268 1.34 joerg wint_t btowc_l(int, locale_t); 269 1.34 joerg size_t mbrlen_l(const char * __restrict, size_t, mbstate_t * __restrict, 270 1.34 joerg locale_t); 271 1.34 joerg size_t mbrtowc_l(wchar_t * __restrict, const char * __restrict, size_t, 272 1.34 joerg mbstate_t * __restrict, locale_t); 273 1.34 joerg int mbsinit_l(const mbstate_t *, locale_t); 274 1.34 joerg size_t mbsrtowcs_l(wchar_t * __restrict, const char ** __restrict, size_t, 275 1.34 joerg mbstate_t * __restrict, locale_t); 276 1.38 joerg size_t mbsnrtowcs_l(wchar_t * __restrict, const char ** __restrict, size_t, 277 1.38 joerg size_t, mbstate_t * __restrict, locale_t); 278 1.34 joerg size_t wcrtomb_l(char * __restrict, wchar_t, mbstate_t * __restrict, locale_t); 279 1.34 joerg size_t wcsrtombs_l(char * __restrict, const wchar_t ** __restrict, size_t, 280 1.34 joerg mbstate_t * __restrict, locale_t); 281 1.38 joerg size_t wcsnrtombs_l(char * __restrict, const wchar_t ** __restrict, size_t, 282 1.38 joerg size_t, mbstate_t * __restrict, locale_t); 283 1.34 joerg int wctob_l(wint_t, locale_t); 284 1.35 joerg 285 1.35 joerg int fwprintf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, ...); 286 1.35 joerg int swprintf_l(wchar_t * __restrict, size_t n, locale_t, 287 1.35 joerg const wchar_t * __restrict, ...); 288 1.35 joerg int vfwprintf_l(FILE * __restrict, locale_t, 289 1.35 joerg const wchar_t * __restrict, __va_list); 290 1.35 joerg int vswprintf_l(wchar_t * __restrict, size_t, locale_t, 291 1.35 joerg const wchar_t * __restrict, __va_list); 292 1.35 joerg int vwprintf_l(locale_t, const wchar_t * __restrict, __va_list); 293 1.35 joerg int wprintf_l(locale_t, const wchar_t * __restrict, ...); 294 1.36 joerg 295 1.36 joerg int fwscanf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, ...); 296 1.36 joerg int swscanf_l(const wchar_t * __restrict, locale_t, const wchar_t * 297 1.36 joerg __restrict, ...); 298 1.36 joerg int wscanf_l(locale_t, const wchar_t * __restrict, ...); 299 1.36 joerg int vfwscanf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, 300 1.36 joerg __va_list); 301 1.36 joerg int vswscanf_l(const wchar_t * __restrict, locale_t, const wchar_t * __restrict, 302 1.36 joerg __va_list); 303 1.36 joerg int vwscanf_l(locale_t, const wchar_t * __restrict, __va_list); 304 1.37 joerg __END_DECLS 305 1.34 joerg #endif /* _NETBSD_SOURCE */ 306 1.31 joerg 307 1.1 kleink #endif /* !_WCHAR_H_ */ 308