annotate doc/manual/manual_dynload_api.tex @ 228:f8a6e60598cc

- completed dynload API doc
author Tassilo Philipp
date Sun, 16 Apr 2017 13:34:39 +0200
parents 3e629dc19168
children 2a77747a5496
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 %//////////////////////////////////////////////////////////////////////////////
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2 %
228
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
3 % Copyright (c) 2007-2017 Daniel Adler <dadler@uni-goettingen.de>,
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 % Tassilo Philipp <tphilipp@potion-studios.com>
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 % Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 % purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 % copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
9 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 % THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11 % WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 % MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 % ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 % WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15 % ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 % OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 %//////////////////////////////////////////////////////////////////////////////
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 \newpage
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 \section{\product{Dynload} C library API}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23 The \product{dynload} library encapsulates dynamic loading mechanisms and
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 gives access to functions in foreign dynamic libraries and code modules.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26 \subsection{Loading code}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 \begin{lstlisting}[language=c,label=dl-load]
228
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
29 DLLib* dlLoadLibrary(const char* libpath);
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30 void dlFreeLibrary(void* libhandle);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31 \end{lstlisting}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33 \lstinline{dlLoadLibrary} loads a dynamic library at \lstinline{libpath}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34 and returns a handle to it for use in \lstinline{dlFreeLibrary} and
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
35 \lstinline{dlFindSymbol} calls.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
37 \lstinline{dlFreeLibrary} frees the loaded library with handle \lstinline{pLib}.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
38
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39 \subsection{Retrieving functions}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
40
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
41 \begin{lstlisting}[language=c]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42 void* dlFindSymbol(void* libhandle, const char* symbol);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
43 \end{lstlisting}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
44
228
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
45 This function returns a pointer to a symbol with name \lstinline{pSymbolName} in the
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
46 library with handle \lstinline{pLib}, or returns a null pointer if the symbol cannot
228
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
47 be found. The name is specified as it would appear in C source code (mangled if C++, etc.).
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
48
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
49 \subsection{Symbol iteration}
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
50
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
51 \begin{lstlisting}[language=c]
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
52 DLSyms* dlSymsInit(const char* libPath);
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
53 void dlSymsCleanup(DLSyms* pSyms);
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
54 int dlSymsCount(DLSyms* pSyms);
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
55 const char* dlSymsName(DLSyms* pSyms, int index);
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
56 const char* dlSymsNameFromValue(DLSyms* pSyms, void* value); /* symbol must be loaded */
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
57 \end{lstlisting}
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
58
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
59 These functions can be used to iterate over symbols. Note that they are made
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
60 for symbol name lookups, not to get a symbol's address. For that refer to
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
61 \lstinline{dlFindSymbol}. \lstinline{dlSymsInit} will return a handle (or a null pointer
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
62 on error) to the shared object specified by \lstinline{libPath}. The returned
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
63 handle is to be used with the other functions. The handle must be freed with
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
64 \lstinline{dlSymsCleanup}. \lstinline{dlSymsCount} returns the number of
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
65 symbols in the shared object, \lstinline{dlSymsName} and \lstinline{dlSymsNameFromValue}
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
66 are used to lookup symbol names using an index or symbol's address, respectively,
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
67 returning a null pointer on error. The names are returned as they would appear
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
68 in C source code (mangled if C++, etc.). The address passed to \lstinline{dlSymsNameFromValue}
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
69 must point to a loaded symbol.
f8a6e60598cc - completed dynload API doc
Tassilo Philipp
parents: 0
diff changeset
70