]> git.sesse.net Git - vlc/blobdiff - modules/access/ftp.c
Rewrite a useful tooltip for Windows DShow.
[vlc] / modules / access / ftp.c
index 3aca2f6050521559349cea059b55492325c3ced7..7d874566ef85f3d797740efdd6babb455a3c7f71 100644 (file)
@@ -30,7 +30,8 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 
 #include <assert.h>
 
@@ -69,7 +70,7 @@ static void OutClose( vlc_object_t * );
 
 vlc_module_begin();
     set_shortname( "FTP" );
-    set_description( _("FTP input") );
+    set_description( N_("FTP input") );
     set_capability( "access", 0 );
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_ACCESS );
@@ -86,7 +87,7 @@ vlc_module_begin();
 
     add_submodule();
     set_shortname( "FTP" );
-    set_description( _("FTP upload output") );
+    set_description( N_("FTP upload output") );
     set_capability( "sout access", 0 );
     set_category( CAT_SOUT );
     set_subcategory( SUBCAT_SOUT_ACO );
@@ -110,6 +111,7 @@ struct access_sys_t
     int        fd_data;
 
     char       sz_epsv_ip[NI_MAXNUMERICHOST];
+    bool       out;
 };
 #define GET_OUT_SYS( p_this ) \
     ((access_sys_t *)(((sout_access_out_t *)(p_this))->p_sys))
@@ -317,6 +319,7 @@ static int InOpen( vlc_object_t *p_this )
     /* Init p_access */
     STANDARD_READ_ACCESS_INIT
     p_sys->fd_data = -1;
+    p_sys->out = false;
 
     if( parseURL( &p_sys->url, p_access->psz_path ) )
         goto exit_error;
@@ -334,7 +337,7 @@ static int InOpen( vlc_object_t *p_this )
     }
     p_access->info.i_size = atoll( &psz_arg[4] );
     free( psz_arg );
-    msg_Dbg( p_access, "file size: "I64Fd, p_access->info.i_size );
+    msg_Dbg( p_access, "file size: %"PRId64, p_access->info.i_size );
 
     /* Start the 'stream' */
     if( ftp_StartStream( p_this, p_sys, 0 ) < 0 )
@@ -367,6 +370,7 @@ static int OutOpen( vlc_object_t *p_this )
 
     /* Init p_access */
     p_sys->fd_data = -1;
+    p_sys->out = true;
 
     if( parseURL( &p_sys->url, p_access->psz_path ) )
         goto exit_error;
@@ -436,7 +440,7 @@ static int _Seek( vlc_object_t *p_access, access_sys_t *p_sys, int64_t i_pos )
     if( i_pos < 0 )
         return VLC_EGENERIC;
 
-    msg_Dbg( p_access, "seeking to "I64Fd, i_pos );
+    msg_Dbg( p_access, "seeking to %"PRId64, i_pos );
 
     ftp_StopStream( (vlc_object_t *)p_access, p_sys );
     if( ftp_StartStream( (vlc_object_t *)p_access, p_sys, i_pos ) < 0 )
@@ -471,7 +475,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
     int i_read;
 
     assert( p_sys->fd_data != -1 );
-    assert( p_access->i_object_type == VLC_OBJECT_ACCESS );
+    assert( !p_sys->out );
 
     if( p_access->info.b_eof )
         return 0;
@@ -549,7 +553,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
         case ACCESS_GET_PTS_DELAY:
             pi_64 = (int64_t*)va_arg( args, int64_t * );
             var_Get( p_access, "ftp-caching", &val );
-            *pi_64 = (int64_t)var_GetInteger( p_access, "ftp-caching" ) * I64C(1000);
+            *pi_64 = (int64_t)var_GetInteger( p_access, "ftp-caching" ) * INT64_C(1000);
             break;
 
         /* */
@@ -734,7 +738,7 @@ static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
 
     if( i_start > 0 )
     {
-        if( ftp_SendCommand( p_access, p_sys, "REST "I64Fu, i_start ) < 0 ||
+        if( ftp_SendCommand( p_access, p_sys, "REST %"PRIu64, i_start ) < 0 ||
             ftp_ReadCommand( p_access, p_sys, &i_answer, NULL ) > 3 )
         {
             msg_Err( p_access, "cannot set restart offset" );
@@ -754,8 +758,7 @@ static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
 
     /* "1xx" message */
     if( ftp_SendCommand( p_access, p_sys, "%s %s",
-                         (p_access->i_object_type == VLC_OBJECT_ACCESS)
-                                 ? "RETR" : "STOR",
+                         p_sys->out ? "STOR" : "RETR",
                          p_sys->url.psz_path ) < 0 ||
         ftp_ReadCommand( p_access, p_sys, &i_answer, NULL ) > 2 )
     {
@@ -763,8 +766,7 @@ static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
         return VLC_EGENERIC;
     }
 
-    shutdown( p_sys->fd_data,
-              ( p_access->i_object_type == VLC_OBJECT_ACCESS ) );
+    shutdown( p_sys->fd_data, p_sys->out ? SHUT_RD : SHUT_WR );
 
     return VLC_SUCCESS;
 }