aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_str.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/mhd_str.c')
-rw-r--r--src/microhttpd/mhd_str.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c
index 822feccc..08781cb9 100644
--- a/src/microhttpd/mhd_str.c
+++ b/src/microhttpd/mhd_str.c
@@ -1354,3 +1354,24 @@ MHD_uint8_to_str_pad (uint8_t val,
1354 buf[pos++] = '0' + val; 1354 buf[pos++] = '0' + val;
1355 return pos; 1355 return pos;
1356} 1356}
1357
1358
1359size_t
1360MHD_bin_to_hex (const void *bin,
1361 size_t size,
1362 char *hex)
1363{
1364 size_t i;
1365
1366 for (i = 0; i < size; ++i)
1367 {
1368 uint8_t j;
1369 const uint8_t b = ((uint8_t *) bin)[i];
1370 j = b >> 4;
1371 hex[i * 2] = (char) ((j < 10) ? (j + '0') : (j - 10 + 'a'));
1372 j = b & 0x0f;
1373 hex[i * 2 + 1] = (char) ((j < 10) ? (j + '0') : (j - 10 + 'a'));
1374 }
1375 hex[i * 2] = 0;
1376 return i;
1377}