ctype.h revision 172619
11539Srgrimes/*
21539Srgrimes * Copyright (c) 1989, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes * (c) UNIX System Laboratories, Inc.
51539Srgrimes * All or some portions of this file are derived from material licensed
61539Srgrimes * to the University of California by American Telephone and Telegraph
71539Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81539Srgrimes * the permission of UNIX System Laboratories, Inc.
91539Srgrimes *
101539Srgrimes * This code is derived from software contributed to Berkeley by
111539Srgrimes * Paul Borman at Krystal Technologies.
121539Srgrimes *
131539Srgrimes * Redistribution and use in source and binary forms, with or without
141539Srgrimes * modification, are permitted provided that the following conditions
151539Srgrimes * are met:
161539Srgrimes * 1. Redistributions of source code must retain the above copyright
171539Srgrimes *    notice, this list of conditions and the following disclaimer.
181539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
191539Srgrimes *    notice, this list of conditions and the following disclaimer in the
201539Srgrimes *    documentation and/or other materials provided with the distribution.
211539Srgrimes * 3. All advertising materials mentioning features or use of this software
221539Srgrimes *    must display the following acknowledgement:
231539Srgrimes *	This product includes software developed by the University of
241539Srgrimes *	California, Berkeley and its contributors.
251539Srgrimes * 4. Neither the name of the University nor the names of its contributors
261539Srgrimes *    may be used to endorse or promote products derived from this software
271539Srgrimes *    without specific prior written permission.
281539Srgrimes *
291539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
301539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
311539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
321539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
331539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
341539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
351539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
361539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
371539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
381539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
391539Srgrimes * SUCH DAMAGE.
401539Srgrimes *
411539Srgrimes *	@(#)ctype.h	8.4 (Berkeley) 1/21/94
4254746Sphantom *      $FreeBSD: head/include/ctype.h 172619 2007-10-13 16:28:22Z ache $
431539Srgrimes */
441539Srgrimes
457655Sbde#ifndef _CTYPE_H_
467655Sbde#define	_CTYPE_H_
471539Srgrimes
48103113Smike#include <sys/cdefs.h>
49103113Smike#include <sys/_types.h>
50133559Stjr#include <_ctype.h>
511539Srgrimes
527655Sbde__BEGIN_DECLS
5393032Simpint	isalnum(int);
5493032Simpint	isalpha(int);
5593032Simpint	iscntrl(int);
5693032Simpint	isdigit(int);
5793032Simpint	isgraph(int);
5893032Simpint	islower(int);
5993032Simpint	isprint(int);
6093032Simpint	ispunct(int);
6193032Simpint	isspace(int);
6293032Simpint	isupper(int);
6393032Simpint	isxdigit(int);
6493032Simpint	tolower(int);
6593032Simpint	toupper(int);
661539Srgrimes
67102998Smike#if __XSI_VISIBLE
68102998Smikeint	_tolower(int);
69102998Smikeint	_toupper(int);
70102998Smikeint	isascii(int);
71102998Smikeint	toascii(int);
72102998Smike#endif
73102998Smike
74128523Stjr#if __ISO_C_VISIBLE >= 1999
75128523Stjrint	isblank(int);
76128523Stjr#endif
77128523Stjr
78102998Smike#if __BSD_VISIBLE
7993032Simpint	digittoint(int);
8093032Simpint	ishexnumber(int);
8193032Simpint	isideogram(int);
8293032Simpint	isnumber(int);
8393032Simpint	isphonogram(int);
8493032Simpint	isrune(int);
8593032Simpint	isspecial(int);
867655Sbde#endif
877655Sbde__END_DECLS
887655Sbde
89172619Sache#define	isalnum(c)	__sbistype((c), _CTYPE_A|_CTYPE_D)
90172619Sache#define	isalpha(c)	__sbistype((c), _CTYPE_A)
91172619Sache#define	iscntrl(c)	__sbistype((c), _CTYPE_C)
9257035Sobrien#define	isdigit(c)	__isctype((c), _CTYPE_D) /* ANSI -- locale independent */
93172619Sache#define	isgraph(c)	__sbistype((c), _CTYPE_G)
94172619Sache#define	islower(c)	__sbistype((c), _CTYPE_L)
95172619Sache#define	isprint(c)	__sbistype((c), _CTYPE_R)
96172619Sache#define	ispunct(c)	__sbistype((c), _CTYPE_P)
97172619Sache#define	isspace(c)	__sbistype((c), _CTYPE_S)
98172619Sache#define	isupper(c)	__sbistype((c), _CTYPE_U)
9957035Sobrien#define	isxdigit(c)	__isctype((c), _CTYPE_X) /* ANSI -- locale independent */
100172619Sache#define	tolower(c)	__sbtolower(c)
101172619Sache#define	toupper(c)	__sbtoupper(c)
1027655Sbde
103102998Smike#if __XSI_VISIBLE
104102998Smike/*
105102998Smike * POSIX.1-2001 specifies _tolower() and _toupper() to be macros equivalent to
106102998Smike * tolower() and toupper() respectively, minus extra checking to ensure that
107102998Smike * the argument is a lower or uppercase letter respectively.  We've chosen to
108102998Smike * implement these macros with the same error checking as tolower() and
109102998Smike * toupper() since this doesn't violate the specification itself, only its
110102998Smike * intent.  We purposely leave _tolower() and _toupper() undocumented to
111102998Smike * discourage their use.
112102998Smike *
113102998Smike * XXX isascii() and toascii() should similarly be undocumented.
114102998Smike */
115172619Sache#define	_tolower(c)	__sbtolower(c)
116172619Sache#define	_toupper(c)	__sbtoupper(c)
117102998Smike#define	isascii(c)	(((c) & ~0x7F) == 0)
118102998Smike#define	toascii(c)	((c) & 0x7F)
119102998Smike#endif
120102998Smike
121128523Stjr#if __ISO_C_VISIBLE >= 1999
122172619Sache#define	isblank(c)	__sbistype((c), _CTYPE_B)
123128523Stjr#endif
124128523Stjr
125102998Smike#if __BSD_VISIBLE
126172619Sache#define	digittoint(c)	__sbmaskrune((c), 0xFF)
127172619Sache#define	ishexnumber(c)	__sbistype((c), _CTYPE_X)
128172619Sache#define	isideogram(c)	__sbistype((c), _CTYPE_I)
129172619Sache#define	isnumber(c)	__sbistype((c), _CTYPE_D)
130172619Sache#define	isphonogram(c)	__sbistype((c), _CTYPE_Q)
131172619Sache#define	isrune(c)	__sbistype((c), 0xFFFFFF00L)
132172619Sache#define	isspecial(c)	__sbistype((c), _CTYPE_T)
1331539Srgrimes#endif
1341539Srgrimes
1351539Srgrimes#endif /* !_CTYPE_H_ */
136