/*****************************************************************************
* libvlc.c: main libvlc source
*****************************************************************************
- * Copyright (C) 1998-2004 the VideoLAN team
+ * Copyright (C) 1998-2006 the VideoLAN team
* $Id$
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
* Gildas Bazin <gbazin@videolan.org>
* Derk-Jan Hartman <hartman at videolan dot org>
+ * RĂ©mi Denis-Courmont <rem # 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 <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */
#include <stdlib.h> /* free() */
+#ifdef HAVE_ASSERT
+# include <assert.h>
+#else
+# define assert( c ) ((void)0)
+#endif
#ifndef WIN32
# include <netinet/in.h> /* BSD: struct in_addr */
/* Initialize mutexes */
vlc_mutex_init( p_vlc, &p_vlc->config_lock );
-#ifdef SYS_DARWIN
+#ifdef __APPLE__
vlc_mutex_init( p_vlc, &p_vlc->quicktime_lock );
vlc_thread_set_priority( p_vlc, VLC_THREAD_PRIORITY_LOW );
#endif
if( !config_GetInt( p_vlc, "sse2" ) )
libvlc.i_cpu &= ~CPU_CAPABILITY_SSE2;
#endif
-#if defined( __powerpc__ ) || defined( SYS_DARWIN )
+#if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
if( !config_GetInt( p_vlc, "altivec" ) )
libvlc.i_cpu &= ~CPU_CAPABILITY_ALTIVEC;
#endif
}
libvlc.b_stats = config_GetInt( p_vlc, "stats" );
+ libvlc.p_stats = NULL;
/*
* Initialize hotkey handling
{
VLC_AddIntf( 0, "logger", VLC_FALSE, VLC_FALSE );
}
+#ifdef HAVE_SYSLOG_H
if( config_GetInt( p_vlc, "syslog" ) == 1 )
{
char *psz_logmode = "logmode=syslog";
AddIntfInternal( 0, "logger", VLC_FALSE, VLC_FALSE, 1, &psz_logmode );
}
+#endif
if( config_GetInt( p_vlc, "show-intf" ) == 1 )
{
while( ( p_stats = vlc_object_find( p_vlc, VLC_OBJECT_STATS, FIND_CHILD) ))
{
+ stats_TimersDumpAll( p_vlc );
stats_HandlerDestroy( p_stats );
vlc_object_detach( (vlc_object_t*) p_stats );
vlc_object_release( (vlc_object_t *)p_stats );
&& ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
char * psz_path;
-#if defined( SYS_DARWIN ) || defined ( WIN32 ) || defined( SYS_BEOS )
+#if defined( __APPLE__ ) || defined ( WIN32 ) || defined( SYS_BEOS )
char psz_tmp[1024];
#endif
}
else if( psz_lang )
{
-#ifdef SYS_DARWIN
+#ifdef __APPLE__
/* I need that under Darwin, please check it doesn't disturb
* other platforms. --Meuuh */
setenv( "LANG", psz_lang, 1 );
}
/* Specify where to find the locales for current domain */
-#if !defined( SYS_DARWIN ) && !defined( WIN32 ) && !defined( SYS_BEOS )
+#if !defined( __APPLE__ ) && !defined( WIN32 ) && !defined( SYS_BEOS )
psz_path = LOCALEDIR;
#else
snprintf( psz_tmp, sizeof(psz_tmp), "%s/%s", libvlc.psz_vlcpath,
* to non-const.
*/
inb = strlen( locale );
- outb = inb * 6 + 1;
-
/* FIXME: I'm not sure about the value for the multiplication
* (for western people, multiplication by 3 (Latin9) is sufficient) */
+ outb = inb * 6 + 1;
+
optr = output = calloc( outb , 1);
vlc_mutex_lock( &libvlc.from_locale_lock );
while( vlc_iconv( libvlc.from_locale, &iptr, &inb, &optr, &outb )
== (size_t)-1 )
{
- *optr = '?';
- optr++;
+ *optr++ = '?';
+ outb--;
iptr++;
+ inb--;
vlc_iconv( libvlc.from_locale, NULL, NULL, NULL, NULL );
}
- vlc_mutex_unlock( &libvlc.from_locale_lock );
+ vlc_mutex_unlock( &libvlc.from_locale_lock );
- return realloc( output, strlen( output ) + 1 );
+ assert (inb == 0);
+ assert (*iptr == '\0');
+ assert (*optr == '\0');
+ assert (strlen( output ) == (size_t)(optr - output));
+ return realloc( output, optr - output + 1 );
}
return (char *)locale;
}
while( vlc_iconv( libvlc.to_locale, &iptr, &inb, &optr, &outb )
== (size_t)-1 )
{
- *optr = '?'; /* should not happen, and yes, it sucks */
- optr++;
+ *optr++ = '?'; /* should not happen, and yes, it sucks */
+ outb--;
iptr++;
+ inb--;
vlc_iconv( libvlc.to_locale, NULL, NULL, NULL, NULL );
}
vlc_mutex_unlock( &libvlc.to_locale_lock );
- return realloc( output, strlen( output ) + 1 );
+ assert (inb == 0);
+ assert (*iptr == '\0');
+ assert (*optr == '\0');
+ assert (strlen( output ) == (size_t)(optr - output));
+ return realloc( output, optr - output + 1 );
}
return (char *)utf8;
}