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