-static void hex_to_str(char *dst, char *hex_src)
-{
- int src_pos = 0;
- int dst_pos = 0;
-
- while (hex_src[src_pos] != '\x00') {
- char hex_char = hex_src[src_pos];
- char hex_digit_val =
- (hex_char >=
- 'a') ? hex_char-'a'+
- 10 : (hex_char >= 'A') ? hex_char-'A'+10 : hex_char-'0';
- if (0 == (src_pos & 0x01)) {
- dst[dst_pos] = hex_digit_val;
- dst[dst_pos+1] = 0;
- } else {
- ((unsigned char *)dst)[dst_pos] <<= 4;
- ((unsigned char *)dst)[dst_pos] += hex_digit_val;
- dst_pos++;
- }
- src_pos++;
- }
-
-}
-
-int str_to_hex(char *hex_dst, char *src)
-{
- char *posptr = hex_dst;
- unsigned i;
- for (i = 0; i < strlen(src); i++)
- posptr += sprintf(posptr, "%02x", (unsigned char)src[i]);
- return posptr - hex_dst;
-}
-