home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 4 / CD_Magazyn_EXEC_nr_4.iso / Recent / util / libs / IdentifyDev.lha / Identify / examples / MyExp.c < prev   
C/C++ Source or Header  |  1997-04-16  |  2KB  |  72 lines

  1. /*********************************************************************
  2. **                                                                  **
  3. **                         M Y E X P                                **
  4. **                                                                  **
  5. ** A small example for using the identify.library.                  **
  6. ** Compiles with any C compiler.                                    **
  7. **                                                                  **
  8. *********************************************************************/
  9. /*
  10. **        (C) 1997 by Richard Körber -- All Rights Reserved
  11. */
  12.  
  13. #include <clib/exec_protos.h>
  14. #include <clib/dos_protos.h>
  15. #include <clib/identify_protos.h>
  16. #include <pragmas/exec_pragmas.h>
  17. #include <pragmas/dos_pragmas.h>
  18. #include <pragmas/identify_pragmas.h>
  19. #include <exec/memory.h>
  20. #include <libraries/identify.h>
  21. #include <libraries/configregs.h>
  22. #include <libraries/configvars.h>
  23.  
  24. struct Library *IdentifyBase;
  25. extern struct Library *DOSBase;
  26.  
  27. /*------------------------------------------------------------------**
  28. **  main                  -- MAIN PART
  29. */
  30. int main(void)
  31. {
  32.   if(IdentifyBase = OpenLibrary("identify.library",6))
  33.   {
  34.     struct ConfigDev *expans = NULL;
  35.     UWORD counter = 0;
  36.     ULONG size;
  37.     ULONG unit;
  38.     char manuf[IDENTIFYBUFLEN];
  39.     char prod[IDENTIFYBUFLEN];
  40.     char pclass[IDENTIFYBUFLEN];
  41.  
  42.     Printf("Nr Address  Size Description\n"
  43.            "----------------------------------------------------------\n");
  44.  
  45.     while(!IdExpansionTags(
  46.             IDTAG_ManufStr ,&manuf,
  47.             IDTAG_ProdStr  ,&prod,
  48.             IDTAG_ClassStr ,&pclass,
  49.             IDTAG_Expansion,&expans,
  50.             TAG_DONE))
  51.     {
  52.       unit = 'K';
  53.       size = expans->cd_BoardSize>>10;
  54.       if(size>=1024)
  55.       {
  56.         unit = 'M';
  57.         size >>= 10;
  58.       }
  59.  
  60.       Printf("%2ld %08lx %3ld%lc %s %s (%s)\n",
  61.              ++counter,
  62.              expans->cd_BoardAddr, size, unit,
  63.              prod, pclass, manuf);
  64.     }
  65.     CloseLibrary(IdentifyBase);
  66.   }
  67.   return 0;                             // return code 0
  68. }
  69.  
  70. /********************************************************************/
  71.  
  72.