]> git.sesse.net Git - vlc/blobdiff - src/win32/specific.c
Avoid namespace clash with normal getopt
[vlc] / src / win32 / specific.c
index c3783965fc2ebdb5901b997048219ecf4b6c0c09..c3e3a75c2a71ecb7d09adc5aaa53818cbfb47016 100644 (file)
@@ -30,7 +30,7 @@
 #include "../libvlc.h"
 #include <vlc_playlist.h>
 
-#include "../extras/getopt.h"
+#include "../config/vlc_getopt.h"
 
 #if !defined( UNDER_CE )
 #   include <io.h>
@@ -65,20 +65,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 );
 
@@ -224,24 +221,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( *pi_argc - 1 >= vlc_optind )
             {
                 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 = vlc_optind; i_opt < *pi_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 = *pi_argc - vlc_optind;
                 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 = vlc_optind; i_opt < *pi_argc; i_opt++ )
                 {
                     size_t i_len = strlen( ppsz_argv[ i_opt ] ) + 1;
                     /* Windows will never switch to an architecture
@@ -325,8 +322,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 )
         {
@@ -366,8 +362,6 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
 
             free( ppsz_argv );
         }
-
-        vlc_object_release( p_playlist );
     }
 
     return DefWindowProc( hwnd, uMsg, wParam, lParam );