licensing cleanup (GPLv2)
[org.ibex.core.git] / src / org / ibex / plat / POSIX.java
1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the GNU General Public License version 2 ("the License").
3 // You may not use this file except in compliance with the License.
4
5 package org.ibex.plat;
6
7 import java.util.*;
8 import org.ibex.graphics.*;
9 import org.ibex.core.*;
10 import org.ibex.net.*;
11
12 /** Platform implementation for POSIX compliant operating systems */
13 public class POSIX extends GCJ {
14
15     // General Methods ///////////////////////////////////////////////////////
16
17     protected String getDescriptiveName() { return "GCJ Linux Binary"; }
18
19     /** returns the value of the environment variable key, or null if no such key exists */
20     protected native String _getEnv(String key);
21     
22     /** spawns a process which is immune to SIGHUP */
23     private static native void spawnChildProcess(String[] command);
24
25     protected void _newBrowserWindow(String url) {
26         String browserString = getEnv("BROWSER");
27         if (browserString == null) {
28             browserString = "netscape " + url;
29         } else if (browserString.indexOf("%s") != -1) {
30             browserString =
31                 browserString.substring(0, browserString.indexOf("%s")) +
32                 url + browserString.substring(browserString.indexOf("%s") + 2);
33         } else {
34             browserString += " " + url;
35         }
36
37         StringTokenizer st = new StringTokenizer(browserString, " ");
38         String[] cmd = new String[st.countTokens()];
39         for(int i=0; st.hasMoreTokens(); i++) cmd[i] = st.nextToken();
40
41         spawnChildProcess(cmd);
42     }
43
44 }
45
46
47