* ftp.c:
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: ftp.c,v 1.4 2002/12/25 02:23:36 massiot Exp $
+ * $Id: ftp.c,v 1.14 2003/03/30 18:14:35 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
*****************************************************************************/
#include <stdlib.h>
#include <sys/types.h>
+#include <sys/time.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <vlc/vlc.h>
#include <vlc/input.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+
#ifdef HAVE_UNISTD_H
# include <unistd.h>
-#elif defined( _MSC_VER ) && defined( _WIN32 )
-# include <io.h>
#endif
#ifdef WIN32
static int Read ( input_thread_t * p_input, byte_t * p_buffer,
size_t i_len );
static void Seek ( input_thread_t *, off_t );
-static int SetProgram ( input_thread_t *, pgrm_descriptor_t * );
static ssize_t NetRead ( input_thread_t *, input_socket_t *, byte_t *, size_t );
"value should be set in miliseconds units." )
vlc_module_begin();
- set_description( _("ftp access module") );
+ set_description( _("FTP input") );
set_capability( "access", 0 );
- add_category_hint( "stream", NULL );
+ add_category_hint( "stream", NULL, VLC_FALSE );
add_integer( "ftp-caching", 2 * DEFAULT_PTS_DELAY / 1000, NULL,
- CACHING_TEXT, CACHING_LONGTEXT );
- add_string( "ftp-user", "anonymous", NULL, "ftp user name", "ftp user name" );
- add_string( "ftp-pwd", "anonymous@dummy.org", NULL, "ftp password", "ftp password, be careful with that option..." );
- add_string( "ftp-account", "anonymous", NULL, "ftp account", "ftp account" );
+ CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
+ add_string( "ftp-user", "anonymous", NULL, "ftp user name", "ftp user name", VLC_FALSE );
+ add_string( "ftp-pwd", "anonymous@dummy.org", NULL, "ftp password", "ftp password, be careful with that option...", VLC_FALSE );
+ add_string( "ftp-account", "anonymous", NULL, "ftp account", "ftp account", VLC_FALSE );
add_shortcut( "ftp" );
set_callbacks( Open, Close );
vlc_module_end();
/* *** set exported functions *** */
p_input->pf_read = Read;
p_input->pf_seek = Seek;
- p_input->pf_set_program = SetProgram;
+ p_input->pf_set_program = input_SetProgram;
p_input->pf_set_area = NULL;
p_input->p_private = NULL;
FREE( p_access->url.psz_private );
}
-/*****************************************************************************
- * SetProgram: do nothing
- *****************************************************************************/
-static int SetProgram( input_thread_t * p_input,
- pgrm_descriptor_t * p_program )
-{
- return( 0 );
-}
-
/*****************************************************************************
* Seek: try to go at the right place
*****************************************************************************/
#else
struct timeval timeout;
fd_set fds;
+ ssize_t i_recv;
int i_ret;
/* Initialize file descriptor set */
FD_SET( p_socket->i_handle, &fds );
/* We'll wait 1 second if nothing happens */
- timeout.tv_sec = 0;
- timeout.tv_usec = 1000000;
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
/* Find if some data is available */
- i_ret = select( p_socket->i_handle + 1, &fds,
- NULL, NULL, &timeout );
+ while( (i_ret = select( p_socket->i_handle + 1, &fds,
+ NULL, NULL, &timeout )) == 0
+ || (i_ret < 0 && errno == EINTR) )
+ {
+ FD_ZERO( &fds );
+ FD_SET( p_socket->i_handle, &fds );
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
- if( i_ret == -1 && errno != EINTR )
+ if( p_input->b_die || p_input->b_error )
+ {
+ return 0;
+ }
+ }
+
+ if( i_ret < 0 )
{
msg_Err( p_input, "network select error (%s)", strerror(errno) );
+ return -1;
}
- else if( i_ret > 0 )
- {
- ssize_t i_recv = recv( p_socket->i_handle, p_buffer, i_len, 0 );
- if( i_recv < 0 )
- {
- msg_Err( p_input, "recv failed (%s)", strerror(errno) );
- }
+ i_recv = recv( p_socket->i_handle, p_buffer, i_len, 0 );
- return i_recv;
+ if( i_recv < 0 )
+ {
+ msg_Err( p_input, "recv failed (%s)", strerror(errno) );
}
- return 0;
+ return i_recv;
#endif
}