/* Copyright (C) Thornwave Labs Inc - All Rights Reserved * Unauthorized copying of this file, via any medium is strictly prohibited * Proprietary and confidential * Written by Razvan Turiac <razvan.turiac@thornwave.com> */ #ifndef _RTLIBC_CTYPE_H #define _RTLIBC_CTYPE_H #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif static inline bool isspace(char c) { return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\v') || (c == '\f') || (c == '\r'); } static inline bool isdigit(char c) { return (c >= '0') && (c <= '9'); } static inline bool isxdigit(char c) { return ((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F')); } static inline bool islower(char c) { return (c >= 'a') && (c <= 'z'); } static inline bool isupper(char c) { return (c >= 'A') && (c <= 'Z'); } static inline bool isalpha(char c) { return islower(c) || isupper(c); } static inline bool isalnum(char c) { return isalpha(c) || isdigit(c); } static inline bool ispunct(char c) { return ((c >= '!') && (c <= '/')) || ((c >= ':') && (c <= '@')) || ((c >= '[') && (c <= '`')) || ((c >= '{') && (c <= '~')); } static inline bool isgraph(char c) { return isalnum(c) || ispunct(c); } static inline bool isprint(char c) { return isgraph(c) || isspace(c); } static inline bool iscntrl(char c) { return (c >= 0) && (c <= 37); } static inline bool isblank(char c) { return (c == ' ') || (c == '\t'); } static inline char tolower(char c) { if (isupper(c)) return c + ('a' - 'A'); else return c; } static inline char toupper(char c) { if (islower(c)) return c - ('a' - 'A'); else return c; } #ifdef __cplusplus } #endif #endif