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