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

  1.  
  2. /*************************************************************/
  3. /*                 NeonSoft (C) 06-04-'88                    */
  4. /*                 moredos.c                                 */
  5. /*************************************************************/
  6.  
  7. #include <exec/types.h>
  8. #include <libraries/dosextens.h>
  9. #include "hh:moredos.h"
  10. #include <ctype.h>
  11.  
  12.  
  13.  static BOOL
  14. devcmp(nstr,bstr)
  15.  TEXT *nstr;
  16.  BPTR *bstr;
  17. {
  18.  TEXT *bptr = BADDR(bstr);
  19.  UCOUNT blen = *(TEXT *)bptr, nlen = 0;
  20.  
  21.  bptr++;
  22.  while (nlen<blen && ((isalpha(*nstr))?(_toupper(*nstr)):(*nstr))==*bptr) {
  23.        nstr++; bptr++; nlen++;
  24.  }
  25.  return(((!*nstr) || (*nstr==':' && !nstr[1])) && nlen==blen);
  26. }
  27.  
  28.  BPTR
  29. FindDevice(Entry,Name)
  30.  BPTR Entry;
  31.  TEXT (*Name)[];
  32. {
  33.  BOOL found = FALSE;
  34.  struct DeviceList *dl = BADDR(Entry);
  35.  
  36.  Forbid();
  37.  while (dl && !found) {
  38.         if (devcmp(Name,dl->dl_Name)) {
  39.            found = TRUE;
  40.         } else {
  41.            dl = BADDR((dl->dl_Next));
  42.         }
  43.  }
  44.  Permit();
  45.  return((found)?(NADDR(dl)):(NULL));
  46. }
  47.  
  48.  BPTR
  49. RemoveDevice(Entry,Device)
  50.  BPTR *Entry;
  51.  BPTR Device;
  52. {
  53.  BOOL found = FALSE;
  54.  struct DeviceList *dl = BADDR(Device);
  55.  struct DeviceList *pl = BADDR((*Entry));
  56.  
  57.  Forbid();
  58.  if (pl==dl) {
  59.     *Entry = dl->dl_Next;
  60.     found = TRUE;
  61.  } else {
  62.     while (pl->dl_Next && !found) {
  63.           if (pl->dl_Next==Device) {
  64.              pl->dl_Next = dl->dl_Next;
  65.              found = TRUE;
  66.           } else {
  67.              pl = BADDR((pl->dl_Next));
  68.           }
  69.     }
  70.  }
  71.  if (found) {
  72.     dl->dl_Next = NULL;
  73.  }
  74.  Permit();
  75.  return((found)?(Device):(NULL));
  76. }
  77.  
  78.  VOID
  79. InsertDevice(Entry,Device)
  80.  BPTR *Entry;
  81.  BPTR Device;
  82. {
  83.  struct DeviceList *dl = BADDR(Device);
  84.  
  85.  Forbid();
  86.  if (dl) {
  87.     dl->dl_Next = *Entry;
  88.     *Entry = Device;
  89.  }
  90.  Permit();
  91. }
  92.  
  93.  
  94.