]> git.sesse.net Git - vlc/commitdiff
net_Printf: automagic cast to VLC object
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 7 Feb 2010 10:53:56 +0000 (12:53 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 7 Feb 2010 11:33:50 +0000 (13:33 +0200)
include/vlc_network.h
modules/access/ftp.c
modules/access/http.c
modules/access/mms/mmsh.c
modules/access/rtsp/access.c
modules/misc/audioscrobbler.c
src/network/io.c

index 29078adead998869a949ab207bf84294604210cc..19502d22761061769dc7116db9e58dca015c3b7e 100644 (file)
@@ -146,6 +146,7 @@ VLC_EXPORT( char *, net_Gets, ( vlc_object_t *p_this, int fd, const v_socket_t *
 
 
 VLC_EXPORT( ssize_t, net_Printf, ( vlc_object_t *p_this, int fd, const v_socket_t *, const char *psz_fmt, ... ) LIBVLC_FORMAT( 4, 5 ) );
+#define net_Printf(o,fd,vs,...) net_Printf(VLC_OBJECT(o),fd,vs, __VA_ARGS__)
 VLC_EXPORT( ssize_t, net_vaPrintf, ( vlc_object_t *p_this, int fd, const v_socket_t *, const char *psz_fmt, va_list args ) );
 #define net_vaPrintf(a,b,c,d,e) net_vaPrintf(VLC_OBJECT(a),b,c,d,e)
 
index 89deeb50c44503707b61daaf44575ca6cd65f336..c5ffb2f2c44d9694edf1682ba9d482b13ceac010 100644 (file)
@@ -629,8 +629,7 @@ static int ftp_SendCommand( vlc_object_t *p_access, access_sys_t *p_sys,
 
     msg_Dbg( p_access, "ftp_SendCommand:\"%s\"", psz_cmd);
 
-    if( net_Printf( VLC_OBJECT(p_access), p_sys->fd_cmd, NULL, "%s\r\n",
-                    psz_cmd ) < 0 )
+    if( net_Printf( p_access, p_sys->fd_cmd, NULL, "%s\r\n", psz_cmd ) < 0 )
     {
         msg_Err( p_access, "failed to send command" );
         return VLC_EGENERIC;
index f052d246ee3a87b842ca3146efc602bf93754167..c786c966c19fda252302aae1618ecc73a910aca7 100644 (file)
@@ -1164,7 +1164,7 @@ static int Connect( access_t *p_access, uint64_t i_tell )
                 return -1;
             }
 
-            net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+            net_Printf( p_access, p_sys->fd, NULL,
                         "CONNECT %s:%d HTTP/1.%d\r\nHost: %s:%d\r\n\r\n",
                         p_sys->url.psz_host, p_sys->url.i_port,
                         p_sys->i_version,
@@ -1240,14 +1240,14 @@ static int Request( access_t *p_access, uint64_t i_tell )
     {
         if( p_sys->url.psz_path )
         {
-            net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+            net_Printf( p_access, p_sys->fd, NULL,
                         "GET http://%s:%d%s HTTP/1.%d\r\n",
                         p_sys->url.psz_host, p_sys->url.i_port,
                         p_sys->url.psz_path, p_sys->i_version );
         }
         else
         {
-            net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+            net_Printf( p_access, p_sys->fd, NULL,
                         "GET http://%s:%d/ HTTP/1.%d\r\n",
                         p_sys->url.psz_host, p_sys->url.i_port,
                         p_sys->i_version );
@@ -1262,26 +1262,26 @@ static int Request( access_t *p_access, uint64_t i_tell )
         }
         if( p_sys->url.i_port != (pvs ? 443 : 80) )
         {
-            net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
+            net_Printf( p_access, p_sys->fd, pvs,
                         "GET %s HTTP/1.%d\r\nHost: %s:%d\r\n",
                         psz_path, p_sys->i_version, p_sys->url.psz_host,
                         p_sys->url.i_port );
         }
         else
         {
-            net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
+            net_Printf( p_access, p_sys->fd, pvs,
                         "GET %s HTTP/1.%d\r\nHost: %s\r\n",
                         psz_path, p_sys->i_version, p_sys->url.psz_host );
         }
     }
     /* User Agent */
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "User-Agent: %s\r\n",
+    net_Printf( p_access, p_sys->fd, pvs, "User-Agent: %s\r\n",
                 p_sys->psz_user_agent );
     /* Offset */
     if( p_sys->i_version == 1 && ! p_sys->b_continuous )
     {
         p_sys->b_persist = true;
-        net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
+        net_Printf( p_access, p_sys->fd, pvs,
                     "Range: bytes=%"PRIu64"-\r\n", i_tell );
     }
 
@@ -1303,7 +1303,7 @@ static int Request( access_t *p_access, uint64_t i_tell )
             if( is_in_right_domain )
             {
                 msg_Dbg( p_access, "Sending Cookie %s", psz_cookie_content );
-                if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "Cookie: %s\r\n", psz_cookie_content ) < 0 )
+                if( net_Printf( p_access, p_sys->fd, pvs, "Cookie: %s\r\n", psz_cookie_content ) < 0 )
                     msg_Err( p_access, "failed to send Cookie" );
             }
             free( psz_cookie_content );
@@ -1320,10 +1320,10 @@ static int Request( access_t *p_access, uint64_t i_tell )
         AuthReply( p_access, "Proxy-", &p_sys->proxy, &p_sys->proxy_auth );
 
     /* ICY meta data request */
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "Icy-MetaData: 1\r\n" );
+    net_Printf( p_access, p_sys->fd, pvs, "Icy-MetaData: 1\r\n" );
 
 
-    if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "\r\n" ) < 0 )
+    if( net_Printf( p_access, p_sys->fd, pvs, "\r\n" ) < 0 )
     {
         msg_Err( p_access, "failed to send request" );
         Disconnect( p_access );
@@ -1764,7 +1764,7 @@ static void AuthReply( access_t *p_access, const char *psz_prefix,
     if ( psz_value == NULL )
         return;
 
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, p_sys->p_vs,
+    net_Printf( p_access, p_sys->fd, p_sys->p_vs,
                 "%sAuthorization: %s\r\n", psz_prefix, psz_value );
     free( psz_value );
 }
index d353f0cb4505d2844fc0fa5898474e74461096a4..fe31cc4f6265a51e4cd2fdb21fb17ec99e797347 100644 (file)
@@ -503,7 +503,7 @@ static int OpenConnection( access_t *p_access )
 
     if( p_sys->b_proxy )
     {
-        net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+        net_Printf( p_access, p_sys->fd, NULL,
                     "GET http://%s:%d%s HTTP/1.0\r\n",
                     p_sys->url.psz_host, p_sys->url.i_port,
                     ( (p_sys->url.psz_path == NULL) ||
@@ -523,14 +523,14 @@ static int OpenConnection( access_t *p_access )
             b64 = vlc_b64_encode( buf );
             free( buf );
 
-            net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+            net_Printf( p_access, p_sys->fd, NULL,
                         "Proxy-Authorization: Basic %s\r\n", b64 );
             free( b64 );
         }
     }
     else
     {
-        net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+        net_Printf( p_access, p_sys->fd, NULL,
                     "GET %s HTTP/1.0\r\n"
                     "Host: %s:%d\r\n",
                     ( (p_sys->url.psz_path == NULL) ||
@@ -564,7 +564,7 @@ static int Describe( access_t  *p_access, char **ppsz_location )
     if( OpenConnection( p_access ) )
         return VLC_EGENERIC;
 
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+    net_Printf( p_access, p_sys->fd, NULL,
                 "Accept: */*\r\n"
                 "User-Agent: "MMSH_USER_AGENT"\r\n"
                 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=%d,max-duration=0\r\n"
@@ -573,7 +573,7 @@ static int Describe( access_t  *p_access, char **ppsz_location )
                 p_sys->i_request_context++,
                 GUID_PRINT( p_sys->guid ) );
 
-    if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
+    if( net_Printf( p_access, p_sys->fd, NULL, "\r\n" ) < 0 )
     {
         msg_Err( p_access, "failed to send request" );
         goto error;
@@ -770,24 +770,24 @@ static int Start( access_t *p_access, uint64_t i_pos )
     if( OpenConnection( p_access ) )
         return VLC_EGENERIC;
 
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+    net_Printf( p_access, p_sys->fd, NULL,
                 "Accept: */*\r\n"
                 "User-Agent: "MMSH_USER_AGENT"\r\n" );
     if( p_sys->b_broadcast )
     {
-        net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+        net_Printf( p_access, p_sys->fd, NULL,
                     "Pragma: no-cache,rate=1.000000,request-context=%d\r\n",
                     p_sys->i_request_context++ );
     }
     else
     {
-        net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+        net_Printf( p_access, p_sys->fd, NULL,
                     "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=%u:%u,request-context=%d,max-duration=0\r\n",
                     (uint32_t)((i_pos >> 32)&0xffffffff),
                     (uint32_t)(i_pos&0xffffffff),
                     p_sys->i_request_context++ );
     }
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+    net_Printf( p_access, p_sys->fd, NULL,
                 "Pragma: xPlayStrm=1\r\n"
                 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
                 "Pragma: stream-switch-count=%d\r\n"
@@ -804,15 +804,15 @@ static int Start( access_t *p_access, uint64_t i_pos )
             {
                 i_select = 0;
             }
-            net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+            net_Printf( p_access, p_sys->fd, NULL,
                         "ffff:%d:%d ", i, i_select );
         }
     }
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" );
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+    net_Printf( p_access, p_sys->fd, NULL, "\r\n" );
+    net_Printf( p_access, p_sys->fd, NULL,
                 "Connection: Close\r\n" );
 
-    if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
+    if( net_Printf( p_access, p_sys->fd, NULL, "\r\n" ) < 0 )
     {
         msg_Err( p_access, "failed to send request" );
         return VLC_EGENERIC;
index b23634bbf1d71ec1ca32f560363d2ea75092c95a..bf2dd762913f50898edf804179b5d2c221137209 100644 (file)
@@ -142,7 +142,7 @@ static int RtspWrite( void *p_userdata, uint8_t *p_buffer, int i_buffer )
 
     //fprintf(stderr, "Write: %s", p_buffer);
 
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, 0, "%s", p_buffer );
+    net_Printf( p_access, p_sys->fd, 0, "%s", p_buffer );
 
     return 0;
 }
index fa359489adb102c9a823360f18088f56d29e2863..fbcc95a70b4b7f2cad712958ff05ab6d294f3d73 100644 (file)
@@ -394,7 +394,7 @@ static void Run( intf_thread_t *p_intf )
 
         /* we transmit the data */
         i_net_ret = net_Printf(
-            VLC_OBJECT( p_intf ), i_post_socket, NULL,
+            p_intf, i_post_socket, NULL,
             POST_REQUEST, p_sys->psz_submit_file,
             (unsigned)strlen( psz_submit ), p_sys->psz_submit_host,
             VERSION, psz_submit
index 52877c0e495b99d6491becfcdf0c5d2b810ec140..d11f0fbab5d5918c572d8035d3cc1c7f6389c98b 100644 (file)
@@ -532,6 +532,7 @@ char *net_Gets( vlc_object_t *p_this, int fd, const v_socket_t *p_vs )
     return psz_line;
 }
 
+#undef net_Printf
 ssize_t net_Printf( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
                     const char *psz_fmt, ... )
 {