1    	/* Copyright (C) 1996-2002,2005,2007-2009,2010 Free Software Foundation, Inc.
2    	   This file is part of the GNU C Library.
3    	
4    	   The GNU C Library is free software; you can redistribute it and/or
5    	   modify it under the terms of the GNU Lesser General Public
6    	   License as published by the Free Software Foundation; either
7    	   version 2.1 of the License, or (at your option) any later version.
8    	
9    	   The GNU C Library is distributed in the hope that it will be useful,
10   	   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   	   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   	   Lesser General Public License for more details.
13   	
14   	   You should have received a copy of the GNU Lesser General Public
15   	   License along with the GNU C Library; if not, write to the Free
16   	   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17   	   02111-1307 USA.  */
18   	
19   	/*
20   	 *	ISO C99 Standard: 7.25
21   	 *	Wide character classification and mapping utilities  <wctype.h>
22   	 */
23   	
24   	#ifndef _WCTYPE_H
25   	
26   	#include <features.h>
27   	#include <bits/types.h>
28   	
29   	#ifndef __need_iswxxx
30   	# define _WCTYPE_H	1
31   	
32   	/* Get wint_t from <wchar.h>.  */
33   	# define __need_wint_t
34   	# include <wchar.h>
35   	
36   	/* Constant expression of type `wint_t' whose value does not correspond
37   	   to any member of the extended character set.  */
38   	# ifndef WEOF
39   	#  define WEOF (0xffffffffu)
40   	# endif
41   	#endif
42   	#undef __need_iswxxx
43   	
44   	
45   	/* The following part is also used in the <wcsmbs.h> header when compiled
46   	   in the Unix98 compatibility mode.  */
47   	#ifndef __iswxxx_defined
48   	# define __iswxxx_defined	1
49   	
50   	__BEGIN_NAMESPACE_C99
51   	/* Scalar type that can hold values which represent locale-specific
52   	   character classifications.  */
53   	typedef unsigned long int wctype_t;
54   	__END_NAMESPACE_C99
55   	
56   	# ifndef _ISwbit
57   	/* The characteristics are stored always in network byte order (big
58   	   endian).  We define the bit value interpretations here dependent on the
59   	   machine's byte order.  */
60   	
61   	#  include <endian.h>
62   	#  if __BYTE_ORDER == __BIG_ENDIAN
63   	#   define _ISwbit(bit)	(1 << (bit))
64   	#  else /* __BYTE_ORDER == __LITTLE_ENDIAN */
65   	#   define _ISwbit(bit)	\
66   		((bit) < 8 ? (int) ((1UL << (bit)) << 24)			      \
67   		 : ((bit) < 16 ? (int) ((1UL << (bit)) << 8)			      \
68   		    : ((bit) < 24 ? (int) ((1UL << (bit)) >> 8)			      \
69   		       : (int) ((1UL << (bit)) >> 24))))
70   	#  endif
71   	
72   	enum
73   	{
74   	  __ISwupper = 0,			/* UPPERCASE.  */
75   	  __ISwlower = 1,			/* lowercase.  */
76   	  __ISwalpha = 2,			/* Alphabetic.  */
77   	  __ISwdigit = 3,			/* Numeric.  */
78   	  __ISwxdigit = 4,			/* Hexadecimal numeric.  */
79   	  __ISwspace = 5,			/* Whitespace.  */
80   	  __ISwprint = 6,			/* Printing.  */
81   	  __ISwgraph = 7,			/* Graphical.  */
82   	  __ISwblank = 8,			/* Blank (usually SPC and TAB).  */
83   	  __ISwcntrl = 9,			/* Control character.  */
84   	  __ISwpunct = 10,			/* Punctuation.  */
85   	  __ISwalnum = 11,			/* Alphanumeric.  */
86   	
87   	  _ISwupper = _ISwbit (__ISwupper),	/* UPPERCASE.  */
88   	  _ISwlower = _ISwbit (__ISwlower),	/* lowercase.  */
89   	  _ISwalpha = _ISwbit (__ISwalpha),	/* Alphabetic.  */
90   	  _ISwdigit = _ISwbit (__ISwdigit),	/* Numeric.  */
91   	  _ISwxdigit = _ISwbit (__ISwxdigit),	/* Hexadecimal numeric.  */
92   	  _ISwspace = _ISwbit (__ISwspace),	/* Whitespace.  */
93   	  _ISwprint = _ISwbit (__ISwprint),	/* Printing.  */
94   	  _ISwgraph = _ISwbit (__ISwgraph),	/* Graphical.  */
95   	  _ISwblank = _ISwbit (__ISwblank),	/* Blank (usually SPC and TAB).  */
96   	  _ISwcntrl = _ISwbit (__ISwcntrl),	/* Control character.  */
97   	  _ISwpunct = _ISwbit (__ISwpunct),	/* Punctuation.  */
98   	  _ISwalnum = _ISwbit (__ISwalnum)	/* Alphanumeric.  */
99   	};
100  	# endif /* Not _ISwbit  */
101  	
102  	
103  	__BEGIN_DECLS
104  	
105  	__BEGIN_NAMESPACE_C99
106  	/*
107  	 * Wide-character classification functions: 7.15.2.1.
108  	 */
109  	
110  	/* Test for any wide character for which `iswalpha' or `iswdigit' is
111  	   true.  */
112  	extern int iswalnum (wint_t __wc) __THROW;
113  	
114  	/* Test for any wide character for which `iswupper' or 'iswlower' is
115  	   true, or any wide character that is one of a locale-specific set of
116  	   wide-characters for which none of `iswcntrl', `iswdigit',
117  	   `iswpunct', or `iswspace' is true.  */
118  	extern int iswalpha (wint_t __wc) __THROW;
119  	
120  	/* Test for any control wide character.  */
121  	extern int iswcntrl (wint_t __wc) __THROW;
122  	
123  	/* Test for any wide character that corresponds to a decimal-digit
124  	   character.  */
125  	extern int iswdigit (wint_t __wc) __THROW;
126  	
127  	/* Test for any wide character for which `iswprint' is true and
128  	   `iswspace' is false.  */
129  	extern int iswgraph (wint_t __wc) __THROW;
130  	
131  	/* Test for any wide character that corresponds to a lowercase letter
132  	   or is one of a locale-specific set of wide characters for which
133  	   none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */
134  	extern int iswlower (wint_t __wc) __THROW;
135  	
136  	/* Test for any printing wide character.  */
137  	extern int iswprint (wint_t __wc) __THROW;
138  	
139  	/* Test for any printing wide character that is one of a
140  	   locale-specific et of wide characters for which neither `iswspace'
141  	   nor `iswalnum' is true.  */
142  	extern int iswpunct (wint_t __wc) __THROW;
143  	
144  	/* Test for any wide character that corresponds to a locale-specific
145  	   set of wide characters for which none of `iswalnum', `iswgraph', or
146  	   `iswpunct' is true.  */
147  	extern int iswspace (wint_t __wc) __THROW;
148  	
149  	/* Test for any wide character that corresponds to an uppercase letter
150  	   or is one of a locale-specific set of wide character for which none
151  	   of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */
152  	extern int iswupper (wint_t __wc) __THROW;
153  	
154  	/* Test for any wide character that corresponds to a hexadecimal-digit
155  	   character equivalent to that performed be the functions described
156  	   in the previous subclause.  */
157  	extern int iswxdigit (wint_t __wc) __THROW;
158  	
159  	/* Test for any wide character that corresponds to a standard blank
160  	   wide character or a locale-specific set of wide characters for
161  	   which `iswalnum' is false.  */
162  	# ifdef __USE_ISOC99
163  	extern int iswblank (wint_t __wc) __THROW;
164  	# endif
165  	
166  	/*
167  	 * Extensible wide-character classification functions: 7.15.2.2.
168  	 */
169  	
170  	/* Construct value that describes a class of wide characters identified
171  	   by the string argument PROPERTY.  */
172  	extern wctype_t wctype (__const char *__property) __THROW;
173  	
174  	/* Determine whether the wide-character WC has the property described by
175  	   DESC.  */
176  	extern int iswctype (wint_t __wc, wctype_t __desc) __THROW;
177  	__END_NAMESPACE_C99
178  	
179  	
180  	/*
181  	 * Wide-character case-mapping functions: 7.15.3.1.
182  	 */
183  	
184  	__BEGIN_NAMESPACE_C99
185  	/* Scalar type that can hold values which represent locale-specific
186  	   character mappings.  */
187  	typedef __const __int32_t *wctrans_t;
188  	__END_NAMESPACE_C99
189  	#ifdef __USE_GNU
190  	__USING_NAMESPACE_C99(wctrans_t)
191  	#endif
192  	
193  	__BEGIN_NAMESPACE_C99
194  	/* Converts an uppercase letter to the corresponding lowercase letter.  */
195  	extern wint_t towlower (wint_t __wc) __THROW;
196  	
197  	/* Converts an lowercase letter to the corresponding uppercase letter.  */
198  	extern wint_t towupper (wint_t __wc) __THROW;
199  	__END_NAMESPACE_C99
200  	
201  	__END_DECLS
202  	
203  	#endif	/* need iswxxx.  */
204  	
205  	
206  	/* The remaining definitions and declarations must not appear in the
207  	   <wchar.h> header.  */
208  	#ifdef _WCTYPE_H
209  	
210  	/*
211  	 * Extensible wide-character mapping functions: 7.15.3.2.
212  	 */
213  	
214  	__BEGIN_DECLS
215  	
216  	__BEGIN_NAMESPACE_C99
217  	/* Construct value that describes a mapping between wide characters
218  	   identified by the string argument PROPERTY.  */
219  	extern wctrans_t wctrans (__const char *__property) __THROW;
220  	
221  	/* Map the wide character WC using the mapping described by DESC.  */
222  	extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW;
223  	__END_NAMESPACE_C99
224  	
225  	# ifdef __USE_XOPEN2K8
226  	/* Declare the interface to extended locale model.  */
227  	#  include <xlocale.h>
228  	
229  	/* Test for any wide character for which `iswalpha' or `iswdigit' is
230  	   true.  */
231  	extern int iswalnum_l (wint_t __wc, __locale_t __locale) __THROW;
232  	
233  	/* Test for any wide character for which `iswupper' or 'iswlower' is
234  	   true, or any wide character that is one of a locale-specific set of
235  	   wide-characters for which none of `iswcntrl', `iswdigit',
236  	   `iswpunct', or `iswspace' is true.  */
237  	extern int iswalpha_l (wint_t __wc, __locale_t __locale) __THROW;
238  	
239  	/* Test for any control wide character.  */
240  	extern int iswcntrl_l (wint_t __wc, __locale_t __locale) __THROW;
241  	
242  	/* Test for any wide character that corresponds to a decimal-digit
243  	   character.  */
244  	extern int iswdigit_l (wint_t __wc, __locale_t __locale) __THROW;
245  	
246  	/* Test for any wide character for which `iswprint' is true and
247  	   `iswspace' is false.  */
248  	extern int iswgraph_l (wint_t __wc, __locale_t __locale) __THROW;
249  	
250  	/* Test for any wide character that corresponds to a lowercase letter
251  	   or is one of a locale-specific set of wide characters for which
252  	   none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */
253  	extern int iswlower_l (wint_t __wc, __locale_t __locale) __THROW;
254  	
255  	/* Test for any printing wide character.  */
256  	extern int iswprint_l (wint_t __wc, __locale_t __locale) __THROW;
257  	
258  	/* Test for any printing wide character that is one of a
259  	   locale-specific et of wide characters for which neither `iswspace'
260  	   nor `iswalnum' is true.  */
261  	extern int iswpunct_l (wint_t __wc, __locale_t __locale) __THROW;
262  	
263  	/* Test for any wide character that corresponds to a locale-specific
264  	   set of wide characters for which none of `iswalnum', `iswgraph', or
265  	   `iswpunct' is true.  */
266  	extern int iswspace_l (wint_t __wc, __locale_t __locale) __THROW;
267  	
268  	/* Test for any wide character that corresponds to an uppercase letter
269  	   or is one of a locale-specific set of wide character for which none
270  	   of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */
271  	extern int iswupper_l (wint_t __wc, __locale_t __locale) __THROW;
272  	
273  	/* Test for any wide character that corresponds to a hexadecimal-digit
274  	   character equivalent to that performed be the functions described
275  	   in the previous subclause.  */
276  	extern int iswxdigit_l (wint_t __wc, __locale_t __locale) __THROW;
277  	
278  	/* Test for any wide character that corresponds to a standard blank
279  	   wide character or a locale-specific set of wide characters for
280  	   which `iswalnum' is false.  */
281  	extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW;
282  	
283  	/* Construct value that describes a class of wide characters identified
284  	   by the string argument PROPERTY.  */
285  	extern wctype_t wctype_l (__const char *__property, __locale_t __locale)
286  	     __THROW;
287  	
288  	/* Determine whether the wide-character WC has the property described by
289  	   DESC.  */
290  	extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale)
291  	     __THROW;
292  	
293  	
294  	/*
295  	 * Wide-character case-mapping functions.
296  	 */
297  	
298  	/* Converts an uppercase letter to the corresponding lowercase letter.  */
299  	extern wint_t towlower_l (wint_t __wc, __locale_t __locale) __THROW;
300  	
301  	/* Converts an lowercase letter to the corresponding uppercase letter.  */
302  	extern wint_t towupper_l (wint_t __wc, __locale_t __locale) __THROW;
303  	
304  	/* Construct value that describes a mapping between wide characters
305  	   identified by the string argument PROPERTY.  */
306  	extern wctrans_t wctrans_l (__const char *__property, __locale_t __locale)
307  	     __THROW;
308  	
309  	/* Map the wide character WC using the mapping described by DESC.  */
310  	extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc,
311  				   __locale_t __locale) __THROW;
312  	
313  	# endif /* Use POSIX 2008.  */
314  	
315  	__END_DECLS
316  	
317  	#endif	/* __WCTYPE_H defined.  */
318  	
319  	#endif /* wctype.h  */
320