]> git.sesse.net Git - vlc/blobdiff - src/misc/win32_specific.c
* src/misc/win32_specific.c: mozilla plugin fix.
[vlc] / src / misc / win32_specific.c
index e956f13697c12e015da75d08499f6c4db6536cc8..ff8dc23d49d326b668b351d342c23bcee22bd876 100644 (file)
@@ -2,10 +2,10 @@
  * win32_specific.c: Win32 specific features
  *****************************************************************************
  * Copyright (C) 2001-2004 VideoLAN
- * $Id: win32_specific.c,v 1.32 2004/01/25 17:16:06 zorglub Exp $
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
- *          Gildas Bazin <gbazin@netcourrier.com>
+ *          Gildas Bazin <gbazin@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 #include <stdlib.h>                                                /* free() */
 
 #include <vlc/vlc.h>
+#include <vlc/input.h>
 #include "vlc_playlist.h"
 
 #ifdef WIN32                       /* optind, getopt(), included in unistd.h */
 #if !defined( UNDER_CE )
 #   include <io.h>
 #   include <fcntl.h>
-#   include <winsock2.h>
 #endif
 
+#include <winsock2.h>
+
 /*****************************************************************************
  * system_Init: initialize winsock and misc other things.
  *****************************************************************************/
 void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
 {
-#if !defined( UNDER_CE )
     WSADATA Data;
 
     /* Get our full path */
-    if( ppsz_argv[0] )
+    char psz_path[MAX_PATH];
+    char *psz_vlc;
+
+#if defined( UNDER_CE )
+    wchar_t psz_wpath[MAX_PATH];
+    if( GetModuleFileName( NULL, psz_wpath, MAX_PATH ) )
     {
-        char psz_path[MAX_PATH];
-        char *psz_vlc;
+        WideCharToMultiByte( CP_ACP, 0, psz_wpath, -1,
+                             psz_path, MAX_PATH, NULL, NULL );
+    }
+    else psz_path[0] = '\0';
 
+#else
+    if( ppsz_argv[0] )
+    {
         GetFullPathName( ppsz_argv[0], MAX_PATH, psz_path, &psz_vlc );
-
-        if( psz_vlc > psz_path && psz_vlc[-1] == '\\' )
-        {
-            psz_vlc[-1] = '\0';
-            p_this->p_libvlc->psz_vlcpath = strdup( psz_path );
-        }
-        else
-        {
-            p_this->p_libvlc->psz_vlcpath = strdup( "" );
-        }
     }
-    else
+    else if( !GetModuleFileName( NULL, psz_path, MAX_PATH ) )
     {
-        p_this->p_libvlc->psz_vlcpath = strdup( "" );
+        psz_path[0] = '\0';
     }
+#endif
+
+    if( (psz_vlc = strrchr( psz_path, '\\' )) ) *psz_vlc = '\0';
+
+    p_this->p_libvlc->psz_vlcpath = strdup( psz_path );
 
     /* Set the default file-translation mode */
+#if !defined( UNDER_CE )
     _fmode = _O_BINARY;
+#endif
     _setmode( _fileno( stdin ), _O_BINARY ); /* Needed for pipes */
 
     /* Call mdate() once to make sure it is initialized properly */
@@ -110,8 +118,6 @@ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
     fprintf( stderr, "error: can't initialize WinSocks\n" );
 
     return;
-
-#endif
 }
 
 /*****************************************************************************
@@ -297,7 +303,7 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
 
         if( pwm_data->lpData )
         {
-            int i_argc, i_data, i_opt, i_options,i_id,i_pos,j;
+            int i_argc, i_data, i_opt, i_options;
             char **ppsz_argv;
             char *p_data = (char *)pwm_data->lpData;
 
@@ -321,16 +327,13 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
                 {
                     i_options++;
                 }
-                i_id = playlist_Add( p_playlist, ppsz_argv[ i_opt ],
-                              ppsz_argv[ i_opt ],
-                              PLAYLIST_APPEND | (i_opt? 0 : PLAYLIST_GO),
-                              PLAYLIST_END );
-                i_pos = playlist_GetPositionById( p_playlist, i_id );
-                for( j = 0 ; j < i_options ; j++ )
-                {
-                    playlist_AddOption( p_playlist, i_pos ,
-                                        ppsz_argv[i_opt+1+j] );
-                }
+
+                playlist_AddExt( p_playlist, ppsz_argv[i_opt],ppsz_argv[i_opt],
+                    PLAYLIST_APPEND | (i_opt? 0 : PLAYLIST_GO),
+                    PLAYLIST_END, -1,
+                    (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ),
+                    i_options );
+
                 i_opt += i_options;
             }
 
@@ -348,7 +351,5 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
  *****************************************************************************/
 void system_End( vlc_t *p_this )
 {
-#if !defined( UNDER_CE )
     WSACleanup();
-#endif
 }