1/** @file
2  Single-byte character classification, 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 at least one printing position on an output
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 - 2011, 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.
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#ifndef _CTYPE_H
28#define _CTYPE_H
29#include  <sys/EfiCdefs.h>
30#include  <sys/_ctype.h>
31
32__BEGIN_DECLS
33// Declarations for the classification Functions
34
35/** The isalnum function tests for any character for which isalpha or isdigit
36    is true.
37
38    @param[in]    c   The character to be tested.
39
40    @return   Returns nonzero (true) if and only if the value of the parameter c
41              can be classified as specified in the description of the function.
42**/
43int isalnum(int c);
44
45/** The isalpha function tests for any character for which isupper or islower
46    is true, or any character that is one of a locale-specific set of
47    alphabetic characters for which none of iscntrl, isdigit, ispunct, or
48    isspace is true. In the "C" locale, isalpha returns true only for the
49    characters for which isupper or islower is true.
50
51    @param[in]    c   The character to be tested.
52
53    @return   Returns nonzero (true) if and only if the value of the parameter c
54              can be classified as specified in the description of the function.
55**/
56int isalpha(int c);
57
58/** The isblank function tests that a character is a white-space character that results
59    in a number of space (' ') characters being sent to the output device.  In the C locale
60    this is either ' ' or '\t'.
61
62    @param[in]    c   The character to be tested.
63
64    @return   Returns nonzero (true) if and only if the value of the parameter c
65              can be classified as specified in the description of the function.
66**/
67int isblank(int);
68
69/** The iscntrl function tests for any control character.
70
71    @param[in]    c   The character to be tested.
72
73    @return   Returns nonzero (true) if and only if the value of the parameter c
74              can be classified as specified in the description of the function.
75**/
76int iscntrl(int c);
77
78/** The isdigit function tests for any decimal-digit character.
79
80    @param[in]    c   The character to be tested.
81
82    @return   Returns nonzero (true) if and only if the value of the parameter c
83              can be classified as specified in the description of the function.
84**/
85int isdigit(int c);
86
87/** The isgraph function tests for any printing character except space (' ').
88
89    @param[in]    c   The character to be tested.
90
91    @return   Returns nonzero (true) if and only if the value of the parameter c
92              can be classified as specified in the description of the function.
93**/
94int isgraph(int c);
95
96/** The islower function tests for any character that is a lowercase letter or
97    is one of a locale-specific set of characters for which none of iscntrl,
98    isdigit, ispunct, or isspace is true.  In the "C" locale, islower returns
99    true only for the lowercase letters.
100
101    @param[in]    c   The character to be tested.
102
103    @return   Returns nonzero (true) if and only if the value of the parameter c
104              can be classified as specified in the description of the function.
105**/
106int islower(int c);
107
108/** The isprint function tests for any printing character including space (' ').
109
110    @param[in]    c   The character to be tested.
111
112    @return   Returns nonzero (true) if and only if the value of the parameter c
113              can be classified as specified in the description of the function.
114**/
115int isprint(int c);
116
117/** The ispunct function tests for any printing character that is one of a
118    locale-specific set of punctuation characters for which neither isspace nor
119    isalnum is true. In the "C" locale, ispunct returns true for every printing
120    character for which neither isspace nor isalnum is true.
121
122    @param[in]    c   The character to be tested.
123
124    @return   Returns nonzero (true) if and only if the value of the parameter c
125              can be classified as specified in the description of the function.
126**/
127int ispunct(int c);
128
129/** The isspace function tests for any character that is a standard white-space
130    character or is one of a locale-specific set of characters for which
131    isalnum is false. The standard white-space characters are the following:
132    space (' '), form feed ('\f'), new-line ('\n'), carriage return ('\r'),
133    horizontal tab ('\t'), and vertical tab ('\v'). In the "C" locale, isspace
134    returns true only for the standard white-space characters.
135
136    @param[in]    c   The character to be tested.
137
138    @return   Returns nonzero (true) if and only if the value of the parameter c
139              can be classified as specified in the description of the function.
140**/
141int isspace(int c);
142
143/** The isupper function tests for any character that is an uppercase letter or
144    is one of a locale-specific set of characters for which none of iscntrl,
145    isdigit, ispunct, or isspace is true. In the "C" locale, isupper returns
146    true only for the uppercase letters.
147
148    @param[in]    c   The character to be tested.
149
150    @return   Returns nonzero (true) if and only if the value of the parameter c
151              can be classified as specified in the description of the function.
152**/
153int isupper(int c);
154
155/** The isxdigit function tests for any hexadecimal-digit character.
156
157    @param[in]    c   The character to be tested.
158
159    @return   Returns nonzero (true) if and only if the value of the parameter c
160              can be classified as specified in the description of the function.
161**/
162int isxdigit(int c);
163
164/** The isascii function tests that a character is one of the 128 7-bit ASCII characters.
165    This function is not part of the C standard, but is commonly used.
166
167    @param[in]    c   The character to be tested.
168
169    @return   Returns nonzero (true) if and only if the value of the parameter c
170              can be classified as specified in the description of the function.
171**/
172int isascii(int c);
173
174/** Test whether a character is one of the characters used as a separator
175    between directory elements in a path.
176
177    Characters are '/', '\\'
178
179    This non-standard function is unique to this implementation.
180
181    @param[in]    c   The character to be tested.
182
183    @return   Returns nonzero (true) if and only if the value of the parameter c
184              can be classified as specified in the description of the function.
185**/
186int isDirSep(int c);
187
188/** The tolower function converts an uppercase letter to a corresponding
189    lowercase letter.
190
191    @param[in]    c   The character to be converted.
192
193    @return   If the argument is a character for which isupper is true and
194              there are one or more corresponding characters, as specified by
195              the current locale, for which islower is true, the tolower
196              function returns one of the corresponding characters (always the
197              same one for any given locale); otherwise, the argument is
198              returned unchanged.
199**/
200int tolower(int c);
201
202/** The toupper function converts a lowercase letter to a corresponding
203    uppercase letter.
204
205    @param[in]    c   The character to be converted.
206
207    @return   If the argument is a character for which islower is true and
208              there are one or more corresponding characters, as specified by
209              the current locale, for which isupper is true, the toupper
210              function returns one of the corresponding characters (always the
211              same one for any given locale); otherwise, the argument is
212              returned unchanged.
213**/
214int toupper(int c);
215
216__END_DECLS
217
218/** Character Classification Macros.
219    Undefine individually or define NO_CTYPE_MACROS, before including <ctype.h>,
220    in order to use the Function version of the character classification macros.
221@{
222**/
223#ifndef NO_CTYPE_MACROS
224  #define isalnum(c)    (__isCClass( (int)c, (_CD | _CU | _CL | _XA)))
225  #define isalpha(c)    (__isCClass( (int)c, (_CU | _CL | _XA)))
226  #define iscntrl(c)    (__isCClass( (int)c, (_CC)))
227  #define isdigit(c)    (__isCClass( (int)c, (_CD)))
228  #define isgraph(c)    (__isCClass( (int)c, (_CG)))
229  #define islower(c)    (__isCClass( (int)c, (_CL)))
230  #define isprint(c)    (__isCClass( (int)c, (_CS | _CG)))
231  #define ispunct(c)    (__isCClass( (int)c, (_CP)))
232  #define isspace(c)    (__isCClass( (int)c, (_CW)))
233  #define isupper(c)    (__isCClass( (int)c, (_CU)))
234  #define isxdigit(c)   (__isCClass( (int)c, (_CD | _CX)))
235  #define isDirSep(c)   (__isCClass( (int)c, (_C0)))
236  #define tolower(c)    (__toLower((int)c))
237  #define toupper(c)    (__toUpper((int)c))
238#endif  /* NO_CTYPE_MACROS */
239///@}
240
241#endif  /* _CTYPE_H */
242