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

  1. /*
  2.  * $Source: r:/source/aspi/RCS/aspiscan.c,v $
  3.  * $Revision: 1.4 $
  4.  * $Date: 1999/08/18 00:11:47 $
  5.  * $Locker:  $
  6.  *
  7.  *    Test ASPI Interface Library,
  8.  *    aspiscan-like utility.
  9.  *
  10.  * $Log: aspiscan.c,v $
  11.  * Revision 1.4  1999/08/18 00:11:47  vitus
  12.  * - updated location of defines.h (moved)
  13.  *
  14.  * Revision 1.3  1997/09/22 02:27:51  vitus
  15.  * uses AH*() routines from library
  16.  *
  17.  * Revision 1.2  1997/09/18 01:57:40  vitus
  18.  * changed to new header file names
  19.  *
  20.  * Revision 1.1  1997/09/08 01:59:32  vitus
  21.  * Initial revision
  22.  * ----------------------------------------
  23.  * Sample code to demonstrate use of ASPI Interface.
  24.  */
  25. static char const id[]="$Id: aspiscan.c,v 1.4 1999/08/18 00:11:47 vitus Exp $";
  26.  
  27. #include <stdio.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. PUBLIC int
  41. main(void)
  42. {
  43.     APIRET        rc;
  44.     ASPI_SRB_INQUIRY    srb;
  45.     UCHAR        hacnt = 0xFF;
  46.     UCHAR        ha, target, lun;
  47.  
  48.     rc = AspiOpen(0);
  49.     if( rc != 0 )
  50.     {
  51.     fprintf(stderr, "AspiOpen - rc %lu\n", rc);
  52.     return rc;
  53.     }
  54.  
  55.     for( ha = 0; ha < hacnt; ++ha )
  56.     {
  57.     rc = AspiHAInq(0, &srb);
  58.     if( rc != 0 )
  59.     {
  60.         fprintf(stderr, "AspiHAInq(%u,) - rc %lu (%#lx)\n", ha, rc, rc);
  61.         break;
  62.     }
  63.  
  64.     if( ha == 0 )
  65.     {
  66.         printf("AdapterCount:\t%u\n", srb.AdapterCount);
  67.         hacnt = srb.AdapterCount;
  68.     }
  69.  
  70.     printf("\n========== Adapter %u ==========\n", ha);
  71.     printf("Adapter ID:\t%u\n", srb.AdapterTargetID);
  72.     printf("Manager Name:\t\"%s\"\n", srb.ManagerName);
  73.     printf("Adapter Name:\t\"%s\"\n", srb.AdapterName);
  74.     printf("Adapter Param.:\t\"%s\"\n", srb.AdapterParms);
  75.     printf("Adapter Features:\t%#x\n", srb.AdapterFeatures);
  76.     printf("Adapter SG Cnt:\t\t%u\n", srb.MaximumSGList);
  77.     printf("Adapter Transfer:\t%lu\n", srb.MaximumCDBTransfer);
  78.  
  79.     for( target = 0; target <= 7; ++target )
  80.     {
  81.         for( lun = 0; lun <= 7; ++lun )
  82.         {
  83.         UCHAR    type;            /* see SCSI spec */
  84.  
  85.         rc = AspiGetType(ha, target, lun, &type);
  86.         if( rc != 0 )
  87.             break;
  88.  
  89.         printf("HA %u  Target %u  LUN %u\t\"%s\" (%s)\n",
  90.                ha, target, lun,
  91.                AHInquiryType(type), AHInquiryQual(type));
  92.         }
  93.     }
  94.  
  95.     }
  96.  
  97.     rc = AspiClose();
  98.     if( rc != 0 )
  99.     {
  100.     fprintf(stderr, "AspiClose - rc %lu (%#lx)\n", rc, rc);
  101.     return rc;
  102.     }
  103.  
  104.     return 0;
  105. }
  106.