Forward compatibility: build relative-base link libraries where needed
[AROS.git] / arch / all-hosted / hostlib / getinterface.c
blobe675227dc061a2f994352bfe969516c14687834b
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
8 #include "hostinterface.h"
9 #include "hostlib_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <proto/hostlib.h>
16 AROS_LH3(APTR *, HostLib_GetInterface,
18 /* SYNOPSIS */
19 AROS_LHA(void *, handle, A0),
20 AROS_LHA(const char **, symtable, A1),
21 AROS_LHA(ULONG *, unresolved, A2),
23 /* LOCATION */
24 struct HostLibBase *, HostLibBase, 5, HostLib)
26 /* FUNCTION
27 Resolve array of symbols in the host operating system library.
28 The result is a pointer to a dynamically allocated array of
29 symbol values.
31 INPUTS
32 handle - An opaque library handle provided by HostLib_Open()
33 symbable - A pointer to a NULL-terminated array of symbol names
34 unresolved - An optional location where count of unresolved symbols
35 will be placed. Can be set to NULL to ignore it.
37 RESULT
38 A pointer to a dynamically allocated array of symbol values or NULL if
39 empty symbol table was given.
41 NOTES
42 Note that the resulting array will always have as many entries as there
43 are in symbol names array. It some symbols (or even all of them) fail
44 to resolve, corresponding entries will be set to NULL. You may supply
45 a valid unresolved pointer if you want to get unresolved symbols count.
47 Even incomplete interface needs to be freed using HostLib_DropInterface().
49 Resulting values are valid as long as the library is open. For portability
50 sake it's advised to free interfaces before closing corresponding libraries.
52 This function appeared in v2 of hostlib.resource.
54 EXAMPLE
56 BUGS
58 SEE ALSO
59 HostLib_GetPointer()
61 INTERNALS
63 *****************************************************************************/
65 AROS_LIBFUNC_INIT
67 const char **c;
68 ULONG cnt = 0;
69 APTR *iface = NULL;
71 for (c = symtable; *c; c++)
72 cnt++;
74 if (cnt)
76 iface = AllocVec(cnt * sizeof(APTR), MEMF_ANY);
77 if (iface)
79 ULONG bad = 0;
80 ULONG i;
82 HOSTLIB_LOCK();
84 for (i = 0; i < cnt; i++)
86 iface[i] = HostLibBase->HostIFace->hostlib_GetPointer(handle, symtable[i], NULL);
87 AROS_HOST_BARRIER
89 if (!iface[i])
90 bad++;
93 HOSTLIB_UNLOCK();
95 if (unresolved)
96 *unresolved = bad;
100 return iface;
102 AROS_LIBFUNC_EXIT