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