ctype.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #ifndef __CTYPE
  10. #define __CTYPE
  11. #pragma lib "/$M/lib/ape/libap.a"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. extern int isalnum(int);
  16. extern int isalpha(int);
  17. extern int iscntrl(int);
  18. extern int isdigit(int);
  19. extern int isgraph(int);
  20. extern int islower(int);
  21. extern int isprint(int);
  22. extern int ispunct(int);
  23. extern int isspace(int);
  24. extern int isupper(int);
  25. extern int isxdigit(int);
  26. extern int tolower(int);
  27. extern int toupper(int);
  28. #ifdef __cplusplus
  29. }
  30. #endif
  31. enum
  32. {
  33. _ISupper = 01, /* UPPERCASE. */
  34. _ISlower = 02, /* lowercase. */
  35. _ISdigit = 04, /* Numeric. */
  36. _ISspace = 010, /* Whitespace. */
  37. _ISpunct = 020, /* Punctuation. */
  38. _IScntrl = 040, /* Control character. */
  39. _ISblank = 0100, /* Blank (usually SPC and TAB). */
  40. _ISxdigit = 0200, /* Hexadecimal numeric. */
  41. };
  42. extern unsigned char _ctype[];
  43. #define isalnum(c) (_ctype[(unsigned char)(c)]&(_ISupper|_ISlower|_ISdigit))
  44. #define isalpha(c) (_ctype[(unsigned char)(c)]&(_ISupper|_ISlower))
  45. #define iscntrl(c) (_ctype[(unsigned char)(c)]&_IScntrl)
  46. #define isdigit(c) (_ctype[(unsigned char)(c)]&_ISdigit)
  47. #define isgraph(c) (_ctype[(unsigned char)(c)]&(_ISpunct|_ISupper|_ISlower|_ISdigit))
  48. #define islower(c) (_ctype[(unsigned char)(c)]&_ISlower)
  49. #define isprint(c) (_ctype[(unsigned char)(c)]&(_ISpunct|_ISupper|_ISlower|_ISdigit|_ISblank))
  50. #define ispunct(c) (_ctype[(unsigned char)(c)]&_ISpunct)
  51. #define isspace(c) (_ctype[(unsigned char)(c)]&_ISspace)
  52. #define isupper(c) (_ctype[(unsigned char)(c)]&_ISupper)
  53. #define isxdigit(c) (_ctype[(unsigned char)(c)]&_ISxdigit)
  54. #ifdef _BSD_EXTENSION
  55. #define isascii(c) (((unsigned int)(c))<0x80)
  56. #endif
  57. #endif /* __CTYPE */