152843Sphk/*-
252843Sphk * Copyright (c) 1982, 1988, 1991, 1993
352843Sphk *	The Regents of the University of California.  All rights reserved.
452843Sphk * (c) UNIX System Laboratories, Inc.
552843Sphk * All or some portions of this file are derived from material licensed
652843Sphk * to the University of California by American Telephone and Telegraph
752843Sphk * Co. or Unix System Laboratories, Inc. and are reproduced herein with
852843Sphk * the permission of UNIX System Laboratories, Inc.
952843Sphk *
1052843Sphk * Redistribution and use in source and binary forms, with or without
1152843Sphk * modification, are permitted provided that the following conditions
1252843Sphk * are met:
1352843Sphk * 1. Redistributions of source code must retain the above copyright
1452843Sphk *    notice, this list of conditions and the following disclaimer.
1552843Sphk * 2. Redistributions in binary form must reproduce the above copyright
1652843Sphk *    notice, this list of conditions and the following disclaimer in the
1752843Sphk *    documentation and/or other materials provided with the distribution.
1852843Sphk * 4. Neither the name of the University nor the names of its contributors
1952843Sphk *    may be used to endorse or promote products derived from this software
2052843Sphk *    without specific prior written permission.
2152843Sphk *
2252843Sphk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2352843Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2452843Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2552843Sphk * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2652843Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2752843Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2852843Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2952843Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3052843Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3152843Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3252843Sphk * SUCH DAMAGE.
3352843Sphk *
3452843Sphk * $FreeBSD: stable/10/sys/sys/ctype.h 345943 2019-04-05 11:35:58Z hselasky $
3552843Sphk */
3652843Sphk
3752843Sphk#ifndef _SYS_CTYPE_H_
3852843Sphk#define	_SYS_CTYPE_H_
3952843Sphk
4055205Speter#ifdef _KERNEL
4152843Sphk
42345943Shselaskystatic __inline int
43345943Shselaskyisspace(int c)
44345943Shselasky{
45345943Shselasky	return (c == ' ' || (c >= '\t' && c <= '\r'));
46345943Shselasky}
4752843Sphk
48345943Shselaskystatic __inline int
49345943Shselaskyisascii(int c)
50345943Shselasky{
51345943Shselasky	return ((c & ~0x7f) == 0);
52345943Shselasky}
5352843Sphk
54345943Shselaskystatic __inline int
55345943Shselaskyisupper(int c)
56345943Shselasky{
57345943Shselasky	return (c >= 'A' && c <= 'Z');
58345943Shselasky}
59345943Shselasky
60345943Shselaskystatic __inline int
61345943Shselaskyislower(int c)
62345943Shselasky{
63345943Shselasky	return (c >= 'a' && c <= 'z');
64345943Shselasky}
65345943Shselasky
66345943Shselaskystatic __inline int
67345943Shselaskyisalpha(int c)
68345943Shselasky{
69345943Shselasky	return (isupper(c) || islower(c));
70345943Shselasky}
71345943Shselasky
72345943Shselaskystatic __inline int
73345943Shselaskyisdigit(int c)
74345943Shselasky{
75345943Shselasky	return (c >= '0' && c <= '9');
76345943Shselasky}
77345943Shselasky
78345943Shselaskystatic __inline int
79345943Shselaskyisxdigit(int c)
80345943Shselasky{
81345943Shselasky	return (isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
82345943Shselasky}
83345943Shselasky
84345943Shselaskystatic __inline int
85345943Shselaskyisprint(int c)
86345943Shselasky{
87345943Shselasky	return (c >= ' ' && c <= '~');
88345943Shselasky}
89345943Shselasky
90345943Shselaskystatic __inline int
91345943Shselaskytoupper(int c)
92345943Shselasky{
93345943Shselasky	return (c - 0x20 * ((c >= 'a') && (c <= 'z')));
94345943Shselasky}
95345943Shselasky
96345943Shselaskystatic __inline int
97345943Shselaskytolower(int c)
98345943Shselasky{
99345943Shselasky	return (c + 0x20 * ((c >= 'A') && (c <= 'Z')));
100345943Shselasky}
101345943Shselasky
10255205Speter#endif
10352843Sphk#endif /* !_SYS_CTYPE_H_ */
104