home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 13 / MA_Cover_13.bin / source / c / stefanb_src / private_projects / yath / io.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-06  |  897 b   |  46 lines

  1. #include "io.h"
  2.  
  3. BYTE OpenSCSIchan(struct scsichan *ch)
  4. {
  5.  if (!ch) return(1);
  6.  if (ch->iop || ch->ior) return(2);
  7.  
  8.  if (!(ch->iop=CreateMsgPort())) return(3);
  9.  
  10.  if (!(ch->ior=CreateIORequest(ch->iop,sizeof(struct IOStdReq))))
  11.   {
  12.    DeleteMsgPort(ch->iop);
  13.    ch->iop=NULL;
  14.    return(4);
  15.   }
  16.  
  17.  return(OpenDevice(ch->name,ch->unit,ch->ior,ch->flags));
  18. }
  19.  
  20. BYTE DoSCSIcmd(struct scsichan *ch, struct SCSICmd *cmd)
  21. {
  22.  if (!ch) return(1);
  23.  if (!ch->iop) return(2);
  24.  if (!ch->ior) return(3);
  25.  if (!cmd) return(4);
  26.  ch->ior->io_Command=HD_SCSICMD;
  27.  ch->ior->io_Data=(APTR) cmd;
  28.  ch->ior->io_Length=sizeof(struct SCSICmd);
  29.  DoIO(ch->ior);
  30.  
  31.  return(cmd->scsi_Status);
  32. }
  33.  
  34. BYTE CloseSCSIchan(struct scsichan *ch)
  35. {
  36.  if (!ch) return(1);
  37.  if (!ch->iop) return(2);
  38.  if (!ch->ior) return(3);
  39.  CloseDevice(ch->ior);
  40.  DeleteIORequest(ch->ior);
  41.  ch->ior=NULL;
  42.  DeleteMsgPort(ch->iop);
  43.  ch->iop=NULL;
  44.  return(0);
  45. }
  46.