Mercurial > pub > dyncall > dyncall
comparison 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 |
comparison
equal
deleted
inserted
replaced
227:318a9ffc2b85 | 228:f8a6e60598cc |
---|---|
1 %////////////////////////////////////////////////////////////////////////////// | 1 %////////////////////////////////////////////////////////////////////////////// |
2 % | 2 % |
3 % Copyright (c) 2007,2009 Daniel Adler <dadler@uni-goettingen.de>, | 3 % Copyright (c) 2007-2017 Daniel Adler <dadler@uni-goettingen.de>, |
4 % Tassilo Philipp <tphilipp@potion-studios.com> | 4 % Tassilo Philipp <tphilipp@potion-studios.com> |
5 % | 5 % |
6 % Permission to use, copy, modify, and distribute this software for any | 6 % Permission to use, copy, modify, and distribute this software for any |
7 % purpose with or without fee is hereby granted, provided that the above | 7 % purpose with or without fee is hereby granted, provided that the above |
8 % copyright notice and this permission notice appear in all copies. | 8 % copyright notice and this permission notice appear in all copies. |
24 gives access to functions in foreign dynamic libraries and code modules. | 24 gives access to functions in foreign dynamic libraries and code modules. |
25 | 25 |
26 \subsection{Loading code} | 26 \subsection{Loading code} |
27 | 27 |
28 \begin{lstlisting}[language=c,label=dl-load] | 28 \begin{lstlisting}[language=c,label=dl-load] |
29 void* dlLoadLibrary(const char* libpath); | 29 DLLib* dlLoadLibrary(const char* libpath); |
30 void dlFreeLibrary(void* libhandle); | 30 void dlFreeLibrary(void* libhandle); |
31 \end{lstlisting} | 31 \end{lstlisting} |
32 | 32 |
33 \lstinline{dlLoadLibrary} loads a dynamic library at \lstinline{libpath} | 33 \lstinline{dlLoadLibrary} loads a dynamic library at \lstinline{libpath} |
34 and returns a handle to it for use in \lstinline{dlFreeLibrary} and | 34 and returns a handle to it for use in \lstinline{dlFreeLibrary} and |
40 | 40 |
41 \begin{lstlisting}[language=c] | 41 \begin{lstlisting}[language=c] |
42 void* dlFindSymbol(void* libhandle, const char* symbol); | 42 void* dlFindSymbol(void* libhandle, const char* symbol); |
43 \end{lstlisting} | 43 \end{lstlisting} |
44 | 44 |
45 returns a pointer to a symbol with name \lstinline{pSymbolName} in the | 45 This function returns a pointer to a symbol with name \lstinline{pSymbolName} in the |
46 library with handle \lstinline{pLib}, or returns a null pointer if the symbol cannot | 46 library with handle \lstinline{pLib}, or returns a null pointer if the symbol cannot |
47 be found. | 47 be found. The name is specified as it would appear in C source code (mangled if C++, etc.). |
48 | |
49 \subsection{Symbol iteration} | |
50 | |
51 \begin{lstlisting}[language=c] | |
52 DLSyms* dlSymsInit(const char* libPath); | |
53 void dlSymsCleanup(DLSyms* pSyms); | |
54 int dlSymsCount(DLSyms* pSyms); | |
55 const char* dlSymsName(DLSyms* pSyms, int index); | |
56 const char* dlSymsNameFromValue(DLSyms* pSyms, void* value); /* symbol must be loaded */ | |
57 \end{lstlisting} | |
58 | |
59 These functions can be used to iterate over symbols. Note that they are made | |
60 for symbol name lookups, not to get a symbol's address. For that refer to | |
61 \lstinline{dlFindSymbol}. \lstinline{dlSymsInit} will return a handle (or a null pointer | |
62 on error) to the shared object specified by \lstinline{libPath}. The returned | |
63 handle is to be used with the other functions. The handle must be freed with | |
64 \lstinline{dlSymsCleanup}. \lstinline{dlSymsCount} returns the number of | |
65 symbols in the shared object, \lstinline{dlSymsName} and \lstinline{dlSymsNameFromValue} | |
66 are used to lookup symbol names using an index or symbol's address, respectively, | |
67 returning a null pointer on error. The names are returned as they would appear | |
68 in C source code (mangled if C++, etc.). The address passed to \lstinline{dlSymsNameFromValue} | |
69 must point to a loaded symbol. | |
70 |