some fixes to accented characters
[tangerine.git] / rom / dos / addsegment.c
blobb1f7d38b83e9e3ab527601b73cfa2229992a95d2
1 /*
2 Copyright © 1995-2007, 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 int namelen = strlen(name)+1;
69 sptr = AllocVec(sizeof(struct Segment) + namelen - 4,
70 MEMF_CLEAR | MEMF_PUBLIC);
72 if( sptr != NULL )
74 sptr->seg_UC = type;
75 sptr->seg_Seg = seg;
77 #ifdef AROS_FAST_BPTR
78 CopyMem(name, sptr->seg_Name, namelen);
79 #else
80 CopyMem(name, &sptr->seg_Name[1], namelen);
81 *sptr->seg_Name = namelen;
82 #endif
84 /* Sigh, we just add the segment to the start of the list */
85 Forbid();
87 sptr->seg_Next = DOSBase->dl_ResList;
88 DOSBase->dl_ResList = MKBADDR(sptr);
90 Permit();
92 return TRUE;
95 return FALSE;
97 AROS_LIBFUNC_EXIT
98 } /* AddSegment */