OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [include/] [ctype.h] - Diff between revs 2 and 175

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 2 Rev 175
/*
/*
    ctype.h -- character types
    ctype.h -- character types
    Implements the usual ctype stuff (only valid for ASCII systems)
    Implements the usual ctype stuff (only valid for ASCII systems)
    Copyright (C) 2002 Richard Herveille, rherveille@opencores.org
    Copyright (C) 2002 Richard Herveille, rherveille@opencores.org
 
 
    This file is part of OpenRISC 1000 Reference Platform Monitor (ORPmon)
    This file is part of OpenRISC 1000 Reference Platform Monitor (ORPmon)
 
 
    This program is free software; you can redistribute it and/or modify
    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
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version
    (at your option) any later version
 
 
    This program is distributed in the hope that it will be useful,
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    GNU General Public License for more details.
 
 
    You should have received a copy of the GNU General Public License
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
*/
 
 
 
 
#ifndef __CTYPE_H
#ifndef __CTYPE_H
#define __CTYPE_H
#define __CTYPE_H
 
 
/* basic types                                              */
/* basic types                                              */
#define __CT_d 0x01               /* numeric digit          */
#define __CT_d 0x01               /* numeric digit          */
#define __CT_u 0x02               /* upper case             */
#define __CT_u 0x02               /* upper case             */
#define __CT_l 0x04               /* lower case             */
#define __CT_l 0x04               /* lower case             */
#define __CT_c 0x08               /* control character      */
#define __CT_c 0x08               /* control character      */
#define __CT_s 0x10               /* whitespace             */
#define __CT_s 0x10               /* whitespace             */
#define __CT_p 0x20               /* punctuation            */
#define __CT_p 0x20               /* punctuation            */
#define __CT_x 0x40               /* hexadecimal            */
#define __CT_x 0x40               /* hexadecimal            */
#define __CT_b 0x80               /* blank (is also space)  */
#define __CT_b 0x80               /* blank (is also space)  */
 
 
/* combination types                                        */
/* combination types                                        */
#define __CT_lx (__CT_l | __CT_x) /* lower case hexadecimal */
#define __CT_lx (__CT_l | __CT_x) /* lower case hexadecimal */
#define __CT_ux (__CT_u | __CT_x) /* upper case hexadecimal */
#define __CT_ux (__CT_u | __CT_x) /* upper case hexadecimal */
 
 
#define __CT_space    (__CT_s | __CT_b)
#define __CT_space    (__CT_s | __CT_b)
#define __CT_alphanum (__CT_l | __CT_u | __CT_d)
#define __CT_alphanum (__CT_l | __CT_u | __CT_d)
#define __CT_graph    (__CT_l | __CT_u | __CT_d | __CT_p)
#define __CT_graph    (__CT_l | __CT_u | __CT_d | __CT_p)
#define __CT_print    (__CT_l | __CT_u | __CT_d | __CT_p | __CT_b)
#define __CT_print    (__CT_l | __CT_u | __CT_d | __CT_p | __CT_b)
 
 
extern const unsigned char __ctype_table[256];
extern const unsigned char __ctype_table[256];
 
 
#define _toupper(c)      ( (c) ^ 0x20 )
#define _toupper(c)      ( (c) ^ 0x20 )
#define _tolower(c)      ( (c) ^ 0x20 )
#define _tolower(c)      ( (c) ^ 0x20 )
#define toupper(c)       ( islower(c) ? _tolower(c) : (c) )
#define toupper(c)       ( islower(c) ? _tolower(c) : (c) )
#define tolower(c)       ( isupper(c) ? _toupper(c) : (c) )
#define tolower(c)       ( isupper(c) ? _toupper(c) : (c) )
#define toascii(c)       ( (c) & 0x7F )
#define toascii(c)       ( (c) & 0x7F )
 
 
 
 
/* standard defenitions are taken from man-pages            */
/* standard defenitions are taken from man-pages            */
/*#define isalnum(c)       ( isalpha(c) || isdigit(c) )     */
/*#define isalnum(c)       ( isalpha(c) || isdigit(c) )     */
#define isalnum(c)       ( __ctype_table[(int) c] & __CT_alphanum )
#define isalnum(c)       ( __ctype_table[(int) c] & __CT_alphanum )
/*#define isalpha(c)       ( isupper(c) || islower(c) )     */
/*#define isalpha(c)       ( isupper(c) || islower(c) )     */
#define isalpha(c)       ( __ctype_table[(int) c] & __CT_ul )
#define isalpha(c)       ( __ctype_table[(int) c] & __CT_ul )
#define isascii(c)       ( (c) & ~0x7F )
#define isascii(c)       ( (c) & ~0x7F )
#define isblank(c)       ( __ctype_table[(int) c] & __CT_b )
#define isblank(c)       ( __ctype_table[(int) c] & __CT_b )
#define iscntrl(c)       ( __ctype_table[(int) c] & __CT_c )
#define iscntrl(c)       ( __ctype_table[(int) c] & __CT_c )
#define isdigit(c)       ( __ctype_table[(int) c] & __CT_d )
#define isdigit(c)       ( __ctype_table[(int) c] & __CT_d )
#define isgraph(c)       ( __ctype_table[(int) c] & __CT_graph )
#define isgraph(c)       ( __ctype_table[(int) c] & __CT_graph )
#define islower(c)       ( __ctype_table[(int) c] & __CT_l )
#define islower(c)       ( __ctype_table[(int) c] & __CT_l )
#define isprint(c)       ( __ctype_table[(int) c] & __CT_print)
#define isprint(c)       ( __ctype_table[(int) c] & __CT_print)
#define ispunct(c)       ( __ctype_table[(int) c] & __CT_p )
#define ispunct(c)       ( __ctype_table[(int) c] & __CT_p )
#define isspace(c)       ( __ctype_table[(int) c] & __CT_space )
#define isspace(c)       ( __ctype_table[(int) c] & __CT_space )
#define isupper(c)       ( __ctype_table[(int) c] & __CT_u )
#define isupper(c)       ( __ctype_table[(int) c] & __CT_u )
#define isxdigit(c)      ( __ctype_table[(int) c] & __CT_x )
#define isxdigit(c)      ( __ctype_table[(int) c] & __CT_x )
 
 
#endif /* __CTYPE_H */
#endif /* __CTYPE_H */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.