Home | History | Annotate | Line # | Download | only in include
ctype.h revision 1.13
      1 /*
      2  * Copyright (c) 1989 The Regents of the University of California.
      3  * All rights reserved.
      4  * (c) UNIX System Laboratories, Inc.
      5  * All or some portions of this file are derived from material licensed
      6  * to the University of California by American Telephone and Telegraph
      7  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
      8  * the permission of UNIX System Laboratories, Inc.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  *	from: @(#)ctype.h	5.3 (Berkeley) 4/3/91
     39  *	$Id: ctype.h,v 1.13 1994/05/16 10:58:56 cgd Exp $
     40  */
     41 
     42 #ifndef _CTYPE_H_
     43 #define _CTYPE_H_
     44 #include <sys/cdefs.h>
     45 
     46 #define	_U	0x01
     47 #define	_L	0x02
     48 #define	_N	0x04
     49 #define	_S	0x08
     50 #define	_P	0x10
     51 #define	_C	0x20
     52 #define	_X	0x40
     53 #define	_B	0x80
     54 
     55 extern const char	*_ctype_;
     56 extern const short	*_tolower_tab_;
     57 extern const short	*_toupper_tab_;
     58 
     59 __BEGIN_DECLS
     60 extern int	isalnum __P ((int));
     61 extern int	isalpha __P ((int));
     62 extern int	iscntrl __P ((int));
     63 extern int	isdigit __P ((int));
     64 extern int	isgraph __P ((int));
     65 extern int	islower __P ((int));
     66 extern int	isprint __P ((int));
     67 extern int	ispunct __P ((int));
     68 extern int	isspace __P ((int));
     69 extern int	isupper __P ((int));
     70 extern int	isxdigit __P ((int));
     71 extern int	tolower __P ((int));
     72 extern int	toupper __P ((int));
     73 
     74 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
     75 extern int	isblank __P ((int));
     76 extern int	isascii __P ((int));
     77 extern int	toascii __P ((int));
     78 extern int	_tolower __P ((int));
     79 extern int	_toupper __P ((int));
     80 #endif
     81 __END_DECLS
     82 
     83 #define	isdigit(c)	((_ctype_ + 1)[c] & _N)
     84 #define	islower(c)	((_ctype_ + 1)[c] & _L)
     85 #define	isspace(c)	((_ctype_ + 1)[c] & _S)
     86 #define	ispunct(c)	((_ctype_ + 1)[c] & _P)
     87 #define	isupper(c)	((_ctype_ + 1)[c] & _U)
     88 #define	isalpha(c)	((_ctype_ + 1)[c] & (_U|_L))
     89 #define	isxdigit(c)	((_ctype_ + 1)[c] & (_N|_X))
     90 #define	isalnum(c)	((_ctype_ + 1)[c] & (_U|_L|_N))
     91 #define	isprint(c)	((_ctype_ + 1)[c] & (_P|_U|_L|_N|_B))
     92 #define	isgraph(c)	((_ctype_ + 1)[c] & (_P|_U|_L|_N))
     93 #define	iscntrl(c)	((_ctype_ + 1)[c] & _C)
     94 #define tolower(c)	((_tolower_tab_ + 1)[c])
     95 #define toupper(c)	((_toupper_tab_ + 1)[c])
     96 
     97 #if !defined(_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
     98 #if notyet
     99 #define isblank(c)	((_ctype_ + 1)[c] & _B)
    100 #endif
    101 #define	isascii(c)	((unsigned)(c) <= 0177)
    102 #define	toascii(c)	((c) & 0177)
    103 #define _tolower(c)	((c) - 'A' + 'a')
    104 #define _toupper(c)	((c) - 'a' + 'A')
    105 #endif
    106 
    107 #endif /* !_CTYPE_H_ */
    108