/*
 * Copyright (c) 1996-2008 MIPS Technologies, Inc.
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 
 *      * Redistributions of source code must retain the above copyright
 *        notice, this list of conditions and the following disclaimer.
 *      * Redistributions in binary form must reproduce the above
 *      copyright
 *        notice, this list of conditions and the following disclaimer
 *        in the documentation and/or other materials provided with
 *        the distribution.
 *      * Neither the name of MIPS Technologies Inc. nor the names of its
 *        contributors may be used to endorse or promote products derived
 *        from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * ctype.h : ctype definitions
 */


#ifndef __CTYPE_H
#ifdef __cplusplus
extern "C" {
#endif
#define __CTYPE_H

/* --- Constants --- */
#define	_CT_U	0x01
#define	_CT_L	0x02
#define	_CT_N	0x04
#define	_CT_S	0x08
#define _CT_P	0x10
#define _CT_C	0x20
#define _CT_X	0x40
#define _CT_SP	0x80

/* --- Prototypes --- */
int isalnum	(int c);
int isalpha	(int c);
int isascii	(int c);
int iscntrl	(int c);
int isdigit	(int c);
int isgraph	(int c);
int islower	(int c);
int isprint	(int c);
int ispunct	(int c);
int isspace	(int c);
int isupper	(int c);
int isxdigit	(int c);
int toascii	(int c);
int _tolower	(int c);
int _toupper	(int c);
int tolower	(int c);
int toupper	(int c);

/* --- Storage --- */
extern const char _ctype[];

/* --- Macros --- */
#define isalnum(c)	((_ctype+1)[(unsigned)(c)] & (_CT_U|_CT_L|_CT_N))
#define	isalpha(c)	((_ctype+1)[(unsigned)(c)] & (_CT_U|_CT_L))
#define iscntrl(c)	((_ctype+1)[(unsigned)(c)] & (_CT_C))
#define	isdigit(c)	((_ctype+1)[(unsigned)(c)] & (_CT_N))
#define isgraph(c)	((_ctype+1)[(unsigned)(c)] & (_CT_U|_CT_L|_CT_N|_CT_P))
#define	islower(c)	((_ctype+1)[(unsigned)(c)] & (_CT_L))
#define isprint(c)	((_ctype+1)[(unsigned)(c)] & (_CT_U|_CT_L|_CT_N|_CT_P|_CT_SP))
#define ispunct(c)	((_ctype+1)[(unsigned)(c)] & (_CT_P))
#define	isspace(c)	((_ctype+1)[(unsigned)(c)] & (_CT_S|_CT_SP))
#define	isupper(c)	((_ctype+1)[(unsigned)(c)] & (_CT_U))
#define	isxdigit(c)	((_ctype+1)[(unsigned)(c)] & (_CT_N|_CT_X))

#define isascii(c)	((unsigned)(c) <= 0x7f)
#define toascii(c)	((c) & 0x7f)

#define _tolower(c)	((c) - 'A' + 'a')
#define _toupper(c)	((c) - 'a' + 'A')

#ifdef __cplusplus
}
#endif
#endif /* !defined __CTYPE_H */
