]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
uuid: extend bin2hex (return dst)
authorJaroslav Kysela <perex@perex.cz>
Sun, 17 Dec 2017 17:02:43 +0000 (18:02 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 17 Dec 2017 17:02:43 +0000 (18:02 +0100)
src/uuid.c
src/uuid.h

index e9d604bcd3df278bc09e5ecced63c4862309babb..eba3b954d4cfc967a96d711c064ada40abab45e8 100644 (file)
@@ -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;
 }
 
 /* **************************************************************************
index bf174bd6d9dfca91b6bd19865cbb2ff8af6f2037..88caf28cd9c5238a3c7273e64a8c8c5b427c82fd 100644 (file)
@@ -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__ */