1 /* 2 * Copyright 2008-2009 Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _WCHAR_H 6 #define _WCHAR_H 7 8 9 #include <stddef.h> 10 #include <stdio.h> 11 12 13 /* stddef.h is not supposed to define wint_t, but gcc 2.95.3's one does. 14 * In all other cases we will do that. */ 15 #ifndef _WINT_T 16 #define _WINT_T 17 18 #ifndef __WINT_TYPE__ 19 #define __WINT_TYPE__ unsigned int 20 #endif 21 22 typedef __WINT_TYPE__ wint_t; 23 24 #endif /* _WINT_T */ 25 26 typedef int wctype_t; 27 28 typedef struct { 29 int __count; 30 wint_t __value; 31 } mbstate_t; 32 33 34 #define WEOF ((wint_t)(-1)) 35 36 #define WCHAR_MIN 0x00000000UL 37 #define WCHAR_MAX 0x7FFFFFFFUL 38 39 /* 40 * Haiku is always using UTF32 in wchars, other encodings can be handled 41 * by converting to/from wchar by means of mbsrtowcs() or wcsrtombs(). 42 * TODO: define __STDC_ISO_10646__ accordingly in our compilers. 43 */ 44 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 extern wint_t btowc(int); 51 52 extern wint_t fgetwc(FILE *); 53 extern wchar_t *fgetws(wchar_t *, int, FILE *); 54 extern wint_t fputwc(wchar_t, FILE *); 55 extern int fputws(const wchar_t *, FILE *); 56 extern int fwide(FILE *, int); 57 extern int fwprintf(FILE *, const wchar_t *, ...); 58 extern int fwscanf(FILE *, const wchar_t *, ...); 59 extern wint_t getwc(FILE *); 60 extern wint_t getwchar(void); 61 62 extern int iswalnum(wint_t); 63 extern int iswalpha(wint_t); 64 extern int iswcntrl(wint_t); 65 extern int iswctype(wint_t, wctype_t); 66 extern int iswdigit(wint_t); 67 extern int iswgraph(wint_t); 68 extern int iswlower(wint_t); 69 extern int iswprint(wint_t); 70 extern int iswpunct(wint_t); 71 extern int iswspace(wint_t); 72 extern int iswupper(wint_t); 73 extern int iswxdigit(wint_t); 74 75 extern size_t mbrlen(const char *s, size_t n, mbstate_t *ps); 76 extern size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps); 77 extern int mbsinit(const mbstate_t *); 78 extern size_t mbsrtowcs(wchar_t *dst, const char **src, size_t len, 79 mbstate_t *ps); 80 81 extern wint_t putwc(wchar_t, FILE *); 82 extern wint_t putwchar(wchar_t); 83 84 extern int swprintf(wchar_t *, size_t, const wchar_t *, ...); 85 extern int swscanf(const wchar_t *, const wchar_t *, ...); 86 87 extern wint_t towlower(wint_t); 88 extern wint_t towupper(wint_t); 89 extern wint_t ungetwc(wint_t, FILE *); 90 91 extern int vfwprintf(FILE *, const wchar_t *, va_list); 92 extern int vfwscanf(FILE *, const wchar_t *, va_list); 93 extern int vswprintf(wchar_t *, size_t, const wchar_t *, va_list); 94 extern int vswscanf(const wchar_t *, const wchar_t *, va_list); 95 extern int vwprintf(const wchar_t *, va_list); 96 extern int vwscanf(const wchar_t *, va_list); 97 98 extern size_t wcrtomb(char *, wchar_t, mbstate_t *); 99 extern wchar_t *wcscat(wchar_t *, const wchar_t *); 100 extern wchar_t *wcschr(const wchar_t *, wchar_t); 101 extern int wcscmp(const wchar_t *ws1, const wchar_t *ws2); 102 extern int wcscoll(const wchar_t *ws1, const wchar_t *ws2); 103 extern wchar_t *wcscpy(wchar_t *, const wchar_t *); 104 extern size_t wcscspn(const wchar_t *, const wchar_t *); 105 extern wchar_t *wcsdup(const wchar_t *); 106 extern size_t wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *); 107 extern size_t wcslen(const wchar_t *); 108 extern wchar_t *wcsncat(wchar_t *, const wchar_t *, size_t); 109 extern int wcsncmp(const wchar_t *, const wchar_t *, size_t); 110 extern wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t); 111 extern wchar_t *wcspbrk(const wchar_t *, const wchar_t *); 112 extern wchar_t *wcsrchr(const wchar_t *, wchar_t); 113 extern size_t wcsrtombs(char *dst, const wchar_t **src, size_t len, 114 mbstate_t *ps); 115 extern size_t wcsspn(const wchar_t *, const wchar_t *); 116 extern wchar_t *wcsstr(const wchar_t *, const wchar_t *); 117 extern double wcstod(const wchar_t *, wchar_t **); 118 extern float wcstof(const wchar_t *, wchar_t **); 119 extern wchar_t *wcstok(wchar_t *, const wchar_t *, wchar_t **); 120 extern long wcstol(const wchar_t *, wchar_t **, int); 121 extern long double wcstold(const wchar_t *, wchar_t **); 122 extern long long wcstoll(const wchar_t *, wchar_t **, int); 123 extern unsigned long wcstoul(const wchar_t *, wchar_t **, int); 124 extern unsigned long long wcstoull(const wchar_t *, wchar_t **, int); 125 extern wchar_t *wcswcs(const wchar_t *, const wchar_t *); 126 extern int wcswidth(const wchar_t *, size_t); 127 extern size_t wcsxfrm(wchar_t *, const wchar_t *, size_t); 128 extern int wctob(wint_t); 129 extern wctype_t wctype(const char *); 130 extern int wcwidth(wchar_t); 131 extern wchar_t *wmemchr(const wchar_t *, wchar_t, size_t); 132 extern int wmemcmp(const wchar_t *, const wchar_t *, size_t); 133 extern wchar_t *wmemcpy(wchar_t *, const wchar_t *, size_t); 134 extern wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t); 135 extern wchar_t *wmemset(wchar_t *, wchar_t, size_t); 136 extern int wprintf(const wchar_t *, ...); 137 extern int wscanf(const wchar_t *, ...); 138 139 #ifdef __cplusplus 140 } 141 #endif 142 143 #endif /* _WCHAR_H */ 144