]> git.sesse.net Git - vlc/blobdiff - modules/access/ftp.c
Some more demux and access code factorization
[vlc] / modules / access / ftp.c
index 7a1eeb9c6c6f481137a4394eff83df5fc076bb3e..70728ba3fd61f6feab734c2a6a90b0fbd1f8de78 100644 (file)
@@ -41,16 +41,16 @@ static void    Close( vlc_object_t * );
 
 #define CACHING_TEXT N_("Caching value in ms")
 #define CACHING_LONGTEXT N_( \
-    "Allows you to modify the default caching value for FTP streams. This " \
-    "value should be set in millisecond units." )
+    "Caching value for FTP streams. This " \
+    "value should be set in milliseconds." )
 #define USER_TEXT N_("FTP user name")
-#define USER_LONGTEXT N_("Allows you to modify the user name that will " \
+#define USER_LONGTEXT N_("User name that will " \
     "be used for the connection.")
 #define PASS_TEXT N_("FTP password")
-#define PASS_LONGTEXT N_("Allows you to modify the password that will be " \
+#define PASS_LONGTEXT N_("Password that will be " \
     "used for the connection.")
 #define ACCOUNT_TEXT N_("FTP account")
-#define ACCOUNT_LONGTEXT N_("Allows you to modify the account that will be " \
+#define ACCOUNT_LONGTEXT N_("Account that will be " \
     "used for the connection.")
 
 vlc_module_begin();
@@ -122,8 +122,12 @@ static int Connect( access_t *p_access, access_sys_t *p_sys )
     }
 
     msg_Dbg( p_access, "connection accepted (%d)", i_answer );
+    
+    if( p_sys->url.psz_username && *p_sys->url.psz_username )
+        psz = strdup( p_sys->url.psz_username );
+    else
+        psz = var_CreateGetString( p_access, "ftp-user" );
 
-    psz = var_CreateGetString( p_access, "ftp-user" );
     if( ftp_SendCommand( p_access, "USER %s", psz ) < 0 ||
         ftp_ReadCommand( p_access, &i_answer, NULL ) < 0 )
     {
@@ -139,7 +143,11 @@ static int Connect( access_t *p_access, access_sys_t *p_sys )
             break;
         case 3:
             msg_Dbg( p_access, "password needed" );
-            psz = var_CreateGetString( p_access, "ftp-pwd" );
+            if( p_sys->url.psz_password && *p_sys->url.psz_password )
+                psz = strdup( p_sys->url.psz_password );
+           else
+                psz = var_CreateGetString( p_access, "ftp-pwd" );
+
             if( ftp_SendCommand( p_access, "PASS %s", psz ) < 0 ||
                 ftp_ReadCommand( p_access, &i_answer, NULL ) < 0 )
             {
@@ -199,18 +207,7 @@ static int Open( vlc_object_t *p_this )
     char         *psz_arg;
 
     /* Init p_access */
-    p_access->pf_read = Read;
-    p_access->pf_block = NULL;
-    p_access->pf_seek = Seek;
-    p_access->pf_control = Control;
-    p_access->info.i_update = 0;
-    p_access->info.i_size = 0;
-    p_access->info.i_pos = 0;
-    p_access->info.b_eof = VLC_FALSE;
-    p_access->info.i_title = 0;
-    p_access->info.i_seekpoint = 0;
-    p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
-    memset( p_sys, 0, sizeof( access_sys_t ) );
+    STANDARD_READ_ACCESS_INIT
     p_sys->fd_cmd = -1;
     p_sys->fd_data = -1;