]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/Include/ctype.h
Standard Libraries for EDK II.
[mirror_edk2.git] / StdLib / Include / ctype.h
1 /** @file
2 Single-byte character classification and case conversion macros and
3 function declarations.
4
5 The header <ctype.h> declares several functions useful for testing and mapping
6 characters. In all cases, the argument is an int, the value of which shall be
7 representable as an unsigned char or shall equal the value of the macro EOF.
8 If the argument has any other value, the behavior is undefined.
9
10 The behavior of these functions is affected by the current locale. The
11 default is the "C" locale.
12
13 The term "printing character" refers to a member of a locale-specific
14 set of characters, each of which occupies one printing position on a display
15 device; the term control character refers to a member of a locale-specific
16 set of characters that are not printing characters.
17
18 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
19 This program and the accompanying materials are licensed and made available under
20 the terms and conditions of the BSD License that accompanies this distribution.
21 The full text of the license may be found at
22 http://opensource.org/licenses/bsd-license.php.
23
24 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
25 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
26
27 **/
28 #ifndef _CTYPE_H
29 #define _CTYPE_H
30 #include <sys/EfiCdefs.h>
31 #include <sys/_ctype.h>
32
33 __BEGIN_DECLS
34 // Declarations for the classification Functions
35
36 /** The isalnum function tests for any character for which isalpha or isdigit
37 is true.
38
39 @return Returns nonzero (true) if and only if the value of the argument c
40 conforms to that in the description of the function.
41 **/
42 int isalnum(int c);
43
44 /** The isalpha function tests for any character for which isupper or islower
45 is true, or any character that is one of a locale-specific set of
46 alphabetic characters for which none of iscntrl, isdigit, ispunct, or
47 isspace is true. In the "C" locale, isalpha returns true only for the
48 characters for which isupper or islower is true.
49
50 @return Returns nonzero (true) if and only if the value of the argument c
51 conforms to that in the description of the function.
52 **/
53 int isalpha(int c);
54
55 /** The iscntrl function tests for any control character.
56
57 @return Returns nonzero (true) if and only if the value of the argument c
58 conforms to that in the description of the function.
59 **/
60 int iscntrl(int c);
61
62 /** The isdigit function tests for any decimal-digit character.
63
64 @return Returns nonzero (true) if and only if the value of the argument c
65 conforms to that in the description of the function.
66 **/
67 int isdigit(int c);
68
69 /** The isgraph function tests for any printing character except space (' ').
70
71 @return Returns nonzero (true) if and only if the value of the argument c
72 conforms to that in the description of the function.
73 **/
74 int isgraph(int c);
75
76 /** The islower function tests for any character that is a lowercase letter or
77 is one of a locale-specific set of characters for which none of iscntrl,
78 isdigit, ispunct, or isspace is true. In the "C" locale, islower returns
79 true only for the lowercase letters.
80
81 @return Returns nonzero (true) if and only if the value of the argument c
82 conforms to that in the description of the function.
83 **/
84 int islower(int c);
85
86 /** The isprint function tests for any printing character including space (' ').
87
88 @return Returns nonzero (true) if and only if the value of the argument c
89 conforms to that in the description of the function.
90 **/
91 int isprint(int c);
92
93 /** The ispunct function tests for any printing character that is one of a
94 locale-specific set of punctuation characters for which neither isspace nor
95 isalnum is true. In the "C" locale, ispunct returns true for every printing
96 character for which neither isspace nor isalnum is true.
97
98 @return Returns nonzero (true) if and only if the value of the argument c
99 conforms to that in the description of the function.
100 **/
101 int ispunct(int c);
102
103 /** The isspace function tests for any character that is a standard white-space
104 character or is one of a locale-specific set of characters for which
105 isalnum is false. The standard white-space characters are the following:
106 space (' '), form feed ('\f'), new-line ('\n'), carriage return ('\r'),
107 horizontal tab ('\t'), and vertical tab ('\v'). In the "C" locale, isspace
108 returns true only for the standard white-space characters.
109
110 @return Returns nonzero (true) if and only if the value of the argument c
111 conforms to that in the description of the function.
112 **/
113 int isspace(int c);
114
115 /** The isupper function tests for any character that is an uppercase letter or
116 is one of a locale-specific set of characters for which none of iscntrl,
117 isdigit, ispunct, or isspace is true. In the "C" locale, isupper returns
118 true only for the uppercase letters.
119
120 @return Returns nonzero (true) if and only if the value of the argument c
121 conforms to that in the description of the function.
122 **/
123 int isupper(int c);
124
125 /** The isxdigit function tests for any hexadecimal-digit character.
126
127 @return Returns nonzero (true) if and only if the value of the argument c
128 conforms to that in the description of the function.
129 **/
130 int isxdigit(int c);
131
132 /** The isascii function tests that a character is one of the 128 ASCII characters.
133
134 @param[in] c The character to test.
135 @return Returns nonzero (true) if c is a valid ASCII character. Otherwize,
136 zero (false) is returned.
137 **/
138 int isascii(int c);
139
140 /** The tolower function converts an uppercase letter to a corresponding
141 lowercase letter.
142
143 @return If the argument is a character for which isupper is true and
144 there are one or more corresponding characters, as specified by
145 the current locale, for which islower is true, the tolower
146 function returns one of the corresponding characters (always the
147 same one for any given locale); otherwise, the argument is
148 returned unchanged.
149 **/
150 int tolower(int c);
151
152 /** The toupper function converts a lowercase letter to a corresponding
153 uppercase letter.
154
155 @return If the argument is a character for which islower is true and
156 there are one or more corresponding characters, as specified by
157 the current locale, for which isupper is true, the toupper
158 function returns one of the corresponding characters (always the
159 same one for any given locale); otherwise, the argument is
160 returned unchanged.
161 **/
162 int toupper(int c);
163
164 int isblank(int);
165
166 __END_DECLS
167
168 // Character Classification Macros
169 // Undefine individually or define NO_CTYPE_MACROS, before including <ctype.h>,
170 // in order to use the Function version of the character classification macros.
171 #ifndef NO_CTYPE_MACROS
172 #define isalnum(c) (__isCClass( (int)c, (_CD | _CU | _CL | _XA)))
173 #define isalpha(c) (__isCClass( (int)c, (_CU | _CL | _XA)))
174 #define iscntrl(c) (__isCClass( (int)c, (_CC)))
175 #define isdigit(c) (__isCClass( (int)c, (_CD)))
176 #define isgraph(c) (__isCClass( (int)c, (_CG)))
177 #define islower(c) (__isCClass( (int)c, (_CL)))
178 #define isprint(c) (__isCClass( (int)c, (_CS | _CG)))
179 #define ispunct(c) (__isCClass( (int)c, (_CP)))
180 #define isspace(c) (__isCClass( (int)c, (_CW)))
181 #define isupper(c) (__isCClass( (int)c, (_CU)))
182 #define isxdigit(c) (__isCClass( (int)c, (_CD | _CX)))
183 #define tolower(c) (__toLower((int)c))
184 #define toupper(c) (__toUpper((int)c))
185 #endif /* NO_CTYPE_MACROS */
186
187 #endif /* _CTYPE_H */