iPXE
ctype.h
Go to the documentation of this file.
1 #ifndef _CTYPE_H
2 #define _CTYPE_H
3 
4 /** @file
5  *
6  * Character types
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 /**
13  * Check if character is a decimal digit
14  *
15  * @v character ASCII character
16  * @ret is_digit Character is a decimal digit
17  */
18 static inline int isdigit ( int character ) {
19 
20  return ( ( character >= '0' ) && ( character <= '9' ) );
21 }
22 
23 /**
24  * Check if character is a hexadecimal digit
25  *
26  * @v character ASCII character
27  * @ret is_xdigit Character is a hexadecimal digit
28  */
29 static inline int isxdigit ( int character ) {
30 
31  return ( ( ( character >= '0' ) && ( character <= '9' ) ) ||
32  ( ( character >= 'A' ) && ( character <= 'F' ) ) ||
33  ( ( character >= 'a' ) && ( character <= 'f' ) ) );
34 }
35 
36 /**
37  * Check if character is an upper-case letter
38  *
39  * @v character ASCII character
40  * @ret is_upper Character is an upper-case letter
41  */
42 static inline int isupper ( int character ) {
43 
44  return ( ( character >= 'A' ) && ( character <= 'Z' ) );
45 }
46 
47 /**
48  * Check if character is a lower-case letter
49  *
50  * @v character ASCII character
51  * @ret is_lower Character is a lower-case letter
52  */
53 static inline int islower ( int character ) {
54 
55  return ( ( character >= 'a' ) && ( character <= 'z' ) );
56 }
57 
58 /**
59  * Check if character is alphabetic
60  *
61  * @v character ASCII character
62  * @ret is_alpha Character is alphabetic
63  */
64 static inline int isalpha ( int character ) {
65 
66  return ( isupper ( character ) || islower ( character ) );
67 }
68 
69 /**
70  * Check if character is alphanumeric
71  *
72  * @v character ASCII character
73  * @ret is_alnum Character is alphanumeric
74  */
75 static inline int isalnum ( int character ) {
76 
77  return ( isalpha ( character ) || isdigit ( character ) );
78 }
79 
80 /**
81  * Check if character is printable
82  *
83  * @v character ASCII character
84  * @ret is_print Character is printable
85  */
86 static inline int isprint ( int character ) {
87 
88  return ( ( character >= ' ' ) && ( character <= '~' ) );
89 }
90 
91 /**
92  * Convert character to lower case
93  *
94  * @v character Character
95  * @v character Lower-case character
96  */
97 static inline int tolower ( int character ) {
98 
99  return ( isupper ( character ) ?
100  ( character - 'A' + 'a' ) : character );
101 }
102 
103 /**
104  * Convert character to upper case
105  *
106  * @v character Character
107  * @v character Upper-case character
108  */
109 static inline int toupper ( int character ) {
110 
111  return ( islower ( character ) ?
112  ( character - 'a' + 'A' ) : character );
113 }
114 
115 extern int isspace ( int character );
116 
117 #endif /* _CTYPE_H */
static int isxdigit(int character)
Check if character is a hexadecimal digit.
Definition: ctype.h:29
static int isalpha(int character)
Check if character is alphabetic.
Definition: ctype.h:64
static int isprint(int character)
Check if character is printable.
Definition: ctype.h:86
static int toupper(int character)
Convert character to upper case.
Definition: ctype.h:109
static int isdigit(int character)
Check if character is a decimal digit.
Definition: ctype.h:18
static int islower(int character)
Check if character is a lower-case letter.
Definition: ctype.h:53
static int isalnum(int character)
Check if character is alphanumeric.
Definition: ctype.h:75
static int tolower(int character)
Convert character to lower case.
Definition: ctype.h:97
int isspace(int character)
Check to see if character is a space.
Definition: ctype.c:41
static int isupper(int character)
Check if character is an upper-case letter.
Definition: ctype.h:42
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)