Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / dos / findsegment.c
blob35c270e4cbff08858e5d96b437556465d3b6e68c
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Find a resident segment.
6 Lang: english
7 */
8 #include "dos_intern.h"
9 #include <string.h>
11 /*****************************************************************************
13 NAME */
14 #include <dos/dosextens.h>
15 #include <proto/dos.h>
17 AROS_LH3(struct Segment *, FindSegment,
19 /* SYNOPSIS */
20 AROS_LHA(STRPTR , name, D1),
21 AROS_LHA(struct Segment *, seg, D2),
22 AROS_LHA(BOOL , system, D3),
24 /* LOCATION */
25 struct DosLibrary *, DOSBase, 130, Dos)
27 /* FUNCTION
28 Search for a resident segment by name and type. FindSegment() will
29 return the first segment that exactly matches the name and type.
31 You can continue searching by specifying the last returned segment
32 as the seg argument.
34 INPUTS
35 name - Name of the segment to search for.
36 seg - Start search from this point.
37 system - Search for a system segment.
39 RESULT
40 Will return the segment structure if a match is found, otherwise
41 will return NULL.
43 NOTES
44 FindSegment() does no locking of the segment list. You should
45 lock yourself. FindSegment() also does not increment the value
46 of the seg_UC field. If the value of seg_UC > 0, you MUST
47 perform user counting in order to prevent the segment from being
48 unloaded.
50 EXAMPLE
52 BUGS
54 SEE ALSO
55 AddSegment(), RemSegment()
57 INTERNALS
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
62 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
64 /* Segment seg was the last match, lets start from the next one */
65 if( seg != NULL )
66 seg = BADDR(seg->seg_Next);
67 else
68 seg = BADDR(DOSBase->dl_ResList);
70 while( seg != NULL )
74 (system || (system == FALSE && (seg->seg_UC >=0))) &&
75 (strcasecmp( name, AROS_BSTR_ADDR(seg->seg_Name)) == 0)
78 /* We have a matching segment */
79 return seg;
81 seg = BADDR(seg->seg_Next);
84 return NULL;
85 AROS_LIBFUNC_EXIT
86 } /* FindSegment */