ADTF  3.18.2
cDynamicLinkage

System or platform specific functions for loading shared libraries. More...

Static Public Member Functions

static tHandle Load (const tChar *strFilename, tUInt32 nFlags=0)
 Loads a shared library. More...
 
static tVoid Unload (tHandle hLibrary)
 Unloads a loaded shared library. More...
 
static tVoidGetSymbol (tHandle hLibrary, const tChar *strSymbol)
 Returns a pointer to a function in a shared library. More...
 
static cFilename GetLibraryFilename (const tHandle hModule)
 Returns the filename of a given library using the libraries handle. More...
 
static tResult GetError ()
 Returns the error code if something has gone wrong. More...
 

Static Private Member Functions

static tVoid ClearError ()
 Set the last error code to ERR_NOERROR.
 

Static Private Attributes

static tResult err
 Current error code - may be retrieved using GetError()
 

Detailed Description

System or platform specific functions for loading shared libraries.

Definition at line 18 of file dynamic_linkage.h.

Member Function Documentation

◆ GetError()

static tResult GetError ( )
static

Returns the error code if something has gone wrong.

Returns
One of the error codes defined within A_UTILS describing what went wrong(if any)

◆ GetLibraryFilename()

static cFilename GetLibraryFilename ( const tHandle  hModule)
static

Returns the filename of a given library using the libraries handle.

Returns the filename of a library specified by a handle/pointer in the argument hModule. If hModule is nullptr the current executable is returned. If an error occurs the path returned is empty ("").

Note
If the filename of the module (including path) is longer than MAX_PATH characters, the result is truncated to MAX_PATH characters.
Warning
For some Linux/Unix derivatives (such as FreeBSD or Solaris) this method returns an empty string ("") if the current executable is requested (i.e. hModule is nullptr or not set). More specific this method only names a valid executable on Linux/Unix systems that support a link via /proc/self/exe. (Regular calls with hModule != nullptr work anyway.)
Parameters
hModule[in] Handle to a module or a function. If nullptr (or not set), the current executable is returned.
Returns
The fully qualified absolute path including name of the file.

◆ GetSymbol()

static tVoid* GetSymbol ( tHandle  hLibrary,
const tChar strSymbol 
)
static

Returns a pointer to a function in a shared library.

if hLibrary is nullptr, GetError returns ERR_INVALID_ARG if strSymbol is nullptr, GetError returns ERR_INVALID_ARG

Parameters
hLibrary[in] The handle of the library.
strSymbol[in] The name of the function.
Returns
a pointer to the function, or 0 in case of failure.

◆ Load()

static tHandle Load ( const tChar strFilename,
tUInt32  nFlags = 0 
)
static

Loads a shared library.

(win32) if the file is not found, GetError returns ERR_NOT_FOUND (win32) if the file is found but is no dll, GetError returns ERR_UNKNOWN_FORMAT (win32) if something else goes wrong, the error is set to ERR_UNEXPECTED (linux) if something goes wrong, the error is set to ERR_UNEXPECTED

Parameters
strFilename[in] The filename of the library.
nFlagsunused.
Returns
A handle to the library, or 0 in case of failure.

◆ Unload()

static tVoid Unload ( tHandle  hLibrary)
static

Unloads a loaded shared library.

if hLibrary is nullptr, GetError returns ERR_INVALID_ARG

Parameters
hLibrary[in] The handle of the library.
Returns
void