123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #ifndef _CTYPE_H
- #define _CTYPE_H
-
- /** @file
- *
- * Character types
- *
- */
-
- FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
-
- /**
- * Check if character is a decimal digit
- *
- * @v character ASCII character
- * @ret is_digit Character is a decimal digit
- */
- static inline int isdigit ( int character ) {
-
- return ( ( character >= '0' ) && ( character <= '9' ) );
- }
-
- /**
- * Check if character is a hexadecimal digit
- *
- * @v character ASCII character
- * @ret is_xdigit Character is a hexadecimal digit
- */
- static inline int isxdigit ( int character ) {
-
- return ( ( ( character >= '0' ) && ( character <= '9' ) ) ||
- ( ( character >= 'A' ) && ( character <= 'F' ) ) ||
- ( ( character >= 'a' ) && ( character <= 'f' ) ) );
- }
-
- /**
- * Check if character is an upper-case letter
- *
- * @v character ASCII character
- * @ret is_upper Character is an upper-case letter
- */
- static inline int isupper ( int character ) {
-
- return ( ( character >= 'A' ) && ( character <= 'Z' ) );
- }
-
- /**
- * Check if character is a lower-case letter
- *
- * @v character ASCII character
- * @ret is_lower Character is a lower-case letter
- */
- static inline int islower ( int character ) {
-
- return ( ( character >= 'a' ) && ( character <= 'z' ) );
- }
-
- /**
- * Check if character is alphabetic
- *
- * @v character ASCII character
- * @ret is_alpha Character is alphabetic
- */
- static inline int isalpha ( int character ) {
-
- return ( isupper ( character ) || islower ( character ) );
- }
-
- /**
- * Check if character is alphanumeric
- *
- * @v character ASCII character
- * @ret is_alnum Character is alphanumeric
- */
- static inline int isalnum ( int character ) {
-
- return ( isalpha ( character ) || isdigit ( character ) );
- }
-
- /**
- * Check if character is printable
- *
- * @v character ASCII character
- * @ret is_print Character is printable
- */
- static inline int isprint ( int character ) {
-
- return ( ( character >= ' ' ) && ( character <= '~' ) );
- }
-
- /**
- * Convert character to lower case
- *
- * @v character Character
- * @v character Lower-case character
- */
- static inline int tolower ( int character ) {
-
- return ( isupper ( character ) ?
- ( character - 'A' + 'a' ) : character );
- }
-
- /**
- * Convert character to upper case
- *
- * @v character Character
- * @v character Upper-case character
- */
- static inline int toupper ( int character ) {
-
- return ( islower ( character ) ?
- ( character - 'a' + 'A' ) : character );
- }
-
- extern int isspace ( int character );
-
- #endif /* _CTYPE_H */
|