xref: /netbsd-src/include/ctype.h (revision fdecd6a253f999ae92b139670d9e15cc9df4497c)
1 /*	$NetBSD: ctype.h,v 1.15 1997/06/02 09:52:36 kleink 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 unsigned char	*_ctype_;
57 extern const short	*_tolower_tab_;
58 extern const short	*_toupper_tab_;
59 
60 
61 __BEGIN_DECLS
62 extern int	isalnum __P ((int));
63 extern int	isalpha __P ((int));
64 extern int	iscntrl __P ((int));
65 extern int	isdigit __P ((int));
66 extern int	isgraph __P ((int));
67 extern int	islower __P ((int));
68 extern int	isprint __P ((int));
69 extern int	ispunct __P ((int));
70 extern int	isspace __P ((int));
71 extern int	isupper __P ((int));
72 extern int	isxdigit __P ((int));
73 extern int	tolower __P ((int));
74 extern int	toupper __P ((int));
75 
76 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
77 extern int	isblank __P ((int));
78 extern int	isascii __P ((int));
79 extern int	toascii __P ((int));
80 extern int	_tolower __P ((int));
81 extern int	_toupper __P ((int));
82 #endif
83 __END_DECLS
84 
85 #define	isdigit(c)	((int)((_ctype_ + 1)[c] & _N))
86 #define	islower(c)	((int)((_ctype_ + 1)[c] & _L))
87 #define	isspace(c)	((int)((_ctype_ + 1)[c] & _S))
88 #define	ispunct(c)	((int)((_ctype_ + 1)[c] & _P))
89 #define	isupper(c)	((int)((_ctype_ + 1)[c] & _U))
90 #define	isalpha(c)	((int)((_ctype_ + 1)[c] & (_U|_L)))
91 #define	isxdigit(c)	((int)((_ctype_ + 1)[c] & (_N|_X)))
92 #define	isalnum(c)	((int)((_ctype_ + 1)[c] & (_U|_L|_N)))
93 #define	isprint(c)	((int)((_ctype_ + 1)[c] & (_P|_U|_L|_N|_B)))
94 #define	isgraph(c)	((int)((_ctype_ + 1)[c] & (_P|_U|_L|_N)))
95 #define	iscntrl(c)	((int)((_ctype_ + 1)[c] & _C))
96 #define tolower(c)	((int)((_tolower_tab_ + 1)[c]))
97 #define toupper(c)	((int)((_toupper_tab_ + 1)[c]))
98 
99 #if !defined(_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
100 #if notyet
101 #define isblank(c)	((int)((_ctype_ + 1)[c] & _B))
102 #endif
103 #define	isascii(c)	((unsigned)(c) <= 0177)
104 #define	toascii(c)	((c) & 0177)
105 #define _tolower(c)	((c) - 'A' + 'a')
106 #define _toupper(c)	((c) - 'a' + 'A')
107 #endif
108 
109 #ifdef _CTYPE_PRIVATE
110 #define _CTYPE_NUM_CHARS	(1<<(sizeof(char)<<3))
111 
112 #define _CTYPE_ID	 	"BSDCTYPE"
113 #define _CTYPE_REV		2
114 
115 extern const u_int8_t _C_ctype_[];
116 extern const int16_t _C_toupper_[];
117 extern const int16_t _C_tolower_[];
118 #endif
119 
120 #endif /* !_CTYPE_H_ */
121