home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
archives
/
lilith.zip
/
m2kerm.mod
< prev
next >
Wrap
Text File
|
1988-08-16
|
5KB
|
213 lines
IMPLEMENTATION MODULE M2Kermit;
(************************************************************************)
(* This is the main body of the Modula-2 Kermit version. It reads a *)
(* command line and interprets it *)
(* written: 08.10.85 Matthias Aebi *)
(* last modification: 26.02.86 Matthias Aebi *)
(************************************************************************)
FROM InOut IMPORT WriteString, WriteLn, Write;
FROM KermMisc IMPORT ClrScr, ReadString;
FROM KermDir IMPORT Dir;
FROM KermFini IMPORT Finish;
FROM KermDel IMPORT Delete;
FROM KermGet IMPORT Get;
FROM KermHelp IMPORT Help;
FROM KermParam IMPORT LPrompt;
FROM KermRecv IMPORT Receive;
FROM KermSend IMPORT Send;
FROM KermSet IMPORT Set;
FROM KermServ IMPORT Server;
FROM KermShow IMPORT Show;
FROM KermTerm IMPORT Term;
FROM KermType IMPORT Type;
FROM KermVers IMPORT Version;
VAR
cmd : ARRAY [0..31] OF CHAR;
(************************************************************************)
PROCEDURE GetCmdLine;
(************************************************************************)
VAR
line : ARRAY [0..63] OF CHAR;
i : CARDINAL;
j : CARDINAL;
BEGIN
REPEAT
WriteLn;
WriteString(LPrompt);
Write(">");
ReadString(line);
i := 0;
j := 0;
(* parse cmd line, find parameters *)
WHILE (line[i] # 0C) AND (line[i] = " ") DO (* skip blanks *)
INC(i);
END;
j := 0;
WHILE (line[i] # 0C) AND (line[i] # " ") DO (* move cmd *)
IF (line[i] >= "a") AND (line[i] <= "z")
THEN
line[i] := CAP(line[i]);
END;
cmd[j] := line[i];
INC(j);
INC(i);
END;
cmd[j] := 0C;
WHILE (line[i] # 0C) AND (line[i] = " ") DO (* skip blanks *)
INC(i);
END;
j := 0;
WHILE (line[i] # 0C) AND (line[i] # " ") DO (* move Param1 *)
Param1[j] := line[i];
INC(j);
INC(i);
END;
Param1[j] := 0C;
WHILE (line[i] # 0C) AND (line[i] = " ") DO (* skip blanks *)
INC(i);
END;
j := 0;
WHILE line[i] # 0C DO (* move Param2 (rest of line) *)
Param2[j] := line[i];
INC(j);
INC(i);
END;
Param2[j] := 0C;
UNTIL cmd[0] <> 0C;
END GetCmdLine;
(************************************************************************)
PROCEDURE ExecCmd(): BOOLEAN;
(************************************************************************)
VAR
knownCmd : BOOLEAN;
BEGIN
knownCmd := TRUE;
CASE cmd[0] OF
"B": (* Bye *)
Finish("L");
RETURN TRUE; |
"C": (* Connect *)
Term; |
"D":
CASE cmd[1] OF
"I":
Dir; |
"E":
Delete;
ELSE
knownCmd := FALSE;
END; |
"E": (* Exit *)
RETURN TRUE; |
"F": (* Finish *)
Finish("F"); |
"G":
Get; |
"H","?":
Help; |
"L": (* Logout *)
Finish("L"); |
"Q": (* Quit *)
RETURN TRUE; |
"R":
Receive; |
"S":
CASE cmd[1] OF
"E":
CASE cmd[2] OF
"N":
Send; |
"T":
Set; |
"R":
IF Server()
THEN
RETURN TRUE; (* got logout command *)
END;
ELSE
knownCmd := FALSE;
END; |
"H":
Show;
ELSE
knownCmd := FALSE;
END; |
"T":
Type; |
"V":
Version;
ELSE
knownCmd := FALSE;
END;
IF (NOT knownCmd) AND (cmd[0] <> 0C)
THEN
WriteLn;
WriteString("Unknown or ambigous command. "); WriteLn;
WriteString("For a list of commands type 'Help'"); WriteLn;
END;
RETURN FALSE;
END ExecCmd;
(************************************************************************)
(* Main Program *)
(************************************************************************)
BEGIN
ClrScr;
WriteLn;
WriteString(VersionStr);
WriteLn;
WriteString("For a list of commands type 'Help'");
WriteLn;
WriteLn;
REPEAT
GetCmdLine;
UNTIL ExecCmd();
ClrScr;
END M2Kermit.