propose-patch
[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 gnu.gcj.RawData;
5 import java.util.*;
6
7 /** Platform implementation for POSIX compliant operating systems */
8 public class POSIX extends GCJ {
9
10     // General Methods ///////////////////////////////////////////////////////
11
12     protected String getDescriptiveName() { return "GCJ Linux Binary"; }
13
14     /** returns the value of the environment variable key, or null if no such key exists */
15     protected native String _getEnv(String key);
16     
17     /** spawns a process which is immune to SIGHUP */
18     private static native void spawnChildProcess(String[] command);
19
20     protected void _newBrowserWindow(String url) {
21         String browserString = getEnv("BROWSER");
22         if (browserString == null) {
23             browserString = "netscape " + url;
24         } else if (browserString.indexOf("%s") != -1) {
25             browserString =
26                 browserString.substring(0, browserString.indexOf("%s")) +
27                 url + browserString.substring(browserString.indexOf("%s") + 2);
28         } else {
29             browserString += " " + url;
30         }
31
32         StringTokenizer st = new StringTokenizer(browserString, " ");
33         String[] cmd = new String[st.countTokens()];
34         for(int i=0; st.hasMoreTokens(); i++) cmd[i] = st.nextToken();
35
36         spawnChildProcess(cmd);
37     }
38
39     public POSIX() { }
40 }
41
42
43