Next: libgfx, Previous: libdsp, Up: C API

### 5.15 libdyn

#### 5.15.1 Overview

View lcov test coverage results on http://www.gnu.org/software/liquidwar6/coverage/src/lib/dyn/index.html.

#### 5.15.2 API

— Function: lw6dyn_dl_handle_t * lw6dyn_dlopen_backend_so (char * so_file)

> Opens a .so file directly, using a valid (full) path name.

> Return value: a handle to the module, once it's opened. You might still need to call a module specific `init`() function, but it's another story.

— Function: lw6dyn_dl_handle_t * lw6dyn_dlopen_backend (int argc, char * [] argv, char * top_level_lib, char * backend_name)

> argc: the number of command-line arguments as passed to `main`

> top_level_lib: the top-level library concerned, this means is it "cli", "gfx", "snd" or "srv". This will tell the function to search for the .so file in the correct subdirectory. Think of this as a category.

> Opens a .so file corresponding to the given backend, it is capable to search for system libraries installed after "make install" but if not found, it will also search in the current build directory, finding the .so files in hidden .libs subdirectories.

> Return value: a handle to the module, once it's opened. You might still need to call a module specific `init`() function, but it's another story.

— Function: int lw6dyn_dlclose_backend (lw6dyn_dl_handle_t * handle)

> handle: the backend to close.

> Closes an opened backend. Note that you must call any backend specific clear, destroy, deinit, exit, function before.

> Return value: 1 if success, 0 on error.

— Function: void * lw6dyn_dlsym (lw6dyn_dl_handle_t * handle, char * func_name)

> handle: the backend concerned

> func_name: the function name, as a NULL terminated string

> Finds a C function in the given backend.

> Return value: a pointer to the function, NULL if not found.

— Function: lw6sys_assoc_t * lw6dyn_list_backends (int argc, char * [] argv, char * top_level_lib)

> argc: the number of command line args, as passed to main

> argv: the commind line args, as passed to main

> top_level_lib: the library category to query (gfx, snd, cli, srv ...)

> Returns an assoc which lists all the available modules. The key of the assoc entries in the module internal name such as 'gl' and the value associated is a NULL terminated string describing the module, for instance 'OpenGL'.

> Return value: an assoc object containing key/label pairs.

— Function: char * lw6dyn_path_find_backend (int argc, char * [] argv, char * top_level_lib, char * backend_name)

> argc: the number of command-line arguments as passed to `main`

> top_level_lib: the top-level library concerned, this means is it "cli", "gfx", "snd" or "srv". This will tell the function to search for the .so file in the correct subdirectory. Think of this as a category.

> backend_name: the actual name of the backend, this is the name of the .so file, between "libmod_" and ".so". For instance, to find "libmod_gl.so", the right argument is "gl".

> Get the full path to a .so file corresponding to the given backend, it is capable to search for system libraries installed after "make install" but if not found, it will also search in the current build directory, finding the .so files in hidden .libs subdirectories.

> Return value: the full path of the .so file, needs to be freed.

— Function: int lw6dyn_test (int mode)

> mode: 0 for check only, 1 for full test

> Runs the `dyn` module test suite, testing most (if not all...) functions. Will try to load libraries and query them for standard LW6-expected functions.

> Return value: 1 if test is successfull, 0 on error.