* win32_specific.c: Win32 specific features
*****************************************************************************
* Copyright (C) 2001-2004 VideoLAN
- * $Id: win32_specific.c,v 1.30 2004/01/06 12:02: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
#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 <winsock.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;
_setmode( _fileno( stdin ), _O_BINARY ); /* Needed for pipes */
+#endif
/* Call mdate() once to make sure it is initialized properly */
mdate();
fprintf( stderr, "error: can't initialize WinSocks\n" );
- return;
-
-#endif
+ return;
}
/*****************************************************************************
{
HANDLE hmutex;
- msg_Info( p_this, "One instance mode ENABLED");
+ msg_Info( p_this, "one instance mode ENABLED");
/* Use a named mutex to check if another instance is already running */
- if( ( hmutex = CreateMutex( NULL, TRUE, "VLC ipc "VERSION ) ) == NULL )
+ if( !( hmutex = CreateMutex( 0, TRUE, _T("VLC ipc ") _T(VERSION) ) ) )
{
/* Failed for some reason. Just ignore the option and go on as
* normal. */
- msg_Err( p_this, "One instance mode DISABLED "
+ msg_Err( p_this, "one instance mode DISABLED "
"(mutex couldn't be created)" );
return;
}
if( vlc_thread_create( p_helper, "IPC helper", IPCHelperThread,
VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
{
- msg_Err( p_this, "One instance mode DISABLED "
+ msg_Err( p_this, "one instance mode DISABLED "
"(IPC helper thread couldn't be created)" );
}
/* Locate the window created by the IPC helper thread of the
* 1st instance */
- if( ( ipcwindow = FindWindow( NULL, "VLC ipc "VERSION ) )
- == NULL )
+ if( !( ipcwindow = FindWindow( 0, _T("VLC ipc ") _T(VERSION) ) ) )
{
- msg_Err( p_this, "One instance mode DISABLED "
+ msg_Err( p_this, "one instance mode DISABLED "
"(couldn't find 1st instance of program)" );
ReleaseMutex( hmutex );
return;
MSG message;
ipcwindow =
- CreateWindow( "STATIC", /* name of window class */
- "VLC ipc "VERSION, /* window title bar text */
+ CreateWindow( _T("STATIC"), /* name of window class */
+ _T("VLC ipc ") _T(VERSION), /* window title bar text */
0, /* window style */
0, /* default X coordinate */
0, /* default Y coordinate */
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;
{
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++ )
+ if( i_opt || config_GetInt( p_this, "playlist-enqueue" ) )
{
- 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 ,
+ PLAYLIST_END, -1,
+ (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ),
+ i_options );
+ } else {
+ playlist_AddExt( p_playlist, ppsz_argv[i_opt],
+ ppsz_argv[i_opt], PLAYLIST_APPEND | PLAYLIST_GO,
+ PLAYLIST_END, -1,
+ (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ),
+ i_options );
}
+
i_opt += i_options;
}
*****************************************************************************/
void system_End( vlc_t *p_this )
{
-#if !defined( UNDER_CE )
WSACleanup();
-#endif
}