home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / dev / rkrm.lha / RKRM / Resources / Get_Disk_Unit_ID.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-03  |  2.6 KB  |  85 lines

  1. /*
  2.  * Copyright (c) 1992 Commodore-Amiga, Inc.
  3.  * 
  4.  * This example is provided in electronic form by Commodore-Amiga, Inc. for 
  5.  * use with the "Amiga ROM Kernel Reference Manual: Devices", 3rd Edition, 
  6.  * published by Addison-Wesley (ISBN 0-201-56775-X).
  7.  * 
  8.  * The "Amiga ROM Kernel Reference Manual: Devices" contains additional 
  9.  * information on the correct usage of the techniques and operating system 
  10.  * functions presented in these examples.  The source and executable code 
  11.  * of these examples may only be distributed in free electronic form, via 
  12.  * bulletin board or as part of a fully non-commercial and freely 
  13.  * redistributable diskette.  Both the source and executable code (including 
  14.  * comments) must be included, without modification, in any copy.  This 
  15.  * example may not be published in printed form or distributed with any
  16.  * commercial product.  However, the programming techniques and support
  17.  * routines set forth in these examples may be used in the development
  18.  * of original executable software products for Commodore Amiga computers.
  19.  * 
  20.  * All other rights reserved.
  21.  * 
  22.  * This example is provided "as-is" and is subject to change; no
  23.  * warranties are made.  All use is at your own risk. No liability or
  24.  * responsibility is assumed.
  25.  *
  26.  *****************************************************************************
  27.  *
  28.  *
  29.  * Get_Disk_Unit_ID.c
  30.  *
  31.  * Example of getting the UnitID of a disk
  32.  *
  33.  * Compile with SAS 5.10  lc -b1 -cfistq -v -y -L
  34.  *
  35.  * Run from CLI only
  36.  */
  37.  
  38. #include <exec/types.h>
  39. #include <exec/memory.h>
  40. #include <dos/dos.h>
  41. #include <resources/disk.h>
  42.  
  43. #include <clib/exec_protos.h>
  44.  
  45. #include <stdio.h>
  46.  
  47. #ifdef LATTICE
  48. int CXBRK(void) { return(0); }  /* Disable SAS CTRL/C handling */
  49. int chkabort(void) { return(0); }  /* really */
  50.  
  51. /* There is no amiga.lib stub for this function so a pragma is required
  52.  * This is a pragma for SAS C
  53.  * Your compiler may require a different format
  54.  */
  55. #pragma libcall DiskBase GetUnitID 1e 1
  56. #endif
  57.  
  58. struct Library *DiskBase = NULL;
  59.  
  60. LONG GetUnitID(long);
  61.  
  62. void main(int argc, char **argv)
  63. {
  64. LONG ids= 0;
  65. LONG type;
  66.  
  67. if (!(DiskBase= (struct Library *)OpenResource(DISKNAME)))
  68.     printf("Cannot open %s\n,DISKNAME");
  69. else
  70.    {
  71.     printf("Defined drive types are:\n");
  72.     printf("  AMIGA  $00000000\n");
  73.     printf("  5.25'' $55555555\n");
  74.     printf("  AMIGA  $00000000 (high density)\n"); /* Commodore-only product */
  75.     printf("  None   $FFFFFFFF\n\n");
  76.  
  77.     /* What are the UnitIDs? */
  78.      for (ids = 0; ids < 4; ids++)
  79.         {
  80.          type = GetUnitID(ids);
  81.          printf("The UnitID for unit %d is $%08lx\n",ids,type);
  82.         }
  83.    }
  84. }
  85.