]> git.sesse.net Git - vlc/blobdiff - src/win32/specific.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / src / win32 / specific.c
index 93001409be58f00c45d69b6f11af562475fa05f7..531e29271a6fc4dcecab4de3654ad79ddc9c2935 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * specific.c: Win32 specific initilization
  *****************************************************************************
- * Copyright (C) 2001-2004 the VideoLAN team
+ * Copyright (C) 2001-2004, 2010 the VideoLAN team
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Gildas Bazin <gbazin@videolan.org>
@@ -29,9 +29,9 @@
 #include <vlc_common.h>
 #include "../libvlc.h"
 #include <vlc_playlist.h>
-#include <vlc_charset.h>
+#include <vlc_url.h>
 
-#include "../extras/getopt.h"
+#include "../config/vlc_getopt.h"
 
 #if !defined( UNDER_CE )
 #   include <io.h>
@@ -66,20 +66,17 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] )
         else psz_path[0] = '\0';
     }
 
-    if( (psz_vlc = strrchr( psz_path, '\\' )) ) *psz_vlc = '\0';
+    psz_vlc = strrchr( psz_path, '\\' );
+    if( psz_vlc )
+        *psz_vlc = '\0';
 
-#ifndef HAVE_RELEASE
     {
         /* remove trailing \.libs from executable dir path if seen,
            we assume we are running vlc through libtool wrapper in build dir */
-        int offset  = strlen(psz_path)-sizeof("\\.libs")+1;
-        if( offset > 0 )
-        {
-            psz_vlc = psz_path+offset;
-            if( ! strcmp(psz_vlc, "\\.libs") ) *psz_vlc = '\0';
-        }
+        size_t len = strlen(psz_path);
+        if( len >= 5 && !stricmp(psz_path + len - 5, "\\.libs" ) )
+            psz_path[len - 5] = '\0';
     }
-#endif
 
     psz_vlcpath = strdup( psz_path );
 
@@ -138,7 +135,7 @@ typedef struct
   char data[];
 } vlc_ipc_data_t;
 
-void system_Configure( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] )
+void system_Configure( libvlc_int_t *p_this, int i_argc, const char *const ppsz_argv[] )
 {
 #if !defined( UNDER_CE )
     /* Raise default priority of the current process */
@@ -225,24 +222,24 @@ void system_Configure( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv
 
             /* We assume that the remaining parameters are filenames
              * and their input options */
-            if( *pi_argc - 1 >= optind )
+            if( i_argc > 0 )
             {
                 COPYDATASTRUCT wm_data;
                 int i_opt;
                 vlc_ipc_data_t *p_data;
                 size_t i_data = sizeof (*p_data);
 
-                for( i_opt = optind; i_opt < *pi_argc; i_opt++ )
+                for( i_opt = 0; i_opt < i_argc; i_opt++ )
                 {
                     i_data += sizeof (size_t);
                     i_data += strlen( ppsz_argv[ i_opt ] ) + 1;
                 }
 
                 p_data = malloc( i_data );
-                p_data->argc = *pi_argc - optind;
+                p_data->argc = i_argc;
                 p_data->enqueue = var_InheritBool( p_this, "playlist-enqueue" );
                 i_data = 0;
-                for( i_opt = optind; i_opt < *pi_argc; i_opt++ )
+                for( i_opt = 0; i_opt < i_argc; i_opt++ )
                 {
                     size_t i_len = strlen( ppsz_argv[ i_opt ] ) + 1;
                     /* Windows will never switch to an architecture
@@ -326,8 +323,7 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
         if( !p_this ) return 0;
 
         /* Add files to the playlist */
-        p_playlist = pl_Hold( p_this );
-        if( !p_playlist ) return 0;
+        p_playlist = pl_Get( p_this );
 
         if( pwm_data->lpData )
         {
@@ -349,26 +345,27 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
 
                 /* Count the input options */
                 while( i_opt + i_options + 1 < i_argc &&
-                       *ppsz_argv[ i_opt + i_options + 1 ] == ':' )
+                        *ppsz_argv[ i_opt + i_options + 1 ] == ':' )
                 {
                     i_options++;
                 }
-                playlist_AddExt( p_playlist, ppsz_argv[i_opt],
-                  NULL, PLAYLIST_APPEND |
+
+                char *psz_URI = make_URI( ppsz_argv[i_opt], NULL );
+                playlist_AddExt( p_playlist, psz_URI,
+                        NULL, PLAYLIST_APPEND |
                         ( ( i_opt || p_data->enqueue ) ? 0 : PLAYLIST_GO ),
-                  PLAYLIST_END, -1,
-                  i_options,
-                  (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ),
-                  VLC_INPUT_OPTION_TRUSTED,
-                  true, pl_Unlocked );
+                        PLAYLIST_END, -1,
+                        i_options,
+                        (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ),
+                        VLC_INPUT_OPTION_TRUSTED,
+                        true, pl_Unlocked );
 
                 i_opt += i_options;
+                free( psz_URI );
             }
 
             free( ppsz_argv );
         }
-
-        vlc_object_release( p_playlist );
     }
 
     return DefWindowProc( hwnd, uMsg, wParam, lParam );
@@ -397,7 +394,6 @@ void system_End( libvlc_int_t *p_this )
         }
 
         /* FIXME: thread-safety... */
-        vlc_object_detach (p_helper);
         vlc_object_release (p_helper);
         p_helper = NULL;
     }