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
13extern "C" {
14#endif
15
16int isalnum(int);
17int isalpha(int);
18int isascii(int);
19int isblank(int);
20int iscntrl(int);
21int isdigit(int);
22int isgraph(int);
23int islower(int);
24int isprint(int);
25int ispunct(int);
26int isspace(int);
27int isupper(int);
28int isxdigit(int);
29int toascii(int);
30int tolower(int);
31int toupper(int);
32
33
34int isalnum_l(int, locale_t);
35int isalpha_l(int, locale_t);
36int isblank_l(int, locale_t);
37int iscntrl_l(int, locale_t);
38int isdigit_l(int, locale_t);
39int isgraph_l(int, locale_t);
40int islower_l(int, locale_t);
41int isprint_l(int, locale_t);
42int ispunct_l(int, locale_t);
43int isspace_l(int, locale_t);
44int isupper_l(int, locale_t);
45int isxdigit_l(int, locale_t);
46int tolower_l(int, locale_t);
47int toupper_l(int, locale_t);
48
49enum {
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 */
65extern const unsigned short int *__ctype_b;
66/* Case conversions */
67extern const int *__ctype_tolower;
68extern const int *__ctype_toupper;
69
70extern const unsigned short int **__ctype_b_loc();
71extern const int **__ctype_tolower_loc();
72extern 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
99extern unsigned short int __ctype_mb_cur_max;
100
101#ifdef __cplusplus
102}
103#endif
104
105#endif /* _CTYPE_H */
106