file: STPOps.mesa Edited by:
Smokey, 17-Jul-81 7:57:15
JGS, 17-Aug-81 11:24:06
Karlton, 10-Nov-81 16:51:38
Daniels, 21-Sep-82 13:00:07
Davirro, 16-Nov-82 17:48:07
Andrew Birrell June 1, 1983 2:47 pm
DIRECTORY
PupStream USING [CloseReason],
IO USING [STREAM],
Rope USING [ROPE],
STP
USING [
Access, CompletionProcType, ConfirmProcType, DesiredProperties, ErrorCode, FileInfo,
Type, ValidProperties],
BasicTime USING [GMT];
STPOps:
CEDAR
DEFINITIONS =
BEGIN
Constants
maxStringLength: CARDINAL = 100;
Types
Handle: TYPE = REF Object;
Object:
TYPE =
RECORD[
byteStream: IO.STREAM ← NIL,
userState: ARRAY UserProperties OF Rope.ROPE ← ALL[NIL],
gotMark: BOOLEAN ← FALSE,
mark: [0..256) ← NULL,
remoteString: Rope.ROPE ← NIL,
host: Rope.ROPE ← NIL,
serverType: ServerType ← unknown,
plist: PList ← NIL,
desiredProps: STP.DesiredProperties ← ALL[TRUE],
info: STP.FileInfo ← NIL,
remoteStream: RemoteStream ← NIL];
RemoteStream: TYPE = REF RemoteObject;
RemoteObject:
TYPE =
RECORD[
state: RemoteStreamState,
access: STP.Access,
stp: Handle];
FilenameType: TYPE = {alto, tenex};
Operation: TYPE = {delete, directory, retrieve, store};
ServerType: TYPE = {ifs, tenex, unknown};
PListArray: TYPE = ARRAY STP.ValidProperties OF Rope.ROPE;
PList: TYPE = REF PListArray;
RemoteStreamState: TYPE = {initial, confirm, data, complete, end};
ValidProperties: TYPE = STP.ValidProperties;
FileProperties: TYPE = STP.ValidProperties[directory..author];
UserProperties: TYPE = STP.ValidProperties[userName..directory];
Procedures for doing FTP protocol operations
DoFiles:
PROCEDURE [
stp: Handle,
file: Rope.ROPE,
confirm: STP.ConfirmProcType,
complete: STP.CompletionProcType,
op: Operation];
GetCommand:
PROCEDURE [stp: Handle]
RETURNS[mark: [0..256), code: CHARACTER, ps: Rope.ROPE];
GetFile:
PROCEDURE [stp: Handle, stream:
IO.
STREAM, file: Rope.
ROPE]
RETURNS [BOOLEAN];
GetHereIsAndPList: PROCEDURE [stp: Handle, gobbleEOC: BOOLEAN ← TRUE];
GetPList:
PROCEDURE [stp: Handle, gobbleEOC:
BOOLEAN ←
TRUE,
propertiesOk: BOOL ← FALSE];
PutCommand:
PROCEDURE [stp: Handle, mark: [0..256),
code: CHARACTER, string: Rope.ROPE, sendEOC: BOOLEAN ← TRUE];
PutFile: PROCEDURE [stp: Handle, stream: IO.STREAM, file: Rope.ROPE, sendEOC: BOOLEAN ← TRUE];
PutPList: PROCEDURE [stp: Handle, mark: [0..256), sendEOC: BOOLEAN ← TRUE];
Utility routines
CollectString: PROCEDURE [stp: Handle] RETURNS[ Rope.ROPE ];
CollectCode: PROCEDURE [stp: Handle] RETURNS[code: CHARACTER];
CheckConnection: PROCEDURE [stp: Handle];
ErrorIfNextNotEOC: PROCEDURE [stp: Handle];
ErrorIfNextNotYes: PROCEDURE [stp: Handle];
FindFileType: PROCEDURE [stream: IO.STREAM] RETURNS[fileType: STP.Type];
GetServerType: PROCEDURE [server: Rope.ROPE] RETURNS [serverType: ServerType];
LookAtMark: PROCEDURE [stp: Handle] RETURNS [[0..256)];
MakeRemoteName:
PROCEDURE [plist: PList, type: FilenameType]
RETURNS[name: Rope.ROPE];
MyGetChar: PROCEDURE [stp: Handle] RETURNS [char: CHARACTER];
MyGetMark: PROCEDURE [stp: Handle] RETURNS [[0..256)];
MyPutString: PROCEDURE [byteStream: IO.STREAM, string: Rope.ROPE];
PropertyString:
PROCEDURE [prop: ValidProperties]
RETURNS [string: Rope.ROPE]; -- Global string
SelectError: PROCEDURE [stp: Handle, s: Rope.ROPE, mark: [0..256)];
SetByteSize: PROCEDURE [stp: Handle, fileType: STP.Type];
SetCreateTime: PROCEDURE [stp: Handle, creation: BasicTime.GMT];
SetFileType: PROCEDURE [stp: Handle, fileType: STP.Type];
SmashClosed: PROCEDURE [stp: Handle];
PList Utilities
DestroyPList: PROCEDURE [plist: PList] RETURNS [PList];
MakePList: PROCEDURE RETURNS[plist: PList];
NameToPList: PROCEDURE [plist: PList, name: Rope.ROPE, type: FilenameType];
PListToName:
PROCEDURE [plist: PList, type: FilenameType]
RETURNS[name: Rope.ROPE];
PutPListItem:
PROCEDURE [byteStream:
IO.
STREAM,
property: ValidProperties, value: Rope.ROPE];
ResetPList: PROCEDURE [plist: PList];
SetPListItem: PROCEDURE [plist: PList, property, value: Rope.ROPE];
UserStateToPList: PROCEDURE [stp: Handle];
Internal ERRORs and SIGNALs
BadProperty: ERROR;
MarkEncountered: ERROR;
ErrorCodeToSTPErrorCode:
PROCEDURE [errorCode:
STP.ErrorCode, code:
CHARACTER]
RETURNS[STP.ErrorCode];
GenerateErrorString:
PROCEDURE [
stp: Handle, errorCode: STP.ErrorCode, string: Rope.ROPE, code: CHARACTER ← 0C];
GenerateStreamClosingError: PROCEDURE [stp: Handle, why: PupStream.CloseReason];
GenerateProtocolError:
PROCEDURE [
stp: Handle, type: ProtocolError, mark: [0..256), code: CHARACTER ← 0C];
ProtocolError: TYPE = {badVersion, badMark, badPList, eocExpected, noCode};
Registered STP Mark Byte Commands
markRetrieve: [0..256) = 1B;
markStore: [0..256) = 2B;
markYes: [0..256) = 3B;
markNo: [0..256) = 4B;
markHereIsFile: [0..256) = 5B;
markEOC: [0..256) = 6B;
markComment: [0..256) = 7B;
markIAmVersion: [0..256) = 10B;
markNewStore: [0..256) = 11B;
markDirectory: [0..256) = 12B;
markHereIsPList: [0..256) = 13B;
markYouAreUser: [0..256) = 14B;
markNewDirectory: [0..256) = 14B; -- (notice: same as markYouAreUser)
markAbort: [0..256) = 15B;
markDelete: [0..256) = 16B;
markRename: [0..256) = 17B;
Registered Mail Mark Byte Commands
markStoreMail: [0..256) = 20B;
markRetrieveMail: [0..256) = 21B;
markFlushMailBox: [0..256) = 22B;
markMailBoxException: [0..256) = 23B;
END. -- end of STPOps