Commit 6bf37456 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

net_Printf: automagic cast to VLC object

parent 9242bbe1
...@@ -146,6 +146,7 @@ VLC_EXPORT( char *, net_Gets, ( vlc_object_t *p_this, int fd, const v_socket_t * ...@@ -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 ) ); 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 ) ); 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) #define net_vaPrintf(a,b,c,d,e) net_vaPrintf(VLC_OBJECT(a),b,c,d,e)
......
...@@ -629,8 +629,7 @@ static int ftp_SendCommand( vlc_object_t *p_access, access_sys_t *p_sys, ...@@ -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); msg_Dbg( p_access, "ftp_SendCommand:\"%s\"", psz_cmd);
if( net_Printf( VLC_OBJECT(p_access), p_sys->fd_cmd, NULL, "%s\r\n", if( net_Printf( p_access, p_sys->fd_cmd, NULL, "%s\r\n", psz_cmd ) < 0 )
psz_cmd ) < 0 )
{ {
msg_Err( p_access, "failed to send command" ); msg_Err( p_access, "failed to send command" );
return VLC_EGENERIC; return VLC_EGENERIC;
......
...@@ -1164,7 +1164,7 @@ static int Connect( access_t *p_access, uint64_t i_tell ) ...@@ -1164,7 +1164,7 @@ static int Connect( access_t *p_access, uint64_t i_tell )
return -1; 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", "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->url.psz_host, p_sys->url.i_port,
p_sys->i_version, p_sys->i_version,
...@@ -1240,14 +1240,14 @@ static int Request( access_t *p_access, uint64_t i_tell ) ...@@ -1240,14 +1240,14 @@ static int Request( access_t *p_access, uint64_t i_tell )
{ {
if( p_sys->url.psz_path ) 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", "GET http://%s:%d%s HTTP/1.%d\r\n",
p_sys->url.psz_host, p_sys->url.i_port, p_sys->url.psz_host, p_sys->url.i_port,
p_sys->url.psz_path, p_sys->i_version ); p_sys->url.psz_path, p_sys->i_version );
} }
else 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", "GET http://%s:%d/ HTTP/1.%d\r\n",
p_sys->url.psz_host, p_sys->url.i_port, p_sys->url.psz_host, p_sys->url.i_port,
p_sys->i_version ); p_sys->i_version );
...@@ -1262,26 +1262,26 @@ static int Request( access_t *p_access, uint64_t i_tell ) ...@@ -1262,26 +1262,26 @@ static int Request( access_t *p_access, uint64_t i_tell )
} }
if( p_sys->url.i_port != (pvs ? 443 : 80) ) 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", "GET %s HTTP/1.%d\r\nHost: %s:%d\r\n",
psz_path, p_sys->i_version, p_sys->url.psz_host, psz_path, p_sys->i_version, p_sys->url.psz_host,
p_sys->url.i_port ); p_sys->url.i_port );
} }
else 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", "GET %s HTTP/1.%d\r\nHost: %s\r\n",
psz_path, p_sys->i_version, p_sys->url.psz_host ); psz_path, p_sys->i_version, p_sys->url.psz_host );
} }
} }
/* User Agent */ /* 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 ); p_sys->psz_user_agent );
/* Offset */ /* Offset */
if( p_sys->i_version == 1 && ! p_sys->b_continuous ) if( p_sys->i_version == 1 && ! p_sys->b_continuous )
{ {
p_sys->b_persist = true; 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 ); "Range: bytes=%"PRIu64"-\r\n", i_tell );
} }
...@@ -1303,7 +1303,7 @@ static int Request( access_t *p_access, uint64_t i_tell ) ...@@ -1303,7 +1303,7 @@ static int Request( access_t *p_access, uint64_t i_tell )
if( is_in_right_domain ) if( is_in_right_domain )
{ {
msg_Dbg( p_access, "Sending Cookie %s", psz_cookie_content ); 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" ); msg_Err( p_access, "failed to send Cookie" );
} }
free( psz_cookie_content ); free( psz_cookie_content );
...@@ -1320,10 +1320,10 @@ static int Request( access_t *p_access, uint64_t i_tell ) ...@@ -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 ); AuthReply( p_access, "Proxy-", &p_sys->proxy, &p_sys->proxy_auth );
/* ICY meta data request */ /* 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" ); msg_Err( p_access, "failed to send request" );
Disconnect( p_access ); Disconnect( p_access );
...@@ -1764,7 +1764,7 @@ static void AuthReply( access_t *p_access, const char *psz_prefix, ...@@ -1764,7 +1764,7 @@ static void AuthReply( access_t *p_access, const char *psz_prefix,
if ( psz_value == NULL ) if ( psz_value == NULL )
return; 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 ); "%sAuthorization: %s\r\n", psz_prefix, psz_value );
free( psz_value ); free( psz_value );
} }
......
...@@ -503,7 +503,7 @@ static int OpenConnection( access_t *p_access ) ...@@ -503,7 +503,7 @@ static int OpenConnection( access_t *p_access )
if( p_sys->b_proxy ) 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", "GET http://%s:%d%s HTTP/1.0\r\n",
p_sys->url.psz_host, p_sys->url.i_port, p_sys->url.psz_host, p_sys->url.i_port,
( (p_sys->url.psz_path == NULL) || ( (p_sys->url.psz_path == NULL) ||
...@@ -523,14 +523,14 @@ static int OpenConnection( access_t *p_access ) ...@@ -523,14 +523,14 @@ static int OpenConnection( access_t *p_access )
b64 = vlc_b64_encode( buf ); b64 = vlc_b64_encode( buf );
free( 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 ); "Proxy-Authorization: Basic %s\r\n", b64 );
free( b64 ); free( b64 );
} }
} }
else 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" "GET %s HTTP/1.0\r\n"
"Host: %s:%d\r\n", "Host: %s:%d\r\n",
( (p_sys->url.psz_path == NULL) || ( (p_sys->url.psz_path == NULL) ||
...@@ -564,7 +564,7 @@ static int Describe( access_t *p_access, char **ppsz_location ) ...@@ -564,7 +564,7 @@ static int Describe( access_t *p_access, char **ppsz_location )
if( OpenConnection( p_access ) ) if( OpenConnection( p_access ) )
return VLC_EGENERIC; return VLC_EGENERIC;
net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, net_Printf( p_access, p_sys->fd, NULL,
"Accept: */*\r\n" "Accept: */*\r\n"
"User-Agent: "MMSH_USER_AGENT"\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" "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 ) ...@@ -573,7 +573,7 @@ static int Describe( access_t *p_access, char **ppsz_location )
p_sys->i_request_context++, p_sys->i_request_context++,
GUID_PRINT( p_sys->guid ) ); 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" ); msg_Err( p_access, "failed to send request" );
goto error; goto error;
...@@ -770,24 +770,24 @@ static int Start( access_t *p_access, uint64_t i_pos ) ...@@ -770,24 +770,24 @@ static int Start( access_t *p_access, uint64_t i_pos )
if( OpenConnection( p_access ) ) if( OpenConnection( p_access ) )
return VLC_EGENERIC; return VLC_EGENERIC;
net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, net_Printf( p_access, p_sys->fd, NULL,
"Accept: */*\r\n" "Accept: */*\r\n"
"User-Agent: "MMSH_USER_AGENT"\r\n" ); "User-Agent: "MMSH_USER_AGENT"\r\n" );
if( p_sys->b_broadcast ) 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", "Pragma: no-cache,rate=1.000000,request-context=%d\r\n",
p_sys->i_request_context++ ); p_sys->i_request_context++ );
} }
else 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", "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 >> 32)&0xffffffff),
(uint32_t)(i_pos&0xffffffff), (uint32_t)(i_pos&0xffffffff),
p_sys->i_request_context++ ); 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: xPlayStrm=1\r\n"
"Pragma: xClientGUID={"GUID_FMT"}\r\n" "Pragma: xClientGUID={"GUID_FMT"}\r\n"
"Pragma: stream-switch-count=%d\r\n" "Pragma: stream-switch-count=%d\r\n"
...@@ -804,15 +804,15 @@ static int Start( access_t *p_access, uint64_t i_pos ) ...@@ -804,15 +804,15 @@ static int Start( access_t *p_access, uint64_t i_pos )
{ {
i_select = 0; 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 ); "ffff:%d:%d ", i, i_select );
} }
} }
net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ); net_Printf( 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,
"Connection: Close\r\n" ); "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" ); msg_Err( p_access, "failed to send request" );
return VLC_EGENERIC; return VLC_EGENERIC;
......
...@@ -142,7 +142,7 @@ static int RtspWrite( void *p_userdata, uint8_t *p_buffer, int i_buffer ) ...@@ -142,7 +142,7 @@ static int RtspWrite( void *p_userdata, uint8_t *p_buffer, int i_buffer )
//fprintf(stderr, "Write: %s", p_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; return 0;
} }
......
...@@ -394,7 +394,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -394,7 +394,7 @@ static void Run( intf_thread_t *p_intf )
/* we transmit the data */ /* we transmit the data */
i_net_ret = net_Printf( 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, POST_REQUEST, p_sys->psz_submit_file,
(unsigned)strlen( psz_submit ), p_sys->psz_submit_host, (unsigned)strlen( psz_submit ), p_sys->psz_submit_host,
VERSION, psz_submit VERSION, psz_submit
......
...@@ -532,6 +532,7 @@ char *net_Gets( vlc_object_t *p_this, int fd, const v_socket_t *p_vs ) ...@@ -532,6 +532,7 @@ char *net_Gets( vlc_object_t *p_this, int fd, const v_socket_t *p_vs )
return psz_line; return psz_line;
} }
#undef net_Printf
ssize_t net_Printf( vlc_object_t *p_this, int fd, const v_socket_t *p_vs, ssize_t net_Printf( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
const char *psz_fmt, ... ) const char *psz_fmt, ... )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment