home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / drivers / scsi / futrdomn / samples / oemtst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-18  |  2.1 KB  |  104 lines

  1. /*********************** OEMTST.C **********************/
  2.  
  3.   #include <string.h>
  4.   #include <dos.h>
  5.   #include <stdio.h>
  6.   #include <stdlib.h>
  7.   #include <fcntl.h>
  8.   #include <io.h>
  9.  
  10.   #define esc 0x1B
  11.  
  12.   unsigned char buf [4096];
  13.   unsigned char p [32];
  14.  
  15.   struct SREGS segregs ;
  16.   struct oemtable
  17.     {
  18.     unsigned char (far *cmdblock)[];
  19.     unsigned char (far *datablock)[];
  20.     long expectlen;
  21.     long actuallen;
  22.     int timeout;
  23.     int blkfactora;
  24.     int blkfactorb;
  25.     unsigned char scsistatus;
  26.     unsigned char scsimsg;
  27.     unsigned char scsibits;
  28.     unsigned char scsiaddress;
  29.     unsigned char scsiparity;
  30.     int adaptererr;
  31.     } ;
  32.  
  33.   struct oemtable oem ;
  34.   unsigned char cmds [12];    /* build command block */
  35.  
  36. main ()
  37.   {
  38.   int i,ierr;
  39.   int j,k;
  40.   long sect,x;
  41.   int unit;
  42.   unsigned char cc;
  43.   union
  44.     {
  45.     unsigned char (far *point)[];
  46.     unsigned char *ptnear;
  47.     long longval;
  48.     int intval[2];
  49.     unsigned char ch [4];
  50.     } cnvtr ;
  51.   segread(&segregs) ;
  52.   cnvtr.intval[1]=segregs.ds;
  53.   cnvtr.ptnear=&cmds[0];
  54.   oem.cmdblock=cnvtr.point;
  55.   cnvtr.ptnear=&buf[0];
  56.   oem.datablock=cnvtr.point;
  57.   oem.expectlen=512l;
  58.   oem.timeout=5;
  59.   oem.blkfactora=512;
  60.   oem.blkfactorb=512;
  61.   oem.scsiaddress=0;
  62.   oem.scsiparity=0;
  63.   cmds[0]=8;
  64.   cmds[1]=0;
  65.   cmds[5]=0;
  66.   do
  67.     {
  68.     sect = 0l;
  69.     printf("\nSector number - ");
  70.     scanf("%lX",§);
  71.     printf("\nSector entered - %lX\n",sect);
  72.     cnvtr.longval=sect;
  73.     cmds[1]=cnvtr.ch[2];
  74.     cmds[2]=cnvtr.ch[1];
  75.     cmds[3]=cnvtr.ch[0];
  76.     cmds[4]=1;           /* read a single sector */
  77.     for(i=0;i<sizeof buf;i++)buf[i]=-1;
  78.     ierr=oemscsi(&oem);
  79.     if(ierr<0)oemreset();
  80.     if(ierr!=0)oemprint(&oem);
  81.     else
  82.       {
  83.       for (i=0;i<512;i+=16)
  84.     {
  85.     printf ("%04X  ",i);
  86.     k=0 ;
  87.     for(j=i;j<i+16;j++)
  88.       {
  89.       cc=buf[j]&255;
  90.       printf("%02X ",cc);
  91.       if ((cc<0x20)||(cc>0x7e)) cc=0x20;
  92.       p[k]=cc;
  93.       k++ ;
  94.       }
  95.     p[k]=0;
  96.     printf("%s\n",p);
  97.     }
  98.       }
  99.     printf("\nHit any key to continue, ESC to Exit.");
  100.     if(getch()==esc)exit(0);
  101.     } while (1);
  102.   exit (0);
  103.   }
  104.