home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / dos / finddosentry.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  2.9 KB  |  116 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: finddosentry.c,v 1.9 1997/01/27 00:36:19 ldp Exp $
  4.     $Log: finddosentry.c,v $
  5.     Revision 1.9  1997/01/27 00:36:19  ldp
  6.     Polish
  7.  
  8.     Revision 1.8  1996/12/09 13:53:28  aros
  9.     Added empty templates for all missing functions
  10.  
  11.     Moved #include's into first column
  12.  
  13.     Revision 1.7  1996/11/14 08:54:17  aros
  14.     Some more changes
  15.  
  16.     Revision 1.6  1996/10/24 15:50:28  aros
  17.     Use the official AROS macros over the __AROS versions.
  18.  
  19.     Revision 1.5  1996/10/10 13:20:49  digulla
  20.     Use dol_DevName(STRPTR) instead of dol_Name(BSTR) (Fleischer)
  21.  
  22.     Revision 1.4  1996/09/11 12:58:46  digulla
  23.     Determine the size of the name (M. Fleischer)
  24.  
  25.     Revision 1.3  1996/08/13 13:52:46  digulla
  26.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  27.     Replaced AROS_LA by AROS_LHA
  28.  
  29.     Revision 1.2  1996/08/01 17:40:51  digulla
  30.     Added standard header for all files
  31.  
  32.     Desc:
  33.     Lang: english
  34. */
  35. #include <dos/dosextens.h>
  36. #include <proto/utility.h>
  37. #include "dos_intern.h"
  38.  
  39. /*****************************************************************************
  40.  
  41.     NAME */
  42. #include <proto/dos.h>
  43.  
  44.     AROS_LH3(struct DosList *, FindDosEntry,
  45.  
  46. /*  SYNOPSIS */
  47.     AROS_LHA(struct DosList *, dlist, D1),
  48.     AROS_LHA(STRPTR,           name,  D2),
  49.     AROS_LHA(ULONG,            flags, D3),
  50.  
  51. /*  LOCATION */
  52.     struct DosLibrary *, DOSBase, 114, Dos)
  53.  
  54. /*  FUNCTION
  55.     Looks for the next dos list entry with the right name. The list
  56.     must be locked for this. There may be not more than one device
  57.     or assign node of the same name. There are no restrictions on
  58.     volume nodes.
  59.  
  60.     INPUTS
  61.     dlist - the value given by LockDosList() or the last call to
  62.             FindDosEntry().
  63.     name  - logical device name without colon. Case insensitive.
  64.     flags - the same flags as given to LockDosList() or a subset
  65.             of them.
  66.  
  67.     RESULT
  68.     Pointer to dos list entry found or NULL if the are no more entries.
  69.  
  70.     NOTES
  71.  
  72.     EXAMPLE
  73.  
  74.     BUGS
  75.  
  76.     SEE ALSO
  77.  
  78.     INTERNALS
  79.  
  80.     HISTORY
  81.     29-10-95    digulla automatically created from
  82.                 dos_lib.fd and clib/dos_protos.h
  83.  
  84. *****************************************************************************/
  85. {
  86.     AROS_LIBFUNC_INIT
  87.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  88.  
  89.     static const ULONG flagarray[]=
  90.     { 0, LDF_DEVICES, LDF_ASSIGNS, LDF_VOLUMES, LDF_ASSIGNS, LDF_ASSIGNS };
  91.  
  92.     /* Determine the size of the name (-1 if the last character is a ':') */
  93.     STRPTR end=name;
  94.     ULONG size;
  95.     while(*end++)
  96.     ;
  97.     size=~(name-end);
  98.     if(size&&end[-2]==':')
  99.     size--;
  100.  
  101.     /* Follow the list */   
  102.     for(;;)
  103.     {
  104.     /* Get next entry. Return NULL if there is none. */
  105.     dlist=dlist->dol_Next;
  106.     if(dlist==NULL)
  107.         return NULL;
  108.  
  109.     /* Check type and name */
  110.     if(flags&flagarray[dlist->dol_Type+1]&&
  111.        !Strnicmp(name,dlist->dol_DevName,size)&&!dlist->dol_DevName[size])
  112.         return dlist;
  113.     }
  114.     AROS_LIBFUNC_EXIT
  115. } /* FindDosEntry */
  116.