From 6bf374569a1dd0ffcb624d7e35f032e424c07b14 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sun, 7 Feb 2010 12:53:56 +0200 Subject: [PATCH] net_Printf: automagic cast to VLC object --- include/vlc_network.h | 1 + modules/access/ftp.c | 3 +-- modules/access/http.c | 22 +++++++++++----------- modules/access/mms/mmsh.c | 26 +++++++++++++------------- modules/access/rtsp/access.c | 2 +- modules/misc/audioscrobbler.c | 2 +- src/network/io.c | 1 + 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/include/vlc_network.h b/include/vlc_network.h index 29078adead..19502d2276 100644 --- a/include/vlc_network.h +++ b/include/vlc_network.h @@ -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) diff --git a/modules/access/ftp.c b/modules/access/ftp.c index 89deeb50c4..c5ffb2f2c4 100644 --- a/modules/access/ftp.c +++ b/modules/access/ftp.c @@ -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; diff --git a/modules/access/http.c b/modules/access/http.c index f052d246ee..c786c966c1 100644 --- a/modules/access/http.c +++ b/modules/access/http.c @@ -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 ); } diff --git a/modules/access/mms/mmsh.c b/modules/access/mms/mmsh.c index d353f0cb45..fe31cc4f62 100644 --- a/modules/access/mms/mmsh.c +++ b/modules/access/mms/mmsh.c @@ -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; diff --git a/modules/access/rtsp/access.c b/modules/access/rtsp/access.c index b23634bbf1..bf2dd76291 100644 --- a/modules/access/rtsp/access.c +++ b/modules/access/rtsp/access.c @@ -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; } diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c index fa359489ad..fbcc95a70b 100644 --- a/modules/misc/audioscrobbler.c +++ b/modules/misc/audioscrobbler.c @@ -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 diff --git a/src/network/io.c b/src/network/io.c index 52877c0e49..d11f0fbab5 100644 --- a/src/network/io.c +++ b/src/network/io.c @@ -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, ... ) { -- 2.39.2