| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- FOREIGN DEFINITION MODULE TermDevice;
- (* Procedures forming the interface to channels connected to
- the Terminal device. *)
- IMPORT IMPLEMENTATION FROM "TermDevice.obj";
- IMPORT ChanConsts;
- IMPORT IOConsts;
- IMPORT IOLink;
- FROM SYSTEM IMPORT ADDRESS;
- CONST
- (* Device Errors - implementation dependent *)
- InvalidChannel = -1; (* channel not connected to this device *)
- NoError = 0;
- MaxSoftDevErr = 18; (* soft device errors in range 1..18 *)
- MinHardDevErr = 19; (* hard device errors >= 19 *)
- TYPE
- OpenResults = ChanConsts.OpenResults;
- ReadResults = IOConsts.ReadResults;
- DeviceTablePtr = IOLink.DeviceTablePtr;
- ChanId = IOLink.ChanId;
- DeviceData = IOLink.DeviceData;
- DeviceErrNum = IOLink.DeviceErrNum;
- (* Text operations - these perform any required translation between
- the internal and external representation of text. *)
- PROCEDURE Look ( dtp : DeviceTablePtr;
- VAR ch : CHAR;
- VAR res : ReadResults);
- (* If there is a character as the next item in the given input stream,
- assigns its value to the parameter ch without removing it from the stream.
- Otherwise, the value of the parameter ch is not defined.
- The parameter res, and the stored read result, is set to the value
- allRight, endOfLine, or endOfInput. *)
- PROCEDURE Skip (dtp : DeviceTablePtr);
- (* If the input has ended, the exception skipAtEnd is raised,
- otherwise, the next character or line mark in the input is removed. *)
- PROCEDURE SkipLook ( dtp : DeviceTablePtr;
- VAR ch : CHAR;
- VAR res : ReadResults);
- (* If the stream has ended, the exception skipAtEnd is raised,
- otherwise, the next character or line mark is removed.
- If there is a character as the next item in the given input stream,
- assigned its value to the parameter ch without removing it from the stream.
- Otherwise, the value of the parameter ch is not defined.
- The parameter res, and the stored read result, is set to the value
- allRight, endOfLine or endOfInput. *)
- PROCEDURE TextRead ( dtp : DeviceTablePtr;
- to : ADDRESS;
- maxChars : CARDINAL;
- VAR charsRead : CARDINAL);
- (* Reads at most maxChars characters from the current line and assigns
- corresponding values to successive locations, starting at the address
- given by the parameter to, and continuing at increments corresponding
- to the address difference between successive components of an ARRAY OF
- CHAR. The number of characters read is assigned to the parameter
- charsRead. *)
- PROCEDURE TextWrite (dtp : DeviceTablePtr;
- from : ADDRESS;
- chars : CARDINAL);
- (* Writes a number of characters given by the value of the parameter chars,
- starting as the address given by the parameter from and continuing at
- increments corresponding to the address difference between successive
- components of an ARRAY OF CHAR. *)
- PROCEDURE WriteLn (dtp : DeviceTablePtr);
- (* Writes a line mark over the channel *)
- (* Binary operations *)
- PROCEDURE BinRead ( dtp : DeviceTablePtr;
- to : ADDRESS;
- maxLocs : CARDINAL;
- VAR locsRead : CARDINAL);
- (* Reads at most maxLocs items and assigns corresponding values to
- successive locations, starting at the address given by the parameter
- to.
- The number of items read is assigned to the parameter locsRead. *)
- PROCEDURE BinWrite (dtp : DeviceTablePtr;
- from : ADDRESS;
- locs : CARDINAL);
- (* Writes a number of items given by the value of the parameter locs from
- successive locations starting as the address given by the parameter
- from. *)
- (* Common operations *)
- PROCEDURE GetName ( dtp : DeviceTablePtr;
- VAR s : ARRAY OF CHAR);
- (* Copies to the parameter s a name associated with the channel,
- possibly truncated depending on the capacity of s. *)
- PROCEDURE Reset (dtp : DeviceTablePtr);
- (* Reset to a state defined by the device module *)
- PROCEDURE Flush (dtp : DeviceTablePtr);
- (* Flush any data buffered by the device module out to the destination *)
- (* Channel operations *)
- PROCEDURE OpenChannel ( dtp : DeviceTablePtr;
- VAR res : OpenResults);
- (* If a channel can be opened to the terminal, then the fields
- dtp^.cd and dtp^.errNum are initialized, and res is set to opened.
- Otherwise, the value of the parameter res indicates
- the reason for the failure. *)
- PROCEDURE Free (dtp : DeviceTablePtr);
- (* Carries out the operations involved in closing the
- corresponding channel, including flushing buffers, but do
- not unmake the channel. *)
- PROCEDURE LookKey ( dtp : DeviceTablePtr;
- VAR ok : BOOLEAN;
- VAR ch : CHAR;
- VAR res : ReadResults);
- (* Performs 'no-wait' input:
- If there is a character available on TermFile channel cid, return ok TRUE
- and the results of a Look(cid/dtp, ch, res);
- otherwise return ok FALSE. *)
- END TermDevice.
-
|