-- File: STP.mesa Edited by:
-- Smokey,  6-Jul-81 17:58:25
-- Karlton,  9-Dec-81 18:11:47
-- Bruce, 10-Nov-81 16:15:44
-- Mark, 21-May-81 15:45:50
-- JGS,  14-Aug-81 16:50:01
-- Davirro, 27-Aug-82 15:40:22
-- Loretta, 14-Sep-82 15:10:46
-- Schmidt February 6, 1983 9:03 pm
-- Andrew Birrell June 1, 1983 2:45 pm

DIRECTORY
BasicTime USING [GMT],
IO USING [STREAM],
Rope USING[ROPE];

STP: CEDAR DEFINITIONS = {

-- Types and data

Handle: TYPE = REF Object;
Object: TYPE;

Access: TYPE = {read, write};
Completion: TYPE = {ok, error};
Continue: TYPE = {yes, no};
Confirmation: TYPE = {do, skip, abort};
ValidProperties: TYPE = {
userName, userPassword, connectName, connectPassword, directory, nameBody,
version, createDate, readDate, writeDate, byteSize, type, size, author,
eolConversion, account, userAccount, device, serverName};
DesiredProperties: TYPE = PACKED ARRAY ValidProperties OF BOOLALL[FALSE];
CompletionProcType: TYPE = PROC[what: Completion, fileOrError: Rope.ROPE];
ConfirmProcType: TYPE = PROC[file: Rope.ROPE] RETURNS [answer: Confirmation, localStream: IO.STREAM];
NoteFileProcType: TYPE = PROC [file: Rope.ROPE] RETURNS [continue: Continue];
FileInfo: TYPE = REF FileInfoObject;
FileInfoObject: TYPE = RECORD [
directory, body, version: Rope.ROPENIL,
author: Rope.ROPENIL,
create, read, write: Rope.ROPENIL,
size: INT ← 0,
type: Type ← unknown];
Type: TYPE = MACHINE DEPENDENT {unknown(0), text, binary};


-- Procedures

Create: PROC RETURNS [stp: Handle];
Open: PROC [stp: Handle, host: Rope.ROPE] RETURNS [herald: Rope.ROPE];
Close: PROC [stp: Handle];

-- set credentials
Login: PROC [stp: Handle, name, password: Rope.ROPE];
Connect: PROC [stp: Handle, name, password: Rope.ROPE];

-- set various properties
SetHost: PROC [stp: Handle, host: Rope.ROPE];
SetDirectory: PROC [stp: Handle, directory: Rope.ROPE];
SetDesiredProperties: PROC [stp: Handle, props: DesiredProperties];

-- query various properties
IsOpen: PROC [stp: Handle] RETURNS [yes: BOOL];
GetFileInfo: PROC [stp: Handle] RETURNS [FileInfo];
GetProperty: PROC [stp: Handle, prop: ValidProperties] RETURNS [Rope.ROPE];
GetDesiredProperties: PROC [stp: Handle] RETURNS [props: DesiredProperties];

-- retrieve, store, etc.
CreateRemoteStream: PROC [
stp: Handle,
file: Rope.ROPE,
access: Access,
fileType: Type ← unknown,
creation: BasicTime.GMTNULL -- use this default iff access = read -- ]
RETURNS[stream: IO.STREAM];
NextFileName: PROC [remoteStream: IO.STREAM] RETURNS [file: Rope.ROPE];
Delete: PROC [
stp: Handle,
name: Rope.ROPE,
confirm: ConfirmProcType ← NIL,
complete: CompletionProcType ← NIL];
Enumerate: PROC [stp: Handle, name: Rope.ROPE, proc: NoteFileProcType];
Rename: PROC [stp: Handle, old, new: Rope.ROPE];
Retrieve: PROC [
stp: Handle,
file: Rope.ROPE,
confirm: ConfirmProcType ← NIL,
complete: CompletionProcType ← NIL];
Store: PROC [
stp: Handle,
file: Rope.ROPE,
stream: IO.STREAM,
noteFile: NoteFileProcType ← NIL,
fileType: Type ← unknown,
creation: BasicTime.GMT];


-- Signals and Errors

Error: SIGNAL [ stp: Handle, code: ErrorCode, error: Rope.ROPE, reply: CHAR ← 0C];

ErrorCode: TYPE = {
-- connection errors
noSuchHost, noRouteToNetwork, noNameLookupResponse, alreadyAConnection,
noConnection, connectionClosed, connectionRejected,
connectionTimedOut,
-- credentials errors
accessDenied, illegalUserName, illegalUserPassword, illegalUserAccount,
illegalConnectName, illegalConnectPassword, credentailsMissing,
-- protocol errors
protocolError,
-- file errors
illegalFileName, noSuchFile, requestRefused,
-- remote stream errors
accessError,
-- catch all
undefinedError};

ConnectionErrors: TYPE = ErrorCode[noSuchHost..connectionTimedOut];
CredentialsErrors: TYPE = ErrorCode[accessDenied..credentailsMissing];
FileErrors: TYPE = ErrorCode[illegalFileName..requestRefused];

}. -- end of STP