home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 595.lha / MountStuff / UnMount.c < prev    next >
C/C++ Source or Header  |  1990-10-17  |  1KB  |  49 lines

  1.  
  2. #include <exec/types.h>
  3. #include <libraries/dosextens.h>
  4. #include "HH:MoreDos.h"
  5. #include "HH:Template.h"
  6.  
  7. /*************************************************************/
  8. /*                 NeonSoft (C) 06-04-'88                    */
  9. /*                 UnMount.c                                 */
  10. /*************************************************************/
  11.  
  12. TEXT *dv;
  13.  
  14. TEMPLATE Template[] = {
  15.    { A_FLAG, "DEV", &dv },
  16.    { EOTP }
  17. };
  18.  
  19. extern struct DosLibrary *DOSBase;
  20.  
  21.  VOID
  22. program()
  23. {
  24.  struct RootNode   *rn;
  25.  struct DosInfo    *di;
  26.  struct DeviceList *dl;
  27.  
  28.  rn = DOSBase->dl_Root;
  29.  di = BADDR(rn->rn_Info);
  30.  
  31.  if (!(dl=FindDevice(di->di_DevInfo,dv))) {
  32.     if (FindDevice(di->di_Devices,dv)) {
  33.        printf("Error, %ls already unmounted!\n",dv);
  34.        quit(RETURN_WARN);
  35.     } else {
  36.        printf("Error, %ls not found!\n",dv);
  37.        quit(RETURN_FAIL);
  38.     }
  39.  } else if (((struct DeviceList *)BADDR(dl))->dl_Type!=DLT_DEVICE) {
  40.     printf("Error, %ls not a device!\n",dv);
  41.     quit(RETURN_ERROR);
  42.  }
  43.  
  44.  InsertDevice(&di->di_Devices,RemoveDevice(&di->di_DevInfo,dl));
  45.  
  46.  quit(RETURN_OK);
  47. }
  48.  
  49.