]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
* This patch does what the revert'ed patch from before should have done. Changing...
[vlc] / src / libvlc.c
index 793c60825b447cb189228731056e20c532f743be..85046e2e8dd6d452ee63534060b34db4ac98f3f3 100644 (file)
@@ -139,22 +139,25 @@ char const * VLC_Version( void )
 }
 
 /*****************************************************************************
- * VLC_CompileTime, VLC_CompileBy, VLC_CompileHost, VLC_CompileDomain,
+ * VLC_CompileBy, VLC_CompileHost, VLC_CompileDomain,
  * VLC_Compiler, VLC_Changeset
  *****************************************************************************/
 #define DECLARE_VLC_VERSION( func, var )                                    \
-extern const char psz_vlc_##var [];                                         \
 char const * VLC_##func ( void )                                            \
 {                                                                           \
-    return psz_vlc_##var ;                                                  \
+    return VLC_##var ;                                                      \
 }
 
-DECLARE_VLC_VERSION( CompileTime, compile_time );
-DECLARE_VLC_VERSION( CompileBy, compile_by );
-DECLARE_VLC_VERSION( CompileHost, compile_host );
-DECLARE_VLC_VERSION( CompileDomain, compile_domain );
-DECLARE_VLC_VERSION( Compiler, compiler );
-DECLARE_VLC_VERSION( Changeset, changeset );
+DECLARE_VLC_VERSION( CompileBy, COMPILE_BY );
+DECLARE_VLC_VERSION( CompileHost, COMPILE_HOST );
+DECLARE_VLC_VERSION( CompileDomain, COMPILE_DOMAIN );
+DECLARE_VLC_VERSION( Compiler, COMPILER );
+
+extern const char psz_vlc_changeset[];
+char const * VLC_Changeset( void )
+{
+    return psz_vlc_changeset;
+}
 
 /*****************************************************************************
  * VLC_Error: strerror() equivalent
@@ -365,14 +368,17 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
 
     /* Set the config file stuff */
     p_vlc->psz_homedir = config_GetHomeDir();
+    p_vlc->psz_userdir = config_GetUserDir();
+    if( p_vlc->psz_userdir == NULL )
+        p_vlc->psz_userdir = strdup(p_vlc->psz_homedir);
     p_vlc->psz_configfile = config_GetPsz( p_vlc, "config" );
     if( p_vlc->psz_configfile != NULL && p_vlc->psz_configfile[0] == '~'
          && p_vlc->psz_configfile[1] == '/' )
     {
-        char *psz = malloc( strlen(p_vlc->psz_homedir)
+        char *psz = malloc( strlen(p_vlc->psz_userdir)
                              + strlen(p_vlc->psz_configfile) );
         /* This is incomplete : we should also support the ~cmassiot/ syntax. */
-        sprintf( psz, "%s/%s", p_vlc->psz_homedir,
+        sprintf( psz, "%s/%s", p_vlc->psz_userdir,
                                p_vlc->psz_configfile + 2 );
         free( p_vlc->psz_configfile );
         p_vlc->psz_configfile = psz;
@@ -396,7 +402,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
     if( config_GetInt( p_vlc, "daemon" ) )
     {
 #if HAVE_DAEMON
-        if( daemon( 0, 0) != 0 )
+        if( daemon( 1, 0) != 0 )
         {
             msg_Err( p_vlc, "Unable to fork vlc to daemon mode" );
             b_exit = VLC_TRUE;
@@ -742,10 +748,21 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
     }
 
     /*
-     * Allways load the hotkeys interface if it exists
+     * Always load the hotkeys interface if it exists
      */
     VLC_AddIntf( 0, "hotkeys,none", VLC_FALSE, VLC_FALSE );
 
+    /*
+     * If needed, load the Xscreensaver interface
+     * Currently, only for X
+     */
+#ifdef HAVE_X11_XLIB_H
+    if( config_GetInt( p_vlc, "disable-screensaver" ) == 1 )
+    {
+        VLC_AddIntf( 0, "screensaver", VLC_FALSE, VLC_FALSE );
+    }
+#endif
+
     /*
      * FIXME: kludge to use a p_vlc-local variable for the Mozilla plugin
      */
@@ -761,6 +778,8 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
     var_Create( p_vlc, "drawableh", VLC_VAR_INTEGER );
     var_Create( p_vlc, "drawableportx", VLC_VAR_INTEGER );
     var_Create( p_vlc, "drawableporty", VLC_VAR_INTEGER );
+    var_Create( p_vlc, "width", VLC_VAR_INTEGER );
+    var_Create( p_vlc, "height", VLC_VAR_INTEGER );
 
     /*
      * Get input filenames given as commandline arguments
@@ -980,6 +999,12 @@ int VLC_Destroy( int i_object )
         p_vlc->psz_homedir = NULL;
     }
 
+    if( p_vlc->psz_userdir )
+    {
+        free( p_vlc->psz_userdir );
+        p_vlc->psz_userdir = NULL;
+    }
+
     if( p_vlc->psz_configfile )
     {
         free( p_vlc->psz_configfile );
@@ -2390,10 +2415,10 @@ static void Version( void )
 #endif
 
     fprintf( stdout, _("VLC version %s\n"), VLC_Version() );
-    fprintf( stdout, _("Compiled on %s by %s@%s.%s\n"), VLC_CompileTime(),
+    fprintf( stdout, _("Compiled by %s@%s.%s\n"),
              VLC_CompileBy(), VLC_CompileHost(), VLC_CompileDomain() );
     fprintf( stdout, _("Compiler: %s\n"), VLC_Compiler() );
-    if( *VLC_Changeset() )
+    if( strcmp( VLC_Changeset(), "exported" ) )
         fprintf( stdout, _("Based upon svn changeset [%s]\n"),
                  VLC_Changeset() );
     fprintf( stdout,
@@ -2416,11 +2441,21 @@ static void Version( void )
 static void ShowConsole( void )
 {
 #   ifndef UNDER_CE
+    FILE *f_help;
 
     if( getenv( "PWD" ) && getenv( "PS1" ) ) return; /* cygwin shell */
 
     AllocConsole();
-    freopen( "CONOUT$", "w", stdout );
+
+    if( (f_help = fopen( "vlc-help.txt", "wt" )) )
+    {
+        fclose( f_help );
+        freopen( "vlc-help.txt", "wt", stdout );
+        fprintf( stderr, _("\nDumped content to vlc-help.txt file.\n") );
+    }
+
+    else freopen( "CONOUT$", "w", stdout );
+
     freopen( "CONOUT$", "w", stderr );
     freopen( "CONIN$", "r", stdin );
 
@@ -2439,8 +2474,10 @@ static void PauseConsole( void )
 #   ifndef UNDER_CE
 
     if( getenv( "PWD" ) && getenv( "PS1" ) ) return; /* cygwin shell */
-    fprintf( stdout, _("\nPress the RETURN key to continue...\n") );
+
+    fprintf( stderr, _("\nPress the RETURN key to continue...\n") );
     getchar();
+    fclose( stdout );
 
 #   endif
 }
@@ -2577,8 +2614,9 @@ char *FromLocale( const char *locale )
         while( vlc_iconv( libvlc.from_locale, &iptr, &inb, &optr, &outb )
                                                                == (size_t)-1 )
         {
-            *optr++ = '?';
-            *iptr++;
+            *optr = '?';
+            optr++;
+            iptr++;
             vlc_iconv( libvlc.from_locale, NULL, NULL, NULL, NULL );
         }
         vlc_mutex_unlock( &libvlc.from_locale_lock );
@@ -2617,8 +2655,9 @@ char *ToLocale( const char *utf8 )
         while( vlc_iconv( libvlc.to_locale, &iptr, &inb, &optr, &outb )
                                                                == (size_t)-1 )
         {
-            *optr++ = '?'; /* should not happen, and yes, it sucks */
-            *iptr++;
+            *optr = '?'; /* should not happen, and yes, it sucks */
+            optr++;
+            iptr++;
             vlc_iconv( libvlc.to_locale, NULL, NULL, NULL, NULL );
         }
         vlc_mutex_unlock( &libvlc.to_locale_lock );