Map menu key to right amiga to allow clipboard operations on keyboards without right...
[AROS.git] / rom / dos / findsegment.c
blobd7b254c36c43352d8043989be6f1b51e39825dfa
1 /*
2 Copyright © 1995-2008, 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(CONST_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
63 /* Segment seg was the last match, lets start from the next one */
64 if( seg != NULL )
65 seg = BADDR(seg->seg_Next);
66 else
67 seg = BADDR(DOSBase->dl_ResList);
69 while( seg != NULL )
73 (system || (system == FALSE && (seg->seg_UC >=0))) &&
74 (strcasecmp( name, AROS_BSTR_ADDR(seg->seg_Name)) == 0)
77 /* We have a matching segment */
78 return seg;
80 seg = BADDR(seg->seg_Next);
83 return NULL;
84 AROS_LIBFUNC_EXIT
85 } /* FindSegment */