xref: /illumos-gate/usr/src/uts/common/sys/ctype.h (revision 6b1aed11)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*6b1aed11SRichard PALO  *
26*6b1aed11SRichard PALO  * Copyright 2015 PALO, Richard.  All rights reserved.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifndef	_SYS_CTYPE_H
307c478bd9Sstevel@tonic-gate #define	_SYS_CTYPE_H
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/types.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #define	ISDIGIT(_c) \
397c478bd9Sstevel@tonic-gate 	((_c) >= '0' && (_c) <= '9')
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #define	ISXDIGIT(_c) \
427c478bd9Sstevel@tonic-gate 	(ISDIGIT(_c) || \
437c478bd9Sstevel@tonic-gate 	((_c) >= 'a' && (_c) <= 'f') || \
447c478bd9Sstevel@tonic-gate 	((_c) >= 'A' && (_c) <= 'F'))
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #define	ISLOWER(_c) \
477c478bd9Sstevel@tonic-gate 	((_c) >= 'a' && (_c) <= 'z')
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #define	ISUPPER(_c) \
507c478bd9Sstevel@tonic-gate 	((_c) >= 'A' && (_c) <= 'Z')
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #define	ISALPHA(_c) \
537c478bd9Sstevel@tonic-gate 	(ISUPPER(_c) || \
547c478bd9Sstevel@tonic-gate 	ISLOWER(_c))
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #define	ISALNUM(_c) \
577c478bd9Sstevel@tonic-gate 	(ISALPHA(_c) || \
587c478bd9Sstevel@tonic-gate 	ISDIGIT(_c))
597c478bd9Sstevel@tonic-gate 
60*6b1aed11SRichard PALO #define	ISPRINT(_c) \
61*6b1aed11SRichard PALO 	((_c) >= ' ' && (_c) <= '~')
62*6b1aed11SRichard PALO 
637c478bd9Sstevel@tonic-gate #define	ISSPACE(_c) \
647c478bd9Sstevel@tonic-gate 	((_c) == ' ' || \
657c478bd9Sstevel@tonic-gate 	(_c) == '\t' || \
667c478bd9Sstevel@tonic-gate 	(_c) == '\r' || \
677c478bd9Sstevel@tonic-gate 	(_c) == '\n')
687c478bd9Sstevel@tonic-gate 
69*6b1aed11SRichard PALO static __GNU_INLINE boolean_t	/* LINTED E_STATIC_UNUSED */
isdigit(char c)707c478bd9Sstevel@tonic-gate isdigit(char c)
717c478bd9Sstevel@tonic-gate {
727c478bd9Sstevel@tonic-gate 	return (ISDIGIT(c));
737c478bd9Sstevel@tonic-gate }
747c478bd9Sstevel@tonic-gate #pragma inline(isdigit)
757c478bd9Sstevel@tonic-gate 
76*6b1aed11SRichard PALO static __GNU_INLINE boolean_t	/* LINTED E_STATIC_UNUSED */
isxdigit(char c)777c478bd9Sstevel@tonic-gate isxdigit(char c)
787c478bd9Sstevel@tonic-gate {
797c478bd9Sstevel@tonic-gate 	return (ISXDIGIT(c));
807c478bd9Sstevel@tonic-gate }
81*6b1aed11SRichard PALO #pragma inline(isxdigit)
827c478bd9Sstevel@tonic-gate 
83*6b1aed11SRichard PALO static __GNU_INLINE boolean_t	/* LINTED E_STATIC_UNUSED */
islower(char c)847c478bd9Sstevel@tonic-gate islower(char c)
857c478bd9Sstevel@tonic-gate {
867c478bd9Sstevel@tonic-gate 	return (ISLOWER(c));
877c478bd9Sstevel@tonic-gate }
887c478bd9Sstevel@tonic-gate #pragma inline(islower)
897c478bd9Sstevel@tonic-gate 
90*6b1aed11SRichard PALO static __GNU_INLINE boolean_t	/* LINTED E_STATIC_UNUSED */
isupper(char c)917c478bd9Sstevel@tonic-gate isupper(char c)
927c478bd9Sstevel@tonic-gate {
937c478bd9Sstevel@tonic-gate 	return (ISUPPER(c));
947c478bd9Sstevel@tonic-gate }
957c478bd9Sstevel@tonic-gate #pragma inline(isupper)
967c478bd9Sstevel@tonic-gate 
97*6b1aed11SRichard PALO static __GNU_INLINE boolean_t	/* LINTED E_STATIC_UNUSED */
isalpha(char c)987c478bd9Sstevel@tonic-gate isalpha(char c)
997c478bd9Sstevel@tonic-gate {
1007c478bd9Sstevel@tonic-gate 	return (ISALPHA(c));
1017c478bd9Sstevel@tonic-gate }
1027c478bd9Sstevel@tonic-gate #pragma inline(isalpha)
1037c478bd9Sstevel@tonic-gate 
104*6b1aed11SRichard PALO static __GNU_INLINE boolean_t	/* LINTED E_STATIC_UNUSED */
isalnum(char c)1057c478bd9Sstevel@tonic-gate isalnum(char c)
1067c478bd9Sstevel@tonic-gate {
1077c478bd9Sstevel@tonic-gate 	return (ISALNUM(c));
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate #pragma inline(isalnum)
1107c478bd9Sstevel@tonic-gate 
111*6b1aed11SRichard PALO static __GNU_INLINE boolean_t	/* LINTED E_STATIC_UNUSED */
isprint(char c)112*6b1aed11SRichard PALO isprint(char c)
113*6b1aed11SRichard PALO {
114*6b1aed11SRichard PALO 	return (ISPRINT(c));
115*6b1aed11SRichard PALO }
116*6b1aed11SRichard PALO #pragma inline(isprint)
117*6b1aed11SRichard PALO 
118*6b1aed11SRichard PALO static __GNU_INLINE boolean_t	/* LINTED E_STATIC_UNUSED */
isspace(char c)1197c478bd9Sstevel@tonic-gate isspace(char c)
1207c478bd9Sstevel@tonic-gate {
1217c478bd9Sstevel@tonic-gate 	return (ISSPACE(c));
1227c478bd9Sstevel@tonic-gate }
1237c478bd9Sstevel@tonic-gate #pragma inline(isspace)
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1267c478bd9Sstevel@tonic-gate }
1277c478bd9Sstevel@tonic-gate #endif
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate #endif	/* _SYS_CTYPE_H */
130