ctype.h revision 203964
11556Srgrimes/* 21556Srgrimes * Copyright (c) 1989, 1993 31556Srgrimes * The Regents of the University of California. All rights reserved. 41556Srgrimes * (c) UNIX System Laboratories, Inc. 51556Srgrimes * All or some portions of this file are derived from material licensed 61556Srgrimes * to the University of California by American Telephone and Telegraph 71556Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 81556Srgrimes * the permission of UNIX System Laboratories, Inc. 91556Srgrimes * 101556Srgrimes * This code is derived from software contributed to Berkeley by 111556Srgrimes * Paul Borman at Krystal Technologies. 121556Srgrimes * 131556Srgrimes * Redistribution and use in source and binary forms, with or without 141556Srgrimes * modification, are permitted provided that the following conditions 151556Srgrimes * are met: 161556Srgrimes * 1. Redistributions of source code must retain the above copyright 171556Srgrimes * notice, this list of conditions and the following disclaimer. 181556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 191556Srgrimes * notice, this list of conditions and the following disclaimer in the 201556Srgrimes * documentation and/or other materials provided with the distribution. 211556Srgrimes * 3. Neither the name of the University nor the names of its contributors 221556Srgrimes * may be used to endorse or promote products derived from this software 231556Srgrimes * without specific prior written permission. 241556Srgrimes * 251556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 261556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 271556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 281556Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 291556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 301556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 311556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 321556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 331556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3436150Scharnier * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3536150Scharnier * SUCH DAMAGE. 3636150Scharnier * 371556Srgrimes * @(#)ctype.h 8.4 (Berkeley) 1/21/94 3899110Sobrien * $FreeBSD: head/include/ctype.h 203964 2010-02-16 19:39:50Z imp $ 3999110Sobrien */ 401556Srgrimes 4117987Speter#ifndef _CTYPE_H_ 42149017Sstefanf#define _CTYPE_H_ 4317987Speter 441556Srgrimes#include <sys/cdefs.h> 451556Srgrimes#include <sys/_types.h> 461556Srgrimes#include <_ctype.h> 471556Srgrimes 481556Srgrimes__BEGIN_DECLS 491556Srgrimesint isalnum(int); 501556Srgrimesint isalpha(int); 511556Srgrimesint iscntrl(int); 521556Srgrimesint isdigit(int); 531556Srgrimesint isgraph(int); 541556Srgrimesint islower(int); 551556Srgrimesint isprint(int); 561556Srgrimesint ispunct(int); 5717987Speterint isspace(int); 5859436Scracauerint isupper(int); 5917987Speterint isxdigit(int); 601556Srgrimesint tolower(int); 6117987Speterint toupper(int); 621556Srgrimes 631556Srgrimes#if __XSI_VISIBLE 641556Srgrimesint isascii(int); 651556Srgrimesint toascii(int); 661556Srgrimes#endif 67142845Sobrien 68142845Sobrien#if __ISO_C_VISIBLE >= 1999 691556Srgrimesint isblank(int); 701556Srgrimes#endif 7117987Speter 721556Srgrimes#if __BSD_VISIBLE 731556Srgrimesint digittoint(int); 741556Srgrimesint ishexnumber(int); 751556Srgrimesint isideogram(int); 761556Srgrimesint isnumber(int); 771556Srgrimesint isphonogram(int); 781556Srgrimesint isrune(int); 791556Srgrimesint isspecial(int); 801556Srgrimes#endif 811556Srgrimes__END_DECLS 821556Srgrimes 831556Srgrimes#define isalnum(c) __sbistype((c), _CTYPE_A|_CTYPE_D) 84117261Sdds#define isalpha(c) __sbistype((c), _CTYPE_A) 85117261Sdds#define iscntrl(c) __sbistype((c), _CTYPE_C) 86117261Sdds#define isdigit(c) __isctype((c), _CTYPE_D) /* ANSI -- locale independent */ 87117261Sdds#define isgraph(c) __sbistype((c), _CTYPE_G) 881556Srgrimes#define islower(c) __sbistype((c), _CTYPE_L) 89117261Sdds#define isprint(c) __sbistype((c), _CTYPE_R) 901556Srgrimes#define ispunct(c) __sbistype((c), _CTYPE_P) 91117261Sdds#define isspace(c) __sbistype((c), _CTYPE_S) 92117261Sdds#define isupper(c) __sbistype((c), _CTYPE_U) 93117261Sdds#define isxdigit(c) __isctype((c), _CTYPE_X) /* ANSI -- locale independent */ 94117261Sdds#define tolower(c) __sbtolower(c) 95117261Sdds#define toupper(c) __sbtoupper(c) 96179022Sstefanf 971556Srgrimes#if __XSI_VISIBLE 9818018Speter/* 9918018Speter * POSIX.1-2001 specifies _tolower() and _toupper() to be macros equivalent to 1001556Srgrimes * tolower() and toupper() respectively, minus extra checking to ensure that 1011556Srgrimes * the argument is a lower or uppercase letter respectively. We've chosen to 10290111Simp * implement these macros with the same error checking as tolower() and 10390111Simp * toupper() since this doesn't violate the specification itself, only its 10490111Simp * intent. We purposely leave _tolower() and _toupper() undocumented to 10590111Simp * discourage their use. 10690111Simp * 10790111Simp * XXX isascii() and toascii() should similarly be undocumented. 10890111Simp */ 10990111Simp#define _tolower(c) __sbtolower(c) 11090111Simp#define _toupper(c) __sbtoupper(c) 11190111Simp#define isascii(c) (((c) & ~0x7F) == 0) 11290111Simp#define toascii(c) ((c) & 0x7F) 11390111Simp#endif 11490111Simp 11590111Simp#if __ISO_C_VISIBLE >= 1999 11690111Simp#define isblank(c) __sbistype((c), _CTYPE_B) 11790111Simp#endif 1181556Srgrimes 11917987Speter#if __BSD_VISIBLE 1201556Srgrimes#define digittoint(c) __sbmaskrune((c), 0xFF) 1211556Srgrimes#define ishexnumber(c) __sbistype((c), _CTYPE_X) 1221556Srgrimes#define isideogram(c) __sbistype((c), _CTYPE_I) 1231556Srgrimes#define isnumber(c) __sbistype((c), _CTYPE_D) 1241556Srgrimes#define isphonogram(c) __sbistype((c), _CTYPE_Q) 1251556Srgrimes#define isrune(c) __sbistype((c), 0xFFFFFF00L) 12690111Simp#define isspecial(c) __sbistype((c), _CTYPE_T) 12717987Speter#endif 1281556Srgrimes 1291556Srgrimes#endif /* !_CTYPE_H_ */ 13060593Scracauer