home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_05 / 2n05033a < prev    next >
Text File  |  1991-03-27  |  2KB  |  99 lines

  1. /*
  2.  *  File:    CDRom.C
  3.  *  Purpose:    Contains the CDROM Device Driver
  4.  *        specific commands
  5.  */
  6.  
  7. #include    "device.h"
  8.  
  9.  
  10. /*  External Functions  */
  11. int NetSend (FPTR buf, int size, BYTE session);
  12. int NetReceive (FPTR buf, int size, BYTE session);
  13.  
  14. /*  External Data  */
  15. extern    BYTE    localSession;
  16.  
  17.  
  18. /*
  19.  * ReadLong : Read CDROM sectors
  20.  *   Transfer the read request to the server.
  21.  *   Receive the update header and the data
  22.  *   into the dta.  Cooked mode (0) reads handle
  23.  *   2048 bytes per sector, raw mode (1) handle
  24.  *   2352.
  25.  */
  26. int ReadLong (RH_CDREAD far *rh)
  27. {
  28.     int    ret;
  29.  
  30.     /**  Send request to server  **/
  31.     ret = NetSend (rh, rh->rh.length,
  32.                localSession);
  33.  
  34.     /**  Get the header results back  **/
  35.     if (!ret)
  36.         ret = NetReceive (rh, rh->rh.length,
  37.                   localSession);
  38.     
  39.     /**  See if DTA read to come in  **/
  40.     if (!ret) {
  41.         if (rh->rh.status != 0x100)
  42.             /**  Read failed  **/
  43.             return rh->rh.status;
  44.         
  45.         /**  Okay to get data  **/
  46.         ret = NetReceive (rh->dta,
  47.             (2048+304*rh->readMode)*rh->count,
  48.             localSession);
  49.     }
  50.  
  51.     if (ret)
  52.         /**  An error occurred somewhere  **/
  53.         return DEV_ERROR | DEV_EREAD | DEV_DONE;
  54.     
  55.     else
  56.         return DEV_DONE;
  57. }
  58.  
  59. /*
  60.  * ReadPrefetch : Prefetch CDROM sectors
  61.  *   No read or data transfer is required.  This
  62.  *   command is advisory only.  Therefore, just
  63.  *   say it happened.
  64.  */
  65. int ReadPrefetch (RH_CDREAD far *rh)
  66. {
  67.     return DEV_DONE;
  68. }
  69.  
  70. /*
  71.  * Seek : Seek to CDROM sector
  72.  *   Mandatory seek to given sector.  Only
  73.  *   the request header must travel to and
  74.  *   from the server.
  75.  */
  76. int Seek (RH_CDSEEK far *rh)
  77. {
  78.     int    ret;
  79.  
  80.     /**  Send request to server  **/
  81.     ret = NetSend (rh, rh->rh.length,
  82.                localSession);
  83.  
  84.     /**  Get the header results back  **/
  85.     if (!ret)
  86.         ret = NetReceive (rh, rh->rh.length,
  87.                   localSession);
  88.     
  89.     if (ret)
  90.         /**  An error occurred somewhere  **/
  91.         return DEV_ERROR | DEV_EREAD | DEV_DONE;
  92.  
  93.     if (rh->rh.status != 0x100)
  94.         /**  Seek failed  **/
  95.         return rh->rh.status;
  96.     else
  97.         return DEV_DONE;
  98. }
  99.