/***********************************************************************\ Product Number: PROXLIB-01-2.0 Version: rev2.0 Product Name: Proximity Subroutine Library Filename: cschar.h This document contains private and confidential information and its disclosure does not constitute publication. Some of the information herein also may appear in United States and or Foreign Patents Pending. All rights are reserved by Proximity Technology Inc., except those specifically granted by license. \***********************************************************************/ #ifndef _CSCHAR #define _CSCHAR #ifndef _PROXLIB #include "proxlib.h" #endif /* Character type bits and bit masks */ #define _CSPRINT 0x01 /* bit for random valid characters */ #define _CSWORD 0x1E /* bits for characters valid in word */ #define _CSINWORD 0x02 /* bit for a non-alpha valid in word */ #define _CSALPHA 0x1C /* bits for an alphabetic character */ #define _CSLOWER 0x04 /* bit for a lower case letter */ #define _CSUPPER 0x08 /* bit for an upper case letter */ #define _CSSCASE 0x10 /* bit for a single case letter */ /* scharfes S is an example of above */ #define _CSDIGIT 0x20 /* bit for digit character */ #define _CSHEX 0x40 /* bit for hex digit character */ /* Character classification table & macros. These work for all UCHAR values (e.g. 0-255). */ extern UCHAR Csctype[]; #define csprint(cc) (Csctype[cc]) #define csword(cc) (Csctype[cc] & _CSINWORD) #define csalpha(cc) (Csctype[cc] & _CSALPHA) #define cslower(cc) (Csctype[cc] & _CSLOWER) #define csupper(cc) (Csctype[cc] & _CSUPPER) #define csscase(cc) (Csctype[cc] & _CSSCASE) #define csdigit(cc) (Csctype[cc] & _CSDIGIT) #define cshex(cc) (Csctype[cc] & (_CSHEX|_CSDIGIT)) /* Character conversion tables & macros. These work for all UCHAR values (e.g. 0-255). */ extern UCHAR Cstolower[]; /* table to convert to lower case */ extern UCHAR Cstoupper[]; /* table to convert to upper case */ #define cstolower(cc) (ctoi(Cstolower[cc])) /* convert to lower case */ #define cstoupper(cc) (ctoi(Cstoupper[cc])) /* convert to upper case */ /* Character ordering macro. The values returned by this macro are ordered so that characters which are modified versions of other characters occur after their base characters but before others that have different base characters. The base letters (but not other characters) are ordered in the standard ASCII order. All control characters are mapped to zero. Space is mapped after controls and before letters. Letters come next. Non-letters come last. Letters are ordered in pairs, upper case then lower case. Those letters which have a single case use two order positions. The letters start with an even order value. These allow case insensitive matching: if c1 and c2 are letters then order = (cstoorder(*c1) - cstoorder(*c2)) >> 1; if (order < 0) { (* c1 letter before c2 letter. *) } else if (order == 0) { (* letters equal *) } else { (* order > 0 *) (* c1 letter after c2 letter. *) } compares the two letters ignoring case. Note that the values assigned by this macro have no special meaning and can be changed from release to release. The only purpose which they can be used for (and continue to work) is comparison with other values from the same macro. */ extern UCHAR Cstoorder[]; /* table to get collating order */ #define cstoorder(cc) (ctoi(Cstoorder[cc])) /* get collating order */ #endif /* _CSCHAR */