1 /**
2  * @file wctype.h
3  * Copyright 2012, 2013 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 /* Created by Mumit Khan <khan@xraylith.wisc.edu> */
25 #ifndef _WCTYPE_H
26 #define _WCTYPE_H
27 #pragma GCC system_header
28 #include <_mingw.h>
29 
30 #define	__need_wchar_t
31 #define	__need_wint_t
32 
33 #ifndef RC_INVOKED
34 #include <stddef.h>
35 #endif	/* Not RC_INVOKED */
36 
37 /*
38  * The following flags are used to tell iswctype and _isctype what character
39  * types you are looking for.
40  */
41 #define	_UPPER		0x0001
42 #define	_LOWER		0x0002
43 #define	_DIGIT		0x0004
44 #define	_SPACE		0x0008
45 #define	_PUNCT		0x0010
46 #define	_CONTROL	0x0020
47 #define	_BLANK		0x0040
48 #define	_HEX		0x0080
49 #define	_LEADBYTE	0x8000
50 
51 #define	_ALPHA		0x0103
52 
53 #ifndef RC_INVOKED
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 #ifndef WEOF
60 #define	WEOF	(wchar_t)(0xFFFF)
61 #endif
62 
63 #ifndef _WCTYPE_T_DEFINED
64 typedef wchar_t wctype_t;
65 #define _WCTYPE_T_DEFINED
66 #endif
67 
68 /* Wide character equivalents - also in ctype.h */
69 _CRTIMP int __cdecl __MINGW_NOTHROW	iswalnum(wint_t);
70 _CRTIMP int __cdecl __MINGW_NOTHROW	iswalpha(wint_t);
71 _CRTIMP int __cdecl __MINGW_NOTHROW	iswascii(wint_t);
72 _CRTIMP int __cdecl __MINGW_NOTHROW	iswcntrl(wint_t);
73 _CRTIMP int __cdecl __MINGW_NOTHROW	iswctype(wint_t, wctype_t);
74 _CRTIMP int __cdecl __MINGW_NOTHROW	is_wctype(wint_t, wctype_t);	/* Obsolete! */
75 _CRTIMP int __cdecl __MINGW_NOTHROW	iswdigit(wint_t);
76 _CRTIMP int __cdecl __MINGW_NOTHROW	iswgraph(wint_t);
77 _CRTIMP int __cdecl __MINGW_NOTHROW	iswlower(wint_t);
78 _CRTIMP int __cdecl __MINGW_NOTHROW	iswprint(wint_t);
79 _CRTIMP int __cdecl __MINGW_NOTHROW	iswpunct(wint_t);
80 _CRTIMP int __cdecl __MINGW_NOTHROW	iswspace(wint_t);
81 _CRTIMP int __cdecl __MINGW_NOTHROW	iswupper(wint_t);
82 _CRTIMP int __cdecl __MINGW_NOTHROW	iswxdigit(wint_t);
83 
84 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
85      || !defined __STRICT_ANSI__ || defined __cplusplus
86 int __cdecl __MINGW_NOTHROW iswblank (wint_t);
87 #endif
88 
89 /* Older MS docs uses wchar_t for arg and return type, while newer
90    online MS docs say arg is wint_t and return is int.
91    ISO C uses wint_t for both.  */
92 _CRTIMP wint_t __cdecl __MINGW_NOTHROW	towlower (wint_t);
93 _CRTIMP wint_t __cdecl __MINGW_NOTHROW	towupper (wint_t);
94 
95 _CRTIMP int __cdecl __MINGW_NOTHROW	isleadbyte (int);
96 
97 /* Also in ctype.h */
98 
99   __MINGW_IMPORT unsigned short _ctype[];
100 __MINGW_IMPORT unsigned short* _pctype;
101 
102 
103 #if !(defined (__NO_INLINE__) || defined(__NO_CTYPE_INLINES) \
104       || defined(__WCTYPE_INLINES_DEFINED))
105 #define __WCTYPE_INLINES_DEFINED
iswalnum(wint_t wc)106 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));}
iswalpha(wint_t wc)107 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));}
iswascii(wint_t wc)108 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswascii(wint_t wc) {return ((wc & ~0x7F) ==0);}
iswcntrl(wint_t wc)109 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));}
iswdigit(wint_t wc)110 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));}
iswgraph(wint_t wc)111 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));}
iswlower(wint_t wc)112 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswlower(wint_t wc) {return (iswctype(wc,_LOWER));}
iswprint(wint_t wc)113 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));}
iswpunct(wint_t wc)114 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));}
iswspace(wint_t wc)115 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswspace(wint_t wc) {return (iswctype(wc,_SPACE));}
iswupper(wint_t wc)116 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswupper(wint_t wc) {return (iswctype(wc,_UPPER));}
iswxdigit(wint_t wc)117 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));}
isleadbyte(int c)118 __CRT_INLINE int __cdecl __MINGW_NOTHROW isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);}
119 
120 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
121      || !defined __STRICT_ANSI__ || defined __cplusplus
iswblank(wint_t wc)122 __CRT_INLINE int __cdecl __MINGW_NOTHROW iswblank (wint_t wc)
123   {return (iswctype(wc, _BLANK) || wc == L'\t');}
124 #endif
125 
126 #endif /* !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) */
127 
128 typedef wchar_t wctrans_t;
129 
130 /* These are resolved by libmingwex.a.  Note, that they are also exported
131    by the MS C++ runtime lib (msvcp60.dll).  The msvcp60.dll implementations
132    of wctrans and towctrans are not C99 compliant in that wctrans("tolower")
133    returns 0, while std specifies that a non-zero value should be returned
134    for a valid string descriptor.  If you want the MS behaviour (and you have
135    msvcp60.dll in your path) add -lmsvcp60 to your command line.  */
136 
137 wint_t __cdecl __MINGW_NOTHROW		towctrans(wint_t, wctrans_t);
138 wctrans_t __cdecl __MINGW_NOTHROW	wctrans(const char*);
139 wctype_t __cdecl __MINGW_NOTHROW	wctype(const char*);
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif	/* Not RC_INVOKED */
146 
147 #endif	/* Not _WCTYPE_H */
148