home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / aspio02.zip / devtype.c < prev    next >
C/C++ Source or Header  |  1999-08-17  |  2KB  |  84 lines

  1. /*
  2.  * $Source: r:/source/aspi/RCS/devtype.c,v $
  3.  * $Revision: 1.4 $
  4.  * $Date: 1999/08/18 00:13:41 $
  5.  * $Locker:  $
  6.  *
  7.  *    ASPI Interface Library, GET DEVICE TYPE
  8.  *
  9.  * $Log: devtype.c,v $
  10.  * Revision 1.4  1999/08/18 00:13:41  vitus
  11.  * - updated location of defines.h (moved)
  12.  * - changed function comments to new layout
  13.  *
  14.  * Revision 1.3  1997/09/22 02:25:37  vitus
  15.  * commented
  16.  *
  17.  * Revision 1.2  1997/09/18 01:58:51  vitus
  18.  * changed to new header file names
  19.  *
  20.  * Revision 1.1  1997/09/08 02:02:26  vitus
  21.  * Initial revision
  22.  * ----------------------------------------
  23.  * Sample code to demonstrate use of ASPI Interface.
  24.  */
  25. static char const id[]="$Id: devtype.c,v 1.4 1999/08/18 00:13:41 vitus Exp $";
  26.  
  27. #include <string.h>
  28.  
  29. #define INCL_DOS
  30. #include <os2.h>
  31.  
  32. #include "../lib/defines.h"
  33. #include "scsi.h"
  34. #include "srb.h"
  35. #include "aspio.h"
  36.  
  37.  
  38.  
  39.  
  40.  
  41. /*# ----------------------------------------------------------------------
  42.  * AspiGetType(ha,target,lun,type)
  43.  *
  44.  * PARAMETER
  45.  *    ha,target,lun    addresses device to query
  46.  *    type        return type here
  47.  *
  48.  * RETURNS
  49.  *    ASPIRET
  50.  *
  51.  * GLOBAL
  52.  *    (none)
  53.  *
  54.  * DESPRIPTION
  55.  *    Uses ASPI to query device type of ha,target,lun and
  56.  *    returns that type to caller.
  57.  *
  58.  * REMARKS
  59.  */
  60. PUBLIC APIRET _System
  61. AspiGetType(UCHAR ha,UCHAR target,UCHAR lun,PUCHAR type)
  62. {
  63.     APIRET        rc;
  64.     ASPI_SRB_DEVICE_TYPE srb;
  65.  
  66.     memset(&srb, 0, sizeof(srb));
  67.     srb.SRBHdr.CommandCode = ASPI_CMD_GET_DEVICE_TYPE;
  68.     srb.SRBHdr.AdapterIndex  = ha;
  69.     srb.SRBHdr.ASPIReqFlags = 0;        /* no flags set */
  70.     srb.DeviceTargetID = target;
  71.     srb.DeviceTargetLUN = lun;
  72.  
  73.     rc = AspiSendSRB(&srb.SRBHdr, sizeof(srb));
  74.  
  75.     if( rc == 0 )
  76.     {
  77.     if( srb.SRBHdr.ASPIStatus != ASPI_STATUS_NO_ERROR )
  78.         rc = 0xF0000000 | srb.SRBHdr.ASPIStatus;
  79.     else
  80.         *type = srb.DeviceType;
  81.     }
  82.     return rc;
  83. }
  84.