AlpineFTPCmdsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Bob Hagmann April 25, 1985 1:44:45 pm PST
DIRECTORY
AlpineFTP USING [CreateListener, DestroyListener],
Commander USING [CommandProc, Handle, Register],
CommandTool USING [ArgumentVector, Failed, Parse],
Rope;
AlpineFTPCmdsImpl:
CEDAR
MONITOR
IMPORTS AlpineFTP, Commander, CommandTool, Rope
= BEGIN
ROPE: TYPE = Rope.ROPE;
CurrentServerName: ROPE ← NIL;
StartAlpineFTPServer: Commander.CommandProc = {
[cmd: REF CommandObject] RETURNS [result: REF ← NIL, msg: ROPE ← NIL]
CommandObject = [
in, out, err: STREAM, commandLine, command: ROPE,
propertyList: List.AList, procData: CommandProcHandle]
Parse the volumeGroupName, make sure it is not already running, then start up the Alpine FTP server.
volGroup: ROPE;
new: BOOL;
anotherRunning: BOOL;
argv: CommandTool.ArgumentVector ← CommandTool.Parse[cmd
! CommandTool.Failed => {msg ← errorMsg; GO TO Usage}];
IF argv.argc # 2 THEN GOTO Usage;
volGroup ← argv[1] ;
[new, anotherRunning] ← registerVolGroup[volGroup];
SELECT
TRUE
FROM
new AND ~anotherRunning => AlpineFTP.CreateListener[volumeGroupName: volGroup];
new AND anotherRunning => RETURN[$Failure, "Server for a different volume group already running "];
~new => RETURN[$Failure, "Server for volume group already running "];
ENDCASE;
EXITS
Usage => RETURN[$Failure, "Usage: StartAlpineFTPServer volumeGroupName "];
};
StopAlpineFTPServer: Commander.CommandProc = {
[cmd: REF CommandObject] RETURNS [result: REF ← NIL, msg: ROPE ← NIL]
CommandObject = [
in, out, err: STREAM, commandLine, command: ROPE,
propertyList: List.AList, procData: CommandProcHandle]
Parse the volumeGroupName, make sure it is not already running, then start up the Alpine FTP server.
volGroup: ROPE;
argv: CommandTool.ArgumentVector ← CommandTool.Parse[cmd
! CommandTool.Failed => {msg ← errorMsg; GO TO Usage}];
IF argv.argc # 2 THEN GOTO Usage;
volGroup ← argv[1] ;
IF unregisterVolGroup[volGroup] THEN AlpineFTP.DestroyListener[]
ELSE RETURN[$Failure, "Server for volume group not running "];
EXITS
Usage => RETURN[$Failure, "Usage: StopAlpineFTPServer volumeGroupName "];
};
registerVolGroup:
ENTRY
PROC[volumeGroupName:
ROPE]
RETURNS [new:
BOOL ←
TRUE, anotherRunning:
BOOL ←
FALSE] = {
ENABLE UNWIND => NULL;
IF CurrentServerName.IsEmpty[] THEN {CurrentServerName ← volumeGroupName; RETURN};
IF CurrentServerName.Equal[volumeGroupName, FALSE] THEN RETURN[FALSE, FALSE]
ELSE RETURN[FALSE, TRUE];
};
unregisterVolGroup:
ENTRY
PROC[volumeGroupName:
ROPE]
RETURNS [found:
BOOL] = {
ENABLE UNWIND => NULL;
IF CurrentServerName.Equal[volumeGroupName,
FALSE]
THEN {
CurrentServerName ← NIL;
RETURN[TRUE];
};
RETURN[FALSE];
};
Init:
PROCEDURE = {
Commander.Register[
"///Commands/StartAlpineFTPServer", StartAlpineFTPServer,
"StartAlpineFTPServer volumeGroupName -- Start up the Alpine FTP Server for the named volume group"];
Commander.Register[
"///Commands/StopAlpineFTPServer", StopAlpineFTPServer,
"StopAlpineFTPServer volumeGroupName -- Stop up the Alpine FTP Server for the named volume group"];
};
Initialization
END.
Bob Hagmann April 24, 1985 7:43:13 am PST
changes to: DIRECTORY, AlpineFTPCmdsImpl, ServerList, StartAlpineFTPServer, StopAlpineFTPServer, registerVolGroup, unregisterVolGroup, Init
Bob Hagmann April 25, 1985 1:44:08 pm PST
changes to: StopAlpineFTPServer