]> git.sesse.net Git - vlc/blobdiff - modules/access/ftp.c
Revert the so-called whitelisting commits that are actually blacklisting
[vlc] / modules / access / ftp.c
index 8ea6528e200f9efe3996c63843228179bdbe2ba9..2e12d8e8eb1502134547985ad5daaf706f506ed5 100644 (file)
@@ -28,8 +28,6 @@
  *****************************************************************************/
 #include <vlc/vlc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <assert.h>
 
 #include <vlc_access.h>
@@ -88,15 +86,14 @@ vlc_module_begin();
     set_capability( "sout access", 0 );
     set_category( CAT_SOUT );
     set_subcategory( SUBCAT_SOUT_ACO );
-    add_shortcut( "ftp" );
     set_callbacks( OutOpen, OutClose );
 vlc_module_end();
 
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int Read( access_t *, uint8_t *, int );
-static int Write( sout_access_out_t *, block_t * );
+static ssize_t Read( access_t *, uint8_t *, size_t );
+static ssize_t Write( sout_access_out_t *, block_t * );
 static int Seek( access_t *, int64_t );
 static int OutSeek( sout_access_out_t *, int64_t );
 static int Control( access_t *, int, va_list );
@@ -129,7 +126,7 @@ static int Login( vlc_object_t *p_access, access_sys_t *p_sys )
     if( fd == -1 )
     {
         msg_Err( p_access, "connection failed" );
-        intf_UserFatal( p_access, VLC_FALSE, _("Network interaction failed"), 
+        intf_UserFatal( p_access, VLC_FALSE, _("Network interaction failed"),
                         _("VLC could not connect with the given server.") );
         return -1;
     }
@@ -139,7 +136,7 @@ static int Login( vlc_object_t *p_access, access_sys_t *p_sys )
     if( i_answer / 100 != 2 )
     {
         msg_Err( p_access, "connection rejected" );
-        intf_UserFatal( p_access, VLC_FALSE, _("Network interaction failed"), 
+        intf_UserFatal( p_access, VLC_FALSE, _("Network interaction failed"),
                         _("VLC's connection to the given server was rejected.") );
         return -1;
     }
@@ -199,8 +196,8 @@ static int Login( vlc_object_t *p_access, access_sys_t *p_sys )
                     if( i_answer / 100 != 2 )
                     {
                         msg_Err( p_access, "account rejected" );
-                        intf_UserFatal( p_access, VLC_FALSE, 
-                                        _("Network interaction failed"), 
+                        intf_UserFatal( p_access, VLC_FALSE,
+                                        _("Network interaction failed"),
                                         _("Your account was rejected.") );
                         return -1;
                     }
@@ -209,17 +206,17 @@ static int Login( vlc_object_t *p_access, access_sys_t *p_sys )
 
                 default:
                     msg_Err( p_access, "password rejected" );
-                    intf_UserFatal( p_access, VLC_FALSE, 
-                                    _("Network interaction failed"), 
+                    intf_UserFatal( p_access, VLC_FALSE,
+                                    _("Network interaction failed"),
                                     _("Your password was rejected.") );
                     return -1;
             }
             break;
         default:
             msg_Err( p_access, "user rejected" );
-            intf_UserFatal( p_access, VLC_FALSE, 
-                        _("Network interaction failed"), 
-                        _("Your connection attemp to the server was rejected.") );
+            intf_UserFatal( p_access, VLC_FALSE,
+                        _("Network interaction failed"),
+                        _("Your connection attempt to the server was rejected.") );
             return -1;
     }
 
@@ -464,7 +461,7 @@ static int OutSeek( sout_access_out_t *p_access, off_t i_pos )
 /*****************************************************************************
  * Read:
  *****************************************************************************/
-static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
+static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
 {
     access_sys_t *p_sys = p_access->p_sys;
     int i_read;
@@ -488,7 +485,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
 /*****************************************************************************
  * Write:
  *****************************************************************************/
-static int Write( sout_access_out_t *p_access, block_t *p_buffer )
+static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
 {
     access_sys_t *p_sys = GET_OUT_SYS(p_access);
     size_t i_write = 0;
@@ -553,17 +550,21 @@ static int Control( access_t *p_access, int i_query, va_list args )
 
         /* */
         case ACCESS_SET_PAUSE_STATE:
-            /* Nothing to do */
+            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
+            if ( !pb_bool )
+              return Seek( p_access, p_access->info.i_pos );
             break;
 
         case ACCESS_GET_TITLE_INFO:
         case ACCESS_SET_TITLE:
         case ACCESS_SET_SEEKPOINT:
         case ACCESS_SET_PRIVATE_ID_STATE:
+        case ACCESS_GET_CONTENT_TYPE:
+        case ACCESS_GET_META:
             return VLC_EGENERIC;
 
         default:
-            msg_Warn( p_access, "unimplemented query in control);
+            msg_Warn( p_access, "unimplemented query in control: %d", i_query);
             return VLC_EGENERIC;
 
     }
@@ -754,7 +755,7 @@ static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
                          p_sys->url.psz_path ) < 0 ||
         ftp_ReadCommand( p_access, p_sys, &i_answer, NULL ) > 2 )
     {
-        msg_Err( p_access, "cannot retreive file" );
+        msg_Err( p_access, "cannot retrieve file" );
         return VLC_EGENERIC;
     }
 
@@ -777,11 +778,16 @@ static int ftp_StopStream ( vlc_object_t *p_access, access_sys_t *p_sys )
 
     if( p_sys->fd_data != -1 )
     {
+        int i_answer;
+        ftp_ReadCommand( p_access, p_sys, &i_answer, NULL );
+        if ( i_answer != 227 )
+            /* If answer is from the previous command,
+             * rathen that succesful ABOR - read next command */
+            ftp_ReadCommand( p_access, p_sys, NULL, NULL );
+
         net_Close( p_sys->fd_data );
         p_sys->fd_data = -1;
-        ftp_ReadCommand( p_access, p_sys, NULL, NULL );
     }
-    ftp_ReadCommand( p_access, p_sys, NULL, NULL );
 
     return VLC_SUCCESS;
 }