diff --git a/gdb.c b/gdb.c index 06e0bff..1f50e99 100644 --- a/gdb.c +++ b/gdb.c @@ -179,18 +179,6 @@ static void gdb_packet_end(struct gdb_data *data) gdb_printf(data, "#%02x", c); } -static int hexval(int c) -{ - if (isdigit(c)) - return c - '0'; - if (isupper(c)) - return c - 'A' + 10; - if (islower(c)) - return c - 'a' + 10; - - return 0; -} - static int gdb_send(struct gdb_data *data, const char *msg) { gdb_packet_start(data); diff --git a/srec.c b/srec.c index 7d3aa68..dac2d29 100644 --- a/srec.c +++ b/srec.c @@ -45,16 +45,6 @@ int srec_check(FILE *in) return 1; } -static int hexval(int c) -{ - if (isdigit(c)) - return c - '0'; - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - - return c - 'a' + 10; -} - int srec_extract(FILE *in, binfile_imgcb_t cb, void *user_data) { char buf[128]; diff --git a/util.c b/util.c index 0fc673b..a42123e 100644 --- a/util.c +++ b/util.c @@ -317,3 +317,15 @@ void debug_hexdump(const char *label, const uint8_t *data, int len) offset += i; } } + +int hexval(int c) +{ + if (isdigit(c)) + return c - '0'; + if (isupper(c)) + return c - 'A' + 10; + if (islower(c)) + return c - 'a' + 10; + + return 0; +} diff --git a/util.h b/util.h index 49f0359..3246d5e 100644 --- a/util.h +++ b/util.h @@ -57,4 +57,6 @@ static inline int ishex(int c) return isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); } +int hexval(int c); + #endif