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