Mercurial > projects > ldc
comparison dmd/root/man.c @ 1194:1853dcd9b944
Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Fri, 03 Apr 2009 17:02:52 +0200 |
parents | dmd/man.c@b30fe7e1dbb9 |
children | 8026319762be |
comparison
equal
deleted
inserted
replaced
1193:c271eca933fb | 1194:1853dcd9b944 |
---|---|
1 | |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 2008-2009 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 | |
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 char *browser = getenv("BROWSER"); | |
41 if (browser) | |
42 browser = strdup(browser); | |
43 else | |
44 browser = "x-www-browser"; | |
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 | |
61 #if __APPLE__ | |
62 | |
63 #include <sys/types.h> | |
64 #include <sys/wait.h> | |
65 #include <unistd.h> | |
66 | |
67 void browse(const char *url) | |
68 { | |
69 pid_t childpid; | |
70 const char *args[5]; | |
71 | |
72 char *browser = getenv("BROWSER"); | |
73 if (browser) | |
74 { browser = strdup(browser); | |
75 args[0] = browser; | |
76 args[1] = url; | |
77 args[2] = NULL; | |
78 } | |
79 else | |
80 { | |
81 //browser = "/Applications/Safari.app/Contents/MacOS/Safari"; | |
82 args[0] = "open"; | |
83 args[1] = "-a"; | |
84 args[2] = "/Applications/Safari.app"; | |
85 args[3] = url; | |
86 args[4] = NULL; | |
87 } | |
88 | |
89 childpid = fork(); | |
90 if (childpid == 0) | |
91 { | |
92 execvp(args[0], (char**)args); | |
93 perror(args[0]); // failed to execute | |
94 return; | |
95 } | |
96 } | |
97 | |
98 #endif | |
99 | |
100 | |
101 #if __FreeBSD__ | |
102 #endif |