Fixed missing fprintf argument.
[AROS.git] / rom / dos / remassignlist.c
bloba177a4a300ecb7da008dfe4f1110b74a9c14d72f
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: RemAssignList() - Remove an entry from a multi-dir assign.
6 Lang: English
7 */
9 #include <aros/debug.h>
10 #include "dos_intern.h"
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
16 #include <proto/dos.h>
18 AROS_LH2(LONG, RemAssignList,
20 /* SYNOPSIS */
21 AROS_LHA(STRPTR, name, D1),
22 AROS_LHA(BPTR , lock, D2),
24 /* LOCATION */
25 struct DosLibrary *, DOSBase, 106, Dos)
27 /* FUNCTION
28 Remove an entry from a multi-dir assign. The entry removed will be
29 the first one that the SameLock() function called on the 'lock'
30 parameter returns that they belong to the same object.
32 The entry for this lock will be remove from the lock, and the
33 lock for the entry in the list will be unlocked.
35 INPUTS
36 name - Name of the device to remove lock from. This should
37 not contain the trailing ':'.
38 lock - Lock on the object to remove from the list.
40 RESULT
41 success - Have we actually succeeded
43 NOTES
45 EXAMPLE
47 BUGS
48 If this is the first lock in a list, this will not set
49 dol_Device/dol_Unit correctly. This will be fixed shortly.
51 SEE ALSO
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
58 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
60 struct DosList *dl = NULL;
61 BOOL res = DOSFALSE;
63 D(bug("RemAssignList: name = \"%s\", lock = $%lx\n", name, lock));
64 dl = LockDosList(LDF_ASSIGNS | LDF_WRITE);
66 while (!res && (dl = FindDosEntry(dl, name, LDF_ASSIGNS)))
68 struct AssignList *al, *lastal = NULL;
70 al = dl->dol_misc.dol_assign.dol_List;
73 We have a matching element, lets find the correct
74 member to remove. Initially check the inline lock.
77 if (SameLock(dl->dol_Lock, lock) == LOCK_SAME)
80 This is a bit tricky, me move the first element
81 in the list to the header
83 dl->dol_misc.dol_assign.dol_List = al->al_Next;
84 UnLock(dl->dol_Lock);
85 dl->dol_Lock = al->al_Lock;
86 FreeVec(al);
87 res = DOSTRUE;
89 else
91 while (al)
93 if (SameLock(al->al_Lock, lock) == LOCK_SAME)
95 /* Remove this element. Singly linked list */
96 if (lastal == NULL)
98 /* First element of list... */
99 dl->dol_misc.dol_assign.dol_List = al->al_Next;
101 else
103 lastal->al_Next = al->al_Next;
106 UnLock(al->al_Lock);
107 FreeVec(al);
108 al = NULL;
109 res = DOSTRUE;
111 else
113 lastal = al;
114 al = al->al_Next;
117 } /* in the assignlist */
119 } /* the assign exists */
121 UnLockDosList(LDF_ASSIGNS | LDF_WRITE);
123 return res;
125 AROS_LIBFUNC_EXIT
126 } /* RemAssignList */