-
Notifications
You must be signed in to change notification settings - Fork 3
/
Loader.java
55 lines (49 loc) · 1.08 KB
/
Loader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.io.*;
public class Loader extends Thread
{
static final int OK = 0;
static final int ERROR = -1;
public Loader( ) {
}
public Loader( String args[] ) {
}
private static void help( ) {
SysLib.cout( "?: print a help message\n" );
SysLib.cout( "q: exit from threadOS\n" );
SysLib.cout( "l prog: load prog\n" );
}
public void run( ) {
String cmdLine = "";
char cmd = ' ';
while ( true ) {
do {
StringBuffer inputBuf = new StringBuffer( );
SysLib.cerr( "-->" );
SysLib.cin( inputBuf );
cmdLine = inputBuf.toString( );
} while ( cmdLine.length( ) == 0 );
System.out.println( cmdLine );
cmd = cmdLine.charAt( 0 );
switch( cmd ) {
case '?':
help( );
break;
case 'q':
SysLib.sync( );
System.exit( 1 );
break;
case 'l':
String intrArgs[]
= SysLib.stringToArgs( cmdLine.substring( 2 ) );
if ( SysLib.exec( intrArgs ) == ERROR ) {
SysLib.cerr( intrArgs[0] + " failed in loading\n" );
break;
}
SysLib.join( );
break;
case 'r':
break;
}
}
}
}