2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
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_intern.h"
17 #include "exec_debug.h"
18 #include "exec_locks.h"
21 /*****************************************************************************
25 AROS_LH2(struct Library
*, OpenLibrary
,
28 AROS_LHA(CONST_STRPTR
, libName
, A1
),
29 AROS_LHA(ULONG
, version
, D0
),
32 struct ExecBase
*, SysBase
, 92, Exec
)
35 Opens a library given by name and revision. If the library does not
36 exist in the current system shared library list, the first the
37 system ROMTag module list is tried. If this fails, and the DOS is
38 running, then the library will be loaded from disk.
41 libName - Pointer to the library's name.
42 version - the library's version number.
45 Pointer to library structure or NULL.
58 *****************************************************************************/
62 struct Library
* library
;
64 DRAMLIB("OpenLibrary(\"%s\", %ld)", libName
, version
);
66 /* Arbitrate for the library list */
67 EXEC_LOCK_LIST_READ_AND_FORBID(&SysBase
->LibList
);
69 /* Look for the library in our list */
70 library
= (struct Library
*) FindName (&SysBase
->LibList
, libName
);
72 EXEC_UNLOCK_LIST(&SysBase
->LibList
);
74 /* Something found ? */
78 if(library
->lib_Version
>=version
)
80 /* Call Open vector */
81 library
=AROS_LVO_CALL1(struct Library
*,
82 AROS_LCA(ULONG
,version
,D0
),
83 struct Library
*,library
,1,lib
88 DRAMLIB("Version mismatch (have %ld, wanted %ld)", library
->lib_Version
, version
);
94 * We cannot handle loading libraries from disk. But this is taken
95 * care of by dos.library (well lddemon really) replacing this
96 * function with a SetFunction() call.
102 DRAMLIB("OpenLibrary(\"%s\", %ld) = %p", libName
, version
, library
);