Commit 5885e88a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

oldrc: fix reading from standard input

parent bd6ddfdd
......@@ -1851,8 +1851,6 @@ static bool ReadWin32( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
bool ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
{
int i_read = 0;
#ifdef _WIN32
if( p_intf->p_sys->i_socket == -1 && !p_intf->p_sys->b_quiet )
return ReadWin32( p_intf, p_buffer, pi_size );
......@@ -1863,34 +1861,35 @@ bool ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
}
#endif
while( *pi_size < MAX_LINE_LENGTH &&
(i_read = net_Read( p_intf, p_intf->p_sys->i_socket == -1 ?
0 /*STDIN_FILENO*/ : p_intf->p_sys->i_socket,
(uint8_t *)p_buffer + *pi_size, 1, false ) ) > 0 )
{
if( p_buffer[ *pi_size ] == '\r' || p_buffer[ *pi_size ] == '\n' )
break;
(*pi_size)++;
}
/* Connection closed */
if( i_read <= 0 )
while( *pi_size < MAX_LINE_LENGTH )
{
if( p_intf->p_sys->i_socket != -1 )
{
net_Close( p_intf->p_sys->i_socket );
p_intf->p_sys->i_socket = -1;
if( p_intf->p_sys->i_socket == -1 )
{
if( read( 0/*STDIN_FILENO*/, p_buffer + *pi_size, 1 ) <= 0 )
{ /* Standard input closed: exit */
vlc_value_t empty;
Quit( VLC_OBJECT(p_intf), NULL, empty, empty, NULL );
p_buffer[*pi_size] = 0;
return true;
}
}
else
{
/* Standard input closed: exit */
vlc_value_t empty;
Quit( VLC_OBJECT(p_intf), NULL, empty, empty, NULL );
{ /* Connection closed */
if( net_Read( p_intf, p_intf->p_sys->i_socket, p_buffer + *pi_size,
1, false ) <= 0 )
{
net_Close( p_intf->p_sys->i_socket );
p_intf->p_sys->i_socket = -1;
p_buffer[*pi_size] = 0;
return true;
}
}
p_buffer[ *pi_size ] = 0;
return true;
if( p_buffer[ *pi_size ] == '\r' || p_buffer[ *pi_size ] == '\n' )
break;
(*pi_size)++;
}
if( *pi_size == MAX_LINE_LENGTH ||
......
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