some fixes to accented characters
[tangerine.git] / rom / dos / loadseg.c
blobfc21ed3821a81dd23d6a8570af06f066f8389312
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: DOS function LoadSeg()
6 Lang: english
7 */
8 #define DEBUG 0
10 #include <dos/dos.h>
11 #include <dos/dosextens.h>
12 #include <proto/dos.h>
13 #include <aros/debug.h>
14 #include "dos_intern.h"
16 /*****************************************************************************
18 NAME */
19 #include <proto/dos.h>
21 AROS_LH1(BPTR, LoadSeg,
23 /* SYNOPSIS */
24 AROS_LHA(CONST_STRPTR, name, D1),
26 /* LOCATION */
27 struct DosLibrary *, DOSBase, 25, Dos)
29 /* FUNCTION
30 Loads an executable file into memory. Each hunk of the loadfile
31 is loaded into its own memory section and a handle on all of them
32 is returned. The segments can be freed with UnLoadSeg().
34 INPUTS
35 name - NUL terminated name of the file.
37 RESULT
38 Handle to the loaded executable or NULL if the load failed.
39 IoErr() gives additional information in that case.
41 NOTES
42 This function is built on top of InternalLoadSeg()
44 EXAMPLE
46 BUGS
48 SEE ALSO
49 UnLoadSeg()
51 INTERNALS
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 void (* FunctionArray[3])();
58 BPTR file, segs=0;
60 FunctionArray[0] = __AROS_GETVECADDR(DOSBase,7); /* Read() */
61 FunctionArray[1] = __AROS_GETVECADDR(SysBase,33); /* AllocMem() */
62 FunctionArray[2] = __AROS_GETVECADDR(SysBase,35); /* FreeMem() */
64 /* Open the file */
65 D(bug("[LoadSeg] Opening '%s'...\n", name));
66 file = Open (name, FMF_READ);
68 if (file)
70 D(bug("[LoadSeg] Loading '%s'...\n", name));
72 segs = InternalLoadSeg(file, NULL, (void *)FunctionArray, NULL);
74 if (segs)
75 SetIoErr(0);
76 else
77 bug("[LoadSeg] Failed to load '%s'\n", name);
78 Close(file);
80 D(else
81 bug("[LoadSeg] Failed to open '%s'\n", name));
84 /* And return */
85 return segs;
87 AROS_LIBFUNC_EXIT
88 } /* LoadSeg */