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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [include/] [ctype.h] - Blame information for rev 673

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 marcus.erl
/*
2
    ctype.h -- character types
3
    Implements the usual ctype stuff (only valid for ASCII systems)
4
    Copyright (C) 2002 Richard Herveille, rherveille@opencores.org
5
 
6
    This file is part of OpenRISC 1000 Reference Platform Monitor (ORPmon)
7
 
8
    This program is free software; you can redistribute it and/or modify
9
    it under the terms of the GNU General Public License as published by
10
    the Free Software Foundation; either version 2 of the License, or
11
    (at your option) any later version
12
 
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17
 
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
*/
22
 
23
 
24
#ifndef __CTYPE_H
25
#define __CTYPE_H
26
 
27
/* basic types                                              */
28
#define __CT_d 0x01               /* numeric digit          */
29
#define __CT_u 0x02               /* upper case             */
30
#define __CT_l 0x04               /* lower case             */
31
#define __CT_c 0x08               /* control character      */
32
#define __CT_s 0x10               /* whitespace             */
33
#define __CT_p 0x20               /* punctuation            */
34
#define __CT_x 0x40               /* hexadecimal            */
35
#define __CT_b 0x80               /* blank (is also space)  */
36
 
37
/* combination types                                        */
38
#define __CT_lx (__CT_l | __CT_x) /* lower case hexadecimal */
39
#define __CT_ux (__CT_u | __CT_x) /* upper case hexadecimal */
40
 
41
#define __CT_space    (__CT_s | __CT_b)
42
#define __CT_alphanum (__CT_l | __CT_u | __CT_d)
43
#define __CT_graph    (__CT_l | __CT_u | __CT_d | __CT_p)
44
#define __CT_print    (__CT_l | __CT_u | __CT_d | __CT_p | __CT_b)
45
 
46
extern const unsigned char __ctype_table[256];
47
 
48
#define _toupper(c)      ( (c) ^ 0x20 )
49
#define _tolower(c)      ( (c) ^ 0x20 )
50
#define toupper(c)       ( islower(c) ? _tolower(c) : (c) )
51
#define tolower(c)       ( isupper(c) ? _toupper(c) : (c) )
52
#define toascii(c)       ( (c) & 0x7F )
53
 
54
 
55
/* standard defenitions are taken from man-pages            */
56
/*#define isalnum(c)       ( isalpha(c) || isdigit(c) )     */
57
#define isalnum(c)       ( __ctype_table[(int) c] & __CT_alphanum )
58
/*#define isalpha(c)       ( isupper(c) || islower(c) )     */
59
#define isalpha(c)       ( __ctype_table[(int) c] & __CT_ul )
60
#define isascii(c)       ( (c) & ~0x7F )
61
#define isblank(c)       ( __ctype_table[(int) c] & __CT_b )
62
#define iscntrl(c)       ( __ctype_table[(int) c] & __CT_c )
63
#define isdigit(c)       ( __ctype_table[(int) c] & __CT_d )
64
#define isgraph(c)       ( __ctype_table[(int) c] & __CT_graph )
65
#define islower(c)       ( __ctype_table[(int) c] & __CT_l )
66
#define isprint(c)       ( __ctype_table[(int) c] & __CT_print)
67
#define ispunct(c)       ( __ctype_table[(int) c] & __CT_p )
68
#define isspace(c)       ( __ctype_table[(int) c] & __CT_space )
69
#define isupper(c)       ( __ctype_table[(int) c] & __CT_u )
70
#define isxdigit(c)      ( __ctype_table[(int) c] & __CT_x )
71
 
72
#endif /* __CTYPE_H */

powered by: WebSVN 2.1.0

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