*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
- * Gildas Bazin <gbazin@netcourrier.com>
+ * Gildas Bazin <gbazin@videolan.org>
* Derk-Jan Hartman <hartman at videolan dot org>
*
* This program is free software; you can redistribute it and/or modify
#include <vlc/vlc.h>
#include <vlc/input.h>
-#ifdef HAVE_ERRNO_H
-# include <errno.h> /* ENOMEM */
-#endif
+#include <errno.h> /* ENOMEM */
#include <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */
#include <stdlib.h> /* free() */
#ifdef WIN32
static void ShowConsole ( void );
+static void PauseConsole ( void );
#endif
static int ConsoleWidth ( void );
return VLC_EGENERIC;
}
p_vlc->thread_id = 0;
- vlc_thread_set_priority( p_vlc, VLC_THREAD_PRIORITY_LOW );
p_vlc->psz_object_name = "root";
vlc_mutex_init( p_vlc, &p_vlc->config_lock );
#ifdef SYS_DARWIN
vlc_mutex_init( p_vlc, &p_vlc->quicktime_lock );
+ vlc_thread_set_priority( p_vlc, VLC_THREAD_PRIORITY_LOW );
#endif
/* Store our newly allocated structure in the global list */
#ifndef WIN32
if( config_GetInt( p_vlc, "daemon" ) )
{
- pid_t i_pid = 0;
+#if HAVE_DAEMON
+ if( daemon( 0, 0) != 0 )
+ {
+ msg_Err( p_vlc, "Unable to fork vlc to daemon mode" );
+ b_exit = VLC_TRUE;
+ }
+
+ p_vlc->p_libvlc->b_daemon = VLC_TRUE;
+
+#else
+ pid_t i_pid;
if( ( i_pid = fork() ) < 0 )
{
{
/* We are the child */
msg_Dbg( p_vlc, "daemon spawned" );
- close( 0 );
- close( 1 );
- close( 2 );
+ close( STDIN_FILENO );
+ close( STDOUT_FILENO );
+ close( STDERR_FILENO );
p_vlc->p_libvlc->b_daemon = VLC_TRUE;
}
+#endif
}
#endif
ShowConsole();
/* Pause the console because it's destroyed when we exit */
fprintf( stderr, "The command line options couldn't be loaded, check "
- "that they are valid.\nPress the RETURN key to continue..." );
- getchar();
+ "that they are valid.\n" );
+ PauseConsole();
#endif
vlc_object_detach( p_help_module );
config_Free( p_help_module );
/*****************************************************************************
* VLC_VariableGet: get a vlc variable
*****************************************************************************/
-int VLC_Get( int i_object, char const *psz_var, vlc_value_t *p_value )
+int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value )
{
vlc_t *p_vlc = vlc_current_object( i_object );
int i_ret;
return VLC_ENOOBJ;
}
- i_ret = var_Get( p_vlc, psz_var, p_value );
+ i_ret = var_Get( p_vlc , psz_var, p_value );
if( i_object ) vlc_object_release( p_vlc );
return i_ret;
vlc_list_release( p_list );
#ifdef WIN32 /* Pause the console because it's destroyed when we exit */
- fprintf( stdout, _("\nPress the RETURN key to continue...\n") );
- getchar();
+ PauseConsole();
#endif
}
vlc_list_release( p_list );
#ifdef WIN32 /* Pause the console because it's destroyed when we exit */
- fprintf( stdout, _("\nPress the RETURN key to continue...\n") );
- getchar();
+ PauseConsole();
#endif
}
"Written by the VideoLAN team; see the AUTHORS file.\n") );
#ifdef WIN32 /* Pause the console because it's destroyed when we exit */
- fprintf( stdout, _("\nPress the RETURN key to continue...\n") );
- getchar();
+ PauseConsole();
#endif
}
static void ShowConsole( void )
{
# ifndef UNDER_CE
+
+ if( getenv( "PWD" ) && getenv( "PS1" ) ) return; /* cygwin shell */
+
AllocConsole();
freopen( "CONOUT$", "w", stdout );
freopen( "CONOUT$", "w", stderr );
freopen( "CONIN$", "r", stdin );
+
+# endif
+}
+#endif
+
+/*****************************************************************************
+ * PauseConsole: On Win32, wait for a key press before closing the console
+ *****************************************************************************
+ * This function is useful only on Win32.
+ *****************************************************************************/
+#ifdef WIN32 /* */
+static void PauseConsole( void )
+{
+# ifndef UNDER_CE
+
+ if( getenv( "PWD" ) && getenv( "PS1" ) ) return; /* cygwin shell */
+ fprintf( stdout, _("\nPress the RETURN key to continue...\n") );
+ getchar();
+
# endif
- return;
}
#endif