Last Edited by: teitelman, December 25, 1982 3:52 pm
DIRECTORY
ConvertUnsafe USING [ToRefText],
Exec USING [commandLine, CommandLine],
ExecOps USING [ ],
IO USING [SP, CR, TAB, NUL],
Rope USING [FromRefText],
TTY USING [Handle],
UserExec USING [ExecHandle, GetExecHandle, UserAbort, ResetUserAbort],
UserExecPrivate USING [Register]
;
ExecImpl: PROGRAM
IMPORTS ConvertUnsafe, Exec, Rope, UserExec, UserExecPrivate
EXPORTS Exec, ExecOps, UserExecPrivate
= BEGIN
w: PUBLIC TTY.Handle; -- set in CallRegisteredProc
commandString: PUBLIC LONG STRING ← [256];
commandLine: PUBLIC Exec.CommandLine ← [s: commandString, i: 0];
AddCommand: PUBLIC PROCEDURE [name: LONG STRING, proc: UNSAFE PROCEDURE] = {
UserExecPrivate.Register[name: Rope.FromRefText[ConvertUnsafe.ToRefText[name]], oldStyleProc: proc];
};
CheckForAbort: PUBLIC PROCEDURE RETURNS [BOOLEAN] = {
execHandle: UserExec.ExecHandle = UserExec.GetExecHandle[];
IF UserExec.UserAbort[execHandle] THEN {UserExec.ResetUserAbort[execHandle]; RETURN[TRUE]}
ELSE RETURN[FALSE]; 
};
GetChar: PUBLIC PROCEDURE RETURNS [char: CHARACTER] = {
OPEN Exec.commandLine;
IF i >= s.length THEN RETURN[IO.NUL];
char ← s[i];
i ← i + 1;
};
GetToken: PUBLIC PROCEDURE [get: UNSAFE PROC RETURNS [CHARACTER], token, switches: STRING] = {
char: CHARACTER;
str: STRING ← token;
token.length ← 0;
switches.length ← 0;
UNTIL (char ← get[]) # IO.SP OR char = IO.TAB DO NULL; ENDLOOP; -- skip white space
DO
SELECT char FROM
'/ => {str ← switches; char ← get[]; LOOP};
IO.SP, IO.TAB, IO.CR, IO.NUL => EXIT;
'', '^ => char ← get[];
ENDCASE;
str[str.length] ← char;
str.length ← str.length + 1;
char ← get[];
ENDLOOP;
};
AppendCommands: PUBLIC PROC [LONG STRING] = {-- nop for eric --};
MatchPattern, AppendCommands, PrependCommands, RemoveCommand, and Exec.GetNameandPassWord not implemented nobody is using them.
END. -- of ExecImpl