1 /*****************************************************************************
2 * darwin_specific.m: Darwin specific features
3 *****************************************************************************
4 * Copyright (C) 2001-2004 the VideoLAN team
7 * Authors: Sam Hocevar <sam@zoy.org>
8 * Christophe Massiot <massiot@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
24 #include <string.h> /* strdup() */
25 #include <stdlib.h> /* free() */
29 #include <Cocoa/Cocoa.h>
30 #include <CoreFoundation/CFString.h>
36 /*****************************************************************************
37 * system_Init: fill in program path & retrieve language
38 *****************************************************************************/
39 static int FindLanguage( const char * psz_lang )
41 const char ** ppsz_parser;
42 const char * ppsz_all[] =
57 "Brazilian Portuguese", "pt_BR",
61 "Simplified Chinese", "zh_CN",
62 "Chinese Traditional", "zh_TW",
66 for( ppsz_parser = ppsz_all ; ppsz_parser[0] ; ppsz_parser += 2 )
68 if( !strcmp( psz_lang, ppsz_parser[0] )
69 || !strcmp( psz_lang, ppsz_parser[1] ) )
71 setenv( "LANG", ppsz_parser[1], 1 );
79 void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
82 char *p_char, *p_oldchar = &i_dummy;
84 /* Get the full program path and name */
85 p_char = p_this->p_libvlc->psz_vlcpath = strdup( ppsz_argv[ 0 ] );
87 /* Remove trailing program name */
100 /* Check if $LANG is set. */
101 if ( (p_char = getenv("LANG")) == NULL )
103 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
105 /* Retrieve user's preferences. */
106 NSUserDefaults * o_defs = [NSUserDefaults standardUserDefaults];
107 NSArray * o_languages = [o_defs objectForKey:@"AppleLanguages"];
108 NSEnumerator * o_enumerator = [o_languages objectEnumerator];
111 while ( (o_lang = [o_enumerator nextObject]) )
113 const char * psz_string = [o_lang lossyCString];
114 if ( FindLanguage( psz_string ) )
123 vlc_mutex_init( p_this, &p_this->p_libvlc->iconv_lock );
124 p_this->p_libvlc->iconv_macosx = vlc_iconv_open( "UTF-8", "UTF-8-MAC" );
127 /*****************************************************************************
128 * system_Configure: check for system specific configuration options.
129 *****************************************************************************/
130 void system_Configure( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
135 /*****************************************************************************
136 * system_End: free the program path.
137 *****************************************************************************/
138 void system_End( vlc_t *p_this )
140 free( p_this->p_libvlc->psz_vlcpath );
142 if ( p_this->p_libvlc->iconv_macosx != (vlc_iconv_t)-1 )
143 vlc_iconv_close( p_this->p_libvlc->iconv_macosx );
144 vlc_mutex_destroy( &p_this->p_libvlc->iconv_lock );