]> git.sesse.net Git - vlc/blob - modules/codec/cmml/browser_open.c
f8b8b11564a93cbd5246f189ce0b0c256b30304a
[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 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <stdio.h>
32 #include <stdlib.h>
33
34 #include "browser_open.h"
35
36 #if 0
37 int browser_Open( const char *psz_url )
38 {
39 #ifdef __APPLE__
40     char *psz_open_commandline;
41     int i_ret;
42
43     if( asprintf( &psz_open_commandline, "/usr/bin/open %s", psz_url ) == -1 )
44         return -1;
45
46     i_ret = system( psz_open_commandline );
47     free( psz_open_commandline );
48     return i_ret;
49
50 #elif defined( UNDER_CE )
51     return -1;
52
53 #elif defined( WIN32 )
54     char *psz_open_commandline;
55     int i_ret;
56
57     if( asprintf( &psz_open_commandline, "explorer %s", psz_url ) == -1 )
58         return -1;
59
60     i_ret = system( psz_open_commandline );
61     free( psz_open_commandline );
62     return i_ret;
63
64 #else
65     /* Assume we're on a UNIX of some sort */
66     char *psz_open_commandline;
67     int i_ret;
68
69     /* Debian uses www-browser */
70     if( asprintf( &psz_open_commandline, "www-browser %s", psz_url ) == -1 )
71         return -1;
72
73     i_ret = system( psz_open_commandline );
74     free( psz_open_commandline );
75
76     if( i_ret == 0 )
77         return 0;
78
79     /* Try mozilla */
80     if( asprintf( &psz_open_commandline, "mozilla %s", psz_url ) == -1 )
81         return -1;
82
83     i_ret = system( psz_open_commandline );
84     free( psz_open_commandline );
85     return i_ret;
86 #endif
87 }
88 #else
89 int browser_Open( const char *psz_url )
90 {
91     (void)psz_url;
92     return -1;
93 }
94 #endif
95