iPXE
ctype.h
Go to the documentation of this file.
00001 #ifndef _CTYPE_H
00002 #define _CTYPE_H
00003 
00004 /** @file
00005  *
00006  * Character types
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 /**
00013  * Check if character is a decimal digit
00014  *
00015  * @v character         ASCII character
00016  * @ret is_digit        Character is a decimal digit
00017  */
00018 static inline int isdigit ( int character ) {
00019 
00020         return ( ( character >= '0' ) && ( character <= '9' ) );
00021 }
00022 
00023 /**
00024  * Check if character is a hexadecimal digit
00025  *
00026  * @v character         ASCII character
00027  * @ret is_xdigit       Character is a hexadecimal digit
00028  */
00029 static inline int isxdigit ( int character ) {
00030 
00031         return ( ( ( character >= '0' ) && ( character <= '9' ) ) ||
00032                  ( ( character >= 'A' ) && ( character <= 'F' ) ) ||
00033                  ( ( character >= 'a' ) && ( character <= 'f' ) ) );
00034 }
00035 
00036 /**
00037  * Check if character is an upper-case letter
00038  *
00039  * @v character         ASCII character
00040  * @ret is_upper        Character is an upper-case letter
00041  */
00042 static inline int isupper ( int character ) {
00043 
00044         return ( ( character >= 'A' ) && ( character <= 'Z' ) );
00045 }
00046 
00047 /**
00048  * Check if character is a lower-case letter
00049  *
00050  * @v character         ASCII character
00051  * @ret is_lower        Character is a lower-case letter
00052  */
00053 static inline int islower ( int character ) {
00054 
00055         return ( ( character >= 'a' ) && ( character <= 'z' ) );
00056 }
00057 
00058 /**
00059  * Check if character is alphabetic
00060  *
00061  * @v character         ASCII character
00062  * @ret is_alpha        Character is alphabetic
00063  */
00064 static inline int isalpha ( int character ) {
00065 
00066         return ( isupper ( character ) || islower ( character ) );
00067 }
00068 
00069 /**
00070  * Check if character is alphanumeric
00071  *
00072  * @v character         ASCII character
00073  * @ret is_alnum        Character is alphanumeric
00074  */
00075 static inline int isalnum ( int character ) {
00076 
00077         return ( isalpha ( character ) || isdigit ( character ) );
00078 }
00079 
00080 /**
00081  * Check if character is printable
00082  *
00083  * @v character         ASCII character
00084  * @ret is_print        Character is printable
00085  */
00086 static inline int isprint ( int character ) {
00087 
00088         return ( ( character >= ' ' ) && ( character <= '~' ) );
00089 }
00090 
00091 /**
00092  * Convert character to lower case
00093  *
00094  * @v character         Character
00095  * @v character         Lower-case character
00096  */
00097 static inline int tolower ( int character ) {
00098 
00099         return ( isupper ( character ) ?
00100                  ( character - 'A' + 'a' ) : character );
00101 }
00102 
00103 /**
00104  * Convert character to upper case
00105  *
00106  * @v character         Character
00107  * @v character         Upper-case character
00108  */
00109 static inline int toupper ( int character ) {
00110 
00111         return ( islower ( character ) ?
00112                  ( character - 'a' + 'A' ) : character );
00113 }
00114 
00115 extern int isspace ( int character );
00116 
00117 #endif /* _CTYPE_H */