ctype.h revision 233600
1139749Simp/* 2124137Simp * Copyright (c) 1989, 1993 377195Simp * The Regents of the University of California. All rights reserved. 477195Simp * (c) UNIX System Laboratories, Inc. 577195Simp * All or some portions of this file are derived from material licensed 677195Simp * to the University of California by American Telephone and Telegraph 777195Simp * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8140035Simp * the permission of UNIX System Laboratories, Inc. 977195Simp * 1077195Simp * This code is derived from software contributed to Berkeley by 1177195Simp * Paul Borman at Krystal Technologies. 1277195Simp * 13140035Simp * Redistribution and use in source and binary forms, with or without 14140035Simp * modification, are permitted provided that the following conditions 15140035Simp * are met: 16140035Simp * 1. Redistributions of source code must retain the above copyright 17140035Simp * notice, this list of conditions and the following disclaimer. 18140035Simp * 2. Redistributions in binary form must reproduce the above copyright 19140035Simp * notice, this list of conditions and the following disclaimer in the 20140035Simp * documentation and/or other materials provided with the distribution. 21140035Simp * 3. Neither the name of the University nor the names of its contributors 22140035Simp * may be used to endorse or promote products derived from this software 23140035Simp * without specific prior written permission. 2477195Simp * 2577195Simp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2677195Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2777195Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2877195Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29100704Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30100704Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31100704Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32100704Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33152193Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34152193Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35152193Simp * SUCH DAMAGE. 36152193Simp * 37152193Simp * @(#)ctype.h 8.4 (Berkeley) 1/21/94 38152193Simp * $FreeBSD: head/include/ctype.h 233600 2012-03-28 12:11:54Z theraven $ 39111533Simp */ 40111533Simp 41111533Simp#ifndef _CTYPE_H_ 42111533Simp#define _CTYPE_H_ 43150728Simp 44100704Simp#include <sys/cdefs.h> 45100704Simp#include <sys/_types.h> 46100704Simp#include <_ctype.h> 47101632Simp 48100704Simp__BEGIN_DECLS 49100704Simpint isalnum(int); 50152193Simpint isalpha(int); 51152193Simpint iscntrl(int); 52139225Simpint isdigit(int); 53152193Simpint isgraph(int); 54152193Simpint islower(int); 55152193Simpint isprint(int); 56100704Simpint ispunct(int); 57100704Simpint isspace(int); 58100704Simpint isupper(int); 59100704Simpint isxdigit(int); 60100704Simpint tolower(int); 61100704Simpint toupper(int); 62150728Simp 63100704Simp#if __XSI_VISIBLE 64100704Simpint isascii(int); 65100704Simpint toascii(int); 66100704Simp#endif 67100704Simp 68100704Simp#if __ISO_C_VISIBLE >= 1999 69100704Simpint isblank(int); 70100704Simp#endif 71100704Simp 72100704Simp#if __BSD_VISIBLE 73100704Simpint digittoint(int); 74100704Simpint ishexnumber(int); 75100704Simpint isideogram(int); 76100704Simpint isnumber(int); 77100704Simpint isphonogram(int); 78100704Simpint isrune(int); 79100704Simpint isspecial(int); 80100704Simp#endif 81152193Simp 82152193Simp#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) 83152193Simp#include <xlocale/_ctype.h> 84152193Simp#endif 85152193Simp__END_DECLS 86100704Simp 87100704Simp#ifndef __cplusplus 88100704Simp#define isalnum(c) __sbistype((c), _CTYPE_A|_CTYPE_D) 89152193Simp#define isalpha(c) __sbistype((c), _CTYPE_A) 90152193Simp#define iscntrl(c) __sbistype((c), _CTYPE_C) 91152193Simp#define isdigit(c) __isctype((c), _CTYPE_D) /* ANSI -- locale independent */ 92152193Simp#define isgraph(c) __sbistype((c), _CTYPE_G) 93152193Simp#define islower(c) __sbistype((c), _CTYPE_L) 94152193Simp#define isprint(c) __sbistype((c), _CTYPE_R) 95152193Simp#define ispunct(c) __sbistype((c), _CTYPE_P) 96152193Simp#define isspace(c) __sbistype((c), _CTYPE_S) 97152193Simp#define isupper(c) __sbistype((c), _CTYPE_U) 98152193Simp#define isxdigit(c) __isctype((c), _CTYPE_X) /* ANSI -- locale independent */ 99152193Simp#define tolower(c) __sbtolower(c) 100100704Simp#define toupper(c) __sbtoupper(c) 101100704Simp#endif /* !__cplusplus */ 102100704Simp 103100704Simp#if __XSI_VISIBLE 10483159Simp/* 10583159Simp * POSIX.1-2001 specifies _tolower() and _toupper() to be macros equivalent to 10683159Simp * tolower() and toupper() respectively, minus extra checking to ensure that 10783159Simp * the argument is a lower or uppercase letter respectively. We've chosen to 10883159Simp * implement these macros with the same error checking as tolower() and 10983159Simp * toupper() since this doesn't violate the specification itself, only its 11083159Simp * intent. We purposely leave _tolower() and _toupper() undocumented to 11183159Simp * discourage their use. 11283159Simp * 11383159Simp * XXX isascii() and toascii() should similarly be undocumented. 11483159Simp */ 115#define _tolower(c) __sbtolower(c) 116#define _toupper(c) __sbtoupper(c) 117#define isascii(c) (((c) & ~0x7F) == 0) 118#define toascii(c) ((c) & 0x7F) 119#endif 120 121#if __ISO_C_VISIBLE >= 1999 && !defined(__cplusplus) 122#define isblank(c) __sbistype((c), _CTYPE_B) 123#endif 124 125#if __BSD_VISIBLE 126#define digittoint(c) __sbmaskrune((c), 0xFF) 127#define ishexnumber(c) __sbistype((c), _CTYPE_X) 128#define isideogram(c) __sbistype((c), _CTYPE_I) 129#define isnumber(c) __sbistype((c), _CTYPE_D) 130#define isphonogram(c) __sbistype((c), _CTYPE_Q) 131#define isrune(c) __sbistype((c), 0xFFFFFF00L) 132#define isspecial(c) __sbistype((c), _CTYPE_T) 133#endif 134 135#endif /* !_CTYPE_H_ */ 136