From: Jaroslav Kysela Date: Sun, 17 Dec 2017 17:02:43 +0000 (+0100) Subject: uuid: extend bin2hex (return dst) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba0f6a15bf10f76ffe6d1a7d6684ba2834e7e574;p=thirdparty%2Ftvheadend.git uuid: extend bin2hex (return dst) --- diff --git a/src/uuid.c b/src/uuid.c index e9d604bcd..eba3b954d 100644 --- a/src/uuid.c +++ b/src/uuid.c @@ -76,17 +76,19 @@ hex2bin(uint8_t *buf, size_t buflen, const char *str) /** * */ -void +char * bin2hex(char *dst, size_t dstlen, const uint8_t *src, size_t srclen) { + static const char table[] = "0123456789abcdef"; while(dstlen > 2 && srclen > 0) { - *dst++ = "0123456789abcdef"[*src >> 4]; - *dst++ = "0123456789abcdef"[*src & 0xf]; + *dst++ = table[*src >> 4]; + *dst++ = table[*src & 0xf]; src++; srclen--; dstlen -= 2; } *dst = 0; + return dst; } /* ************************************************************************** diff --git a/src/uuid.h b/src/uuid.h index bf174bd6d..88caf28cd 100644 --- a/src/uuid.h +++ b/src/uuid.h @@ -123,6 +123,6 @@ int hex2bin ( uint8_t *buf, size_t buflen, const char *hex ); /** * Binary to hex string */ -void bin2hex ( char *dst, size_t dstlen, const uint8_t *src, size_t srclen ); +char *bin2hex ( char *dst, size_t dstlen, const uint8_t *src, size_t srclen ); #endif /* __TVH_UUID_H__ */