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

  1.    /*
  2.     * Get_Filesys.c
  3.     *
  4.     * Example of examining the FileSysRes list
  5.     *
  6.     * Compile with SAS C 5.10  lc -b1 -cfistq -v -y -L
  7.     *
  8.     * Run from CLI only
  9.     */
  10.  
  11.    #include <exec/types.h>
  12.    #include <exec/memory.h>
  13.    #include <dos/dos.h>
  14.    #include <resources/filesysres.h>
  15.  
  16.    #include <clib/exec_protos.h>
  17.  
  18.    #include <stdio.h>
  19.  
  20.    #ifdef LATTICE
  21.    int CXBRK(void) { return(0); }  /* Disable SAS CTRL/C handling */
  22.    int chkabort(void) { return(0); }  /* really */
  23.    #endif
  24.  
  25.    struct FileSysResource *FileSysResBase = NULL;
  26.  
  27.    void main(int argc, char **argv)
  28.    {
  29.  
  30.    struct FileSysEntry *fse;
  31.    int x;
  32.  
  33.    /* NOTE - you should actually be in a Forbid while accessing any
  34.     * system list for which no other method of arbitration is available.
  35.     * However, for this example we will be printing the information
  36.     * (which would break a Forbid anyway) so we won't Forbid.
  37.     * In real life, you should Forbid, copy the information you need,
  38.     * Permit, then print the info.
  39.     */
  40.    if (!(FileSysResBase = (struct FileSysResource *)OpenResource(FSRNAME)))
  41.        printf("Cannot open %s\n",FSRNAME);
  42.    else
  43.        {
  44.        for ( fse = (struct FileSysEntry *)FileSysResBase->fsr_FileSysEntries.lh_Head;
  45.              fse->fse_Node.ln_Succ;
  46.              fse = (struct FileSysEntry *)fse->fse_Node.ln_Succ)
  47.             {
  48.             printf("Found filesystem creator: %s\n",fse->fse_Node.ln_Name);
  49.  
  50.             printf("                 DosType: ");
  51.             for (x=24; x>=8; x-=8)
  52.                  putchar((fse->fse_DosType >> x) & 0xFF);
  53.  
  54.             putchar((fse->fse_DosType & 0xFF) + 0x30);
  55.  
  56.             printf("\n                 Version: %d",(fse->fse_Version >> 16));
  57.             printf(".%ld\n\n",(fse->fse_Version & 0xFFFF));
  58.             }
  59.         }
  60.    }
  61.