diff options
| author | Michael Brown | 2013-07-12 14:44:20 +0200 |
|---|---|---|
| committer | Michael Brown | 2013-07-12 15:14:36 +0200 |
| commit | 076f58c4bf9fa1ae0faa65a731523cb531705974 (patch) | |
| tree | abe42a7625ab2fc15a572e4e6959310a2b0c9ce3 /src/core/misc.c | |
| parent | [test] Add self-tests for base16 (diff) | |
| download | ipxe-076f58c4bf9fa1ae0faa65a731523cb531705974.tar.gz ipxe-076f58c4bf9fa1ae0faa65a731523cb531705974.tar.xz ipxe-076f58c4bf9fa1ae0faa65a731523cb531705974.zip | |
[base16] Generalise base16_decode() to hex_decode()
Provide a generic hex_decode() routine which can be shared between the
Base16 code and the "hex" and "hexhyp" settings parsers.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/misc.c')
| -rw-r--r-- | src/core/misc.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/misc.c b/src/core/misc.c index 11342481a..eaceddfea 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -33,6 +33,19 @@ int inet_aton ( const char *cp, struct in_addr *inp ) { return 0; } +unsigned int strtoul_charval ( unsigned int charval ) { + + if ( charval >= 'a' ) { + charval = ( charval - 'a' + 10 ); + } else if ( charval >= 'A' ) { + charval = ( charval - 'A' + 10 ); + } else if ( charval <= '9' ) { + charval = ( charval - '0' ); + } + + return charval; +} + unsigned long strtoul ( const char *p, char **endp, int base ) { unsigned long ret = 0; int negative = 0; |
