/* vim: set filetype=c:
 *
 * ctype.h86  -  Character class definitions for target system
 *
 * Copyright (C) 2003-2007 Gero Kuhlmann   <gero@gkminix.han.de>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: ctype.h86,v 1.9 2007/01/06 18:30:54 gkminix Exp $
 */


#ifndef I386_CTYPE_H86
#define I386_CTYPE_H86



/*
 **************************************************************************
 *
 * This file can only get included into target C or assembler source files.
 */
#define GCC_INCLUDE
#include <compiler.h>



/*
 **************************************************************************
 *
 * Some special characters
 */
#define CHR_BREAK	0x03		/* aka Ctrl-C */
#define CHR_BELL	0x07
#define CHR_BS		0x08
#define CHR_TAB		0x09
#define CHR_LF		0x0A		/* aka \n */
#define CHR_FF		0x0C		/* aka \f */
#define CHR_CR		0x0D		/* aka \r */
#define CHR_EOF		0x1A		/* DOS EOF character */
#define CHR_ESC		0x1B
#define CHR_BLANK	0x20
#define CHR_FIRST	0x20		/* first ASCII character */
#define CHR_LAST	0x7F		/* last ASCII character */
#define CHR_DEL		0x7F



/*
 **************************************************************************
 *
 * We are always using the ASCII on the target system, so we can use
 * CPP macros to define the standard character class functions. Since
 * these macros get only used in a very limited number, it gives a smaller
 * code size when using comparisons instead of a conversion table.
 */
#ifndef _ASSEMBLY_

#define tolower(c)	(isupper(c) ? (c) - 'A' + 'a' : (c))
#define toupper(c)	(islower(c) ? (c) - 'a' + 'A' : (c))

#define isascii(c)	((unsigned char)(c) <= CHR_LAST)
#define isdigit(c)	((c) >= '0' && (c) <= '9')
#define isxdigit(c)	(isdigit(c) || (tolower(c) >= 'a' && tolower(c) <= 'f'))
#define isalpha(c)	(((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))
#define isalnum(c)	(isdigit(c) || isalpha(c))
#define iscntrl(c)	((unsigned char)(c) < CHR_FIRST || (c) == CHR_DEL)
#define isspace(c)	((unsigned char)(c) == ' ' || (unsigned char)(c) == '\t')
#define isupper(c)	((unsigned char)(c) >= 'A' && (unsigned char)(c) <= 'Z')
#define islower(c)	((unsigned char)(c) >= 'a' && (unsigned char)(c) <= 'z')
#define isprint(c)	(isascii(c) && (unsigned char)(c) >= CHR_FIRST)
#define isgraph(c)	(isprint(c) && !isspace(c))


#endif /* _ASSEMBLY_ */

#endif

