comparison dmd2/man.c @ 758:f04dde6e882c

Added initial D2 support, D2 frontend and changes to codegen to make things compile.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 11 Nov 2008 01:38:48 +0100
parents
children
comparison
equal deleted inserted replaced
757:2c730d530c98 758:f04dde6e882c
1
2 // Compiler implementation of the D programming language
3 // Copyright (c) 2008-2008 by Digital Mars
4 // All Rights Reserved
5 // written by Walter Bright
6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details.
10
11 #include <stdio.h>
12 #include <string.h>
13 #include <stdlib.h>
14 #include <assert.h>
15
16 #if _WIN32
17
18 #include <windows.h>
19
20 #pragma comment(lib,"shell32.lib")
21
22 void browse(const char *url)
23 {
24 ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
25 }
26
27 #endif
28
29 #if linux || __APPLE__
30
31 #include <sys/types.h>
32 #include <sys/wait.h>
33 #include <unistd.h>
34
35 void browse(const char *url)
36 {
37 pid_t childpid;
38 const char *args[3];
39
40 const char *browser = getenv("BROWSER");
41 if (browser)
42 browser = strdup(browser);
43 else
44 browser = "firefox";
45
46 args[0] = browser;
47 args[1] = url;
48 args[2] = NULL;
49
50 childpid = fork();
51 if (childpid == 0)
52 {
53 execvp(args[0], (char**)args);
54 perror(args[0]); // failed to execute
55 return;
56 }
57 }
58
59 #endif
60