2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: Find a resident segment.
9 #include <aros/debug.h>
10 #include "dos_intern.h"
13 /*****************************************************************************
16 #include <dos/dosextens.h>
17 #include <proto/dos.h>
19 AROS_LH3(struct Segment
*, FindSegment
,
22 AROS_LHA(CONST_STRPTR
, name
, D1
),
23 AROS_LHA(struct Segment
*, seg
, D2
),
24 AROS_LHA(BOOL
, system
, D3
),
27 struct DosLibrary
*, DOSBase
, 130, Dos
)
30 Search for a resident segment by name and type. FindSegment() will
31 return the first segment that exactly matches the name and type.
33 You can continue searching by specifying the last returned segment
37 name - Name of the segment to search for.
38 seg - Start search from this point.
39 system - Search for a system segment.
42 Will return the segment structure if a match is found, otherwise
46 FindSegment() does no locking of the segment list. You should
47 lock yourself. FindSegment() also does not increment the value
48 of the seg_UC field. If the value of seg_UC > 0, you MUST
49 perform user counting in order to prevent the segment from being
57 AddSegment(), RemSegment()
61 *****************************************************************************/
65 struct DosInfo
*dinf
= BADDR(DOSBase
->dl_Root
->rn_Info
);
67 /* Segment seg was the last match, let's start from the next one */
69 seg
= BADDR(seg
->seg_Next
);
71 seg
= BADDR(dinf
->di_ResList
);
75 D(bug("[FindSegment] Checking segment '%s'\n",
76 AROS_BSTR_ADDR(MKBADDR(&seg
->seg_Name
[0]))));
79 (system
|| (system
== FALSE
&& (seg
->seg_UC
>=0))) &&
80 (Stricmp( name
, AROS_BSTR_ADDR(MKBADDR(&seg
->seg_Name
[0]))) == 0)
83 /* We have a matching segment */
86 seg
= BADDR(seg
->seg_Next
);