ctype.h revision 233600
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. 21203964Simp * 3. Neither the name of the University nor the names of its contributors 221539Srgrimes * may be used to endorse or promote products derived from this software 231539Srgrimes * without specific prior written permission. 241539Srgrimes * 251539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 261539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 271539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 281539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 291539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 301539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 311539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 321539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 331539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 341539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 351539Srgrimes * SUCH DAMAGE. 361539Srgrimes * 371539Srgrimes * @(#)ctype.h 8.4 (Berkeley) 1/21/94 3854746Sphantom * $FreeBSD: head/include/ctype.h 233600 2012-03-28 12:11:54Z theraven $ 391539Srgrimes */ 401539Srgrimes 417655Sbde#ifndef _CTYPE_H_ 427655Sbde#define _CTYPE_H_ 431539Srgrimes 44103113Smike#include <sys/cdefs.h> 45103113Smike#include <sys/_types.h> 46133559Stjr#include <_ctype.h> 471539Srgrimes 487655Sbde__BEGIN_DECLS 4993032Simpint isalnum(int); 5093032Simpint isalpha(int); 5193032Simpint iscntrl(int); 5293032Simpint isdigit(int); 5393032Simpint isgraph(int); 5493032Simpint islower(int); 5593032Simpint isprint(int); 5693032Simpint ispunct(int); 5793032Simpint isspace(int); 5893032Simpint isupper(int); 5993032Simpint isxdigit(int); 6093032Simpint tolower(int); 6193032Simpint toupper(int); 621539Srgrimes 63102998Smike#if __XSI_VISIBLE 64102998Smikeint isascii(int); 65102998Smikeint toascii(int); 66102998Smike#endif 67102998Smike 68128523Stjr#if __ISO_C_VISIBLE >= 1999 69128523Stjrint isblank(int); 70128523Stjr#endif 71128523Stjr 72102998Smike#if __BSD_VISIBLE 7393032Simpint digittoint(int); 7493032Simpint ishexnumber(int); 7593032Simpint isideogram(int); 7693032Simpint isnumber(int); 7793032Simpint isphonogram(int); 7893032Simpint isrune(int); 7993032Simpint isspecial(int); 807655Sbde#endif 81232498Stheraven 82233600Stheraven#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) 83232498Stheraven#include <xlocale/_ctype.h> 84232498Stheraven#endif 857655Sbde__END_DECLS 867655Sbde 87227490Stheraven#ifndef __cplusplus 88172619Sache#define isalnum(c) __sbistype((c), _CTYPE_A|_CTYPE_D) 89172619Sache#define isalpha(c) __sbistype((c), _CTYPE_A) 90172619Sache#define iscntrl(c) __sbistype((c), _CTYPE_C) 9157035Sobrien#define isdigit(c) __isctype((c), _CTYPE_D) /* ANSI -- locale independent */ 92172619Sache#define isgraph(c) __sbistype((c), _CTYPE_G) 93172619Sache#define islower(c) __sbistype((c), _CTYPE_L) 94172619Sache#define isprint(c) __sbistype((c), _CTYPE_R) 95172619Sache#define ispunct(c) __sbistype((c), _CTYPE_P) 96172619Sache#define isspace(c) __sbistype((c), _CTYPE_S) 97172619Sache#define isupper(c) __sbistype((c), _CTYPE_U) 9857035Sobrien#define isxdigit(c) __isctype((c), _CTYPE_X) /* ANSI -- locale independent */ 99172619Sache#define tolower(c) __sbtolower(c) 100172619Sache#define toupper(c) __sbtoupper(c) 101227490Stheraven#endif /* !__cplusplus */ 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 121227490Stheraven#if __ISO_C_VISIBLE >= 1999 && !defined(__cplusplus) 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