xref: /illumos-gate/usr/src/boot/include/ctype.h (revision 199767f8)
1*199767f8SToomas Soome /*
2*199767f8SToomas Soome  * Copyright (c) 1989, 1993
3*199767f8SToomas Soome  *	The Regents of the University of California.  All rights reserved.
4*199767f8SToomas Soome  * (c) UNIX System Laboratories, Inc.
5*199767f8SToomas Soome  * All or some portions of this file are derived from material licensed
6*199767f8SToomas Soome  * to the University of California by American Telephone and Telegraph
7*199767f8SToomas Soome  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8*199767f8SToomas Soome  * the permission of UNIX System Laboratories, Inc.
9*199767f8SToomas Soome  *
10*199767f8SToomas Soome  * This code is derived from software contributed to Berkeley by
11*199767f8SToomas Soome  * Paul Borman at Krystal Technologies.
12*199767f8SToomas Soome  *
13*199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
14*199767f8SToomas Soome  * modification, are permitted provided that the following conditions
15*199767f8SToomas Soome  * are met:
16*199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
17*199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
18*199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
19*199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
20*199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
21*199767f8SToomas Soome  * 3. Neither the name of the University nor the names of its contributors
22*199767f8SToomas Soome  *    may be used to endorse or promote products derived from this software
23*199767f8SToomas Soome  *    without specific prior written permission.
24*199767f8SToomas Soome  *
25*199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26*199767f8SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27*199767f8SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28*199767f8SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29*199767f8SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30*199767f8SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31*199767f8SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32*199767f8SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33*199767f8SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34*199767f8SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35*199767f8SToomas Soome  * SUCH DAMAGE.
36*199767f8SToomas Soome  *
37*199767f8SToomas Soome  *	@(#)ctype.h	8.4 (Berkeley) 1/21/94
38*199767f8SToomas Soome  *      $FreeBSD$
39*199767f8SToomas Soome  */
40*199767f8SToomas Soome 
41*199767f8SToomas Soome #ifndef _CTYPE_H_
42*199767f8SToomas Soome #define	_CTYPE_H_
43*199767f8SToomas Soome 
44*199767f8SToomas Soome #include <sys/cdefs.h>
45*199767f8SToomas Soome #include <sys/_types.h>
46*199767f8SToomas Soome #include <_ctype.h>
47*199767f8SToomas Soome 
48*199767f8SToomas Soome __BEGIN_DECLS
49*199767f8SToomas Soome int	isalnum(int);
50*199767f8SToomas Soome int	isalpha(int);
51*199767f8SToomas Soome int	iscntrl(int);
52*199767f8SToomas Soome int	isdigit(int);
53*199767f8SToomas Soome int	isgraph(int);
54*199767f8SToomas Soome int	islower(int);
55*199767f8SToomas Soome int	isprint(int);
56*199767f8SToomas Soome int	ispunct(int);
57*199767f8SToomas Soome int	isspace(int);
58*199767f8SToomas Soome int	isupper(int);
59*199767f8SToomas Soome int	isxdigit(int);
60*199767f8SToomas Soome int	tolower(int);
61*199767f8SToomas Soome int	toupper(int);
62*199767f8SToomas Soome 
63*199767f8SToomas Soome #if __XSI_VISIBLE
64*199767f8SToomas Soome int	isascii(int);
65*199767f8SToomas Soome int	toascii(int);
66*199767f8SToomas Soome #endif
67*199767f8SToomas Soome 
68*199767f8SToomas Soome #if __ISO_C_VISIBLE >= 1999
69*199767f8SToomas Soome int	isblank(int);
70*199767f8SToomas Soome #endif
71*199767f8SToomas Soome 
72*199767f8SToomas Soome #if __BSD_VISIBLE
73*199767f8SToomas Soome int	digittoint(int);
74*199767f8SToomas Soome int	ishexnumber(int);
75*199767f8SToomas Soome int	isideogram(int);
76*199767f8SToomas Soome int	isnumber(int);
77*199767f8SToomas Soome int	isphonogram(int);
78*199767f8SToomas Soome int	isrune(int);
79*199767f8SToomas Soome int	isspecial(int);
80*199767f8SToomas Soome #endif
81*199767f8SToomas Soome 
82*199767f8SToomas Soome #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
83*199767f8SToomas Soome #include <xlocale/_ctype.h>
84*199767f8SToomas Soome #endif
85*199767f8SToomas Soome __END_DECLS
86*199767f8SToomas Soome 
87*199767f8SToomas Soome #ifndef __cplusplus
88*199767f8SToomas Soome #define	isalnum(c)	__sbistype((c), _CTYPE_A|_CTYPE_D|_CTYPE_N)
89*199767f8SToomas Soome #define	isalpha(c)	__sbistype((c), _CTYPE_A)
90*199767f8SToomas Soome #define	iscntrl(c)	__sbistype((c), _CTYPE_C)
91*199767f8SToomas Soome #define	isdigit(c)	__sbistype((c), _CTYPE_D)
92*199767f8SToomas Soome #define	isgraph(c)	__sbistype((c), _CTYPE_G)
93*199767f8SToomas Soome #define	islower(c)	__sbistype((c), _CTYPE_L)
94*199767f8SToomas Soome #define	isprint(c)	__sbistype((c), _CTYPE_R)
95*199767f8SToomas Soome #define	ispunct(c)	__sbistype((c), _CTYPE_P)
96*199767f8SToomas Soome #define	isspace(c)	__sbistype((c), _CTYPE_S)
97*199767f8SToomas Soome #define	isupper(c)	__sbistype((c), _CTYPE_U)
98*199767f8SToomas Soome #define	isxdigit(c)	__sbistype((c), _CTYPE_X)
99*199767f8SToomas Soome #define	tolower(c)	__sbtolower(c)
100*199767f8SToomas Soome #define	toupper(c)	__sbtoupper(c)
101*199767f8SToomas Soome #endif /* !__cplusplus */
102*199767f8SToomas Soome 
103*199767f8SToomas Soome #if __XSI_VISIBLE
104*199767f8SToomas Soome /*
105*199767f8SToomas Soome  * POSIX.1-2001 specifies _tolower() and _toupper() to be macros equivalent to
106*199767f8SToomas Soome  * tolower() and toupper() respectively, minus extra checking to ensure that
107*199767f8SToomas Soome  * the argument is a lower or uppercase letter respectively.  We've chosen to
108*199767f8SToomas Soome  * implement these macros with the same error checking as tolower() and
109*199767f8SToomas Soome  * toupper() since this doesn't violate the specification itself, only its
110*199767f8SToomas Soome  * intent.  We purposely leave _tolower() and _toupper() undocumented to
111*199767f8SToomas Soome  * discourage their use.
112*199767f8SToomas Soome  *
113*199767f8SToomas Soome  * XXX isascii() and toascii() should similarly be undocumented.
114*199767f8SToomas Soome  */
115*199767f8SToomas Soome #define	_tolower(c)	__sbtolower(c)
116*199767f8SToomas Soome #define	_toupper(c)	__sbtoupper(c)
117*199767f8SToomas Soome #define	isascii(c)	(((c) & ~0x7F) == 0)
118*199767f8SToomas Soome #define	toascii(c)	((c) & 0x7F)
119*199767f8SToomas Soome #endif
120*199767f8SToomas Soome 
121*199767f8SToomas Soome #if __ISO_C_VISIBLE >= 1999 && !defined(__cplusplus)
122*199767f8SToomas Soome #define	isblank(c)	__sbistype((c), _CTYPE_B)
123*199767f8SToomas Soome #endif
124*199767f8SToomas Soome 
125*199767f8SToomas Soome #if __BSD_VISIBLE
126*199767f8SToomas Soome #define	digittoint(c)	__sbmaskrune((c), 0xFF)
127*199767f8SToomas Soome #define	ishexnumber(c)	__sbistype((c), _CTYPE_X)
128*199767f8SToomas Soome #define	isideogram(c)	__sbistype((c), _CTYPE_I)
129*199767f8SToomas Soome #define	isnumber(c)	__sbistype((c), _CTYPE_D|_CTYPE_N)
130*199767f8SToomas Soome #define	isphonogram(c)	__sbistype((c), _CTYPE_Q)
131*199767f8SToomas Soome #define	isrune(c)	__sbistype((c), 0xFFFFFF00L)
132*199767f8SToomas Soome #define	isspecial(c)	__sbistype((c), _CTYPE_T)
133*199767f8SToomas Soome #endif
134*199767f8SToomas Soome 
135*199767f8SToomas Soome #endif /* !_CTYPE_H_ */
136