X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Fdarwin_specific.c;h=810bd1b27ae175a7935d64dddd90eff13edf6154;hb=98dede2c4cb2a8283290147606c257f9d37145f5;hp=b33b3bb7419966dc7d91cf8c454e0a26eece34af;hpb=63cedb8d9b7235aef2d178f2b2bce369d5eeea47;p=vlc diff --git a/src/misc/darwin_specific.c b/src/misc/darwin_specific.c index b33b3bb741..810bd1b27a 100644 --- a/src/misc/darwin_specific.c +++ b/src/misc/darwin_specific.c @@ -1,3 +1,4 @@ + /***************************************************************************** * darwin_specific.m: Darwin specific features ***************************************************************************** @@ -30,15 +31,14 @@ #include #include "../libvlc.h" #include /* *dir() */ - +#include +#include #include +#include #ifdef HAVE_LOCALE_H # include #endif -#ifdef HAVE_MACH_O_DYLD_H -# include -#endif #ifndef MAXPATHLEN # define MAXPATHLEN 1024 @@ -57,7 +57,6 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] ) (void)pi_argc; /* Get the full program path and name */ - /* First try to see if we are linked to the framework */ for (i = 0; i < _dyld_image_count(); i++) { @@ -71,7 +70,7 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] ) p_char += 26; /* p_char += strlen(" VLCKit.framework/Versions/" ) */ while( *p_char != '\0' && *p_char != '/') p_char++; - + /* If the string ends with VLC then we've found a winner */ if ( !strcmp( p_char, "/VLCKit" ) ) { @@ -81,8 +80,26 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] ) else p_char = NULL; } + else + { + size_t len = strlen(psz_img_name); + /* Do we end by "VLC"? If so we are the legacy VLC.app that doesn't + * link to VLCKit. */ + if( !strcmp( psz_img_name + len - 3, "VLC") ) + { + p_char = strdup( psz_img_name ); + break; + } + } + } + if ( !p_char ) + { + /* We are not linked to the VLC.framework, let's use dladdr to figure + * libvlc path */ + Dl_info info; + if( dladdr(system_Init, &info) ) + p_char = strdup(dirname( info.dli_fname )); } - if( !p_char ) { char path[MAXPATHLEN+1]; @@ -96,6 +113,7 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] ) p_char = strdup( ppsz_argv[ 0 ] ); } + free(psz_vlcpath); psz_vlcpath = p_char; /* Remove trailing program name */ @@ -107,12 +125,12 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] ) *p_char = '\0'; p_oldchar = p_char; } - p_char++; } +#ifdef ENABLE_NLS /* Check if $LANG is set. */ - if ( (p_char = getenv("LANG")) == NULL ) + if( NULL == getenv("LANG") ) { /* Retrieve the preferred language as chosen in System Preferences.app @@ -138,15 +156,17 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] ) } CFRelease( all_locales ); } +#endif } /***************************************************************************** * system_Configure: check for system specific configuration options. *****************************************************************************/ -void system_Configure( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] ) +void system_Configure( libvlc_int_t *p_this, + int i_argc, const char *const ppsz_argv[] ) { (void)p_this; - (void)pi_argc; + (void)i_argc; (void)ppsz_argv; }