home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Languages / Quick C 2.0 / INCLUDE / CTYPE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1988-12-05  |  2.1 KB  |  67 lines

  1. /***
  2. *ctype.h - character conversion macros and ctype macros
  3. *
  4. *    Copyright (c) 1985-1989, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *    Defines macros for character classification/conversion.
  8. *    [ANSI/System V]
  9. *
  10. ****/
  11.  
  12.  
  13. #ifndef NO_EXT_KEYS    /* extensions enabled */
  14.     #define _CDECL    cdecl
  15.     #define _NEAR    near
  16. #else /* extensions not enabled */
  17.     #define _CDECL
  18.     #define _NEAR
  19. #endif /* NO_EXT_KEYS */
  20.  
  21. /*
  22.  * This declaration allows the user access to the ctype look-up
  23.  * array _ctype defined in ctype.obj by simply including ctype.h
  24.  */
  25.  
  26. extern unsigned char _NEAR _CDECL _ctype[];
  27.  
  28. /* set bit masks for the possible character types */
  29.  
  30. #define _UPPER        0x1    /* upper case letter */
  31. #define _LOWER        0x2    /* lower case letter */
  32. #define _DIGIT        0x4    /* digit[0-9] */
  33. #define _SPACE        0x8    /* tab, carriage return, newline, */
  34.                 /* vertical tab or form feed */
  35. #define _PUNCT        0x10    /* punctuation character */
  36. #define _CONTROL    0x20    /* control character */
  37. #define _BLANK        0x40    /* space char */
  38. #define _HEX        0x80    /* hexadecimal digit */
  39.  
  40. /* the character classification macro definitions */
  41.  
  42. #define isalpha(c)        ( (_ctype+1)[c] & (_UPPER|_LOWER) )
  43. #define isupper(c)        ( (_ctype+1)[c] & _UPPER )
  44. #define islower(c)        ( (_ctype+1)[c] & _LOWER )
  45. #define isdigit(c)        ( (_ctype+1)[c] & _DIGIT )
  46. #define isxdigit(c)        ( (_ctype+1)[c] & _HEX )
  47. #define isspace(c)        ( (_ctype+1)[c] & _SPACE )
  48. #define ispunct(c)        ( (_ctype+1)[c] & _PUNCT )
  49. #define isalnum(c)        ( (_ctype+1)[c] & (_UPPER|_LOWER|_DIGIT) )
  50. #define isprint(c)        ( (_ctype+1)[c] & (_BLANK|_PUNCT|_UPPER|_LOWER|_DIGIT) )
  51. #define isgraph(c)        ( (_ctype+1)[c] & (_PUNCT|_UPPER|_LOWER|_DIGIT) )
  52. #define iscntrl(c)        ( (_ctype+1)[c] & _CONTROL )
  53.  
  54. #define toupper(c)        ( (islower(c)) ? _toupper(c) : (c) )
  55. #define tolower(c)        ( (isupper(c)) ? _tolower(c) : (c) )
  56.  
  57. #define _tolower(c)        ( (c)-'A'+'a' )
  58. #define _toupper(c)        ( (c)-'a'+'A' )
  59.  
  60. #define isascii(c)        ( (unsigned)(c) < 0x80 )
  61. #define toascii(c)        ( (c) & 0x7f )
  62.  
  63. /* MS C version 2.0 extended ctype macros */
  64.  
  65. #define iscsymf(c)        (isalpha(c) || ((c) == '_'))
  66. #define iscsym(c)        (isalnum(c) || ((c) == '_'))
  67.