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