Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.
All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.
All imported code from other projects is compatible with this license.
All GPL licensed code from other projects had previously been removed.
Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-02 17:38:16 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011, 2012, 2013, 2014, 2015 Jonas 'Sortie' Termansen.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* wchar.h
|
|
|
|
* Wide character support.
|
|
|
|
*/
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-07-19 16:36:11 -04:00
|
|
|
#ifndef INCLUDE_WCHAR_H
|
|
|
|
#define INCLUDE_WCHAR_H
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-10-13 07:04:27 -04:00
|
|
|
#include <sys/cdefs.h>
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-08-31 19:42:02 -04:00
|
|
|
#include <__/pthread.h>
|
2013-09-23 10:37:33 -04:00
|
|
|
#include <sys/__/types.h>
|
|
|
|
|
2014-02-13 09:46:08 -05:00
|
|
|
#include <__/wchar.h>
|
|
|
|
|
2014-04-03 17:20:46 -04:00
|
|
|
#if !(__USE_SORTIX || __USE_POSIX)
|
|
|
|
/* Intentional namespace pollution due to ISO C stupidity: */
|
|
|
|
#endif
|
|
|
|
/* TODO: This exposes more than just the required va_list. */
|
2013-12-26 19:51:19 -05:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2014-01-18 10:21:46 -05:00
|
|
|
#if defined(__is_sortix_libc)
|
2013-10-01 09:33:53 -04:00
|
|
|
#include <FILE.h>
|
|
|
|
#endif
|
|
|
|
|
2015-05-13 12:11:02 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2014-02-13 09:46:08 -05:00
|
|
|
#ifndef NULL
|
|
|
|
#define __need_NULL
|
|
|
|
#include <stddef.h>
|
|
|
|
#endif
|
|
|
|
|
2013-12-26 19:44:03 -05:00
|
|
|
#ifndef __size_t_defined
|
|
|
|
#define __size_t_defined
|
|
|
|
#define __need_size_t
|
|
|
|
#include <stddef.h>
|
|
|
|
#endif
|
|
|
|
|
2014-02-13 09:46:08 -05:00
|
|
|
#ifndef __wchar_t_defined
|
|
|
|
#define __wchar_t_defined
|
|
|
|
#define __need_wchar_t
|
|
|
|
#include <stddef.h>
|
|
|
|
#endif
|
|
|
|
|
2013-12-26 19:44:03 -05:00
|
|
|
#ifndef __off_t_defined
|
|
|
|
#define __off_t_defined
|
|
|
|
typedef __off_t off_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __FILE_defined
|
|
|
|
#define __FILE_defined
|
2014-04-03 17:20:46 -04:00
|
|
|
#if !(__USE_SORTIX || __USE_POSIX)
|
|
|
|
/* Intentional namespace pollution due to ISO C stupidity: */
|
|
|
|
#endif
|
2015-05-10 17:41:10 -04:00
|
|
|
typedef struct __FILE FILE;
|
2013-12-26 19:44:03 -05:00
|
|
|
#endif
|
|
|
|
|
2014-04-03 17:20:46 -04:00
|
|
|
#if __USE_SORTIX || 200809L <= __USE_POSIX
|
2013-12-26 19:44:03 -05:00
|
|
|
#ifndef __locale_t_defined
|
|
|
|
#define __locale_t_defined
|
|
|
|
/* TODO: figure out what this does and typedef it properly. This is just a
|
|
|
|
temporary assignment. */
|
|
|
|
typedef int __locale_t;
|
|
|
|
typedef __locale_t locale_t;
|
|
|
|
#endif
|
2014-04-03 17:20:46 -04:00
|
|
|
#endif
|
2013-12-26 19:44:03 -05:00
|
|
|
|
|
|
|
#ifndef __wint_t_defined
|
|
|
|
#define __wint_t_defined
|
|
|
|
typedef __wint_t wint_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WCHAR_MIN
|
|
|
|
#define WCHAR_MIN __WCHAR_MIN
|
|
|
|
#endif
|
|
|
|
|
2014-02-13 09:46:08 -05:00
|
|
|
#ifndef WCHAR_MAX
|
|
|
|
#define WCHAR_MAX __WCHAR_MAX
|
2013-12-26 19:44:03 -05:00
|
|
|
#endif
|
|
|
|
|
2014-02-13 09:46:08 -05:00
|
|
|
#ifndef WEOF
|
|
|
|
#define WEOF __WEOF
|
2013-12-26 19:44:03 -05:00
|
|
|
#endif
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
#ifndef __mbstate_t_defined
|
2014-02-13 09:46:08 -05:00
|
|
|
/* Conversion state information. */
|
|
|
|
typedef struct
|
|
|
|
{
|
2014-04-17 11:41:37 -04:00
|
|
|
#if defined(__is_sortix_libc)
|
|
|
|
unsigned short count;
|
|
|
|
unsigned short length;
|
|
|
|
wint_t wch;
|
|
|
|
#else
|
|
|
|
unsigned short __count;
|
|
|
|
unsigned short __length;
|
|
|
|
wint_t __wch;
|
|
|
|
#endif
|
2014-02-13 09:46:08 -05:00
|
|
|
} mbstate_t;
|
|
|
|
#define __mbstate_t_defined 1
|
2011-08-05 08:25:00 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
struct tm;
|
|
|
|
|
2014-05-03 15:34:35 -04:00
|
|
|
wint_t btowc(int);
|
2014-04-03 17:20:46 -04:00
|
|
|
/* TODO: wint_t fgetwc(FILE*); */
|
|
|
|
/* TODO: wchar_t* fgetws(wchar_t* __restrict, int, FILE* __restrict); */
|
|
|
|
/* TODO: wint_t fputwc(wchar_t, FILE*); */
|
|
|
|
/* TODO: int fputws(const wchar_t* __restrict, FILE* __restrict); */
|
|
|
|
/* TODO: wint_t getwc(FILE*); */
|
|
|
|
/* TODO: wint_t getwchar(void); */
|
2013-04-22 04:06:44 -04:00
|
|
|
size_t mbrlen(const char* __restrict, size_t, mbstate_t* __restrict);
|
2013-04-07 11:27:11 -04:00
|
|
|
size_t mbrtowc(wchar_t* __restrict, const char* __restrict, size_t, mbstate_t* __restrict);
|
2014-04-17 11:41:37 -04:00
|
|
|
int mbsinit(const mbstate_t*);
|
2014-04-03 17:20:46 -04:00
|
|
|
size_t mbsrtowcs(wchar_t* __restrict, const char** __restrict, size_t, mbstate_t* __restrict);
|
|
|
|
/* TODO: wint_t putwc(wchar_t, FILE*); */
|
|
|
|
/* TODO: wint_t putwchar(wchar_t); */
|
|
|
|
/* TODO: wint_t ungetwc(wint_t, FILE*); */
|
|
|
|
size_t wcrtomb(char* __restrict, wchar_t, mbstate_t* __restrict);
|
2013-04-07 11:27:11 -04:00
|
|
|
wchar_t* wcscat(wchar_t* __restrict, const wchar_t* __restrict);
|
2013-03-23 19:37:22 -04:00
|
|
|
wchar_t* wcschr(const wchar_t*, wchar_t);
|
2013-03-23 19:41:35 -04:00
|
|
|
int wcscmp(const wchar_t*, const wchar_t*);
|
2013-07-19 16:49:25 -04:00
|
|
|
int wcscoll(const wchar_t*, const wchar_t*);
|
2013-04-07 11:27:11 -04:00
|
|
|
wchar_t* wcscpy(wchar_t* __restrict, const wchar_t* __restrict);
|
2013-03-23 19:54:34 -04:00
|
|
|
size_t wcscspn(const wchar_t*, const wchar_t*);
|
2013-03-23 19:29:31 -04:00
|
|
|
size_t wcslen(const wchar_t*);
|
2013-04-07 11:27:11 -04:00
|
|
|
wchar_t* wcsncat(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
2013-09-15 18:06:27 -04:00
|
|
|
int wcsncmp(const wchar_t*, const wchar_t*, size_t);
|
2013-04-07 11:27:11 -04:00
|
|
|
wchar_t* wcsncpy(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
2013-09-15 18:20:30 -04:00
|
|
|
wchar_t* wcspbrk(const wchar_t*, const wchar_t*);
|
2013-03-23 19:46:44 -04:00
|
|
|
wchar_t* wcsrchr(const wchar_t*, wchar_t);
|
2013-04-07 11:27:11 -04:00
|
|
|
size_t wcsrtombs(char* __restrict, const wchar_t** __restrict, size_t, mbstate_t* __restrict);
|
2013-03-23 19:52:40 -04:00
|
|
|
size_t wcsspn(const wchar_t*, const wchar_t*);
|
2013-09-16 08:41:16 -04:00
|
|
|
wchar_t* wcsstr(const wchar_t* __restrict, const wchar_t* __restrict);
|
2014-05-28 12:26:30 -04:00
|
|
|
double wcstod(const wchar_t* __restrict, wchar_t** __restrict);
|
2013-04-07 11:27:11 -04:00
|
|
|
wchar_t* wcstok(wchar_t* __restrict, const wchar_t* __restrict, wchar_t** __restrict);
|
2013-07-19 16:36:11 -04:00
|
|
|
long wcstol(const wchar_t* __restrict, wchar_t** __restrict, int);
|
|
|
|
unsigned long wcstoul(const wchar_t* __restrict, wchar_t** __restrict, int);
|
2013-09-15 18:14:06 -04:00
|
|
|
size_t wcsxfrm(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
2014-05-03 15:34:35 -04:00
|
|
|
int wctob(wint_t);
|
2013-09-16 09:05:52 -04:00
|
|
|
wchar_t* wmemchr(const wchar_t*, wchar_t, size_t);
|
2013-09-15 18:01:19 -04:00
|
|
|
int wmemcmp(const wchar_t*, const wchar_t*, size_t);
|
2013-09-16 09:12:30 -04:00
|
|
|
wchar_t* wmemcpy(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
2013-09-16 09:37:27 -04:00
|
|
|
wchar_t* wmemmove(wchar_t*, const wchar_t*, size_t);
|
2013-09-16 09:46:08 -04:00
|
|
|
wchar_t* wmemset(wchar_t*, wchar_t, size_t);
|
2012-12-20 08:42:28 -05:00
|
|
|
|
2014-04-03 17:20:46 -04:00
|
|
|
#if __USE_SORTIX || 1995 <= __USE_C || 500 <= __USE_XOPEN
|
|
|
|
/* TODO: int fwide(FILE*, int); */
|
|
|
|
/* TODO: int fwprintf(FILE* __restrict, const wchar_t* __restrict, ...); */
|
|
|
|
/* TODO: int fwscanf(FILE* __restrict, const wchar_t* __restrict, ...); */
|
|
|
|
/* TODO: int swprintf(wchar_t* __restrict, size_t, const wchar_t* __restrict, ...); */
|
|
|
|
/* TODO: int swscanf(const wchar_t* __restrict, const wchar_t* __restrict, ...); */
|
|
|
|
/* TODO: int vfwprintf(FILE* __restrict, const wchar_t* __restrict, va_list); */
|
|
|
|
/* TODO: int vswprintf(wchar_t* __restrict, size_t, const wchar_t* __restrict, va_list); */
|
|
|
|
/* TODO: int vwprintf(const wchar_t* __restrict, va_list); */
|
|
|
|
/* TODO: int wprintf(const wchar_t* __restrict, ...); */
|
|
|
|
/* TODO: int wscanf(const wchar_t* __restrict, ...); */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Functions from C99. */
|
|
|
|
#if __USE_SORTIX || 1999 <= __USE_C
|
|
|
|
/* TODO: int vfwscanf(FILE* __restrict, const wchar_t* __restrict, va_list); */
|
|
|
|
/* TODO: int vswscanf(const wchar_t* __restrict, const wchar_t* __restrict, va_list); */
|
2014-05-28 12:26:30 -04:00
|
|
|
float wcstof(const wchar_t* __restrict, wchar_t** __restrict);
|
|
|
|
long double wcstold(const wchar_t* __restrict, wchar_t** __restrict);
|
2014-04-03 17:20:46 -04:00
|
|
|
/* TODO: int vwscanf(const wchar_t* __restrict, va_list); */
|
2014-05-28 13:51:30 -04:00
|
|
|
size_t wcsftime(wchar_t* __restrict, size_t, const wchar_t* __restrict, const struct tm* __restrict);
|
2014-04-03 17:20:46 -04:00
|
|
|
long long wcstoll(const wchar_t* __restrict, wchar_t** __restrict, int);
|
|
|
|
unsigned long long wcstoull(const wchar_t* __restrict, wchar_t** __restrict, int);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Functions from X/Open. */
|
|
|
|
#if __USE_SORTIX || __USE_XOPEN
|
|
|
|
int wcswidth(const wchar_t*, size_t);
|
|
|
|
int wcwidth(wchar_t);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Functions from POSIX 2008. */
|
|
|
|
#if __USE_SORTIX || 200809L <= __USE_POSIX
|
2014-04-17 11:41:37 -04:00
|
|
|
size_t mbsnrtowcs(wchar_t* __restrict, const char** __restrict, size_t, size_t, mbstate_t* __restrict);
|
2014-04-03 17:20:46 -04:00
|
|
|
/* TODO: FILE* open_wmemstream(wchar_t**, size_t*); */
|
2014-05-28 14:08:57 -04:00
|
|
|
wchar_t* wcpcpy(wchar_t* __restrict, const wchar_t* __restrict);
|
2014-05-28 14:13:36 -04:00
|
|
|
wchar_t* wcpncpy(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
2014-05-28 14:49:27 -04:00
|
|
|
int wcscasecmp(const wchar_t*, const wchar_t*);
|
2014-04-03 17:20:46 -04:00
|
|
|
/* TODO: int wcscasecmp_l(const wchar_t*, const wchar_t*, locale_t); */
|
|
|
|
/* TODO: int wcscoll_l(const wchar_t*, const wchar_t*, locale_t); */
|
2014-05-28 14:53:57 -04:00
|
|
|
wchar_t* wcsdup(const wchar_t*);
|
2014-05-28 14:56:53 -04:00
|
|
|
int wcsncasecmp(const wchar_t*, const wchar_t *, size_t);
|
2014-04-03 17:20:46 -04:00
|
|
|
/* TODO: int wcsncasecmp_l(const wchar_t*, const wchar_t *, size_t, locale_t); */
|
2014-05-28 15:00:37 -04:00
|
|
|
size_t wcsnlen(const wchar_t*, size_t);
|
2014-04-17 11:41:37 -04:00
|
|
|
size_t wcsnrtombs(char* __restrict, const wchar_t** __restrict, size_t, size_t, mbstate_t* __restrict);
|
2014-04-03 17:20:46 -04:00
|
|
|
/* TODO: size_t wcsxfrm_l(wchar_t* __restrict, const wchar_t* __restrict, size_t, locale_t); */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Functions copied from elsewhere. */
|
|
|
|
#if __USE_SORTIX
|
|
|
|
/* TODO: getwc_unlocked */
|
|
|
|
/* TODO: getwchar_unlocked */
|
|
|
|
/* TODO: fgetwc_unlocked */
|
|
|
|
/* TODO: fputwc_unlocked */
|
|
|
|
/* TODO: putwc_unlocked */
|
|
|
|
/* TODO: putwchar_unlocked */
|
|
|
|
/* TODO: fgetws_unlocked */
|
|
|
|
/* TODO: fputws_unlocked */
|
|
|
|
wchar_t* wcschrnul(const wchar_t*, wchar_t);
|
|
|
|
/* TODO: wcsftime_l */
|
2014-05-28 16:17:13 -04:00
|
|
|
size_t wcslcat(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
|
|
|
size_t wcslcpy(wchar_t* __restrict, const wchar_t* __restrict, size_t);
|
2014-04-03 17:20:46 -04:00
|
|
|
/* TODO: wchar_t* wmempcpy(wchar_t* __restrict, const wchar_t* __restrict, size_t); */
|
|
|
|
/* TODO: wcstod_l? */
|
|
|
|
/* TODO: wcstof_l? */
|
|
|
|
/* TODO: wcstof_ld? */
|
|
|
|
/* TODO: wcstol_l? */
|
|
|
|
/* TODO: wcstoll_l? */
|
|
|
|
/* TODO: wcstoul_l? */
|
|
|
|
/* TODO: wcstoull_l */
|
2011-08-05 08:25:00 -04:00
|
|
|
#endif
|
|
|
|
|
2015-05-13 12:11:02 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
#endif
|