]> git.sesse.net Git - vlc/blobdiff - src/win32/specific.c
Dash: major warnings cleanup
[vlc] / src / win32 / specific.c
index c3e3a75c2a71ecb7d09adc5aaa53818cbfb47016..abe76b478a3ce6c4f8425dc6bb984c8aa88827dc 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,6 +29,7 @@
 #include <vlc_common.h>
 #include "../libvlc.h"
 #include <vlc_playlist.h>
+#include <vlc_url.h>
 
 #include "../config/vlc_getopt.h"
 
@@ -43,9 +44,8 @@
 /*****************************************************************************
  * system_Init: initialize winsock and misc other things.
  *****************************************************************************/
-void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] )
+void system_Init( void )
 {
-    VLC_UNUSED( p_this ); VLC_UNUSED( pi_argc ); VLC_UNUSED( ppsz_argv );
     WSADATA Data;
     MEMORY_BASIC_INFORMATION mbi;
 
@@ -64,6 +64,7 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] )
         }
         else psz_path[0] = '\0';
     }
+    else psz_path[0] = '\0';
 
     psz_vlc = strrchr( psz_path, '\\' );
     if( psz_vlc )
@@ -87,9 +88,6 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] )
     timeBeginPeriod(5);
 #endif
 
-    /* Call mdate() once to make sure it is initialized properly */
-    mdate();
-
     /* WinSock Library Init. */
     if( !WSAStartup( MAKEWORD( 2, 2 ), &Data ) )
     {
@@ -129,12 +127,12 @@ static HANDLE hIPCHelperReady;
 
 typedef struct
 {
-  int argc;
-  int enqueue;
-  char data[];
+    int argc;
+    int enqueue;
+    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 */
@@ -175,10 +173,8 @@ void system_Configure( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv
         if( GetLastError() != ERROR_ALREADY_EXISTS )
         {
             /* We are the 1st instance. */
-            static const char typename[] = "ipc helper";
             p_helper =
-                vlc_custom_create( p_this, sizeof(vlc_object_t),
-                                   VLC_OBJECT_GENERIC, typename );
+                vlc_custom_create( p_this, sizeof(*p_helper), "ipc helper" );
 
             /* Run the helper thread */
             hIPCHelperReady = CreateEvent( NULL, FALSE, FALSE, NULL );
@@ -193,7 +189,6 @@ void system_Configure( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv
                 vlc_object_release (p_helper);
                 p_helper = NULL;
             }
-            vlc_object_attach (p_helper, p_this);
             CloseHandle( hIPCHelperReady );
 
             /* Initialization done.
@@ -221,24 +216,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 >= vlc_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 = vlc_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 - vlc_optind;
+                p_data->argc = i_argc;
                 p_data->enqueue = var_InheritBool( p_this, "playlist-enqueue" );
                 i_data = 0;
-                for( i_opt = vlc_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
@@ -262,7 +257,7 @@ void system_Configure( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv
             ReleaseMutex( hmutex );
 
             /* Bye bye */
-            system_End( p_this );
+            system_End( );
             exit( 0 );
         }
     }
@@ -344,20 +339,23 @@ 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 );
@@ -370,26 +368,20 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
 /*****************************************************************************
  * system_End: terminate winsock.
  *****************************************************************************/
-void system_End( libvlc_int_t *p_this )
+void system_End( void )
 {
     HWND ipcwindow;
-    if( p_this )
-    {
-        free( psz_vlcpath );
-        psz_vlcpath = NULL;
-    }
 
-    if (p_helper && p_helper->p_parent == VLC_OBJECT(p_this) )
+    free( psz_vlcpath );
+    psz_vlcpath = NULL;
+
+    /* FIXME: thread-safety... */
+    if (p_helper)
     {
-        /* this is the first instance (in a one-instance system)
-         * it is the owner of the helper thread
-         */
         if( ( ipcwindow = FindWindow( 0, L"VLC ipc "VERSION ) ) != 0 )
         {
             SendMessage( ipcwindow, WM_QUIT, 0, 0 );
         }
-
-        /* FIXME: thread-safety... */
         vlc_object_release (p_helper);
         p_helper = NULL;
     }