aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/other/xval.c
blob: c7d1276498004b66632361b20f2d1f12d054dfa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * Hex digit conversions.
 * $Id$
 * Copyright (c) 1997 by Tycho Softworks.
 * For conditions of distribution and reuse see product license.
 */

#include <other/strcvt.h>

int     xdigit(char c)
{
        if(c > '9')
                return upper(c) - '7';

        return digit(c);
};

ulong   xtol(const char *s)
{
        ulong v = 0l;

        while(isxdigit(*s))
        {
                v = v << 4 | xdigit(*s);
                ++s;
        }
        return v;
};