home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / INCLUDE / CTYPE.H < prev    next >
Text File  |  1993-09-17  |  6KB  |  148 lines

  1. #pragma info( none )
  2. #ifndef __CHKHDR__
  3.    #pragma info( none )
  4. #endif
  5. #pragma info( restore )
  6.  
  7. #ifndef __ctype_h
  8.    #define __ctype_h
  9.  
  10.    #ifdef __cplusplus
  11.       extern "C" {
  12.    #endif
  13.  
  14.    /********************************************************************/
  15.    /*  <ctype.h> header file                                           */
  16.    /*                                                                  */
  17.    /*  Licensed Materials - Property of IBM                            */
  18.    /*                                                                  */
  19.    /*  IBM C/C++ Tools Version 2.01                                    */
  20.    /*  Copyright (C) International Business Machines Corp., 1991,1993  */
  21.    /*  All rights reserved                                             */
  22.    /*                                                                  */
  23.    /*  US Government Users Restricted Rights -                         */
  24.    /*  Use, duplication, or disclosure restricted                      */
  25.    /*  by GSA ADP Schedule Contract with IBM Corp.                     */
  26.    /*                                                                  */
  27.    /********************************************************************/
  28.  
  29.    int _Optlink isalnum( int );
  30.    int _Optlink isalpha( int );
  31.    int _Optlink iscntrl( int );
  32.    int _Optlink isdigit( int );
  33.    int _Optlink isgraph( int );
  34.    int _Optlink islower( int );
  35.    int _Optlink isprint( int );
  36.    int _Optlink ispunct( int );
  37.    int _Optlink isspace( int );
  38.    int _Optlink isupper( int );
  39.    int _Optlink isxdigit( int );
  40.    int _Optlink tolower( int );
  41.    int _Optlink toupper( int );
  42.  
  43.    /* masks for using external character table */
  44.    #define __A 0x0100U   /* alphabetic  (isalpha)  */
  45.    #define __U 0x0080U   /* uppercase   (isupper)  */
  46.    #define __L 0x0040U   /* lowercase   (islower)  */
  47.    #define __C 0x0020U   /* control     (iscntrl)  */
  48.    #define __P 0x0010U   /* punctuation (ispunct)  */
  49.    #define __W 0x0008U   /* whitespace  (isspace)  */
  50.    #define __S 0x0004U   /* space                  */
  51.    #define __D 0x0002U   /* decimal     (isdigit)  */
  52.    #define __X 0x0001U   /* hexadecimal (isxdigit) */
  53.  
  54.    /* indexes of toupper/tolower tables in _ctype table */
  55.    #define _TOUPPER_INDEX   257
  56.    #define _TOLOWER_INDEX   514
  57.  
  58.    extern const unsigned short *_ctype;
  59.  
  60.    #ifdef __cplusplus
  61.       inline int isalnum ( int c )
  62.                           { return _ctype[(c)] & (__A | __D); }
  63.       inline int isalpha ( int c )
  64.                           { return _ctype[(c)] & __A; }
  65.       inline int iscntrl ( int c )
  66.                           { return _ctype[(c)] & __C; }
  67.       inline int isdigit ( int c )
  68.                           { return _ctype[(c)] & __D; }
  69.       inline int isgraph ( int c )
  70.                           { return _ctype[(c)] & (__P | __A | __D); }
  71.       inline int islower ( int c )
  72.                           { return _ctype[(c)] & __L; }
  73.       inline int isprint ( int c )
  74.                           { return _ctype[(c)] & (__P | __A | __D | __S); }
  75.       inline int ispunct ( int c )
  76.                           { return _ctype[(c)] & __P; }
  77.       inline int isspace ( int c )
  78.                           { return _ctype[(c)] & __W; }
  79.       inline int isupper ( int c )
  80.                           { return _ctype[(c)] & __U; }
  81.       inline int isxdigit( int c )
  82.                           { return _ctype[(c)] & __X; }
  83.       inline int tolower ( int c )
  84.                           { return (signed short)_ctype[(c) + _TOLOWER_INDEX]; }
  85.       inline int toupper ( int c )
  86.                           { return (signed short)_ctype[(c) + _TOUPPER_INDEX]; }
  87.    #else
  88.       #pragma info( none )
  89.       #define isalnum( c )  ( _ctype[(c)] & (__A | __D) )
  90.       #define isalpha( c )  ( _ctype[(c)] & __A )
  91.       #define iscntrl( c )  ( _ctype[(c)] & __C )
  92.       #define isdigit( c )  ( _ctype[(c)] & __D )
  93.       #define isgraph( c )  ( _ctype[(c)] & (__P | __A | __D) )
  94.       #define islower( c )  ( _ctype[(c)] & __L )
  95.       #define isprint( c )  ( _ctype[(c)] & (__P | __A | __D | __S) )
  96.       #define ispunct( c )  ( _ctype[(c)] & __P )
  97.       #define isspace( c )  ( _ctype[(c)] & __W )
  98.       #define isupper( c )  ( _ctype[(c)] & __U )
  99.       #define isxdigit( c ) ( _ctype[(c)] & __X )
  100.       #define tolower( c )  (signed short)( _ctype[(c) + _TOLOWER_INDEX] )
  101.       #define toupper( c )  (signed short)( _ctype[(c) + _TOUPPER_INDEX] )
  102.       #pragma info( restore )
  103.    #endif
  104.  
  105.    #if defined(__EXTENDED__)
  106.  
  107.       int _Optlink _tolower( int );
  108.       int _Optlink _toupper( int );
  109.       int _Optlink _isascii( int );
  110.       int _Optlink _iscsymf( int );
  111.       int _Optlink _iscsym( int );
  112.       int _Optlink _toascii( int );
  113.  
  114.       #pragma info( none )
  115.       #define _tolower( c ) ( (c) + 'a' - 'A' )
  116.       #define _toupper( c ) ( (c) + 'A' - 'a' )
  117.       #define _isascii( c ) ( (unsigned)(c) < 0x80 )
  118.       #define _iscsymf( c ) ( isalpha( c ) || (c) == '_' )
  119.       #define _iscsym( c )  ( isalnum( c ) || (c) == '_' )
  120.       #define _toascii( c ) ( (c) & 0x7f )
  121.  
  122.       #ifdef __cplusplus
  123.          inline int isascii( int c ) { return _isascii( c ); }
  124.          inline int iscsymf( int c ) { return _iscsymf( c ); }
  125.          inline int iscsym ( int c ) { return _iscsym ( c ); }
  126.          inline int toascii( int c ) { return _toascii( c ); }
  127.       #else
  128.          #define  isascii( c )        _isascii( c )
  129.          #define  iscsymf( c )        _iscsymf( c )
  130.          #define  iscsym( c )         _iscsym( c )
  131.          #define  toascii( c )        _toascii( c )
  132.       #endif
  133.       #pragma info( restore )
  134.  
  135.    #endif
  136.  
  137.    #ifdef __cplusplus
  138.       }
  139.    #endif
  140.  
  141. #endif
  142.  
  143. #pragma info( none )
  144. #ifndef __CHKHDR__
  145.    #pragma info( restore )
  146. #endif
  147. #pragma info( restore )
  148.