Add new strings.
[AROS.git] / rom / dos / remsegment.c
blob555ac141aeab5e357c41eebf0dc22a1dbbfd0edc
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Remove a segment from the system list.
6 Lang: English
7 */
9 #include "dos_intern.h"
10 #include <proto/exec.h>
12 /*****************************************************************************
14 NAME */
15 #include <dos/dosextens.h>
16 #include <proto/dos.h>
18 AROS_LH1(LONG, RemSegment,
20 /* SYNOPSIS */
21 AROS_LHA(struct Segment *, seg, D1),
23 /* LOCATION */
24 struct DosLibrary *, DOSBase, 131, Dos)
26 /* FUNCTION
27 Remove the segment seg from the DOS resident command list.
29 The segment to be removed should be in the list, and should
30 have a usercount of 0. System or internal segment cannot be
31 removed (although they can be replaced).
33 INPUTS
34 seg - Segment to remove.
36 RESULT
37 != 0 Segment was removed
38 == 0 Segment was not removed (not in list, or not free).
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 AddSegment(), FindSegment()
49 INTERNALS
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
55 /* Make sure segment is freeable */
56 #if AROS_FLAVOUR & AROS_FLAVOUR_BINCOMPAT
57 if (seg->seg_UC == 0 || seg->seg_UC == 1)
58 #else
59 if (seg->seg_UC == 0)
60 #endif
62 struct Segment *next, *prev;
63 struct DosInfo *dinf = BADDR(DOSBase->dl_Root->rn_Info);
65 prev = NULL;
66 next = BADDR(dinf->di_ResList);
67 while (next != NULL)
69 if (next == seg)
71 if (prev)
73 prev->seg_Next = next->seg_Next;
75 else
77 dinf->di_ResList = MKBADDR(next->seg_Next);
80 return DOSTRUE;
83 prev = next;
84 next = BADDR(next->seg_Next);
88 return DOSFALSE;
90 AROS_LIBFUNC_EXIT
91 } /* RemSegment */