home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / inc.pak / CTYPE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  6.0 KB  |  249 lines

  1. /*  ctype.h
  2.  
  3.     Defines the locale aware ctype macros.
  4.  
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 6.5
  9.  *
  10.  *      Copyright (c) 1987, 1994 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14.  
  15. #ifndef __CTYPE_H
  16. #define __CTYPE_H
  17.  
  18. #if !defined(___DEFS_H)
  19. #include <_defs.h>
  20. #endif
  21.  
  22.  
  23. #if !defined(RC_INVOKED)
  24.  
  25. #if defined(__STDC__)
  26. #pragma warn -nak
  27. #endif
  28.  
  29. #endif  /* !RC_INVOKED */
  30.  
  31.  
  32. #if !defined(__FLAT__)
  33.  
  34. #ifndef _SIZE_T
  35. #define _SIZE_T
  36. typedef unsigned size_t;
  37. #endif
  38.  
  39. extern unsigned char _Cdecl _ctype[ 257 ];
  40.  
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. int _CType isalnum (int __c);
  45. int _CType isalpha (int __c);
  46. int _CType iscntrl (int __c);
  47. int _CType isdigit (int __c);
  48. int _CType isgraph (int __c);
  49. int _CType islower (int __c);
  50. int _CType isprint (int __c);
  51. int _CType ispunct (int __c);
  52. int _CType isspace (int __c);
  53. int _CType isupper (int __c);
  54. int _CType isxdigit(int __c);
  55. int _CType isascii (int __c);
  56.  
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60.  
  61.  
  62. /* character classes */
  63.  
  64. #define _IS_SP     1           /* space */
  65. #define _IS_DIG    2           /* digit */
  66. #define _IS_UPP    4           /* upper case */
  67. #define _IS_LOW    8           /* lower case */
  68. #define _IS_HEX   16           /* [0..9] or [A-F] or [a-f] */
  69. #define _IS_CTL   32           /* control */
  70. #define _IS_PUN   64           /* punctuation */
  71. #define _IS_BLK  128           /* blank */
  72.  
  73. #define _IS_ALPHA    (_IS_UPP | _IS_LOW)
  74. #define _IS_ALNUM    (_IS_DIG | _IS_ALPHA)
  75. #define _IS_GRAPH    (_IS_ALNUM | _IS_HEX | _IS_PUN)
  76.  
  77. #ifndef __USELOCALES__
  78.  
  79. /* C locale character classification macros */
  80.  
  81. #define isalnum(c)   (_ctype[ (c)+1 ] & (_IS_ALNUM))
  82.                      
  83. #define isalpha(c)   (_ctype[ (c)+1 ] & (_IS_ALPHA))
  84.                      
  85. #define iscntrl(c)   (_ctype[ (c)+1 ] & (_IS_CTL))
  86.                      
  87. #define isdigit(c)   (_ctype[ (c)+1 ] & (_IS_DIG))
  88.                      
  89. #define isgraph(c)   (_ctype[ (c)+1 ] & (_IS_GRAPH))
  90.                      
  91. #define islower(c)   (_ctype[ (c)+1 ] & (_IS_LOW))
  92.                      
  93. #define isprint(c)   (_ctype[ (c)+1 ] & (_IS_GRAPH | _IS_BLK))
  94.                      
  95. #define ispunct(c)   (_ctype[ (c)+1 ] & (_IS_PUN))
  96.                      
  97. #define isspace(c)   (_ctype[ (c)+1 ] & (_IS_SP))
  98.                      
  99. #define isupper(c)   (_ctype[ (c)+1 ] & (_IS_UPP))
  100.                      
  101. #define isxdigit(c)  (_ctype[ (c)+1 ] & (_IS_HEX))
  102.  
  103. #endif /* __USELOCALES__ */
  104.  
  105. #define isascii(c)  ((unsigned)(c) < 128)
  106. #define toascii(c)  ((c) & 0x7f)
  107.  
  108. #ifdef __cplusplus
  109. extern "C" {
  110. #endif
  111.  
  112. int _CType tolower(int __ch);
  113. int _CType _ltolower(int __ch);
  114. int _CType toupper(int __ch);
  115. int _CType _ltoupper(int __ch);
  116.  
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120.  
  121. #if !__STDC__
  122. #define _toupper(c) ((c) + 'A' - 'a')
  123. #define _tolower(c) ((c) + 'a' - 'A')
  124. #endif
  125.  
  126. #if defined( __USELOCALES__ )
  127.  
  128. #define toupper    _ltoupper
  129. #define tolower    _ltolower
  130.  
  131. #endif
  132.  
  133. #else  /* defined __FLAT__  */
  134.  
  135. #ifndef _SIZE_T
  136. #define _SIZE_T
  137. typedef unsigned size_t;
  138. #endif
  139.  
  140. extern unsigned char _RTLENTRY _EXPDATA _ctype[ 257 ];
  141. extern unsigned char _RTLENTRY _EXPDATA _lower[ 256 ];
  142. extern unsigned char _RTLENTRY _EXPDATA _upper[ 256 ];
  143.  
  144. #ifdef __cplusplus
  145. extern "C" {
  146. #endif
  147. int _RTLENTRY _EXPFUNC isalnum (int __c);
  148. int _RTLENTRY _EXPFUNC isalpha (int __c);
  149. int _RTLENTRY _EXPFUNC iscntrl (int __c);
  150. int _RTLENTRY _EXPFUNC isdigit (int __c);
  151. int _RTLENTRY _EXPFUNC isgraph (int __c);
  152. int _RTLENTRY _EXPFUNC islower (int __c);
  153. int _RTLENTRY _EXPFUNC isprint (int __c);
  154. int _RTLENTRY _EXPFUNC ispunct (int __c);
  155. int _RTLENTRY _EXPFUNC isspace (int __c);
  156. int _RTLENTRY _EXPFUNC isupper (int __c);
  157. int _RTLENTRY _EXPFUNC isxdigit(int __c);
  158. int _RTLENTRY _EXPFUNC isascii (int __c);
  159.  
  160. #ifdef __cplusplus
  161. }
  162. #endif
  163.  
  164. /* character classes */
  165.  
  166. #define _IS_SP     1           /* space */
  167. #define _IS_DIG    2           /* digit */
  168. #define _IS_UPP    4           /* upper case */
  169. #define _IS_LOW    8           /* lower case */
  170. #define _IS_HEX   16           /* [0..9] or [A-F] or [a-f] */
  171. #define _IS_CTL   32           /* control */
  172. #define _IS_PUN   64           /* punctuation */
  173. #define _IS_BLK  128           /* blank */
  174.  
  175. #define _IS_ALPHA    (_IS_UPP | _IS_LOW)
  176. #define _IS_ALNUM    (_IS_DIG | _IS_ALPHA)
  177. #define _IS_GRAPH    (_IS_ALNUM | _IS_HEX | _IS_PUN)
  178.  
  179. #ifndef __USELOCALES__
  180.  
  181. /* C locale character classification macros */
  182.  
  183. #define isalnum(c)   (_ctype[ (c)+1 ] & (_IS_ALNUM))
  184.                      
  185. #define isalpha(c)   (_ctype[ (c)+1 ] & (_IS_ALPHA))
  186.                      
  187. #define iscntrl(c)   (_ctype[ (c)+1 ] & (_IS_CTL))
  188.                      
  189. #define isdigit(c)   (_ctype[ (c)+1 ] & (_IS_DIG))
  190.                      
  191. #define isgraph(c)   (_ctype[ (c)+1 ] & (_IS_GRAPH))
  192.                      
  193. #define islower(c)   (_ctype[ (c)+1 ] & (_IS_LOW))
  194.                      
  195. #define isprint(c)   (_ctype[ (c)+1 ] & (_IS_GRAPH | _IS_BLK))
  196.                      
  197. #define ispunct(c)   (_ctype[ (c)+1 ] & (_IS_PUN))
  198.                      
  199. #define isspace(c)   (_ctype[ (c)+1 ] & (_IS_SP))
  200.                      
  201. #define isupper(c)   (_ctype[ (c)+1 ] & (_IS_UPP))
  202.                      
  203. #define isxdigit(c)  (_ctype[ (c)+1 ] & (_IS_HEX))
  204.  
  205. #endif /* __USELOCALES__ */
  206.  
  207. #define isascii(c)  ((unsigned)(c) < 128)
  208. #define toascii(c)  ((c) & 0x7f)
  209.  
  210. #ifdef __cplusplus
  211. extern "C" {
  212. #endif
  213.  
  214. int _RTLENTRY _EXPFUNC tolower(int __ch);
  215. int _RTLENTRY _EXPFUNC _ltolower(int __ch);
  216. int _RTLENTRY _EXPFUNC toupper(int __ch);
  217. int _RTLENTRY _EXPFUNC _ltoupper(int __ch);
  218.  
  219. #if !__STDC__             /* NON-ANSI */
  220. #define _toupper(c) ((c) + 'A' - 'a')
  221. #define _tolower(c) ((c) + 'a' - 'A')
  222. #endif
  223.  
  224.  
  225. #ifdef __cplusplus
  226. }
  227. #endif
  228.  
  229. #if defined( __USELOCALES__ )
  230.  
  231. #define toupper    _ltoupper
  232. #define tolower    _ltolower
  233.  
  234. #endif
  235.  
  236. #endif /* __FLAT__  */
  237.  
  238.  
  239. #if !defined(RC_INVOKED)
  240.  
  241. #if defined(__STDC__)
  242. #pragma warn .nak
  243. #endif
  244.  
  245. #endif  /* !RC_INVOKED */
  246.  
  247.  
  248. #endif /* __CTYPE_H */
  249.