Subversion Repositories Kolibri OS

Rev

Rev 9811 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef _CTYPE_H_
  2. #define _CTYPE_H_
  3. /*
  4. ** All character classification functions except isascii().
  5. ** Integer argument (c) must be in ASCII range (0-127) for
  6. ** dependable answers.
  7. */
  8.  
  9. #include <stddef.h>
  10.  
  11. #define __ALNUM  1
  12. #define __ALPHA  2
  13. #define __CNTRL  4
  14. #define __DIGIT  8
  15. #define __GRAPH  16
  16. #define __LOWER  32
  17. #define __PRINT  64
  18. #define __PUNCT  128
  19. #define __BLANK  256
  20. #define __UPPER  512
  21. #define __XDIGIT 1024
  22.  
  23. #ifdef _BUILD_LIBC
  24. extern unsigned short __is[129];
  25. #else
  26. extern unsigned short* __is;
  27. #endif
  28.  
  29. #define isalnum(c)  (__is[c + 1] & __ALNUM)  /* 'a'-'z', 'A'-'Z', '0'-'9' */
  30. #define isalpha(c)  (__is[c + 1] & __ALPHA)  /* 'a'-'z', 'A'-'Z' */
  31. #define iscntrl(c)  (__is[c + 1] & __CNTRL)  /* 0-31, 127 */
  32. #define isdigit(c)  (__is[c + 1] & __DIGIT)  /* '0'-'9' */
  33. #define isgraph(c)  (__is[c + 1] & __GRAPH)  /* '!'-'~' */
  34. #define islower(c)  (__is[c + 1] & __LOWER)  /* 'a'-'z' */
  35. #define isprint(c)  (__is[c + 1] & __PRINT)  /* ' '-'~' */
  36. #define ispunct(c)  (__is[c + 1] & __PUNCT)  /* !alnum && !cntrl && !space */
  37. #define isspace(c)  (__is[c + 1] & __BLANK)  /* HT, LF, VT, FF, CR, ' ' */
  38. #define isupper(c)  (__is[c + 1] & __UPPER)  /* 'A'-'Z' */
  39. #define isxdigit(c) (__is[c + 1] & __XDIGIT) /* '0'-'9', 'a'-'f', 'A'-'F' */
  40.  
  41. #define isascii(c) (!((c) & (~0x7f)))
  42. #define toascii(c) ((c)&0x7f)
  43.  
  44. DLLAPI int tolower(int c);
  45. DLLAPI int toupper(int c);
  46.  
  47. #endif
  48.