Complete Citrus import. Import message catalog implement from
[dragonfly.git] / include / ctype.h
1 /*      $NetBSD: src/include/ctype.h,v 1.25 2003/10/22 15:51:18 kleink Exp $    */
2 /*      $DragonFly: src/include/ctype.h,v 1.6 2005/04/21 16:36:34 joerg Exp $ */
3
4 /*
5  * Copyright (c) 1989 The Regents of the University of California.
6  * All rights reserved.
7  * (c) UNIX System Laboratories, Inc.
8  * All or some portions of this file are derived from material licensed
9  * to the University of California by American Telephone and Telegraph
10  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11  * the permission of UNIX System Laboratories, Inc.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *      @(#)ctype.h     5.3 (Berkeley) 4/3/91
38  */
39
40 #ifndef _CTYPE_H_
41 #define _CTYPE_H_
42
43 #include <sys/cdefs.h>
44 #include <machine/stdint.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 __uint16_t *__libc_ctype_;
56 extern const __int16_t  *__libc_tolower_tab_;
57 extern const __int16_t  *__libc_toupper_tab_;
58
59 __BEGIN_DECLS
60 int     isalnum(int);
61 int     isalpha(int);
62 int     iscntrl(int);
63 int     isdigit(int);
64 int     isgraph(int);
65 int     islower(int);
66 int     isprint(int);
67 int     ispunct(int);
68 int     isspace(int);
69 int     isupper(int);
70 int     isxdigit(int);
71 int     tolower(int);
72 int     toupper(int);
73
74 #if defined(__XSI_VISIBLE)
75 int     isascii(int);
76 int     toascii(int);
77 int     _tolower(int);
78 int     _toupper(int);
79 #endif
80
81 #if _ISO_C_VISIBLE >= 1999 || _POSIX_VISIBLE >= 200112L || \
82     __XSI_VISIBLE >= 600
83 int     isblank(int);
84 #endif
85 __END_DECLS
86
87 #define isdigit(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & _N))
88 #define islower(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & _L))
89 #define isspace(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & _S))
90 #define ispunct(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & _P))
91 #define isupper(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & _U))
92 #define isalpha(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & (_U|_L)))
93 #define isxdigit(c)     ((int)((__libc_ctype_ + 1)[(int)(c)] & (_N|_X)))
94 #define isalnum(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & (_U|_L|_N)))
95 #define isprint(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & (_P|_U|_L|_N|_B)))
96 #define isgraph(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & (_P|_U|_L|_N)))
97 #define iscntrl(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & _C))
98 #define tolower(c)      ((int)((__libc_tolower_tab_ + 1)[(int)(c)]))
99 #define toupper(c)      ((int)((__libc_toupper_tab_ + 1)[(int)(c)]))
100
101 #if defined(__XSI_VISIBLE)
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 #if __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE >= 200112L || \
109     __XSI_VISIBLE >= 600
110 #define isblank(c)      ((int)((__libc_ctype_ + 1)[(int)(c)] & _B))
111 #endif
112
113 #ifdef _CTYPE_PRIVATE
114 #include <machine/limits.h>     /* for CHAR_BIT */
115
116 #define _CTYPE_NUM_CHARS        (1 << CHAR_BIT)
117
118 #define _CTYPE_ID               "DFCTYPE"
119 #define _CTYPE_REV              3
120
121 extern const __uint16_t __libc_C_ctype_[];
122 extern const __int16_t  __libc_C_toupper_[];
123 extern const __int16_t  __libc_C_tolower_[];
124 #endif
125
126 #endif /* !_CTYPE_H_ */