XCommunications.mesa
Copyright Ó 1988, 1989, 1991 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, July 29, 1988 2:30:53 pm PDT
Christian Jacobi, February 17, 1989 1:16:23 pm PST
DIRECTORY
IO USING [STREAM, UnsafeBlock],
Rope USING [ROPE];
XCommunications: CEDAR DEFINITIONS
Module name means both
--communication base for X
--or
--inter application shared communication base
~ BEGIN
Error: ERROR [what: Rope.ROPE];
ProtocolData: TYPE = RECORD [
create: PROC [base: Rope.ROPE, port: REF ANY] RETURNS [StreamData] ¬ NIL,
protocol: ATOM ¬ NIL,
success: BOOL ¬ FALSE
];
StreamData: TYPE = RECORD [
in, out: IO.STREAM ¬ NIL,
putChar: PROC [self: IO.STREAM, char: CHAR] ¬ NIL, -- IO.PutChar,
unsafePutBlock: PROC [self: IO.STREAM, block: IO.UnsafeBlock] ¬ NIL, -- IO.UnsafePutBlock,
getChar: PROC [self: IO.STREAM] RETURNS [CHAR] ¬ NIL, -- IO.GetChar,
sendNow: PROC [self: IO.STREAM] ¬ NIL, -- IO.Flush,
--May be a faster proc which guarantees delivery soon but without waiting
errorFromStream: PROC [self: IO.STREAM] RETURNS [Rope.ROPE] ¬ NIL,
--In case IO.Failure was raised
errorMsg: Rope.ROPE ¬ NIL,
success: BOOL ¬ FALSE
];
ScannedName: TYPE = RECORD [
protocol: Rope.ROPE,
server: Rope.ROPE,
specific: Rope.ROPE --interpretation depends on both, protocol and application
];
ScanName: PROC [name: Rope.ROPE] RETURNS [ScannedName];
Scans a name into parts; the name is supposed to have the right syntax.
Error is raised if name syntactically wrong.
GetProtocol: PROC [protocol: Rope.ROPE ¬ NIL, defaultProtocol: ATOM ¬ NIL] RETURNS [ProtocolData];
Find communication protocol to be used.
defaultProtocol used if protocol is empty
Does not raise errors
ScanSpecific: PROC [application: ATOM, protocol: ATOM, scannedName: ScannedName] RETURNS [base: Rope.ROPE, port: REF ANY];
Scans scanned name into necessary create parameters.
The scan proc may ignore the protocol field of scannedName.
Error is raised if application/protocol not registered
CreateStreams: PROC [application: ATOM, name: Rope.ROPE, defaultProtocol: ATOM ¬ NIL] RETURNS [StreamData];
The doit all procedure for simple applications.
Returns streams or error message on failure; err=NIL means success
Does not raise errors
RegisterCommunication: PROC [protocolData: ProtocolData];
To be called by implementor of communication protocols.
The create proc may assume that its caller will also call FinishStreamData.
ScanProcType: TYPE = PROC [application: ATOM, protocol: ATOM, scannedName: ScannedName] RETURNS [base: Rope.ROPE, port: REF ANY];
RegisterScanSpecific: PROC [application: ATOM, protocol: ATOM, scan: ScanProcType];
To be called by implementor of application programs, once per supported protocol.
The scan proc may ignore the protocol field of scannedName.
FinishStreamData: PROC [sd: StreamData] RETURNS [StreamData];
Fills in defaulted fields into StreamData record
END.