ReactOS
0.4.16-dev-329-g9223134
wchar.h
Go to the documentation of this file.
1
/* @(#)wchar.h 1.21 11/07/19 Copyright 2007-2011 J. Schilling */
2
/*
3
* Abstraction from wchar.h
4
*
5
* Copyright (c) 2007-2011 J. Schilling
6
*/
7
/*
8
* The contents of this file are subject to the terms of the
9
* Common Development and Distribution License, Version 1.0 only
10
* (the "License"). You may not use this file except in compliance
11
* with the License.
12
*
13
* See the file CDDL.Schily.txt in this distribution for details.
14
*
15
* When distributing Covered Code, include this CDDL HEADER in each
16
* file and include the License file CDDL.Schily.txt from this distribution.
17
*/
18
19
#ifndef _SCHILY_WCHAR_H
20
#define _SCHILY_WCHAR_H
21
22
#ifndef _SCHILY_MCONFIG_H
23
#include <
schily/mconfig.h
>
24
#endif
25
26
#ifndef _SCHILY_STDLIB_H
27
#include <
schily/stdlib.h
>
/* for MB_CUR_MAX, mbtowc()/wctomb() */
28
#endif
29
#ifndef _SCHILY_TYPES_H
30
#include <
schily/types.h
>
31
#endif
32
#ifdef HAVE_STDDEF_H
33
#ifndef _INCL_STDDEF_H
34
#include <stddef.h>
/* Needed for e.g. size_t (POSIX) */
35
#define _INCL_STDDEF_H
36
#endif
37
#endif
38
#ifndef _SCHILY_STDIO_H
39
#include <
schily/stdio.h
>
/* Needed for e.g. FILE (POSIX) */
40
#endif
41
#ifndef _SCHILY_VARARGS_H
42
#include <
schily/varargs.h
>
/* Needed for e.g. va_list (POSIX) */
43
#endif
44
45
46
#if !defined(HAVE_MBTOWC) || !defined(HAVE_WCTOMB)
47
#if defined(HAVE_MBRTOWC) && defined(HAVE_WCRTOMB)
48
# define mbtowc(wp, cp, len) mbrtowc(wp, cp, len, (mbstate_t *)0)
49
# define wctomb(cp, wc) wcrtomb(cp, wc, (mbstate_t *)0)
50
#else
51
# define NO_WCHAR
52
#endif
53
#endif
54
55
#ifdef HAVE_WCHAR_H
56
57
#ifndef _INCL_WCHAR_H
58
#include <wchar.h>
59
#define _INCL_WCHAR_H
60
#endif
61
62
#ifndef HAVE_MBSINIT
63
#define mbsinit(sp) ((int)((sp) == 0))
64
#endif
65
#ifndef HAVE_MBRTOWC
66
#define mbrtowc(wp, cp, len, sp) mbtowc(wp, cp, len)
67
#endif
68
#ifndef HAVE_WCRTOMB
69
#define wcrtomb(cp, wc, sp) wctomb(cp, wc)
70
#endif
71
72
#ifndef USE_WCHAR
73
#define USE_WCHAR
74
#endif
75
76
#else
/* HAVE_WCHAR_H */
77
78
#undef USE_WCHAR
79
#endif
/* !HAVE_WCHAR_H */
80
81
#if !defined(HAVE_WCTYPE_H) && !defined(HAVE_ISWPRINT)
82
#undef USE_WCHAR
83
#undef USE_WCTYPE
84
#endif
85
86
#ifdef NO_WCTYPE
87
#undef USE_WCHAR
88
#undef USE_WCTYPE
89
#endif
90
91
#ifdef NO_WCHAR
92
#undef USE_WCHAR
93
#undef USE_WCTYPE
94
#endif
95
96
#ifndef USE_WCHAR
97
98
/*
99
* We either don't have wide chars or we don't use them...
100
*/
101
#undef wchar_t
102
#define wchar_t char
103
#undef wint_t
104
#define wint_t int
105
/*
106
* We cannot define wctype_t here because of a bug in Linux (missing xctype_t
107
* definition in wchar.h
108
*/
109
#ifdef __never__
110
#undef wctype_t
111
#define wctype_t int
112
#endif
113
114
#undef WEOF
115
#define WEOF ((wint_t)-1)
116
117
#ifndef _SCHILY_UTYPES_H
118
#include <
schily/utypes.h
>
/* For TYPE_MAXVAL() */
119
#endif
120
121
#undef WCHAR_MAX
122
#define WCHAR_MAX TYPE_MAXVAL(wchar_t)
123
#undef WCHAR_MIN
124
#define WCHAR_MIN TYPE_MINVAL(wchar_t)
125
126
#undef WINT_MAX
127
#define WINT_MAX TYPE_MAXVAL(wint_t)
128
#undef WINT_MIN
129
#define WINT_MIN TYPE_MINVAL(wint_t)
130
131
#undef WCTYPE_MAX
132
#define WCTYPE_MAX TYPE_MAXVAL(wctype_t)
133
#undef WCTYPE_MIN
134
#define WCTYPE_MIN TYPE_MINVAL(wctype_t)
135
136
#undef SIZEOF_WCHAR_T
137
#define SIZEOF_WCHAR_T SIZEOF_CHAR
138
139
#undef MB_CUR_MAX
140
#define MB_CUR_MAX 1
141
#undef MB_LEN_MAX
142
#define MB_LEN_MAX 1
143
144
/*
145
* The mbtowc() for the non-multibyte case could be as simple as
146
*
147
* #define mbtowc(wp, cp, len) (*(wp) = *(cp), 1)
148
*
149
* but Mac OS X forces us to do many mbtowc(NULL, NULL, 0) calls in order
150
* to reset the internal state. On other platforms that do not support
151
* wide chars, NULL may be defined as (void *)0, so we need to check
152
* for "wp" != NULL and to cast "wp" and "cp" to their expected types.
153
*/
154
#undef mbtowc
155
#define mbtowc(wp, cp, len) ((void)((wp) ? \
156
*(wchar_t *)(wp) = *(char *)(cp) : 1), 1)
157
#undef mbrtowc
158
#define mbrtowc(wp, cp, len, sp) ((void)((wp) ? \
159
*(wchar_t *)(wp) = *(char *)(cp) : 1), 1)
160
#undef wctomb
161
#define wctomb(cp, wc) (*(cp) = wc, 1)
162
#undef wcrtomb
163
#define wcrtomb(cp, wc, sp) (*(cp) = wc, 1)
164
165
#undef mbsinit
166
#define mbsinit(sp) ((int)((sp) == 0))
167
168
#undef wcwidth
169
#define wcwidth(wc) (1)
170
171
#else
/* USE_WCHAR */
172
173
#ifndef HAVE_WCWIDTH
174
#undef wcwidth
175
#define wcwidth(wc) (1)
176
#endif
177
178
#endif
/* USE_WCHAR */
179
180
#endif
/* _SCHILY_WCHAR_H */
mconfig.h
types.h
stdio.h
stdlib.h
varargs.h
utypes.h
sdk
tools
mkisofs
schilytools
include
schily
wchar.h
Generated on Sun Dec 8 2024 06:14:26 for ReactOS by
1.9.6