[vlc-commits] satip: privatize net_Printf()

Rémi Denis-Courmont git at videolan.org
Sun Nov 11 16:33:39 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 10 15:17:38 2018 +0200| [184fbc5c54835729361293ef21948de12f818934] | committer: Rémi Denis-Courmont

satip: privatize net_Printf()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=184fbc5c54835729361293ef21948de12f818934
---

 include/vlc_network.h  |  2 --
 modules/access/satip.c | 17 +++++++++++++++++
 src/network/io.c       | 12 ------------
 3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/include/vlc_network.h b/include/vlc_network.h
index 9aa2f30909..9a3e9675da 100644
--- a/include/vlc_network.h
+++ b/include/vlc_network.h
@@ -199,8 +199,6 @@ VLC_API ssize_t net_Read( vlc_object_t *p_this, int fd, void *p_data, size_t i_d
 VLC_API ssize_t net_Write( vlc_object_t *p_this, int fd, const void *p_data, size_t i_data );
 #define net_Write(a,b,c,d) net_Write(VLC_OBJECT(a),b,c,d)
 
-VLC_API ssize_t net_Printf( vlc_object_t *p_this, int fd, const char *psz_fmt, ... ) VLC_FORMAT( 3, 4 );
-#define net_Printf(o,fd,...) net_Printf(VLC_OBJECT(o),fd, __VA_ARGS__)
 VLC_API ssize_t net_vaPrintf( vlc_object_t *p_this, int fd, const char *psz_fmt, va_list args );
 #define net_vaPrintf(a,b,c,d) net_vaPrintf(VLC_OBJECT(a),b,c,d)
 
diff --git a/modules/access/satip.c b/modules/access/satip.c
index 8ecea610b4..ae71e5fb86 100644
--- a/modules/access/satip.c
+++ b/modules/access/satip.c
@@ -118,6 +118,23 @@ typedef struct
     bool woken;
 } access_sys_t;
 
+VLC_FORMAT(3, 4)
+static void net_Printf(stream_t *access, int fd, const char *fmt, ...)
+{
+    va_list ap;
+    char *str;
+    int val;
+
+    va_start(ap, fmt);
+    val = vasprintf(&str, fmt, ap);
+    va_end(ap);
+
+    if (val >= 0) {
+        net_Write(access, fd, str, val);
+        free(str);
+    }
+}
+
 static void parse_session(char *request_line, char *session, unsigned max, int *timeout) {
     char *state;
     char *tok;
diff --git a/src/network/io.c b/src/network/io.c
index 7cff7569e1..7fea132724 100644
--- a/src/network/io.c
+++ b/src/network/io.c
@@ -445,18 +445,6 @@ ssize_t (net_Write)(vlc_object_t *obj, int fd, const void *buf, size_t len)
     return written;
 }
 
-#undef net_Printf
-ssize_t net_Printf( vlc_object_t *p_this, int fd, const char *psz_fmt, ... )
-{
-    int i_ret;
-    va_list args;
-    va_start( args, psz_fmt );
-    i_ret = net_vaPrintf( p_this, fd, psz_fmt, args );
-    va_end( args );
-
-    return i_ret;
-}
-
 #undef net_vaPrintf
 ssize_t net_vaPrintf( vlc_object_t *p_this, int fd,
                       const char *psz_fmt, va_list args )



More information about the vlc-commits mailing list