home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 1.2 / amidev_cd_12.iso / reference_library / devices / dev_examples / get_disk_unit_id.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-20  |  1.4 KB  |  59 lines

  1.  
  2.    /*
  3.     * Get_Disk_Unit_ID.c
  4.     *
  5.     * Example of getting the UnitID of a disk
  6.     *
  7.     * Compile with SAS C 5.10  lc -b1 -cfistq -v -y -L
  8.     *
  9.     * Run from CLI only
  10.     */
  11.  
  12.    #include <exec/types.h>
  13.    #include <exec/memory.h>
  14.    #include <dos/dos.h>
  15.    #include <resources/disk.h>
  16.  
  17.    #include <clib/exec_protos.h>
  18.  
  19.    #include <stdio.h>
  20.  
  21.    #ifdef LATTICE
  22.    int CXBRK(void) { return(0); }  /* Disable SAS CTRL/C handling */
  23.    int chkabort(void) { return(0); }  /* really */
  24.  
  25.    /* There is no amiga.lib stub for this function so a pragma is required
  26.     * This is a pragma for SAS C
  27.     * Your compiler may require a different format
  28.     */
  29.    #pragma libcall DiskBase GetUnitID 1e 1
  30.    #endif
  31.  
  32.    struct Library *DiskBase = NULL;
  33.  
  34.    LONG GetUnitID(long);
  35.  
  36.    void main(int argc, char **argv)
  37.    {
  38.    LONG ids= 0;
  39.    LONG type;
  40.  
  41.    if (!(DiskBase= (struct Library *)OpenResource(DISKNAME)))
  42.        printf("Cannot open %s\n,DISKNAME");
  43.    else
  44.       {
  45.        printf("Defined drive types are:\n");
  46.        printf("  AMIGA  $00000000\n");
  47.        printf("  5.25'' $55555555\n");
  48.        printf("  AMIGA  $00000000 (high density)\n");
  49.        printf("  None   $FFFFFFFF\n\n");
  50.  
  51.        /* What are the UnitIDs? */
  52.         for (ids = 0; ids < 4; ids++)
  53.            {
  54.             type = GetUnitID(ids);
  55.             printf("The UnitID for unit %d is $%08lx\n",ids,type);
  56.            }
  57.       }
  58.    }
  59.