ctype.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* ctype.h
  2. * Character classification and conversion */
  3. #ifndef __CTYPE_H
  4. #define __CTYPE_H
  5. #ifdef USE_CTYPE_C_FUNCTIONS
  6. /* function prototpes */
  7. extern int isalnum(int c);
  8. extern int isalpha(int c);
  9. extern int isascii(int c);
  10. extern int iscntrl(int c);
  11. extern int isdigit(int c);
  12. extern int isgraph(int c);
  13. extern int islower(int c);
  14. extern int isprint(int c);
  15. extern int ispunct(int c);
  16. extern int isspace(int c);
  17. extern int isupper(int c);
  18. extern int isxdigit(int c);
  19. extern int isxlower(int c);
  20. extern int isxupper(int c);
  21. extern int toascii(int c);
  22. extern int tolower(int c);
  23. extern int toupper(int c);
  24. #else
  25. /* macro definitions */
  26. #define isalnum(c) (isalpha(c) || isdigit(c))
  27. #define isalpha(c) (isupper(c) || islower(c))
  28. #define isascii(c) (c > 0 && c <= 0x7f)
  29. #define iscntrl(c) ((c > 0) && ((c <= 0x1F) || (c == 0x7f)))
  30. #define isdigit(c) (c >= '0' && c <= '9')
  31. #define isgraph(c) (c != ' ' && isprint(c))
  32. #define islower(c) (c >= 'a' && c <= 'z')
  33. #define isprint(c) (c >= ' ' && c <= '~')
  34. #define ispunct(c) ((c > ' ' && c <= '~') && !isalnum(c))
  35. #define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||\
  36. c == '\t' || c == '\v')
  37. #define isupper(c) (c >= 'A' && c <= 'Z')
  38. #define isxdigit(c) (isxupper(c) || isxlower(c))
  39. #define isxlower(c) (isdigit(c) || (c >= 'a' && c <= 'f'))
  40. #define isxupper(c) (isdigit(c) || (c >= 'A' && c <= 'F'))
  41. #define toascii(c) (c & 0x7f)
  42. #define tolower(c) (isupper(c) ? ( c - 'A' + 'a') : (c))
  43. #define toupper(c) (islower(c) ? (c - 'a' + 'A') : (c))
  44. #endif
  45. #endif /* __CTYPE_H */