home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / 0 next >
Encoding:
Text File  |  1992-12-09  |  3.0 KB  |  112 lines

  1. /*
  2.  *   ctype.h -- ANSI 
  3.  *
  4.  *   Functions for handling characters.
  5.  *
  6.  *           Copyright (c) 1990, 1991, 1992, MetaWare Incorporated
  7.  */
  8.  
  9. #ifndef    _CTYPE_H
  10. #define    _CTYPE_H
  11. #pragma push_align_members(64);
  12.  
  13. #ifdef __CPLUSPLUS__
  14. extern "C" {
  15. #endif
  16.  
  17. #define    _UPPER 1
  18. #define    _LOWER 2
  19. #define    _NUMBER    4
  20. #define    _DIGIT    4
  21. #define    _SPACE    8
  22. #define    _PUNCT    16
  23. #define    _CONTROL 32
  24. #define    _CNTRL    32
  25. #if _AIX || _ATT || _XNX || _ATT4 || _SOL
  26. #define    _BLANK    64
  27. #define    _HEX    128
  28. #else
  29. #define    _HEX    64
  30. #define    _BLANK    128
  31. #endif
  32.  
  33. #if _IBMESA
  34.     /* Structure info derived from localedef.h. */
  35.     extern struct { 
  36.         char a,b; short c,d,e; void *f; 
  37.         struct { 
  38.             short a,b,c,d,e,f; char g; int h; void *i; int j;
  39.             unsigned short *lc_ctype;    /* At offset 28. */
  40.             } *lc_chrtbl;
  41.         } *_locp;
  42.     #define _CTYPE(c) ((_locp->lc_chrtbl->lc_ctype+1)[c])
  43. #elif _AIX || _XNX || _ATT || _ATT4 || _SOL
  44.     #if __ATTSTDC /* AT&T ANSI-std vs. non-ANSI std. ctype.    */
  45.     #define    _CTYPE(c)    ((__ctype+1)[(c)])
  46.      extern const unsigned char __ctype[];
  47.     #else
  48.     #define    _CTYPE(c)    ((_ctype+1)[(c)])
  49.     extern const unsigned char _ctype[];
  50.     #endif    /* __ATTSTDC */
  51. #else
  52.     #define    _CTYPE(c)    ((_ctype_+1)[(c)])
  53.     extern const unsigned char _ctype_[];
  54. #endif    /* _AIX    || _XNX    || _ATT    */
  55.  
  56. extern    int    isupper(int __c);
  57. extern    int    islower(int __c);
  58. extern    int    isalpha(int __c);
  59. extern    int    isdigit(int __c);
  60. extern    int    isxdigit(int    __c);
  61. extern    int    isspace(int __c);
  62. extern    int    ispunct(int __c);
  63. extern    int    isalnum(int __c);
  64. extern    int    isgraph(int __c);
  65. extern    int    isprint(int __c);
  66. extern    int    iscntrl(int __c);
  67. extern    int    toupper(int __c);
  68. extern    int    tolower(int __c);
  69. extern    int    _isascii(int    __c);
  70. extern    int    _isodigit(int __c);
  71. extern    int    _toupper(int    __c);
  72. extern    int    _tolower(int    __c);
  73.  
  74. #define    isupper(c)    (_CTYPE(c) &    _UPPER)
  75. #define    islower(c)    (_CTYPE(c) &    _LOWER)
  76. #define    isalpha(c)    (_CTYPE(c) &    (_UPPER    | _LOWER))
  77. #define    isdigit(c)    (_CTYPE(c) &    _NUMBER)
  78. #define    isxdigit(c)    (_CTYPE(c) &     (_NUMBER |    _HEX))
  79. #define    isspace(c)    (_CTYPE(c) &    _SPACE)
  80. #define    ispunct(c)    (_CTYPE(c) &    _PUNCT)
  81. #define    isalnum(c)    (_CTYPE(c) &    (_UPPER|_LOWER|_NUMBER))
  82. #define    isgraph(c)    (_CTYPE(c) &    (_UPPER    | _LOWER | _NUMBER | _PUNCT))
  83. #define    isprint(c)    (_CTYPE(c) &     (_UPPER |_LOWER |_NUMBER |_PUNCT |_BLANK))
  84. #define    iscntrl(c)    (_CTYPE(c) &    _CNTRL)
  85.  
  86. #if __HIGHC__
  87. #define    _toupper(c)    ((c) - 'a' + 'A')
  88. #define    _tolower(c)    ((c) - 'A' + 'a')
  89. #define    isascii(c)    ((unsigned)(c) <= 0177)
  90. #define    toascii(c)    ((unsigned)(c) & 0177)
  91. #endif
  92.  
  93. #ifdef _K_AND_R
  94. #define    _isascii(c)    ((unsigned)(c) <= 0177)
  95. #define    isascii(c)    ((unsigned)(c) <= 0177)
  96. #define    toascii(c)    ((unsigned)(c) & 0177)
  97. #endif
  98.  
  99. #if _MSDOS
  100. #define    _isodigit(c)    ((unsigned int)(((c)&0xFF) - '0') <= 7)
  101. #if __HIGHC__
  102. #define    toupper(c)    (islower(c) ? _toupper(c) : (c))
  103. #define    tolower(c)    (isupper(c) ? _tolower(c) : (c))
  104. #endif
  105. #endif
  106.  
  107. #ifdef __CPLUSPLUS__
  108. }
  109. #endif
  110. #pragma pop_align_members();
  111. #endif /* _CTYPE_H */
  112.