xref: /haiku/headers/posix/wchar.h (revision fccd8899fcb583bfb73c5c26c9fcd714b963959b)
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 	void* converter;
31 	char charset[64];
32 	unsigned int count;
33 	char data[1024 + 8];	// 1024 bytes for data, 8 for alignment space
34 } mbstate_t;
35 
36 
37 #define WEOF		((wint_t)(-1))
38 
39 #define WCHAR_MIN	0x00000000UL
40 #define WCHAR_MAX	0x7FFFFFFFUL
41 
42 /*
43  * Haiku is always using UTF32 in wchars, other encodings can be handled
44  * by converting to/from wchar by means of mbrtowc() or wcrtomb().
45  */
46 
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 extern wint_t	btowc(int);
53 
54 extern wint_t	fgetwc(FILE *);
55 extern wchar_t	*fgetws(wchar_t *, int, FILE *);
56 extern wint_t	fputwc(wchar_t, FILE *);
57 extern int		fputws(const wchar_t *, FILE *);
58 extern int		fwide(FILE *, int);
59 extern int		fwprintf(FILE *, const wchar_t *, ...);
60 extern int		fwscanf(FILE *, const wchar_t *, ...);
61 extern wint_t	getwc(FILE *);
62 extern wint_t	getwchar(void);
63 
64 extern size_t 	mbrlen(const char *s, size_t n, mbstate_t *ps);
65 extern size_t 	mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
66 extern int		mbsinit(const mbstate_t *);
67 extern size_t	mbsrtowcs(wchar_t *dst, const char **src, size_t len,
68 					mbstate_t *ps);
69 
70 extern wint_t	putwc(wchar_t, FILE *);
71 extern wint_t	putwchar(wchar_t);
72 
73 extern int		swprintf(wchar_t *, size_t, const wchar_t *, ...);
74 extern int		swscanf(const wchar_t *, const wchar_t *, ...);
75 
76 extern wint_t	ungetwc(wint_t, FILE *);
77 
78 extern int		vfwprintf(FILE *, const wchar_t *, va_list);
79 extern int		vfwscanf(FILE *, const wchar_t *, va_list);
80 extern int		vswprintf(wchar_t *, size_t, const wchar_t *, va_list);
81 extern int		vswscanf(const wchar_t *, const wchar_t *, va_list);
82 extern int		vwprintf(const wchar_t *, va_list);
83 extern int		vwscanf(const wchar_t *, va_list);
84 
85 extern size_t   wcrtomb(char *, wchar_t, mbstate_t *);
86 extern wchar_t	*wcscat(wchar_t *, const wchar_t *);
87 extern wchar_t	*wcschr(const wchar_t *, wchar_t);
88 extern int      wcscmp(const wchar_t *ws1, const wchar_t *ws2);
89 extern int      wcscoll(const wchar_t *ws1, const wchar_t *ws2);
90 extern wchar_t	*wcscpy(wchar_t *, const wchar_t *);
91 extern size_t	wcscspn(const wchar_t *, const wchar_t *);
92 extern wchar_t	*wcsdup(const wchar_t *);
93 extern size_t	wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *);
94 extern size_t	wcslen(const wchar_t *);
95 extern wchar_t 	*wcsncat(wchar_t *, const wchar_t *, size_t);
96 extern int		wcsncmp(const wchar_t *, const wchar_t *, size_t);
97 extern wchar_t	*wcsncpy(wchar_t *, const wchar_t *, size_t);
98 extern wchar_t	*wcspbrk(const wchar_t *, const wchar_t *);
99 extern wchar_t	*wcsrchr(const wchar_t *, wchar_t);
100 extern size_t   wcsrtombs(char *dst, const wchar_t **src, size_t len,
101 					mbstate_t *ps);
102 extern size_t	wcsspn(const wchar_t *, const wchar_t *);
103 extern wchar_t	*wcsstr(const wchar_t *, const wchar_t *);
104 extern double	wcstod(const wchar_t *, wchar_t **);
105 extern float	wcstof(const wchar_t *, wchar_t **);
106 extern wchar_t	*wcstok(wchar_t *, const wchar_t *, wchar_t **);
107 extern long		wcstol(const wchar_t *, wchar_t **, int);
108 extern long double			wcstold(const wchar_t *, wchar_t **);
109 extern long long			wcstoll(const wchar_t *, wchar_t **, int);
110 extern unsigned long		wcstoul(const wchar_t *, wchar_t **, int);
111 extern unsigned long long	wcstoull(const wchar_t *, wchar_t **, int);
112 extern wchar_t	*wcswcs(const wchar_t *, const wchar_t *);
113 extern int		wcswidth(const wchar_t *, size_t);
114 extern size_t	wcsxfrm(wchar_t *, const wchar_t *, size_t);
115 extern int		wctob(wint_t);
116 extern int		wcwidth(wchar_t);
117 extern wchar_t	*wmemchr(const wchar_t *, wchar_t, size_t);
118 extern int		wmemcmp(const wchar_t *, const wchar_t *, size_t);
119 extern wchar_t	*wmemcpy(wchar_t *, const wchar_t *, size_t);
120 extern wchar_t	*wmemmove(wchar_t *, const wchar_t *, size_t);
121 extern wchar_t	*wmemset(wchar_t *, wchar_t, size_t);
122 extern int		wprintf(const wchar_t *, ...);
123 extern int		wscanf(const wchar_t *, ...);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif /* _WCHAR_H */
130