STREAMFI.DEF 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. DEFINITION MODULE StreamFile;
  2. (* Independent sequential data streams *)
  3. IMPORT IOLink;
  4. IMPORT ChanConsts;
  5. FROM ChanConsts IMPORT ChanFlags;
  6. TYPE
  7. ChanId = IOLink.ChanId;
  8. FlagSet = ChanConsts.FlagSet;
  9. OpenResults = ChanConsts.OpenResults;
  10. (* Accept singleton values of FlagSet *)
  11. CONST
  12. read = FlagSet{readFlag};
  13. (* input operations are requested/available *)
  14. write = FlagSet{writeFlag};
  15. (* output operations are requested/available *)
  16. old = FlagSet{oldFlag};
  17. (* a file may/must/did exist before the channel
  18. was opened *)
  19. text = FlagSet{textFlag};
  20. (* text operations are requested/available *)
  21. raw = FlagSet{rawFlag};
  22. (* raw operations are requested/available *)
  23. PROCEDURE Open (VAR cid : ChanId;
  24. name : ARRAY OF CHAR;
  25. flags : FlagSet;
  26. VAR res : OpenResults);
  27. (* The read flag implies old;
  28. without the binary flag, text is implied.
  29. If successful, assigns to the parameter cid the identity of a channel
  30. open to a source/destination of the given name and assigns the value
  31. opened to the parameter res.
  32. If a channel cannot be opened as required, the value of the parameter
  33. res indicates the reason and cid identifies the bad channel. *)
  34. PROCEDURE IsStreamFile (cid : ChanId) : BOOLEAN;
  35. (* Tests if the channel is open to a sequential stream *)
  36. PROCEDURE Close (VAR cid : ChanId);
  37. (* If the channel is not open to a sequential stream, the exception
  38. wrongDevice is raised. Otherwise, the channel is closed and the value
  39. identifying the bad channel is assigned to the parameter cid. *)
  40. END StreamFile.