home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xco212p.zip / ISODEF / iolink.def < prev    next >
Text File  |  1994-12-22  |  5KB  |  116 lines

  1. DEFINITION MODULE IOLink;
  2.  
  3.   (* Types and procedures for the standard implementation of channels *)
  4.  
  5. IMPORT IOChan, IOConsts, ChanConsts, SYSTEM;
  6.  
  7. TYPE
  8.   DeviceId;
  9.     (* Values of this type are used to identify new device modules, and are normally
  10.        obtained by them during their initialization.
  11.     *)
  12.  
  13. PROCEDURE AllocateDeviceId (VAR did: DeviceId);
  14.   (* Allocates a unique value of type DeviceId, and assigns this value to did. *)
  15.  
  16. PROCEDURE MakeChan (did: DeviceId; VAR cid: IOChan.ChanId);
  17.   (* Attempts to make a new channel for the device module identified by did. If no more
  18.      channels can be made, the identity of the invalid channel is assigned to cid.
  19.      Otherwise, the identity of a new channel is assigned to cid.
  20.   *)
  21.  
  22. PROCEDURE UnMakeChan (did: DeviceId; VAR cid: IOChan.ChanId);
  23.   (* If the device module identified by did is not the module that made the channel
  24.      identified by cid, the exception wrongDevice is raised; otherwise the channel is
  25.      deallocated, and the value identifying the invalid channel is assigned to cid.
  26.   *)
  27.  
  28. TYPE
  29.   DeviceTablePtr = POINTER TO DeviceTable;
  30.     (* Values of this type are used to refer to device tables *)
  31.  
  32. TYPE
  33.   LookProc =      PROCEDURE (DeviceTablePtr, VAR CHAR, VAR IOConsts.ReadResults);
  34.   SkipProc =      PROCEDURE (DeviceTablePtr);
  35.   SkipLookProc =  PROCEDURE (DeviceTablePtr, VAR CHAR, VAR IOConsts.ReadResults);
  36.   WriteLnProc =   PROCEDURE (DeviceTablePtr);
  37.   TextReadProc =  PROCEDURE (DeviceTablePtr, SYSTEM.ADDRESS, CARDINAL, VAR CARDINAL);
  38.   TextWriteProc = PROCEDURE (DeviceTablePtr, SYSTEM.ADDRESS, CARDINAL);
  39.   RawReadProc =   PROCEDURE (DeviceTablePtr, SYSTEM.ADDRESS, CARDINAL, VAR CARDINAL);
  40.   RawWriteProc =  PROCEDURE (DeviceTablePtr, SYSTEM.ADDRESS, CARDINAL);
  41.   GetNameProc =   PROCEDURE (DeviceTablePtr, VAR ARRAY OF CHAR);
  42.   ResetProc =     PROCEDURE (DeviceTablePtr);
  43.   FlushProc =     PROCEDURE (DeviceTablePtr);
  44.   FreeProc =      PROCEDURE (DeviceTablePtr);
  45.       (* Carry out the operations involved in closing the corresponding channel, including
  46.          flushing buffers, but do not unmake the channel.
  47.       *)
  48.  
  49. TYPE
  50.   DeviceData = SYSTEM.ADDRESS;
  51.  
  52.   DeviceTable =
  53.     RECORD                         (* Initialized by MakeChan to: *)
  54.       cd: DeviceData;              (* the value NIL *)
  55.       did: DeviceId;               (* the value given in the call of MakeChan *)
  56.       cid: IOChan.ChanId;          (* the identity of the channel *)
  57.       result: IOConsts.ReadResults;(* the value notKnown *)
  58.       errNum: IOChan.DeviceErrNum; (* undefined *)
  59.       flags: ChanConsts.FlagSet;   (* ChanConsts.FlagSet{} *)
  60.       doLook: LookProc;            (* raise exception notAvailable *)
  61.       doSkip: SkipProc;            (* raise exception notAvailable *)
  62.       doSkipLook: SkipLookProc;    (* raise exception notAvailable *)
  63.       doLnWrite: WriteLnProc;      (* raise exception notAvailable *)
  64.       doTextRead: TextReadProc;    (* raise exception notAvailable *)
  65.       doTextWrite: TextWriteProc;  (* raise exception notAvailable *)
  66.       doRawRead: RawReadProc;      (* raise exception notAvailable *)
  67.       doRawWrite: RawWriteProc;    (* raise exception notAvailable *)
  68.       doGetName: GetNameProc;      (* return the empty string *)
  69.       doReset: ResetProc;          (* do nothing *)
  70.       doFlush: FlushProc;          (* do nothing *)
  71.       doFree: FreeProc;            (* do nothing *)
  72.     END;
  73.  
  74.  
  75.   (* The pointer to the device table for a channel is obtained using the
  76.      following procedure: *)
  77.  
  78. TYPE
  79.   DevExceptionRange = [IOChan.notAvailable ..  IOChan.textParseError];
  80.  
  81. PROCEDURE DeviceTablePtrValue (cid: IOChan.ChanId; did: DeviceId;
  82.                                x: DevExceptionRange; s:  ARRAY OF CHAR): DeviceTablePtr;
  83.   (* If the device module identified by did is not the module that made the channel 
  84.      identified by cid, the exception wrongDevice is raised; otherwise the given exception
  85.      is raised, and the string value in s is included in the exception message.
  86.   *)
  87.  
  88.  
  89. PROCEDURE IsDevice (cid: IOChan.ChanId; did: DeviceId) : BOOLEAN;
  90.   (* Tests if the device module identified by did is the module that made the channel
  91.      identified by cid.
  92.   *)
  93.  
  94.  
  95. PROCEDURE RAISEdevException (cid: IOChan.ChanId; did: DeviceId;
  96.                              x: DevExceptionRange; s: ARRAY OF CHAR);
  97.  
  98.   (* If the device module identified by did is not the module that made the channel
  99.      identified by cid, the exception wrongDevice is raised; otherwise the given exception
  100.      is raised, and the string value in s is included in the exception message.
  101.   *)
  102.  
  103. PROCEDURE IsIOException () : BOOLEAN;
  104.   (* Returns TRUE if the current coroutine is in the exceptional execution state
  105.      because of the raising af an exception from ChanExceptions;
  106.      otherwise FALSE.
  107.   *)
  108.  
  109. PROCEDURE IOException () : IOChan.ChanExceptions;
  110.   (* If the current coroutine is in the exceptional execution state because of the 
  111.      raising af an exception from ChanExceptions, returns the corresponding
  112.      enumeration value, and otherwise raises an exception.
  113.   *)
  114.  
  115. END IOLink.
  116.