* @brief Decode from hexadecimal format into character counted string * * @param in ptr to an input counted string in hexadecimal format * @param inLen input character count * @param out ptr to a buffer to store the decoded counted string * @param outLen output character count (inLen/2) * @return the number of character actually added to the output buffer. */
| 89 | * @return the number of character actually added to the output buffer. |
| 90 | */ |
| 91 | size_t |
| 92 | hexDecode(const char *in, size_t inLen, char *out, size_t outLen) |
| 93 | { |
| 94 | const char *src = in; |
| 95 | const char *srcEnd = in + inLen; |
| 96 | char *dst = out; |
| 97 | char *dstEnd = out + outLen; |
| 98 | |
| 99 | while (src < (srcEnd - 1) && dst < dstEnd) { |
| 100 | *dst++ = hex2uchar(*src) << 4 | hex2uchar(*(src + 1)); |
| 101 | src += 2; |
| 102 | } |
| 103 | return dst - out; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * @brief URL(percent)-encode a counted string |
no test coverage detected