home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 13 / MA_Cover_13.bin / source / c / stefanb_src / dospath / src / remove.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-25  |  1.4 KB  |  64 lines

  1. /*
  2.  * remove.c  V1.0
  3.  *
  4.  * Remove a directory from a path list
  5.  *
  6.  * (c) 1996 Stefan Becker
  7.  */
  8.  
  9. #include "dospath.h"
  10.  
  11. __geta4 struct PathListEntry *RemoveFromPathList(
  12.                               __A0 struct PathListEntry *path,
  13.                               __A1 BPTR dirlock,
  14.                               __A6 struct DOSPathBase *dpb)
  15. {
  16.  struct Library       *DOSBase = dpb->dpb_DOSBase;
  17.  struct PathListEntry *rc      = path;
  18.  struct PathListEntry *prev    = NULL;
  19.  
  20.  DEBUGLOG(kprintf("Remove: List 0x%08lx Lock 0x%08lx Base 0x%08lx\n",
  21.                   path, dirlock, dpb);)
  22.  
  23.  /* Scan path list */
  24.  while (path) {
  25.  
  26.   DEBUGLOG(kprintf("Remove: Lock 0x%08lx\n", path->ple_Lock);)
  27.  
  28.   /* Same directory? */
  29.   if (SameLock(path->ple_Lock, dirlock) == LOCK_SAME) {
  30.  
  31.    DEBUGLOG(kprintf("Remove: Entry 0x%08lx\n", path);)
  32.  
  33.    /* Yes, unlink current entry from list */
  34.    if (prev)
  35.  
  36.     /* Remove a node INSIDE the list */
  37.     prev->ple_Next = path->ple_Next;
  38.  
  39.    else
  40.  
  41.     /* Head node will be removed, set new head pointer */
  42.     rc = (struct PathListEntry *) BADDR(path->ple_Next);
  43.  
  44.    /* Unlock directory lock from this entry */
  45.    UnLock(path->ple_Lock);
  46.  
  47.    /* Free entry */
  48.    FreeVec(path);
  49.  
  50.    /* Leave loop */
  51.    break;
  52.   }
  53.  
  54.   /* Next entry */
  55.   prev = path;
  56.   path = BADDR(path->ple_Next);
  57.  }
  58.  
  59.  DEBUGLOG(kprintf("Remove: Result 0x%08lx\n", rc);)
  60.  
  61.  /* Return pointer to (new) head of list */
  62.  return(rc);
  63. }
  64.