TERMDEVI.DEF 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. FOREIGN DEFINITION MODULE TermDevice;
  2. (* Procedures forming the interface to channels connected to
  3. the Terminal device. *)
  4. IMPORT IMPLEMENTATION FROM "TermDevice.obj";
  5. IMPORT ChanConsts;
  6. IMPORT IOConsts;
  7. IMPORT IOLink;
  8. FROM SYSTEM IMPORT ADDRESS;
  9. CONST
  10. (* Device Errors - implementation dependent *)
  11. InvalidChannel = -1; (* channel not connected to this device *)
  12. NoError = 0;
  13. MaxSoftDevErr = 18; (* soft device errors in range 1..18 *)
  14. MinHardDevErr = 19; (* hard device errors >= 19 *)
  15. TYPE
  16. OpenResults = ChanConsts.OpenResults;
  17. ReadResults = IOConsts.ReadResults;
  18. DeviceTablePtr = IOLink.DeviceTablePtr;
  19. ChanId = IOLink.ChanId;
  20. DeviceData = IOLink.DeviceData;
  21. DeviceErrNum = IOLink.DeviceErrNum;
  22. (* Text operations - these perform any required translation between
  23. the internal and external representation of text. *)
  24. PROCEDURE Look ( dtp : DeviceTablePtr;
  25. VAR ch : CHAR;
  26. VAR res : ReadResults);
  27. (* If there is a character as the next item in the given input stream,
  28. assigns its value to the parameter ch without removing it from the stream.
  29. Otherwise, the value of the parameter ch is not defined.
  30. The parameter res, and the stored read result, is set to the value
  31. allRight, endOfLine, or endOfInput. *)
  32. PROCEDURE Skip (dtp : DeviceTablePtr);
  33. (* If the input has ended, the exception skipAtEnd is raised,
  34. otherwise, the next character or line mark in the input is removed. *)
  35. PROCEDURE SkipLook ( dtp : DeviceTablePtr;
  36. VAR ch : CHAR;
  37. VAR res : ReadResults);
  38. (* If the stream has ended, the exception skipAtEnd is raised,
  39. otherwise, the next character or line mark is removed.
  40. If there is a character as the next item in the given input stream,
  41. assigned its value to the parameter ch without removing it from the stream.
  42. Otherwise, the value of the parameter ch is not defined.
  43. The parameter res, and the stored read result, is set to the value
  44. allRight, endOfLine or endOfInput. *)
  45. PROCEDURE TextRead ( dtp : DeviceTablePtr;
  46. to : ADDRESS;
  47. maxChars : CARDINAL;
  48. VAR charsRead : CARDINAL);
  49. (* Reads at most maxChars characters from the current line and assigns
  50. corresponding values to successive locations, starting at the address
  51. given by the parameter to, and continuing at increments corresponding
  52. to the address difference between successive components of an ARRAY OF
  53. CHAR. The number of characters read is assigned to the parameter
  54. charsRead. *)
  55. PROCEDURE TextWrite (dtp : DeviceTablePtr;
  56. from : ADDRESS;
  57. chars : CARDINAL);
  58. (* Writes a number of characters given by the value of the parameter chars,
  59. starting as the address given by the parameter from and continuing at
  60. increments corresponding to the address difference between successive
  61. components of an ARRAY OF CHAR. *)
  62. PROCEDURE WriteLn (dtp : DeviceTablePtr);
  63. (* Writes a line mark over the channel *)
  64. (* Binary operations *)
  65. PROCEDURE BinRead ( dtp : DeviceTablePtr;
  66. to : ADDRESS;
  67. maxLocs : CARDINAL;
  68. VAR locsRead : CARDINAL);
  69. (* Reads at most maxLocs items and assigns corresponding values to
  70. successive locations, starting at the address given by the parameter
  71. to.
  72. The number of items read is assigned to the parameter locsRead. *)
  73. PROCEDURE BinWrite (dtp : DeviceTablePtr;
  74. from : ADDRESS;
  75. locs : CARDINAL);
  76. (* Writes a number of items given by the value of the parameter locs from
  77. successive locations starting as the address given by the parameter
  78. from. *)
  79. (* Common operations *)
  80. PROCEDURE GetName ( dtp : DeviceTablePtr;
  81. VAR s : ARRAY OF CHAR);
  82. (* Copies to the parameter s a name associated with the channel,
  83. possibly truncated depending on the capacity of s. *)
  84. PROCEDURE Reset (dtp : DeviceTablePtr);
  85. (* Reset to a state defined by the device module *)
  86. PROCEDURE Flush (dtp : DeviceTablePtr);
  87. (* Flush any data buffered by the device module out to the destination *)
  88. (* Channel operations *)
  89. PROCEDURE OpenChannel ( dtp : DeviceTablePtr;
  90. VAR res : OpenResults);
  91. (* If a channel can be opened to the terminal, then the fields
  92. dtp^.cd and dtp^.errNum are initialized, and res is set to opened.
  93. Otherwise, the value of the parameter res indicates
  94. the reason for the failure. *)
  95. PROCEDURE Free (dtp : DeviceTablePtr);
  96. (* Carries out the operations involved in closing the
  97. corresponding channel, including flushing buffers, but do
  98. not unmake the channel. *)
  99. PROCEDURE LookKey ( dtp : DeviceTablePtr;
  100. VAR ok : BOOLEAN;
  101. VAR ch : CHAR;
  102. VAR res : ReadResults);
  103. (* Performs 'no-wait' input:
  104. If there is a character available on TermFile channel cid, return ok TRUE
  105. and the results of a Look(cid/dtp, ch, res);
  106. otherwise return ok FALSE. *)
  107. END TermDevice.