grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / dos / matchend.c
blob226ef7ca4a3c8227661e0a9503f6c163bb2c6c79
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <proto/exec.h>
9 #include "dos_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <dos/dosasl.h>
15 #include <proto/dos.h>
17 AROS_LH1(void, MatchEnd,
19 /* SYNOPSIS */
20 AROS_LHA(struct AnchorPath *, AP, D1),
22 /* LOCATION */
23 struct DosLibrary *, DOSBase, 139, Dos)
25 /* FUNCTION
26 Free the memory and file locks that were allocated by calls to
27 MatchFirst() and MatchNext().
29 INPUTS
30 AP - pointer to Anchor Path structure which had been passed to
31 MatchFirst() before.
33 RESULT
34 None.
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 *****************************************************************************/
48 AROS_LIBFUNC_INIT
50 struct AChain *ac = AP->ap_Base, *acnext;
52 if (ac)
54 #if MATCHFUNCS_NO_DUPLOCK
56 ** CurrentDir to a valid lock, ie. one that will not be
57 ** killed further below
60 CurrentDir(ac->an_Lock);
61 #endif
63 while(ac)
65 acnext = ac->an_Child;
68 ** Dont unlock lock in first AChain because it is the same
69 ** as the current directory when MatchFirst was called. And
70 ** this lock was not DupLock()ed (except MATCHFUNCS_NO_DUPLOCK == 0)!!!
73 if (ac->an_Lock
74 #if MATCHFUNCS_NO_DUPLOCK
75 && (ac != AP->ap_Base)
76 #endif
79 UnLock(ac->an_Lock);
81 Match_FreeAChain(ac, DOSBase);
83 ac = acnext;
87 AP->ap_Current = NULL;
88 AP->ap_Base = NULL;
90 AROS_LIBFUNC_EXIT
92 } /* MatchEnd */