grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / exec / openlibrary.c
blob91293615538ecca2674c4af20bbe07a1f309f021
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Open a library.
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <exec/execbase.h>
11 #include <exec/lists.h>
12 #include <exec/libraries.h>
13 #include <aros/libcall.h>
14 #include <proto/exec.h>
16 #include "exec_debug.h"
18 /*****************************************************************************
20 NAME */
22 AROS_LH2(struct Library *, OpenLibrary,
24 /* SYNOPSIS */
25 AROS_LHA(CONST_STRPTR, libName, A1),
26 AROS_LHA(ULONG, version, D0),
28 /* LOCATION */
29 struct ExecBase *, SysBase, 92, Exec)
31 /* FUNCTION
32 Opens a library given by name and revision. If the library does not
33 exist in the current system shared library list, the first the
34 system ROMTag module list is tried. If this fails, and the DOS is
35 running, then the library will be loaded from disk.
37 INPUTS
38 libName - Pointer to the library's name.
39 version - the library's version number.
41 RESULT
42 Pointer to library structure or NULL.
44 NOTES
46 EXAMPLE
48 BUGS
50 SEE ALSO
51 CloseLibrary()
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
59 struct Library * library;
61 DRAMLIB("OpenLibrary(\"%s\", %ld)", libName, version);
63 /* Arbitrate for the library list */
64 Forbid();
66 /* Look for the library in our list */
67 library = (struct Library *) FindName (&SysBase->LibList, libName);
69 /* Something found ? */
70 if(library!=NULL)
72 /* Check version */
73 if(library->lib_Version>=version)
75 /* Call Open vector */
76 library=AROS_LVO_CALL1(struct Library *,
77 AROS_LCA(ULONG,version,D0),
78 struct Library *,library,1,lib
81 else
83 DRAMLIB("Version mismatch (have %ld, wanted %ld)", library->lib_Version, version);
84 library = NULL;
89 * We cannot handle loading libraries from disk. But this is taken
90 * care of by dos.library (well lddemon really) replacing this
91 * function with a SetFunction() call.
94 /* All done. */
95 Permit();
97 DRAMLIB("OpenLibrary(\"%s\", %ld) = %p", libName, version, library);
98 return library;
100 AROS_LIBFUNC_EXIT
101 } /* OpenLibrary */