]> git.sesse.net Git - vlc/blob - modules/codec/cmml/browser_open.c
ce307c546df8029e821ee659dd6caf7dee74e3f5
[vlc] / modules / codec / cmml / browser_open.c
1 /*****************************************************************************
2  * browser_open.c: platform-independent opening of a web browser
3  *****************************************************************************
4  * Copyright (C) 2004 Commonwealth Scientific and Industrial Research
5  *                    Organisation (CSIRO) Australia
6  * Copyright (C) 2004 VideoLAN
7  *
8  * $Id$
9  *
10  * Authors: Andre Pang <Andre.Pang@csiro.au>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  * 
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
25  *****************************************************************************/
26
27 #include <stdlib.h>
28 #include <string.h>
29
30 #include "xstrcat.h"
31
32 int browser_Open( const char *psz_url )
33 {
34 #ifdef SYS_DARWIN
35     char *psz_open_commandline;
36
37     psz_open_commandline = strdup( "/usr/bin/open " );
38     psz_open_commandline = xstrcat( psz_open_commandline, psz_url );
39
40     return system( psz_open_commandline );
41 #elif defined( WIN32 )
42     char *psz_open_commandline;
43
44     psz_open_commandline = strdup( "explorer " );
45     xstrcat( psz_open_commandline, psz_url );
46
47     return system( psz_open_commandline );
48 #else
49     /* Assume we're on a UNIX of some sort */
50     char *psz_open_commandline;
51     int i_ret;
52
53     /* Debian uses www-browser */
54     psz_open_commandline = strdup( "www-browser" );
55     xstrcat( psz_open_commandline, psz_url );
56     i_ret = system( psz_open_commandline );
57
58     if( i_ret == 0 )
59     {
60         return 0;
61     }
62
63     free( psz_open_commandline );
64
65     /* Try mozilla */
66     psz_open_commandline = strdup( "mozilla" );
67     xstrcat( psz_open_commandline, psz_url );
68     return system( psz_open_commandline );
69 #endif
70 }
71