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

Subversion Repositories de1_olpcl2294_system

[/] [de1_olpcl2294_system/] [trunk/] [sw/] [ecos/] [shell/] [dbg_sh.h] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 qaztronic
//
2
//
3
//
4
 
5
 
6
//-----------------------------------------------------------------------------
7
// String functions. Some of these are duplicates of the same functions in
8
// the I18N package.
9
 
10
// Validate a hex character
11
__inline__ static bool
12
_is_hex(char c)
13
{
14
    return (((c >= '0') && (c <= '9')) ||
15
            ((c >= 'A') && (c <= 'F')) ||
16
            ((c >= 'a') && (c <= 'f')));
17
}
18
 
19
// Convert a single hex nibble
20
__inline__ static int
21
_from_hex(char c)
22
{
23
    int ret = 0;
24
 
25
    if ((c >= '0') && (c <= '9')) {
26
        ret = (c - '0');
27
    } else if ((c >= 'a') && (c <= 'f')) {
28
        ret = (c - 'a' + 0x0a);
29
    } else if ((c >= 'A') && (c <= 'F')) {
30
        ret = (c - 'A' + 0x0A);
31
    }
32
    return ret;
33
}
34
 
35
// Convert a character to lower case
36
__inline__ static char
37
_tolower(char c)
38
{
39
    if ((c >= 'A') && (c <= 'Z')) {
40
        c = (c - 'A') + 'a';
41
    }
42
    return c;
43
}
44
 
45
// Validate alpha
46
__inline__ static bool
47
isalpha(int c)
48
{
49
    return (((c >= 'a') && (c <= 'z')) ||
50
            ((c >= 'A') && (c <= 'Z')));
51
}
52
 
53
// Validate digit
54
__inline__ static bool
55
isdigit(int c)
56
{
57
    return ((c >= '0') && (c <= '9'));
58
}
59
 
60
// Validate alphanum
61
__inline__ static bool
62
isalnum(int c)
63
{
64
    return (isalpha(c) || isdigit(c));
65
}
66
 

powered by: WebSVN 2.1.0

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