<html><head></head><body>Not OK for me. This belongs as a separate source and binary.<br><br><div class="gmail_quote">Le 7 janvier 2020 19:17:18 GMT+09:00, Vincenzo Nicosia <katolaz@freaknet.org> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On Tue, Jan 07, 2020 at 09:10:09AM +0100, Steve Lhomme wrote:<br><br>[cut]<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;">However, I understand that it makes sense to have a consistent coding<br>style in the same file. I will adapt the patch to match the style used<br>in tcp.c then.<br></blockquote> That's the idea, we usually try to follow the style of the existing file for<br> additions. For new code, especially modules, it depends on the author. But<br> in general we use a space before the { of a if().<br><br></blockquote><br>Hi Steve,<br><br>I used the same style found in tcp.c ({ on a lonely line, aligned with<br>'if', no space before '(' and ')', uncuddled 'else'), and replaced<br>msg_Info with msg_Warn. Amended patch below.<br><br>Thanks for your review.<hr> modules/access/tcp.c | 86 ++++++++++++++++++++++++++++++++++++++++++++<br> src/input/item.c     |  1 +<br> 2 files changed, 87 insertions(+)<br><br>diff --git a/modules/access/tcp.c b/modules/access/tcp.c<br>index 214a5853be..b3599a0472 100644<br>--- a/modules/access/tcp.c<br>+++ b/modules/access/tcp.c<br>@@ -2,8 +2,10 @@<br>  * tcp.c: TCP input module<br>  *****************************************************************************<br>  * Copyright (C) 2003-2004 VLC authors and VideoLAN<br>+ * Copyright (C) 2020 Vincenzo "KatolaZ" Nicosia<br>  *<br>  * Authors: Laurent Aimar <fenrir@via.ecp.fr><br>+ *          Vincenzo "KatolaZ" Nicosia <katolaz@freaknet.org> (gopher sub-module)<br>  *<br>  * This program is free software; you can redistribute it and/or modify it<br>  * under the terms of the GNU Lesser General Public License as published by<br>@@ -29,9 +31,13 @@<br> #include <vlc_common.h><br> #include <vlc_plugin.h><br> #include <vlc_access.h><br>+#include <vlc_messages.h><br> #include <vlc_url.h><br> #include <vlc_tls.h><br> <br>+#include <stdlib.h><br>+#include <string.h><br>+<br> static ssize_t Read(stream_t *access, void *buf, size_t len)<br> {<br>     return vlc_tls_Read(access->p_sys, buf, len, false);<br>@@ -106,6 +112,76 @@ static void Close( vlc_object_t *p_this )<br>     vlc_tls_SessionDelete(access->p_sys);<br> }<br> <br>+static int GopherOpen(vlc_object_t *obj)<br>+{<br>+    char *psz_path = NULL;<br>+    stream_t *access = (stream_t *)obj;<br>+    vlc_tls_t *sock;<br>+    vlc_url_t url;<br>+<br>+<br>+    if (vlc_UrlParse(&url, access->psz_url) || url.psz_host == NULL) <br>+    {<br>+        msg_Err(access, "invalid location: %s", access->psz_location);<br>+        vlc_UrlClean(&url);<br>+        return VLC_EGENERIC;<br>+    }<br>+<br>+    if (url.i_port == 0)<br>+    {<br>+        url.i_port = 70;<br>+    }<br>+    sock = vlc_tls_SocketOpenTCP(obj, url.psz_host, url.i_port);<br>+<br>+    if (unlikely(sock == NULL))<br>+    {<br>+        msg_Err(access, "cannot connect to %s:%d", url.psz_host, url.i_port);<br>+        vlc_UrlClean(&url);<br>+        return VLC_EGENERIC;<br>+    }<br>+<br>+    if (url.psz_path == NULL || strlen(url.psz_path) <= 3)<br>+    {<br>+        /* If no resource type is specified, look for the root resource */<br>+        if (asprintf(&psz_path, "\r\n") == -1)<br>+        {<br>+            vlc_UrlClean(&url);<br>+            vlc_tls_SessionDelete(sock);<br>+            return VLC_EGENERIC;<br>+        }<br>+        msg_Warn(access, "path set to root resource");<br>+    }<br>+    else { /* strip resource type from URL */<br>+        if(asprintf(&psz_path, "%s\r\n", url.psz_path+2) == -1)<br>+        {<br>+            vlc_UrlClean(&url);<br>+            vlc_tls_SessionDelete(sock);<br>+            return VLC_EGENERIC;<br>+        }<br>+        msg_Warn(access, "stripped resource type from path");<br>+    }<br>+    vlc_UrlClean(&url);<br>+<br>+    access->p_sys = sock;<br>+    access->pf_read = Read;<br>+    access->pf_block = NULL;<br>+    access->pf_control = Control;<br>+    access->pf_seek = NULL;<br>+<br>+    msg_Warn(access, "requesting resource: %s", psz_path);<br>+    if (vlc_tls_Write(access->p_sys, psz_path, strlen(psz_path)) < 0)<br>+    {<br>+        vlc_tls_SessionDelete(access->p_sys);<br>+        free(psz_path);<br>+        return VLC_EGENERIC;<br>+    }<br>+<br>+    free(psz_path);<br>+    return VLC_SUCCESS;<br>+}<br>+<br>+<br>+<br> /*****************************************************************************<br>  * Module descriptor<br>  *****************************************************************************/<br>@@ -118,4 +194,14 @@ vlc_module_begin ()<br>     set_capability( "access", 0 )<br>     add_shortcut( "tcp" )<br>     set_callbacks( Open, Close )<br>+<br>+/* Gopher submodule */<br>+    add_submodule ()<br>+        set_description( N_("Gopher input") )<br>+        set_capability( "access", 0 )<br>+        set_shortname( "gopher" )<br>+        set_category( CAT_INPUT )<br>+        set_subcategory( SUBCAT_INPUT_ACCESS )<br>+        add_shortcut( "gopher" )<br>+        set_callbacks( GopherOpen, Close )<br> vlc_module_end ()<br>diff --git a/src/input/item.c b/src/input/item.c<br>index 9c3442d5c7..1a8a2bdb3f 100644<br>--- a/src/input/item.c<br>+++ b/src/input/item.c<br>@@ -1187,6 +1187,7 @@ static enum input_item_type_e GuessType( const input_item_t *p_item, bool *p_net<br>         { "fd",     ITEM_TYPE_UNKNOWN, false },<br>         { "file",   ITEM_TYPE_FILE, false },<br>         { "ftp",    ITEM_TYPE_FILE, true },<br>+        { "gopher", ITEM_TYPE_STREAM, true },<br>         { "http",   ITEM_TYPE_FILE, true },<br>         { "icyx",   ITEM_TYPE_STREAM, true },<br>         { "imem",   ITEM_TYPE_UNKNOWN, false },</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>