Autodoc formatting fixes.
[AROS.git] / arch / all-hosted / hostlib / getinterface.c
blob36c18a05ae04f9071042e139aade19fbbd6dcad0
1 #include <proto/exec.h>
3 #include "hostinterface.h"
4 #include "hostlib_intern.h"
6 /*****************************************************************************
8 NAME */
9 #include <proto/hostlib.h>
11 AROS_LH3(APTR *, HostLib_GetInterface,
13 /* SYNOPSIS */
14 AROS_LHA(void *, handle, A0),
15 AROS_LHA(const char **, symtable, A1),
16 AROS_LHA(ULONG *, unresolved, A2),
18 /* LOCATION */
19 struct HostLibBase *, HostLibBase, 5, HostLib)
21 /* FUNCTION
22 Resolve array of symbols in the host operating system library.
23 The result is a pointer to a dynamically allocated array of
24 symbol values.
26 INPUTS
27 handle - An opaque library handle provided by HostLib_Open()
28 symbable - A pointer to a NULL-terminated array of symbol names
29 unresolved - An optional location where count of unresolved symbols
30 will be placed. Can be set to NULL to ignore it.
32 RESULT
33 A pointer to a dynamically allocated array of symbol values or NULL if
34 empty symbol table was given.
36 NOTES
37 Note that the resulting array will always have as many entries as there
38 are in symbol names array. It some symbols (or even all of them) fail
39 to resolve, correspondind entries will be set to NULL. You may supply
40 a valid unresolved pointer if you want to get unresolved symbols count.
42 Even incomplete interface needs to be freed using HostLib_DropInterface().
44 Resulting values are valid as long as the library is open. For portability
45 sake it's advised to free interfaces before closing corresponding libraries.
47 This function appeared in v2 of hostlib.resource.
49 EXAMPLE
51 BUGS
53 SEE ALSO
54 HostLib_GetPointer()
56 INTERNALS
58 *****************************************************************************/
60 AROS_LIBFUNC_INIT
62 const char **c;
63 ULONG cnt = 0;
64 APTR *iface = NULL;
66 for (c = symtable; *c; c++)
67 cnt++;
69 if (cnt)
71 iface = AllocVec(cnt * sizeof(APTR), MEMF_ANY);
72 if (iface)
74 ULONG bad = 0;
75 ULONG i;
77 HOSTLIB_LOCK();
79 for (i = 0; i < cnt; i++)
81 iface[i] = HostLibBase->HostIFace->hostlib_GetPointer(handle, symtable[i], NULL);
82 AROS_HOST_BARRIER
84 if (!iface[i])
85 bad++;
88 HOSTLIB_UNLOCK();
90 if (unresolved)
91 *unresolved = bad;
95 return iface;
97 AROS_LIBFUNC_EXIT