/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos72X src/bos/usr/include/ctype.h 1.31.6.3                            */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 1989,2021              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)98       1.31.6.3  src/bos/usr/include/ctype.h, libcchr, bos72X, x2021_25A9 6/4/21 03:15:32 */ 
/*
 * COMPONENT_NAME: LIBCCHR
 *
 * FUNCTIONS:
 *
 * ORIGINS: 27
 *
 * (C) COPYRIGHT International Business Machines Corp. 1989, 1994
 * All Rights Reserved
 * Licensed Materials - Property of IBM
 *
 * US Government Users Restricted Rights - Use, duplication or
 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 *
 */

#ifndef __H_CTYPE
#define __H_CTYPE

#ifndef _H_STANDARDS
#include <standards.h>
#endif

#include <comp_macros.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _ANSI_C_SOURCE

#define _ISALPHA	0x001
#define _ISALNUM	0x002
#define _ISBLANK	0x004
#define _ISCNTRL	0x008
#define _ISDIGIT	0x010
#define _ISGRAPH	0x020
#define _ISLOWER	0x040
#define _ISPRINT	0x080
#define _ISPUNCT	0x100
#define _ISSPACE	0x200
#define _ISUPPER	0x400
#define _ISXDIGIT	0x800

#ifndef _LOCALE_T
#define _LOCALE_T
typedef void *  locale_t;
#endif

#ifdef _NO_PROTO
	extern int	_NOTHROW(isalpha, ());
	extern int	_NOTHROW(isalnum, ());
#ifdef _ISOC99_SOURCE 
	extern int	_NOTHROW(isblank, ());
#endif
	extern int	_NOTHROW(iscntrl, ());
	extern int	_NOTHROW(isdigit, ());
	extern int	_NOTHROW(isgraph, ());
	extern int	_NOTHROW(islower, ());
	extern int	_NOTHROW(isprint, ());
	extern int	_NOTHROW(ispunct, ());
	extern int	_NOTHROW(isspace, ());
	extern int	_NOTHROW(isupper, ());
	extern int	_NOTHROW(isxdigit, ());
	extern int	_NOTHROW(toupper, ());
	extern int	_NOTHROW(tolower, ());
#if (_XOPEN_SOURCE >= 700)
	extern int  	_NOTHROW(isalpha_l, ());
	extern int  	_NOTHROW(isalnum_l, ());
        extern int      _NOTHROW(isblank_l, ());
	extern int  	_NOTHROW(iscntrl_l, ());
    	extern int  	_NOTHROW(isdigit_l, ());
    	extern int  	_NOTHROW(isgraph_l, ());
    	extern int  	_NOTHROW(islower_l, ());
    	extern int  	_NOTHROW(isprint_l, ());
    	extern int  	_NOTHROW(ispunct_l, ());
    	extern int  	_NOTHROW(isspace_l, ());
    	extern int  	_NOTHROW(isupper_l, ());
    	extern int  	_NOTHROW(isxdigit_l, ());
    	extern int  	_NOTHROW(toupper_l, ());
    	extern int  	_NOTHROW(tolower_l, ());
#endif
#else /* _NO_PROTO */

	extern int	_NOTHROW(isalpha, (int));
	extern int	_NOTHROW(isalnum, (int));
#ifdef _ISOC99_SOURCE 
	extern int      _NOTHROW(isblank, (int));
#endif
	extern int	_NOTHROW(iscntrl, (int));
	extern int	_NOTHROW(isdigit, (int));
	extern int	_NOTHROW(isgraph, (int));
	extern int	_NOTHROW(islower, (int));
	extern int	_NOTHROW(isprint, (int));
	extern int	_NOTHROW(ispunct, (int));
	extern int	_NOTHROW(isspace, (int));
	extern int	_NOTHROW(isupper, (int));
	extern int	_NOTHROW(isxdigit, (int));
	extern int	_NOTHROW(toupper, (int));
	extern int	_NOTHROW(tolower, (int));
#if (_XOPEN_SOURCE >= 700) 
        extern int      _NOTHROW(isalpha_l, (int, locale_t));
        extern int      _NOTHROW(isalnum_l, (int, locale_t));
        extern int      _NOTHROW(isblank_l, (int, locale_t));
        extern int      _NOTHROW(iscntrl_l, (int, locale_t));
        extern int      _NOTHROW(isdigit_l, (int, locale_t));
        extern int      _NOTHROW(isgraph_l, (int, locale_t));
        extern int      _NOTHROW(islower_l, (int, locale_t));
        extern int      _NOTHROW(isprint_l, (int, locale_t));
        extern int      _NOTHROW(ispunct_l, (int, locale_t));
        extern int      _NOTHROW(isspace_l, (int, locale_t));
        extern int      _NOTHROW(isupper_l, (int, locale_t));
        extern int      _NOTHROW(isxdigit_l, (int, locale_t));
        extern int      _NOTHROW(toupper_l, (int, locale_t));
        extern int      _NOTHROW(tolower_l, (int, locale_t));
#endif
#endif /* _NO_PROTO */

#endif /* _ANSI_C_SOURCE */

#ifdef _XOPEN_SOURCE

#   ifndef _WCHAR_T
#	define _WCHAR_T
#	ifdef __64BIT__
	    typedef unsigned int	wchar_t;
#	else
	    typedef unsigned short	wchar_t;
#	endif
#   endif /* _WCHAR_T */

#   ifndef _WCTYPE_T
#	define _WCTYPE_T
	typedef unsigned int	wctype_t;
#   endif /* _WCTYPE_T */

#   ifndef _WINT_T
#	define _WINT_T
	typedef int	wint_t;
#   endif /* _WINT_T */

#ifdef _NO_PROTO
	extern int	_NOTHROW(isascii, ());
	extern int	_NOTHROW(toascii, ());
#else /* _NO_PROTO */
	extern int	_NOTHROW(isascii, (int));
	extern int	_NOTHROW(toascii, (int));
#endif /* _NO_PROTO */

#define _toupper(__a) toupper(__a)
#define _tolower(__a) tolower(__a)

#endif /* _XOPEN_SOURCE */

#ifdef _ALL_SOURCE

#ifndef __H_LOCALEDEF
#include <sys/localedef.h>
#endif

#ifdef _NO_PROTO
	extern int	is_wctype();
	extern wctype_t	get_wctype();
#else
	extern int	is_wctype(wint_t, wctype_t);
	extern wctype_t	get_wctype(char *);
#endif /* NO_PROTO */

#ifdef _ILS_MACROS	

/* macros for ANSI functions */
#define _VALC(__c)		((__c)>=0&&(__c)<=256)
#ifdef _THREAD_SAFE
#define _IS(__c,__m)		(__OBJ_DATA((*__lc_ctype_ptr))->mask[__c] & __m)
#else
#define _IS(__c,__m)            (__OBJ_DATA(__lc_ctype)->mask[__c] & __m)
#endif

#define isalpha(__a)	(_VALC(__a)?_IS(__a,_ISALPHA):0)
#define isalnum(__a)	(_VALC(__a)?_IS(__a,_ISALNUM):0)
#define iscntrl(__a)	(_VALC(__a)?_IS(__a,_ISCNTRL):0)
#define isdigit(__a)	(_VALC(__a)?_IS(__a,_ISDIGIT):0)
#define isgraph(__a)	(_VALC(__a)?_IS(__a,_ISGRAPH):0)
#define islower(__a)	(_VALC(__a)?_IS(__a,_ISLOWER):0)
#define isprint(__a)	(_VALC(__a)?_IS(__a,_ISPRINT):0)
#define ispunct(__a)	(_VALC(__a)?_IS(__a,_ISPUNCT):0)
#define isspace(__a)	(_VALC(__a)?_IS(__a,_ISSPACE):0)
#define isupper(__a)	(_VALC(__a)?_IS(__a,_ISUPPER):0)
#define isxdigit(__a)	(_VALC(__a)?_IS(__a,_ISXDIGIT):0)
#define isascii(c)	(!((c) & ~0177))

#ifdef _THREAD_SAFE
#define _XUPPER(__a)	(__OBJ_DATA((*__lc_ctype_ptr))->upper[__a])
#define _XLOWER(__a)	(__OBJ_DATA((*__lc_ctype_ptr))->lower[__a])
#else
#define _XUPPER(__a)    (__OBJ_DATA(__lc_ctype)->upper[__a])
#define _XLOWER(__a)    (__OBJ_DATA(__lc_ctype)->lower[__a])
#endif

#ifdef _C_LOCALE_ONLY
/******
 * The macros are only useable if the application will only
 * be used in the "C", or "POSIX", locale. Use in other
 * locales may yield unpredictable results.
 ******/
#define toupper(__a)    (_VALC(__a)?_XUPPER(__a):__a)
#define tolower(__a)    (_VALC(__a)?_XLOWER(__a):__a)
#endif

/* macros for XOPEN functions */
#ifdef _THREAD_SAFE
#define _SBCK(__a,__m)	(__OBJ_DATA((*__lc_ctype_ptr))->mask[__a] & __m)
#define _MBCK(__a,__m)	(__OBJ_DATA((*__lc_ctype_ptr))->qmask[__OBJ_DATA((*__lc_ctype_ptr))->qidx[(__a)-256]] & __m)
#define _MBVALCK(__a,__m) ((__a)>__OBJ_DATA((*__lc_ctype_ptr))->max_wc?0:_MBCK(__a,__m))
#else
#define _SBCK(__a,__m)  (__OBJ_DATA(__lc_ctype)->mask[__a] & __m)
#define _MBCK(__a,__m)  (__OBJ_DATA(__lc_ctype)->qmask[__OBJ_DATA(__lc_ctype)->qidx[(__a)-256]] & __m)
#define _MBVALCK(__a,__m) ((__a)>__OBJ_DATA(__lc_ctype)->max_wc?0:_MBCK(__a,__m))
#endif
#define _VALCK(__a,__m)	((__a)<256?_SBCK(__a,__m):_MBVALCK(__a,__m))
#define iswalpha(__a)	((__a)>=0?_VALCK(__a,_ISALPHA):0)
#define iswalnum(__a)	((__a)>=0?_VALCK(__a,_ISALNUM):0)
#define iswcntrl(__a)	((__a)>=0?_VALCK(__a,_ISCNTRL):0)
#define iswdigit(__a)	((__a)>=0?_VALCK(__a,_ISDIGIT):0)
#define iswgraph(__a)	((__a)>=0?_VALCK(__a,_ISGRAPH):0)
#define iswlower(__a)	((__a)>=0?_VALCK(__a,_ISLOWER):0)
#define iswprint(__a)	((__a)>=0?_VALCK(__a,_ISPRINT):0)
#define iswpunct(__a)	((__a)>=0?_VALCK(__a,_ISPUNCT):0)
#define iswspace(__a)	((__a)>=0?_VALCK(__a,_ISSPACE):0)
#define iswupper(__a)	((__a)>=0?_VALCK(__a,_ISUPPER):0)
#define iswxdigit(__a)	((__a)>=0?_VALCK(__a,_ISXDIGIT):0)
#define is_wctype(__a,__b)	((__a)>=0?_VALCK(__a,__b):0)
#define iswctype(__a,__b)	((__a)>=0?_VALCK(__a,__b):0)
#ifdef _THREAD_SAFE
#define towupper(__a)	(((__a) >= __OBJ_DATA((*__lc_ctype_ptr))->min_wc && \
			  (__a) <= __OBJ_DATA((*__lc_ctype_ptr))->max_wc) ? \
				      __OBJ_DATA((*__lc_ctype_ptr))->upper[__a] : __a)
#define towlower(__a)	(((__a) >= __OBJ_DATA((*__lc_ctype_ptr))->min_wc && \
			  (__a) <= __OBJ_DATA((*__lc_ctype_ptr))->max_wc) ? \
				      __OBJ_DATA((*__lc_ctype_ptr))->lower[__a] : __a)
#else
#define towupper(__a)   (((__a) >= __OBJ_DATA(__lc_ctype)->min_wc && \
                          (__a) <= __OBJ_DATA(__lc_ctype)->max_wc) ? \
                                      __OBJ_DATA(__lc_ctype)->upper[__a] : __a)
#define towlower(__a)   (((__a) >= __OBJ_DATA(__lc_ctype)->min_wc && \
                          (__a) <= __OBJ_DATA(__lc_ctype)->max_wc) ? \
                                      __OBJ_DATA(__lc_ctype)->lower[__a] : __a)
#endif

#endif /* _ILS_MACROS */

#ifdef _C_LOCALE_ONLY
/******
 * The macros are only useable if the application will only
 * be used in the "C", or "POSIX", locale. Use in other
 * locales may yield unpredictable results.
 ******/

#undef _toupper
#undef _tolower

#ifdef _THREAD_SAFE
#define _toupper(__a)   (__OBJ_DATA((*__lc_ctype_ptr))->upper[__a])
#define _tolower(__a)   (__OBJ_DATA((*__lc_ctype_ptr))->lower[__a])
#else
#define _toupper(__a)   (__OBJ_DATA(__lc_ctype)->upper[__a])
#define _tolower(__a)   (__OBJ_DATA(__lc_ctype)->lower[__a])
#endif

#endif

#endif /* _ALL_SOURCE */

#ifdef __cplusplus
}
#endif

#endif /* __H_CTYPE */