home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / wctype.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-20  |  9.0 KB  |  230 lines

  1. #ifndef __wctype_h
  2.    #define __wctype_h
  3.  
  4.    #ifdef __cplusplus
  5.       extern "C" {
  6.    #endif
  7.  
  8.    #ifndef  _LNK_CONV
  9.      #ifdef _M_I386
  10.        #define  _LNK_CONV   _Optlink
  11.      #else
  12.        #define _LNK_CONV
  13.      #endif
  14.    #endif
  15.  
  16.    #ifndef _IMPORT
  17.       #ifdef __IMPORTLIB__
  18.          #define _IMPORT _Import
  19.       #else
  20.          #define _IMPORT
  21.       #endif
  22.    #endif
  23.  
  24.    /********************************************************************/
  25.    /*  <wctype.h> header file                                          */
  26.    /*                                                                  */
  27.    /*  VisualAge for C++ for Windows, Version 3.5                      */
  28.    /*    Licensed Material - Property of IBM                           */
  29.    /*                                                                  */
  30.    /*  5801-ARR and Other Materials                                    */
  31.    /*                                                                  */
  32.    /*  (c) Copyright IBM Corp 1991, 1996. All rights reserved.         */
  33.    /*                                                                  */
  34.    /********************************************************************/
  35.  
  36.    #include <stdio.h>
  37.    #include <stdarg.h>
  38.  
  39.   #ifndef __wchar_t
  40.      #define __wchar_t
  41.      typedef unsigned short wchar_t;
  42.   #endif
  43.  
  44.   #ifndef __wctype_t
  45.      #define __wctype_t
  46.      typedef unsigned int        wctype_t;
  47.   #endif
  48.  
  49.   #ifndef __wint_t
  50.      #define __wint_t
  51.      typedef int        wint_t;
  52.   #endif
  53.  
  54.   #ifndef WEOF
  55.      #define WEOF -1
  56.   #endif
  57.  
  58.   #ifndef __ISXDIGIT
  59.      #define __ISXDIGIT       0x0001U
  60.   #endif
  61.   #ifndef __ISDIGIT
  62.      #define __ISDIGIT        0x0002U
  63.   #endif
  64.   #ifndef __ISSPACE
  65.      #define __ISSPACE        0x0008U
  66.   #endif
  67.   #ifndef __ISPUNCT
  68.      #define __ISPUNCT        0x0010U
  69.   #endif
  70.   #ifndef __ISCNTRL
  71.      #define __ISCNTRL        0x0020U
  72.   #endif
  73.   #ifndef __ISLOWER
  74.      #define __ISLOWER        0x0040U
  75.   #endif
  76.   #ifndef __ISUPPER
  77.      #define __ISUPPER        0x0080U
  78.   #endif
  79.   #ifndef __ISALPHA
  80.      #define __ISALPHA        0x0100U
  81.   #endif
  82.   #ifndef __ISGRAPH
  83.      #define __ISGRAPH        0x0200U
  84.   #endif
  85.   #ifndef __ISPRINT
  86.      #define __ISPRINT        0x0400U
  87.   #endif
  88.   #ifndef __ISALNUM
  89.      #define __ISALNUM        0x0800U
  90.   #endif
  91.   #ifndef __ISBLANK
  92.      #define __ISBLANK        0x1000U
  93.   #endif
  94.  
  95.   /* indexes of toupper/tolower tables in _ctype table */
  96.   #ifndef _TOUPPER_INDEX
  97.      #define _TOUPPER_INDEX   257
  98.   #endif
  99.   #ifndef _TOLOWER_INDEX
  100.      #define _TOLOWER_INDEX   514
  101.   #endif
  102.  
  103.   #if defined _WIN32S
  104.      extern const unsigned short** _IMPORT _LNK_CONV __ctype( void );
  105.      extern const unsigned char ** _IMPORT _LNK_CONV __ctype_upperidx( void );
  106.      extern const unsigned char ** _IMPORT _LNK_CONV __ctype_loweridx( void );
  107.      extern const wchar_t       ** _IMPORT _LNK_CONV __ctype_upper( void );
  108.      extern const wchar_t       ** _IMPORT _LNK_CONV __ctype_lower( void );
  109.      extern const unsigned char ** _IMPORT _LNK_CONV __ctype_ctypeidx( void );
  110.      extern const unsigned short** _IMPORT _LNK_CONV __ctype_cmask( void );
  111.      extern const unsigned int  ** _IMPORT _LNK_CONV __ctype_mask( void );
  112.      #define _ctype           (*__ctype())
  113.      #define _ctype_upperidx  (*__ctype_upperidx())
  114.      #define _ctype_loweridx  (*__ctype_loweridx())
  115.      #define _ctype_upper     (*__ctype_upper())
  116.      #define _ctype_lower     (*__ctype_lower())
  117.      #define _ctype_ctypeidx  (*__ctype_ctypeidx())
  118.      #define _ctype_cmask     (*__ctype_cmask())
  119.      #define _ctype_mask      (*__ctype_mask())
  120.   #else
  121.      extern const unsigned short* _IMPORT _ctype;
  122.      extern const unsigned char * _IMPORT _ctype_upperidx;
  123.      extern const unsigned char * _IMPORT _ctype_loweridx;
  124.      extern const wchar_t       * _IMPORT _ctype_upper;
  125.      extern const wchar_t       * _IMPORT _ctype_lower;
  126.      extern const unsigned char * _IMPORT _ctype_ctypeidx;
  127.      extern const unsigned short* _IMPORT _ctype_cmask;
  128.      extern const unsigned int  * _IMPORT _ctype_mask;
  129.   #endif
  130.  
  131.   static int  __temp;
  132.   static int  __temp2;
  133.  
  134.   extern int      _IMPORT (_LNK_CONV iswalnum) (wint_t);
  135.   extern int      _IMPORT (_LNK_CONV iswalpha) (wint_t);
  136.   #ifdef __EXTENDED__
  137.      extern int   _IMPORT (_LNK_CONV iswblank) (wint_t);
  138.   #endif
  139.   extern int      _IMPORT (_LNK_CONV iswcntrl) (wint_t);
  140.   extern int      _IMPORT (_LNK_CONV iswdigit) (wint_t);
  141.   extern int      _IMPORT (_LNK_CONV iswgraph) (wint_t);
  142.   extern int      _IMPORT (_LNK_CONV iswlower) (wint_t);
  143.   extern int      _IMPORT (_LNK_CONV iswprint) (wint_t);
  144.   extern int      _IMPORT (_LNK_CONV iswpunct) (wint_t);
  145.   extern int      _IMPORT (_LNK_CONV iswspace) (wint_t);
  146.   extern int      _IMPORT (_LNK_CONV iswupper) (wint_t);
  147.   extern int      _IMPORT (_LNK_CONV iswxdigit)(wint_t);
  148.   extern wint_t   _IMPORT (_LNK_CONV towlower) (wint_t);
  149.   extern wint_t   _IMPORT (_LNK_CONV towupper) (wint_t);
  150.   extern wctype_t _IMPORT (_LNK_CONV wctype)   (const char *);
  151.   extern int      _IMPORT (_LNK_CONV iswctype) (wint_t, wctype_t);
  152.  
  153.   #define iswalnum(c)  __iswalnum(c)
  154.   #define iswalpha(c)  __iswalpha(c)
  155.   #ifdef __EXTENDED__
  156.      #define iswblank(c)  __iswblank(c)
  157.   #endif
  158.   #define iswcntrl(c)  __iswcntrl(c)
  159.   #define iswdigit(c)  __iswdigit(c)
  160.   #define iswgraph(c)  __iswgraph(c)
  161.   #define iswlower(c)  __iswlower(c)
  162.   #define iswprint(c)  __iswprint(c)
  163.   #define iswpunct(c)  __iswpunct(c)
  164.   #define iswspace(c)  __iswspace(c)
  165.   #define iswupper(c)  __iswupper(c)
  166.   #define iswxdigit(c) __iswxdigit(c)
  167.   #define towlower(c)  __towlower(c)
  168.   #define towupper(c)  __towupper(c)
  169.   #define iswctype(c, d) __iswctype(c, d)
  170.  
  171.   #define __SBCK(a,m)   (_ctype[a] & m)
  172.   #define __SBCK2(a,m)  (_ctype_cmask == 0 ? 0                         \
  173.                         :_ctype_cmask[a] & (m >> 16))
  174.   #define __MBCK(a,m)   (((_ctype_ctypeidx == 0) ||                    \
  175.                          (_ctype_ctypeidx[__temp>>8] == 0)) ? 0        \
  176.                         : _ctype_mask[(_ctype_ctypeidx                 \
  177.                         [__temp>>8]*256)+(__temp&0x00ff)] & m)
  178.   #define __VALCK(a,m)  ((a)<256?__SBCK(a,m):__MBCK(a,m))
  179.   #define __iswalpha(a)  (__temp=(a),__VALCK(__temp,__ISALPHA))
  180.   #define __iswalnum(a)  (__temp=(a),__VALCK(__temp,__ISALNUM))
  181.   #ifdef __EXTENDED__
  182.     #define __iswblank(a)  (__temp=(a),__VALCK(__temp,__ISBLANK))
  183.   #endif
  184.   #define __iswcntrl(a)  (__temp=(a),__VALCK(__temp,__ISCNTRL))
  185.   #define __iswdigit(a)  (__temp=(a),__VALCK(__temp,__ISDIGIT))
  186.   #define __iswgraph(a)  (__temp=(a),__VALCK(__temp,__ISGRAPH))
  187.   #define __iswlower(a)  (__temp=(a),__VALCK(__temp,__ISLOWER))
  188.   #define __iswprint(a)  (__temp=(a),__VALCK(__temp,__ISPRINT))
  189.   #define __iswpunct(a)  (__temp=(a),__VALCK(__temp,__ISPUNCT))
  190.   #define __iswspace(a)  (__temp=(a),__VALCK(__temp,__ISSPACE))
  191.   #define __iswupper(a)  (__temp=(a),__VALCK(__temp,__ISUPPER))
  192.   #define __iswxdigit(a) (__temp=(a),__VALCK(__temp,__ISXDIGIT))
  193.   #define __iswctype(a,m) (__temp=(a), __temp2=(m),                    \
  194.                           (__temp < 256                                \
  195.                            ? (__temp2 > 0x8000                         \
  196.                               ? __SBCK2(__temp,__temp2)                \
  197.                               : __SBCK(__temp,__temp2))                \
  198.                            : __MBCK(__temp,__temp2)))
  199.   #define __SBUPPER(a)       (_ctype[a+_TOUPPER_INDEX])
  200.   #define __MBUPPER(a)       (((_ctype_upperidx == 0) ||               \
  201.                               (_ctype_upperidx[__temp>>8] == 0)) ? (a) \
  202.                              : _ctype_upper                            \
  203.                          [_ctype_upperidx[__temp>>8]*256+(__temp&0x00ff)])
  204.  
  205.   #define __SBLOWER(a)       (_ctype[a+_TOLOWER_INDEX])
  206.   #define __MBLOWER(a)       (((_ctype_loweridx == 0) ||               \
  207.                               (_ctype_loweridx[__temp>>8] == 0)) ? (a) \
  208.                              : _ctype_lower                            \
  209.              [_ctype_loweridx[__temp>>8]*256+(__temp&0x00ff)])
  210.  
  211.   #define __towupper(a) (__temp=(a),                                   \
  212.                          (unsigned int)__temp < 256                    \
  213.                                       ? __SBUPPER(__temp)              \
  214.                                       : (__temp == WEOF)               \
  215.                                         ? WEOF                         \
  216.                                         : __MBUPPER(__temp))
  217.   #define __towlower(a) (__temp=(a),                                   \
  218.                          (unsigned int)__temp < 256                    \
  219.                                       ? __SBLOWER(__temp)              \
  220.                                       : (__temp == WEOF)               \
  221.                                       ? WEOF                           \
  222.                                       : __MBLOWER(__temp))
  223.  
  224.    #ifdef __cplusplus
  225.       }
  226.    #endif
  227.  
  228. #endif
  229.  
  230.