[vlc-devel] [PATCH v2 02/15] strings: add function to hex-encode binary data
Rémi Denis-Courmont
remi at remlab.net
Wed Apr 8 10:58:04 CEST 2020
Wrong format specifier, should be hhu, and invalid removal of const.
Le 8 avril 2020 01:04:18 GMT+03:00, Marvin Scholz <epirat07 at gmail.com> a écrit :
>---
> include/vlc_strings.h | 12 ++++++++++++
> src/libvlccore.sym | 1 +
> src/text/strings.c | 10 ++++++++++
> 3 files changed, 23 insertions(+)
>
>diff --git a/include/vlc_strings.h b/include/vlc_strings.h
>index 411f4a8ceb..e229b32d5d 100644
>--- a/include/vlc_strings.h
>+++ b/include/vlc_strings.h
>@@ -118,6 +118,18 @@ VLC_API void vlc_xml_decode(char *st);
> */
> VLC_API char *vlc_xml_encode(const char *str) VLC_MALLOC;
>
>+/**
>+ * Encode binary data as hex string
>+ *
>+ * Writes a given data buffer to the output buffer as a null
>terminated
>+ * string in hexadecimal representation.
>+ *
>+ * \param input Input buffer
>+ * \param size Input buffer size
>+ * \param[out] output Output buffer to write the string to
>+ */
>+VLC_API void vlc_hex_encode_binary(const void *input, size_t size,
>char *output);
>+
> /**
> * Base64 encoding.
> *
>diff --git a/src/libvlccore.sym b/src/libvlccore.sym
>index cc8098edd9..17561db932 100644
>--- a/src/libvlccore.sym
>+++ b/src/libvlccore.sym
>@@ -483,6 +483,7 @@ vlc_b64_decode_binary
> vlc_b64_decode_binary_to_buffer
> vlc_b64_encode
> vlc_b64_encode_binary
>+vlc_hex_encode_binary
> vlc_cancel
> vlc_clone
> VLC_CompileBy
>diff --git a/src/text/strings.c b/src/text/strings.c
>index 658249f890..5180f16a83 100644
>--- a/src/text/strings.c
>+++ b/src/text/strings.c
>@@ -346,6 +346,16 @@ char *vlc_xml_encode (const char *str)
> return stream.ptr;
> }
>
>+/* Hex encoding */
>+void vlc_hex_encode_binary(const void *input, size_t size, char
>*output)
>+{
>+ unsigned char *buffer = input;
>+
>+ for (size_t i = 0; i < size; i++) {
>+ sprintf(&output[i * 2], "%02" PRIx8, buffer[i]);
>+ }
>+}
>+
> /* Base64 encoding */
> char *vlc_b64_encode_binary(const void *src, size_t length)
> {
>--
>2.24.1 (Apple Git-126)
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel
--
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200408/0af7fac1/attachment.html>
More information about the vlc-devel
mailing list