Detabbed
[AROS.git] / rom / dos / finddosentry.c
blob510ba1ae0823c53ee522059dab8e370f88f08721
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <aros/debug.h>
10 #include <dos/dosextens.h>
11 #include <proto/utility.h>
12 #include "dos_intern.h"
15 /*****************************************************************************
17 NAME */
18 #include <proto/dos.h>
20 AROS_LH3(struct DosList *, FindDosEntry,
22 /* SYNOPSIS */
23 AROS_LHA(struct DosList *, dlist, D1),
24 AROS_LHA(CONST_STRPTR, name, D2),
25 AROS_LHA(ULONG, flags, D3),
27 /* LOCATION */
28 struct DosLibrary *, DOSBase, 114, Dos)
30 /* FUNCTION
31 Looks for the next dos list entry with the right name. The list
32 must be locked for this. There may be not more than one device
33 or assign node of the same name. There are no such restrictions
34 on volume nodes.
36 INPUTS
37 dlist - the value given by LockDosList() or the last call to
38 FindDosEntry().
39 name - logical device name without colon. Case insensitive.
40 flags - the same flags as given to LockDosList() or a subset
41 of them.
43 RESULT
44 Pointer to dos list entry found or NULL if the are no more entries.
46 NOTES
48 EXAMPLE
50 BUGS
52 SEE ALSO
54 INTERNALS
56 *****************************************************************************/
58 AROS_LIBFUNC_INIT
60 static const ULONG flagarray[]=
61 { 0, LDF_DEVICES, LDF_ASSIGNS, LDF_VOLUMES, LDF_ASSIGNS, LDF_ASSIGNS };
63 /* Determine the size of the name (-1 if the last character is a ':') */
64 CONST_STRPTR end = name;
65 ULONG size;
67 if (!dlist)
68 return NULL;
70 while (*end++)
73 size = ~(name-end);
75 if (size && end[-2] == ':')
77 size--;
80 /* Follow the list */
81 for (;;)
83 /* Get next entry. Return NULL if there is none. */
84 dlist = BADDR(dlist->dol_Next);
86 if (dlist == NULL)
88 return NULL;
91 D(bug("[FindDosEntry] Found list entry 0x%p, '%b' type %d\n", dlist, dlist->dol_Name, dlist->dol_Type));
93 /* Check type and name */
94 if (flags & flagarray[dlist->dol_Type + 1] &&
95 !CMPNICBSTR(name, dlist->dol_Name, size) &&
96 !AROS_BSTR_ADDR(dlist->dol_Name)[size])
98 return dlist;
101 AROS_LIBFUNC_EXIT
102 } /* FindDosEntry */