home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / famapi.zip / INCLUDE.ZIP / CTYPE.H < prev    next >
C/C++ Source or Header  |  1992-12-19  |  3KB  |  85 lines

  1. //
  2. //      **************************************************************
  3. //       JdeBP C++ Library Routines      General Public Licence v1.00
  4. //          Copyright (c) 1991,1992  Jonathan de Boyne Pollard
  5. //      **************************************************************
  6. //
  7. //  CHARACTER TYPE FUNCTIONS (ANSI)
  8. //
  9.  
  10. #if !defined(___STDDEF_H_INCLUDED)
  11. #include <_stddef.h>
  12. #endif
  13.  
  14. #ifndef __CTYPE_H_INCLUDED
  15.  
  16. #define _CT_UPPER   0x0001U /* 'A' to 'Z' (variable in non-"C" locale)  */
  17. #define _CT_LOWER   0x0002U /* 'a' to 'z' (variable in non-"C" locale)  */
  18. #define _CT_ALPHA   0x0004U /* Any other alphabetic (non-"C" locales)   */
  19. #define _CT_PUNCT   0x0008U /* Punctuation chars    (variable)          */
  20. #define _CT_CNTRL   0x0010U /* Control characters   (variable)          */
  21. #define _CT_MCTRL   0x0020U /* Motion control characters FF NL CR VT HT */
  22. #define _CT_SPACE   0x0040U /* The ' ' char                             */
  23. #define _CT_WHITE   0x0080U /* Other whitespace (variable in non"C")    */
  24. #define _CT_DIGIT   0x0100U /* '0' to '9'                               */
  25. #define _CT_HEX     0x0200U /* 'A' to 'F' and 'a' to 'f'                */
  26.  
  27. extern "C" {
  28.  
  29. int     _CDECL  isalnum     (int);
  30. int     _CDECL  isalpha     (int);
  31. int     _CDECL  iscntrl     (int);
  32. int     _CDECL  isdigit     (int);
  33. int     _CDECL  isgraph     (int);
  34. int     _CDECL  islower     (int);
  35. int     _CDECL  isprint     (int);
  36. int     _CDECL  ispunct     (int);
  37. int     _CDECL  isspace     (int);
  38. int     _CDECL  isupper     (int);
  39. int     _CDECL  isxdigit    (int);
  40. int     _CDECL  tolower     (int);
  41. int     _CDECL  toupper     (int);
  42.  
  43. #if _SYSTEM_V_SOURCE > 0
  44. int     _CDECL  _tolower    (int);
  45. int     _CDECL  _toupper    (int);
  46. int     _CDECL  isascii     (int);
  47. int     _CDECL  toascii     (int);
  48. #endif
  49.  
  50. }
  51.  
  52. /*
  53.  * Actually, these point to one beyond the start of the table to make
  54.  * the macro overrides simpler and faster, even when dealing with EOF (-1).
  55.  */
  56. extern unsigned short * _CDECL _Ctype, * _CDECL _Cupper, * _CDECL _Clower;
  57.  
  58. #define isdigit(c)  (_Ctype[(int)(c)] & _CT_DIGIT)
  59. #define ispunct(c)  (_Ctype[(int)(c)] & _CT_PUNCT)
  60. #define isxdigit(c) (_Ctype[(int)(c)] & (_CT_DIGIT|_CT_HEX))
  61.  
  62. #define isalpha(c)  (_Ctype[(int)(c)] & (_CT_ALPHA|_CT_UPPER|_CT_LOWER))
  63. #define isalnum(c)  (_Ctype[(int)(c)] & (_CT_ALPHA|_CT_UPPER|_CT_LOWER|_CT_DIGIT))
  64. #define isgraph(c)  (_Ctype[(int)(c)] & (_CT_ALPHA|_CT_UPPER|_CT_LOWER|_CT_DIGIT|_CT_PUNCT))
  65. #define isprint(c)  (_Ctype[(int)(c)] & (_CT_ALPHA|_CT_UPPER|_CT_LOWER|_CT_DIGIT|_CT_PUNCT|_CT_SPACE))
  66.  
  67. #define iscntrl(c)  (_Ctype[(int)(c)] & (_CT_MCTRL|_CT_CNTRL))
  68. #define isspace(c)  (_Ctype[(int)(c)] & (_CT_MCTRL|_CT_SPACE|_CT_WHITE))
  69.  
  70. #define islower(c)  (_Ctype[(int)(c)] & _CT_LOWER)
  71. #define isupper(c)  (_Ctype[(int)(c)] & _CT_UPPER)
  72.  
  73. #define tolower(c)  (_Clower[(int)(c)])
  74. #define toupper(c)  (_Cupper[(int)(c)])
  75.  
  76. #if _SYSTEM_V_SOURCE > 0
  77. #define isascii(c)  ((unsigned)(c) < 0x80U)
  78. #define toascii(c)  ((unsigned)(c) & 0x7fU)
  79. #define _tolower(c) ((c)-'A'+'a')
  80. #define _toupper(c) ((c)-'a'+'A')
  81. #endif
  82.  
  83. #define __CTYPE_H_INCLUDED
  84. #endif
  85.