version 1.1.1.1, 1999/11/02 11:52:34 |
version 1.4, 1999/11/04 18:21:42 |
|
|
|
/** |
|
* $OpenXM: OpenXM/src/OpenMath/OMproxy.java,v 1.3 1999/11/03 07:19:16 tam Exp $ |
|
*/ |
|
|
import JP.ac.kobe_u.math.tam.OpenXM.*; |
import JP.ac.kobe_u.math.tam.OpenXM.*; |
import java.util.Stack; |
import java.util.Stack; |
import java.io.*; |
import java.io.*; |
|
|
class OMproxy implements Runnable{ |
class OMproxy implements Runnable{ |
private OpenXM ox; |
private OpenXM ox; |
private Stack stack = new Stack(); |
private Stack stack = new Stack(); |
|
private boolean debug = true; |
|
|
public OMproxy(String host,int ControlPort,int DataPort) throws IOException{ |
public OMproxy(String host,int ControlPort,int DataPort) throws IOException{ |
ox = new OpenXM(this,host,ControlPort,DataPort); |
ox = new OpenXM(this,host,ControlPort,DataPort); |
Line 25 class OMproxy implements Runnable{ |
|
Line 30 class OMproxy implements Runnable{ |
|
|
|
case OpenXM.OX_DATA: |
case OpenXM.OX_DATA: |
stack.push(ox.receiveCMO()); |
stack.push(ox.receiveCMO()); |
System.out.println("push: "+ stack.peek()); |
debug("push: "+ stack.peek()); |
break; |
break; |
} |
} |
} |
} |
Line 60 class OMproxy implements Runnable{ |
|
Line 65 class OMproxy implements Runnable{ |
|
private void SM_executeFunction() throws java.io.IOException{ |
private void SM_executeFunction() throws java.io.IOException{ |
String function_name; |
String function_name; |
CMO[] argv; |
CMO[] argv; |
int argc; |
int argc = 1; |
|
|
if(!(stack.peek() instanceof CMO_STRING)){ |
if(!(stack.peek() instanceof CMO_STRING)){ |
stack.push(new CMO_ERROR2()); |
stack.push(new CMO_ERROR2()); |
return; |
return; |
} |
} |
function_name = ((CMO_STRING)stack.pop()).getString(); |
function_name = ((CMO_STRING)stack.pop()).getString(); |
argc = ((CMO_INT32)stack.pop()).intValue(); |
//argc = ((CMO_INT32)stack.pop()).intValue(); |
argv = new CMO[argc]; |
argv = new CMO[argc]; |
for(int i=0;i<argc;i++){ |
for(int i=0;i<argc;i++){ |
argv[i] = (CMO)stack.pop(); |
argv[i] = (CMO)stack.pop(); |
Line 91 class OMproxy implements Runnable{ |
|
Line 96 class OMproxy implements Runnable{ |
|
} |
} |
|
|
private void StackMachine(SM mesg) throws java.io.IOException{ |
private void StackMachine(SM mesg) throws java.io.IOException{ |
|
debug("receive: "+mesg); |
|
|
switch(mesg.getCode()){ |
switch(mesg.getCode()){ |
case SM.SM_popCMO: |
case SM.SM_popCMO: |
SM_popCMO(); |
SM_popCMO(); |
Line 117 class OMproxy implements Runnable{ |
|
Line 124 class OMproxy implements Runnable{ |
|
ByteArrayInputStream stream; |
ByteArrayInputStream stream; |
CMO ret; |
CMO ret; |
|
|
|
debug("OMXML2CMO called: "+ret); |
|
|
if(obj instanceof CMO_STRING){ |
if(obj instanceof CMO_STRING){ |
return new CMO_ERROR2(); |
return new CMO_ERROR2(); |
} |
} |
Line 128 class OMproxy implements Runnable{ |
|
Line 137 class OMproxy implements Runnable{ |
|
return new CMO_ERROR2(new CMO_STRING(e.toString())); |
return new CMO_ERROR2(new CMO_STRING(e.toString())); |
} |
} |
|
|
|
debug("push: "+ret); |
return ret; |
return ret; |
} |
} |
|
|
|
private void debug(String str){ |
|
if(debug){ |
|
System.out.println(str); |
|
} |
|
} |
|
|
|
private static String usage(){ |
|
String ret = ""; |
|
|
|
ret += "usage\t: java OMproxy [options]\n"; |
|
ret += "options\t:\n"; |
|
ret += "\t -h \t show this message\n"; |
|
ret += "\t -host hostname \t (default localhost)\n"; |
|
ret += "\t -data port \t (default 1300)\n"; |
|
ret += "\t -control port \t (default 1200)\n"; |
|
|
|
return ret; |
|
} |
|
|
public static void main(String argv[]){ |
public static void main(String argv[]){ |
String host = "localhost"; |
String host = "localhost"; |
int DataPort = 1300, ControlPort = 1200; |
int DataPort = 1300, ControlPort = 1200; |
|
|
for(int i=0;i<argv.length;i++){ |
for(int i=0;i<argv.length;i++){ |
if(argv[i].equals("-h")){ |
if(argv[i].equals("-h")){ |
System.out.println(""); |
System.out.print(usage()); |
System.exit(0); |
System.exit(0); |
}else if(argv[i].equals("-host")){ |
}else if(argv[i].equals("-host")){ |
host = argv[++i]; |
host = argv[++i]; |
Line 146 class OMproxy implements Runnable{ |
|
Line 175 class OMproxy implements Runnable{ |
|
}else if(argv[i].equals("-control")){ |
}else if(argv[i].equals("-control")){ |
ControlPort = Integer.valueOf(argv[++i]).intValue(); |
ControlPort = Integer.valueOf(argv[++i]).intValue(); |
}else{ |
}else{ |
System.err.println("unknown option :"+ argv[i]); |
System.err.println("unknown option : "+ argv[i]); |
|
System.err.print(usage()); |
System.exit(1); |
System.exit(1); |
} |
} |
} |
} |
|
|
System.out.println("host(ctrl,data): "+ host |
System.out.println("host(ctrl,data): "+ host |
+"("+ ControlPort +","+ DataPort +")"); |
+"("+ ControlPort +","+ DataPort +")"); |
|
|