<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div><br></div><div><br></div><div>On Mon, Sep 28, 2020, at 10:48, Rémi Denis-Courmont wrote:<br></div><blockquote type="cite" id="qt" style=""><div>Hi,<br></div><div><br></div><div>Since when we require the vlc prefix for (new) private APIs<br></div></blockquote><div><br></div><div>We never really discuted it. </div><div>I personnaly would love to make it a new requirement. Anyway, it's not a big deal. </div><div><br></div><blockquote type="cite" id="qt" style=""><div><br></div><div>And it's not through review because I've had enough of getting blatant filibuster on the previous versions of the same patchset.<br></div></blockquote><div><br></div><div>These reviews were very useful. We spotted some possible regressions that you gladly fixed (adaptive, m3u, priority). I really don't see what is the problem with these reviews. </div><div><br></div><blockquote type="cite" id="qt" style=""><div>I did send all the core changes for review. I don't like how I'm being singled out for sending non-core non-lib changes, when I'm evidently not the only one to do do. Especially not when I did in fact send patches for review to a large extent.<br></div><div><br></div><div class="qt-gmail_quote"><div>Le 28 septembre 2020 11:20:06 GMT+03:00, Thomas Guillem <thomas@gllm.fr> a écrit :<br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:0pt;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;"><pre class="qt-k9mail"><div><br></div><div><br></div><div>On Sun, Sep 27, 2020, at 15:16, Rémi Denis-Courmont wrote:<br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(114, 159, 207);padding-left:1ex;"><div>vlc | branch: master | Rémi Denis-Courmont <remi@remlab.net> | Sun Sep <br></div><div>27 15:19:42 2020 +0300| [c4c1bc81e819cee65f673a10f58e40f56eab9704] | <br></div><div>committer: Rémi Denis-Courmont<br></div><div><br></div><div>JSON representation and Javascript unescaping<br></div><div><br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(173, 127, 168);padding-left:1ex;"><a href="http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c4c1bc81e819cee65f673a10f58e40f56eab9704">http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c4c1bc81e819cee65f673a10f58e40f56eab9704</a><br></blockquote><div><hr> modules/demux/Makefile.am | 7 +++<br></div><div> modules/demux/json/json.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++<br></div><div> modules/demux/json/json.h | 73 +++++++++++++++++++++++<br></div><div> 3 files changed, 225 insertions(+)<br></div><div><br></div><div>diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am<br></div><div>index 675b2d10af..f46fcdb92e 100644<br></div><div>--- a/modules/demux/Makefile.am<br></div><div>+++ b/modules/demux/Makefile.am<br></div><div>@@ -512,3 +512,10 @@ libdemux_mock_plugin_la_SOURCES = demux/mock.c<br></div><div> libdemux_mock_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(demuxdir)'<br></div><div> libdemux_mock_plugin_la_LIBADD = $(LIBM)<br></div><div> noinst_LTLIBRARIES += libdemux_mock_plugin.la<br></div><div>+<br></div><div>+libvlc_json_la_SOURCES = \<br></div><div>+ demux/json/json.c demux/json/json.h<br></div><div>+libvlc_json_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/demux/json<br></div><div>+libvlc_json_la_LIBADD = $(LTLIBVLCCORE) ../compat/libcompat.la<br></div><div>+libvlc_json_la_LDFLAGS = -static<br></div><div>+noinst_LTLIBRARIES += libvlc_json.la<br></div><div>diff --git a/modules/demux/json/json.c b/modules/demux/json/json.c<br></div><div>new file mode 100644<br></div><div>index 0000000000..d0ab86120a<br></div><div>--- /dev/null<br></div><div>+++ b/modules/demux/json/json.c<br></div><div>@@ -0,0 +1,145 @@<br></div><div>+/*****************************************************************************<br></div><div>+ * json/json.c: JSON parsing library<br></div><div>+ *****************************************************************************<br></div><div>+ * Copyright © 2020 Rémi Denis-Courmont<br></div><div>+ *<br></div><div>+ * This program is free software; you can redistribute it and/or modify it<br></div><div>+ * under the terms of the GNU Lesser General Public License as published by<br></div><div>+ * the Free Software Foundation; either version 2.1 of the License, or<br></div><div>+ * (at your option) any later version.<br></div><div>+ *<br></div><div>+ * This program is distributed in the hope that it will be useful,<br></div><div>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br></div><div>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br></div><div>+ * GNU Lesser General Public License for more details.<br></div><div>+ *<br></div><div>+ * You should have received a copy of the GNU Lesser General Public License<br></div><div>+ * along with this program; if not, write to the Free Software Foundation,<br></div><div>+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br></div><div>+ *****************************************************************************/<br></div><div>+<br></div><div>+#ifdef HAVE_CONFIG_H<br></div><div>+# include <config.h><br></div><div>+#endif<br></div><div>+<br></div><div>+#include <assert.h><br></div><div>+#include <math.h><br></div><div>+#include <stdint.h><br></div><div>+#include <stdlib.h><br></div><div>+#include <string.h><br></div><div>+#include <vlc_common.h><br></div><div>+#include <vlc_charset.h><br></div><div>+#include "json.h"<br></div><div>+<br></div><div>+#ifdef WORDS_BIGENDIAN<br></div><div>+# define ENDIAN(x) x "BE"<br></div><div>+#else<br></div><div>+# define ENDIAN(x) x "LE"<br></div><div>+#endif<br></div><div>+<br></div><div>+char *json_unescape(const char *in, size_t inlen)<br></div><div>+{<br></div><div>+ /* 1) Convert UTF-8 to UTF-16.<br></div><div>+ * This will catch any invalid UTF-8 byte sequence.<br></div><div>+ */<br></div><div>+ size_t buflen = 2 * (inlen + 1);<br></div><div>+ void *buf = malloc(buflen);<br></div><div>+<br></div><div>+ if (unlikely(buf == NULL))<br></div><div>+ return NULL;<br></div><div>+<br></div><div>+ vlc_iconv_t hd = vlc_iconv_open(ENDIAN("UTF-16") , "UTF-8");<br></div><div>+<br></div><div>+ if (unlikely(hd == (vlc_iconv_t)-1)) {<br></div><div>+ free(buf);<br></div><div>+ return NULL;<br></div><div>+ }<br></div><div>+<br></div><div>+ char *out = buf;<br></div><div>+ size_t outlen = buflen;<br></div><div>+ size_t val = vlc_iconv(hd, &in, &inlen, &out, &outlen);<br></div><div>+<br></div><div>+ vlc_iconv_close(hd);<br></div><div>+<br></div><div>+ if (val == (size_t)-1) {<br></div><div>+ free(buf);<br></div><div>+ return NULL;<br></div><div>+ }<br></div><div>+<br></div><div>+ /* 2) Unescape in UTF-16 (in place).<br></div><div>+ */<br></div><div>+ const uint16_t *in2 = buf, *end2 = in2 + ((buflen - outlen) / 2);<br></div><div>+ uint16_t *out2 = buf;<br></div><div>+<br></div><div>+ while (in2 < end2) {<br></div><div>+ uint16_t c = *(in2++);<br></div><div>+<br></div><div>+ if (c == '\\') {<br></div><div>+ switch (*(in2++)) {<br></div><div>+ case 'b':<br></div><div>+ c = '\b';<br></div><div>+ break;<br></div><div>+ case 'f':<br></div><div>+ c = '\f';<br></div><div>+ break;<br></div><div>+ case 'n':<br></div><div>+ c = '\n';<br></div><div>+ break;<br></div><div>+ case 'r':<br></div><div>+ c = '\r';<br></div><div>+ break;<br></div><div>+ case 't':<br></div><div>+ c = '\t';<br></div><div>+ break;<br></div><div>+ case 'u': {<br></div><div>+ char hex[5] = { in2[0], in2[1], in2[2], in2[3], 0 };<br></div><div>+<br></div><div>+ /* Tokeniser requires 4 hex-digits, so this cannot fail. */<br></div><div>+ if (sscanf(hex, "%4"SCNx16, &c) != 1)<br></div><div>+ vlc_assert_unreachable();<br></div><div>+<br></div><div>+ in2 += 4;<br></div><div>+ break;<br></div><div>+ }<br></div><div>+ default:<br></div><div>+ /* Invalid escape is not allowed by tokeniser. */<br></div><div>+ vlc_assert_unreachable();<br></div><div>+ }<br></div><div>+ }<br></div><div>+<br></div><div>+ assert(out2 < in2); /* Safely in place */<br></div><div>+ *(out2++) = c;<br></div><div>+ }<br></div><div>+<br></div><div>+ /* 3) Convert back to UTF-8.<br></div><div>+ * This will catch any invalid sequence of escaped UTF-16 surrogates.<br></div><div>+ */<br></div><div>+ char *ret = FromCharset(ENDIAN("UTF-16"), buf, (char *)out2 - (char *)buf);<br></div><div>+<br></div><div>+ free(buf);<br></div><div>+ return ret;<br></div><div>+}<br></div><div>+<br></div><div>+const struct json_value *json_get(const struct json_object *obj,<br></div><div>+ const char *name)<br></div><div>+{<br></div><div>+ for (size_t i = 0; i < obj->count; i++)<br></div><div>+ if (!strcmp(obj->members[i].name, name))<br></div><div>+ return &obj->members[i].value;<br></div><div>+<br></div><div>+ return NULL;<br></div><div>+}<br></div><div>+<br></div><div>+const char *json_get_str(const struct json_object *obj, const char *name)<br></div><div>+{<br></div><div>+ const struct json_value *v = json_get(obj, name);<br></div><div>+<br></div><div>+ return (v != NULL && v->type == JSON_STRING) ? v->string : NULL;<br></div><div>+}<br></div><div>+<br></div><div>+double json_get_num(const struct json_object *obj, const char *name)<br></div><div>+{<br></div><div>+ const struct json_value *v = json_get(obj, name);<br></div><div>+<br></div><div>+ return (v != NULL && v->type == JSON_NUMBER) ? v->number : NAN;<br></div><div>+}<br></div><div>diff --git a/modules/demux/json/json.h b/modules/demux/json/json.h<br></div><div>new file mode 100644<br></div><div>index 0000000000..e468ec871f<br></div><div>--- /dev/null<br></div><div>+++ b/modules/demux/json/json.h<br></div><div>@@ -0,0 +1,73 @@<br></div><div>+/*****************************************************************************<br></div><div>+ * json/json.h:<br></div><div>+ *****************************************************************************<br></div><div>+ * Copyright © 2020 Rémi Denis-Courmont<br></div><div>+ *<br></div><div>+ * This program is free software; you can redistribute it and/or modify it<br></div><div>+ * under the terms of the GNU Lesser General Public License as published by<br></div><div>+ * the Free Software Foundation; either version 2.1 of the License, or<br></div><div>+ * (at your option) any later version.<br></div><div>+ *<br></div><div>+ * This program is distributed in the hope that it will be useful,<br></div><div>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br></div><div>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br></div><div>+ * GNU Lesser General Public License for more details.<br></div><div>+ *<br></div><div>+ * You should have received a copy of the GNU Lesser General Public License<br></div><div>+ * along with this program; if not, write to the Free Software Foundation,<br></div><div>+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br></div><div>+ *****************************************************************************/<br></div><div>+<br></div><div>+#ifndef JSON_H<br></div><div>+#define JSON_H<br></div><div>+<br></div><div>+#include <stdbool.h><br></div><div>+#include <stdio.h><br></div><div>+<br></div><div>+enum json_type {<br></div><div>+ JSON_NULL,<br></div><div>+ JSON_BOOLEAN,<br></div><div>+ JSON_NUMBER,<br></div><div>+ JSON_STRING,<br></div><div>+ JSON_ARRAY,<br></div><div>+ JSON_OBJECT,<br></div><div>+};<br></div><div>+<br></div><div>+struct json_array {<br></div><div>+ size_t size;<br></div><div>+ struct json_value *entries;<br></div><div>+};<br></div><div>+<br></div><div>+struct json_object {<br></div><div>+ size_t count;<br></div><div>+ struct json_member *members;<br></div><div>+};<br></div><div>+<br></div><div>+struct json_value {<br></div><div>+ enum json_type type;<br></div><div>+ union {<br></div><div>+ bool boolean;<br></div><div>+ double number;<br></div><div>+ char *string;<br></div><div>+ struct json_array array;<br></div><div>+ struct json_object object;<br></div><div>+ };<br></div><div>+};<br></div><div>+<br></div><div>+struct json_member {<br></div><div>+ char *name;<br></div><div>+ struct json_value value;<br></div><div>+};<br></div><div>+<br></div><div>+void json_parse_error(void *log, const char *msg);<br></div><div>+char *json_unescape(const char *, size_t);<br></div><div>+<br></div><div>+int json_parse(void *log, FILE *in, struct json_object *result);<br></div><div>+void json_free(struct json_object *);<br></div><div>+<br></div><div>+const struct json_value *json_get(const struct json_object *obj,<br></div><div>+ const char *name);<br></div><div>+const char *json_get_str(const struct json_object *obj, const char *name);<br></div><div>+double json_get_num(const struct json_object *obj, const char *name);<br></div></blockquote><div><br></div><div>Please prefix with *vlc_* for new APIs (even module-only ones).<br></div><div><br></div><div>Also: Why not passing by the mailing list?<br></div><div><br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(114, 159, 207);padding-left:1ex;"><div> +<br></div><div> +#endif<hr> vlc-commits mailing list<br></div><div> vlc-commits@videolan.org<br></div><div> <a href="https://mailman.videolan.org/listinfo/vlc-commits">https://mailman.videolan.org/listinfo/vlc-commits</a><br></div></blockquote><div><hr>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></pre></blockquote></div><div><br></div><div>-- <br></div><div>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté. <br></div><div>_______________________________________________<br></div><div>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></blockquote><div><br></div></body></html>