ctype.h 902 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Minimal freestanding ctype.h for ring-3 commands. */
  2. #ifndef LIBC_CTYPE_H
  3. #define LIBC_CTYPE_H
  4. static inline int isdigit(int c)
  5. {
  6. return c >= '0' && c <= '9';
  7. }
  8. static inline int isxdigit(int c)
  9. {
  10. return (c >= '0' && c <= '9') ||
  11. (c >= 'a' && c <= 'f') ||
  12. (c >= 'A' && c <= 'F');
  13. }
  14. static inline int isupper(int c)
  15. {
  16. return c >= 'A' && c <= 'Z';
  17. }
  18. static inline int islower(int c)
  19. {
  20. return c >= 'a' && c <= 'z';
  21. }
  22. static inline int isalpha(int c)
  23. {
  24. return isupper(c) || islower(c);
  25. }
  26. static inline int isalnum(int c)
  27. {
  28. return isalpha(c) || isdigit(c);
  29. }
  30. static inline int isspace(int c)
  31. {
  32. return c == ' ' || c == '\t' || c == '\n' ||
  33. c == '\v' || c == '\f' || c == '\r';
  34. }
  35. static inline int toupper(int c)
  36. {
  37. return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c;
  38. }
  39. static inline int tolower(int c)
  40. {
  41. return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c;
  42. }
  43. #endif