home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / modu1096.zip / GPMsym / stddevice.def < prev    next >
Text File  |  1996-08-29  |  7KB  |  197 lines

  1. FOREIGN DEFINITION MODULE StdDevice;
  2.   IMPORT IMPLEMENTATION FROM "stddevice.o";
  3.  
  4. (* Procedures forming the interface to channels connected
  5.    to the Standard device. *)
  6.  
  7.  
  8. IMPORT IOConsts, ChanConsts, SYSTEM;
  9. FROM IOChan   IMPORT ChanId;
  10. FROM IOLink   IMPORT DeviceData, DeviceTablePtr;
  11. FROM RndFile  IMPORT FilePos;
  12.  
  13.  
  14. CONST
  15.   (* Device Errors - implementation dependent *)
  16.   InvalidChannel = -1;    (* channel not connected to this device *)
  17.   NoError        =  0;
  18.   MaxSoftDevErr  = 18;    (* soft device errors in range 1..18 *)
  19.   MinHardDevErr  = 19;    (* hard device errors >= 19 *)
  20.  
  21.  
  22.   (* Codes for the Standard Channels connected to the StdDevice *)
  23.   
  24.   StdBad  = -2;
  25.   StdNull = -1;
  26.   StdIn   =  0;
  27.   StdOut  =  1;
  28.   StdErr  =  2;
  29.  
  30.  
  31. TYPE
  32.   StdChanCode  = [StdBad..StdErr];
  33.   OpenResults  = ChanConsts.OpenResults;
  34.   ReadResults  = IOConsts.ReadResults;
  35.  
  36.   OpenMode  = (ReadOnly,     WriteOnly,     ReadWrite,     Append,     Update,
  37.            ReadOnlyText, WriteOnlyText, ReadWriteText, AppendText, UpdateText);
  38.  
  39.  
  40. (* Text operations - these perform any required translation between
  41.    the internal and external representation of text. *)
  42.  
  43. PROCEDURE Look (    dtp : DeviceTablePtr;
  44.                 VAR ch  : CHAR;
  45.                 VAR res : ReadResults);
  46. (* If there is a character as the next item in the given input stream,
  47.    assigns its value to the parameter ch without removing it from the stream.
  48.    Otherwise, the value of the parameter ch is not defined.
  49.    The parameter res, and the stored read result, is set to the value
  50.    allRight, endOfLine, or endOfInput. *)
  51.  
  52.  
  53. PROCEDURE Skip (dtp : DeviceTablePtr);
  54. (* If the input has ended, the exception skipAtEnd is raised,
  55.    otherwise, the next character or line mark in the input is removed. *)
  56.  
  57.  
  58. PROCEDURE SkipLook (    dtp : DeviceTablePtr;
  59.                     VAR ch  : CHAR;
  60.                     VAR res : ReadResults);
  61. (* If the stream has ended, the exception skipAtEnd is raised,
  62.    otherwise, the next character or line mark is removed.
  63.    If there is a character as the next item in the given input stream,
  64.    assigned its value to the parameter ch without removing it from the stream.
  65.    Otherwise, the value of the parameter ch is not defined.
  66.    The parameter res, and the stored read result, is set to the value
  67.    allRight, endOfLine or endOfInput. *)
  68.  
  69.  
  70. PROCEDURE TextRead (    dtp      : DeviceTablePtr;
  71.                         to       : SYSTEM.ADDRESS;
  72.                         maxChars : CARDINAL;
  73.                     VAR charsRead : CARDINAL);
  74. (* Reads at most maxChars characters from the current line and assigns
  75.    corresponding values to successive locations, starting at the address
  76.    given by the parameter to, and continuing at increments corresponding
  77.    to the address difference between successive components of an ARRAY OF
  78.    CHAR. The number of characters read is assigned to the parameter
  79.    charsRead. *)
  80.  
  81.  
  82. PROCEDURE TextWrite (dtp   : DeviceTablePtr;
  83.                      from  : SYSTEM.ADDRESS;
  84.                      chars : CARDINAL);
  85. (* Writes a number of characters given by the value of the parameter chars,
  86.    starting as the address given by the parameter from and continuing at
  87.    increments corresponding to the address difference between successive
  88.    components of an ARRAY OF CHAR. *)
  89.  
  90.  
  91. PROCEDURE WriteLn (dtp : DeviceTablePtr);
  92. (* Writes a line mark over the channel *)
  93.  
  94.  
  95.  
  96. (* Binary operations *)
  97.  
  98. PROCEDURE BinRead (    dtp      : DeviceTablePtr;
  99.                        to       : SYSTEM.ADDRESS;
  100.                        maxLocs  : CARDINAL;
  101.                    VAR locsRead : CARDINAL);
  102. (* Reads at most maxLocs items and assigns corresponding values to
  103.    successive locations, starting at the address given by the parameter to.
  104.    The number of items read is assigned to the parameter locsRead. *)
  105.  
  106.  
  107. PROCEDURE BinWrite (dtp  : DeviceTablePtr;
  108.                     from : SYSTEM.ADDRESS;
  109.                     locs : CARDINAL);
  110. (* Writes a number of items given by the value of the parameter locs from
  111.    successive locations starting as the address given by the parameter
  112.    from. *)
  113.  
  114.  
  115.  
  116. (* Common operations *)
  117.  
  118. PROCEDURE GetName (    dtp : DeviceTablePtr;
  119.                    VAR s   : ARRAY OF CHAR);
  120. (* Copies to the parameter s a name associated with the channel,
  121.    possibly truncated depending on the capacity of s. *)
  122.  
  123.  
  124. PROCEDURE Reset (dtp : DeviceTablePtr);
  125. (* Reset to a state defined by the device module *)
  126.  
  127.  
  128. PROCEDURE Flush (dtp : DeviceTablePtr);
  129. (* Flush any data buffered by the device module out to the destination *)
  130.  
  131.  
  132. PROCEDURE Free (dtp : DeviceTablePtr);
  133. (* Carries out the operations involved in closing the
  134.    corresponding channel, including flushing buffers, but do
  135.    not unmake the channel. *)
  136.  
  137.  
  138.  
  139. (* Channel operations *)
  140.  
  141. PROCEDURE MakeStdChanDeviceData (chanCode : StdChanCode) : DeviceData;
  142. (* Returns the device data to be held for all standard
  143.    channels connected to the StdDevice. *)
  144.  
  145.  
  146. PROCEDURE OpenChannel (    dtp     : DeviceTablePtr;
  147.                            oldFile : ARRAY OF CHAR;
  148.                            mode    : OpenMode;
  149.                        VAR res     : OpenResults);
  150. (* If a channel can be opened to the existing oldFile on the
  151.    standard device, then creates dtp with the fields cd and errNum
  152.    initialized, and res is set to opened.
  153.    Otherwise, the value of the parameter res indicates
  154.    the reason for the failure. *)
  155.  
  156.  
  157. PROCEDURE CreateChannel (    dtp     : DeviceTablePtr;
  158.                              newFile : ARRAY OF CHAR;
  159.                              mode    : OpenMode;
  160.                          VAR res     : OpenResults);
  161. (* If a channel can be opened to the newFile on the
  162.    standard device, then creates dtp with the fields cd and errNum
  163.    initialized, and res is set to opened.
  164.    Otherwise, the value of the parameter res indicates
  165.    the reason for the failure. *)
  166.  
  167.  
  168. PROCEDURE Delete (    name : ARRAY OF CHAR;
  169.                   VAR done : BOOLEAN);
  170. (* If done, the file called name has been deleted. *)
  171.  
  172.  
  173. PROCEDURE SetPos (cd  : DeviceData;
  174.                   pos : FilePos);
  175. (* Sets the read/write position to the value given by the parameter pos. *)
  176.  
  177.  
  178. PROCEDURE GetPos (cd : DeviceData) : FilePos;
  179. (* Returns the current read/write position *)
  180.  
  181.  
  182. PROCEDURE StartPos (cd : DeviceData) : FilePos;
  183. (* Returns the first position of the file *)
  184.  
  185.  
  186. PROCEDURE EndPos (cd : DeviceData) : FilePos;
  187. (* Returns the first position at or after which there have been no writes *)
  188.  
  189.  
  190. PROCEDURE FileExists (fileName : ARRAY OF CHAR) : BOOLEAN;
  191. (* Does the file exist? *)
  192.  
  193. PROCEDURE FileMode (cd : DeviceData) : OpenMode;
  194. (* Returns the mode file was opened/created with *)
  195.  
  196. END StdDevice.
  197.