[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>
This commit is contained in:
Michael Brown
2013-07-12 14:44:20 +02:00
parent 362a628e52
commit 076f58c4bf
4 changed files with 63 additions and 36 deletions

View File

@@ -34,19 +34,7 @@ static inline int strtoul_base ( const char **pp, int base )
return base;
}
static inline 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;
}
extern unsigned int strtoul_charval ( unsigned int charval );
extern unsigned long strtoul ( const char *p, char **endp, int base );
extern unsigned long long strtoull ( const char *p, char **endp, int base );