1 /* 2 * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _CTYPE_H 6 #define _CTYPE_H 7 8 9 #include <locale_t.h> 10 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 int isalnum(int); 17 int isalpha(int); 18 int isascii(int); 19 int isblank(int); 20 int iscntrl(int); 21 int isdigit(int); 22 int isgraph(int); 23 int islower(int); 24 int isprint(int); 25 int ispunct(int); 26 int isspace(int); 27 int isupper(int); 28 int isxdigit(int); 29 int toascii(int); 30 int tolower(int); 31 int toupper(int); 32 33 34 int isalnum_l(int, locale_t); 35 int isalpha_l(int, locale_t); 36 int isblank_l(int, locale_t); 37 int iscntrl_l(int, locale_t); 38 int isdigit_l(int, locale_t); 39 int isgraph_l(int, locale_t); 40 int islower_l(int, locale_t); 41 int isprint_l(int, locale_t); 42 int ispunct_l(int, locale_t); 43 int isspace_l(int, locale_t); 44 int isupper_l(int, locale_t); 45 int isxdigit_l(int, locale_t); 46 int tolower_l(int, locale_t); 47 int toupper_l(int, locale_t); 48 49 enum { 50 _ISblank = 0x0001, /* blank */ 51 _IScntrl = 0x0002, /* control */ 52 _ISpunct = 0x0004, /* punctuation */ 53 _ISalnum = 0x0008, /* alpha-numeric */ 54 _ISupper = 0x0100, /* uppercase */ 55 _ISlower = 0x0200, /* lowercase */ 56 _ISalpha = 0x0400, /* alphabetic */ 57 _ISdigit = 0x0800, /* digit */ 58 _ISxdigit = 0x1000, /* hexadecimal digit */ 59 _ISspace = 0x2000, /* white space */ 60 _ISprint = 0x4000, /* printing */ 61 _ISgraph = 0x8000 /* graphical */ 62 }; 63 64 /* Characteristics */ 65 extern const unsigned short int *__ctype_b; 66 /* Case conversions */ 67 extern const int *__ctype_tolower; 68 extern const int *__ctype_toupper; 69 70 extern const unsigned short int **__ctype_b_loc(); 71 extern const int **__ctype_tolower_loc(); 72 extern const int **__ctype_toupper_loc(); 73 74 #define __isctype(c, type) \ 75 ((*__ctype_b_loc())[(int)(c)] & (unsigned short int)type) 76 77 #define tolower(c) ((int)(*__ctype_tolower_loc())[(int)(c)]) 78 #define toupper(c) ((int)(*__ctype_toupper_loc())[(int)(c)]) 79 80 #define isascii(c) (((c) & ~0x7f) == 0) /* ASCII characters have bit 8 cleared */ 81 #define toascii(c) ((c) & 0x7f) /* Clear higher bits */ 82 83 #define _tolower(c) tolower(c) 84 #define _toupper(c) toupper(c) 85 86 #define isalnum(c) __isctype((c), _ISalnum) 87 #define isalpha(c) __isctype((c), _ISalpha) 88 #define isblank(c) __isctype((c), _ISblank) 89 #define iscntrl(c) __isctype((c), _IScntrl) 90 #define isdigit(c) __isctype((c), _ISdigit) 91 #define islower(c) __isctype((c), _ISlower) 92 #define isgraph(c) __isctype((c), _ISgraph) 93 #define isprint(c) __isctype((c), _ISprint) 94 #define ispunct(c) __isctype((c), _ISpunct) 95 #define isspace(c) __isctype((c), _ISspace) 96 #define isupper(c) __isctype((c), _ISupper) 97 #define isxdigit(c) __isctype((c), _ISxdigit) 98 99 extern unsigned short int __ctype_mb_cur_max; 100 101 #ifdef __cplusplus 102 } 103 #endif 104 105 #endif /* _CTYPE_H */ 106