ARGDEVIC.DEF 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. DEFINITION MODULE ArgDevice;
  2. (* Procedures forming the interface to channels connected to
  3. the standard program argument device. *)
  4. FROM IOConsts IMPORT ReadResults;
  5. IMPORT IOLink;
  6. FROM SYSTEM IMPORT ADDRESS;
  7. CONST
  8. (* Identifier of the standard argument channel *)
  9. StdArg = -3;
  10. (* Device Errors *)
  11. NoError = 0;
  12. TYPE
  13. DeviceTablePtr = IOLink.DeviceTablePtr;
  14. DeviceData = IOLink.DeviceData;
  15. (* Text operations - these perform any required translation between
  16. the internal and external representation of text. *)
  17. PROCEDURE Look ( dtp : DeviceTablePtr;
  18. VAR ch : CHAR;
  19. VAR res : ReadResults);
  20. (* If there is a character as the next item in the given input stream,
  21. assigns its value to the parameter ch without removing it from the stream.
  22. Otherwise, the value of the parameter ch is not defined.
  23. The parameter res, and the stored read result, is set to the value
  24. allRight, endOfLine, or endOfInput. *)
  25. PROCEDURE Skip (dtp : DeviceTablePtr);
  26. (* If the input has ended, the exception skipAtEnd is raised,
  27. otherwise, the next character or line mark in the input is removed
  28. and the stored read result is set to the value allRight. *)
  29. PROCEDURE SkipLook ( dtp : DeviceTablePtr;
  30. VAR ch : CHAR;
  31. VAR res : ReadResults);
  32. (* If the stream has ended, the exception skipAtEnd is raised,
  33. otherwise, the next character or line mark is removed.
  34. If there is a character as the next item in the given input stream,
  35. assigned its value to the parameter ch without removing it from the stream.
  36. Otherwise, the value of the parameter ch is not defined.
  37. The parameter res, and the stored read result, is set to the value
  38. allRight, endOfLine or endOfInput. *)
  39. PROCEDURE TextRead ( dtp : DeviceTablePtr;
  40. to : ADDRESS;
  41. maxChars : CARDINAL;
  42. VAR charsRead : CARDINAL);
  43. (* Reads at most maxChars characters from the current line and assigns
  44. corresponding values to successive locations, starting at the address
  45. given by the parameter to, and continuing at increments corresponding
  46. to the address difference between successive components of an ARRAY OF
  47. CHAR. The number of characters read is assigned to the parameter charsRead.
  48. The read result is set to the value allRight, endOfLine, or endOfInput. *)
  49. PROCEDURE TextWrite (dtp : DeviceTablePtr;
  50. from : ADDRESS;
  51. chars : CARDINAL);
  52. (* Writes a number of characters given by the value of the parameter chars,
  53. starting as the address given by the parameter from and continuing at
  54. increments corresponding to the address difference between successive
  55. components of an ARRAY OF CHAR. *)
  56. PROCEDURE WriteLn (dtp : DeviceTablePtr);
  57. (* Writes a line mark over the channel *)
  58. (* Binary operations *)
  59. PROCEDURE RawRead ( dtp : DeviceTablePtr;
  60. to : ADDRESS;
  61. maxLocs : CARDINAL;
  62. VAR locsRead : CARDINAL);
  63. (* Reads at most maxLocs items and assigns corresponding values to
  64. successive locations, starting at the address given by the parameter
  65. to.
  66. The number of items read is assigned to the parameter locsRead.
  67. The read result is set to the value allRight or endOfInput. *)
  68. PROCEDURE RawWrite (dtp : DeviceTablePtr;
  69. from : ADDRESS;
  70. locs : CARDINAL);
  71. (* Writes a number of items given by the value of the parameter locs from
  72. successive locations starting as the address given by the parameter
  73. from. *)
  74. (* Common operations *)
  75. PROCEDURE GetName ( dtp : DeviceTablePtr;
  76. VAR s : ARRAY OF CHAR);
  77. (* Copies to the parameter s a name associated with the channel,
  78. possibly truncated depending on the capacity of s. *)
  79. PROCEDURE Reset (dtp : DeviceTablePtr);
  80. (* Reset to a state defined by the device module *)
  81. PROCEDURE Flush (dtp : DeviceTablePtr);
  82. (* Flush any data buffered by the device module out to the destination *)
  83. PROCEDURE Free (dtp : DeviceTablePtr);
  84. (* Carries out the operations involved in closing the
  85. corresponding channel, including flushing buffers, but do
  86. not unmake the channel. *)
  87. PROCEDURE MakeArgChanDeviceData () : DeviceData;
  88. (* Returns the device data to be held for the standard
  89. argument channel *)
  90. END ArgDevice.