New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / dos / internalloadseg.c
blob6c496a0b81fa5e038f7628fbee4662635acdde71
2 /*
3 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
4 $Id$
6 Desc: DOS function InternalLoadSeg()
7 Lang: english
8 */
11 #define DEBUG 0
13 #include <dos/dos.h>
14 #include <dos/dosextens.h>
15 #include <proto/dos.h>
16 #include <aros/debug.h>
17 #include "dos_intern.h"
18 #include "internalloadseg.h"
20 /*****************************************************************************
22 NAME */
23 #include <proto/dos.h>
25 AROS_LH4(BPTR, InternalLoadSeg,
27 /* SYNOPSIS */
28 AROS_LHA(BPTR , fh , D0),
29 AROS_LHA(BPTR , table , A0),
30 AROS_LHA(LONG_FUNC, functionarray, A1),
31 AROS_LHA(LONG * , stack , A2),
33 /* LOCATION */
34 struct DosLibrary *, DOSBase, 126, Dos)
36 /* FUNCTION
37 Loads from fh.
38 Functionarray is a pointer to an array of functions. See below.
40 This function really only tries to load the different file
41 formats aos, elf and aout.
43 INPUTS
44 fh : Filehandle to load from
45 table : ignored
46 functionarray : Array of function to be used fro read, alloc and free
47 FuncTable[0] -> bytes = ReadFunc(readhandle, buffer, length),DOSBase
48 D0 D1 A0 D0 A6
49 FuncTable[1] -> Memory = AllocFunc(size,flags), ExecBase
50 D0 D0 D1 A6
51 FuncTable[2] -> FreeFunc(memory, size), ExecBase
52 A1 D0 A6
53 stack : pointer to storage (ULONG) for stacksize.
54 (currently ignored)
56 RESULT
57 seglist - pointer to loaded Seglist or NULL in case of failure.
59 NOTES
61 EXAMPLE
63 BUGS
64 Use of table and stack are not implemented, yet!
66 SEE ALSO
67 UnLoadSeg()
69 INTERNALS
71 *****************************************************************************/
73 AROS_LIBFUNC_INIT
74 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
76 typedef struct _segfunc_t
78 BPTR (*func)(BPTR, BPTR, LONG *, LONG *, struct DosLibrary *);
79 D(CONST_STRPTR format;)
80 } segfunc_t;
82 #define SEGFUNC(format) { InternalLoadSeg_##format D(, #format)}
84 static const segfunc_t funcs[] =
86 SEGFUNC(ELF),
87 #if !defined(__mc68000__) && !defined(__arm__)
88 SEGFUNC(ELF_AROS),
89 #endif
90 SEGFUNC(AOS),
91 SEGFUNC(AOUT)
94 BPTR segs = 0;
96 if (fh)
98 int i = 0;
99 const int num_funcs = sizeof(funcs)/sizeof(funcs[0]);
103 SetIoErr(0);
105 segs = (*funcs[i].func)(fh, MKBADDR(NULL), (LONG *)functionarray, NULL, DOSBase);
107 D(bug("[InternalLoadSeg] %s loading %p as an %s object.\n",
108 segs ? "Succeeded" : "FAILED", fh, funcs[i].format));
110 } while (!segs && (IoErr() == ERROR_NOT_EXECUTABLE) && (++i < num_funcs));
113 return segs;
115 AROS_LIBFUNC_EXIT
116 } /* InternalLoadSeg */