TERMFILE.DEF 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. DEFINITION MODULE TermFile;
  2. (* Channels opened by this module are connected to a single terminal
  3. device; typed characters are distributed between channels according
  4. to the sequence of read requests. *)
  5. IMPORT IOLink;
  6. IMPORT ChanConsts;
  7. FROM ChanConsts IMPORT ChanFlags;
  8. TYPE
  9. ChanId = IOLink.ChanId;
  10. FlagSet = ChanConsts.FlagSet;
  11. OpenResults = ChanConsts.OpenResults;
  12. (* Accept singleton values of FlagSet *)
  13. CONST
  14. read = FlagSet{readFlag};
  15. (* input operations are requested/available *)
  16. write = FlagSet{writeFlag};
  17. (* output operations are requested/available *)
  18. text = FlagSet{textFlag};
  19. (* text operations are requested/available *)
  20. raw = FlagSet{rawFlag};
  21. (* raw operations are requested/available *)
  22. echo = FlagSet{echoFlag};
  23. (* echoing by interactive device on reading of characters from
  24. input stream requested/applies *)
  25. (* In line mode, items are echoed before being added to the input stream
  26. and are added a line at a time.
  27. In single character mode, items are added to the input stream one at a
  28. time and are echoed as they are removed from the input stream by a
  29. read operation *)
  30. PROCEDURE Open (VAR cid : ChanId;
  31. flags : FlagSet;
  32. VAR res : OpenResults);
  33. (* Without the binary flag, text is implied.
  34. Without the echo flag, line mode is requested, otherwise single character
  35. mode is requested.
  36. If successful, assigns to the parameter cid the identity of a channel
  37. open to the terminal and assigns the value, opened to the parameter res.
  38. Otherwise, the value of the parameter res indicates the reason for failure
  39. and cid identifies the bad channel. *)
  40. PROCEDURE IsTermFile (cid : ChanId) : BOOLEAN;
  41. (* Tests if the channel is open to the terminal *)
  42. PROCEDURE Close (VAR cid : ChanId);
  43. (* If the channel is not open to the terminal, the exception
  44. wrongDevice is raised. Otherwise, the channel is closed and the value
  45. identifying the bad channel is assigned to the parameter cid. *)
  46. END TermFile.