Added a test for MUIA_Listview_SelectChange.
[AROS.git] / rom / dos / addsegment.c
blobc93cbd32d820d3f5dad55382aacf351cd2eba4d0
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add a segment to the resident list.
6 Lang: english
7 */
8 #include "dos_intern.h"
9 #include <string.h>
10 #include <proto/exec.h>
12 /*****************************************************************************
14 NAME */
15 #include <dos/dosextens.h>
16 #include <proto/dos.h>
18 AROS_LH3(BOOL, AddSegment,
20 /* SYNOPSIS */
21 AROS_LHA(CONST_STRPTR, name, D1),
22 AROS_LHA(BPTR , seg, D2),
23 AROS_LHA(LONG , type, D3),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 129, Dos)
28 /* FUNCTION
29 Adds a program segment to the system resident list. You can later
30 use these segments to run programs.
32 The name field should refer to a NULL terminated strings, which
33 will be copied. The type field determines the type of resident
34 program. Normal programs should have type >= 0, system segments
35 should have type == CMD_SYSTEM.
37 Note that all other values of type are reserved.
39 INPUTS
40 name - Name of the segment. This is used by FindSegment().
41 seg - Segment to add.
42 type - What type of segment (initial use count).
44 RESULT
45 Segment will have been added to the DOS resident list.
47 != 0 success
48 == 0 failure
50 NOTES
52 EXAMPLE
54 BUGS
55 Uses Forbid() based locking.
57 SEE ALSO
58 FindSegment(), RemSegment()
60 INTERNALS
62 *****************************************************************************/
64 AROS_LIBFUNC_INIT
66 struct Segment *sptr;
67 struct DosInfo *dinf;
68 int namelen = strlen(name) + 1;
70 Forbid();
72 if (FindSegment(name, NULL, type)) {
73 Permit();
74 return FALSE;
77 sptr = AllocVec(sizeof(struct Segment) + namelen - 4 + 1,
78 MEMF_CLEAR | MEMF_PUBLIC);
80 if( sptr == NULL ) {
81 Permit();
82 return FALSE;
85 dinf = BADDR(DOSBase->dl_Root->rn_Info);
87 sptr->seg_UC = type;
88 sptr->seg_Seg = seg;
90 #ifdef AROS_FAST_BPTR
91 CopyMem(name, sptr->seg_Name, namelen);
92 #else
93 CopyMem(name, &sptr->seg_Name[1], namelen);
94 sptr->seg_Name[0] = namelen - 1;
95 #endif
97 /* Sigh, we just add the segment to the start of the list */
98 sptr->seg_Next = dinf->di_ResList;
99 dinf->di_ResList = MKBADDR(sptr);
101 Permit();
102 return TRUE;
104 AROS_LIBFUNC_EXIT
105 } /* AddSegment */