rcutils  master
C API providing common utilities and data structures.
Classes | Typedefs | Functions
shared_library.h File Reference
#include <string.h>
#include "rcutils/allocator.h"
#include "rcutils/types/rcutils_ret.h"
#include "rcutils/macros.h"
#include "rcutils/visibility_control.h"
Include dependency graph for shared_library.h:

Go to the source code of this file.

Classes

struct  rcutils_shared_library_t
 Handle to a loaded shared library. More...
 

Typedefs

typedef struct rcutils_shared_library_t rcutils_shared_library_t
 Handle to a loaded shared library. More...
 

Functions

rcutils_shared_library_t rcutils_get_zero_initialized_shared_library (void)
 Return an empty shared library struct. More...
 
rcutils_ret_t rcutils_load_shared_library (rcutils_shared_library_t *lib, const char *library_path, rcutils_allocator_t allocator)
 Return shared library pointer. More...
 
void * rcutils_get_symbol (const rcutils_shared_library_t *lib, const char *symbol_name)
 Return shared library symbol pointer. More...
 
bool rcutils_has_symbol (const rcutils_shared_library_t *lib, const char *symbol_name)
 Return true if the shared library contains a specific symbol name otherwise returns false. More...
 
rcutils_ret_t rcutils_unload_shared_library (rcutils_shared_library_t *lib)
 Unload the shared library. More...
 
bool rcutils_is_shared_library_loaded (rcutils_shared_library_t *lib)
 Check if the library is loaded. More...
 
rcutils_ret_t rcutils_get_platform_library_name (const char *library_name, char *library_name_platform, unsigned int buffer_size, bool debug)
 Get the library name for the compiled platform. More...
 

Typedef Documentation

◆ rcutils_shared_library_t

Handle to a loaded shared library.

Function Documentation

◆ rcutils_get_zero_initialized_shared_library()

rcutils_shared_library_t rcutils_get_zero_initialized_shared_library ( void  )

Return an empty shared library struct.

◆ rcutils_load_shared_library()

rcutils_ret_t rcutils_load_shared_library ( rcutils_shared_library_t lib,
const char *  library_path,
rcutils_allocator_t  allocator 
)

Return shared library pointer.

Parameters
[in,out]libstruct with the shared library pointer and shared library path name
[in]library_pathstring with the path of the library
[in]allocatorto be used to allocate and deallocate memory
Returns
RCUTILS_RET_OK if successful, or
RCUTILS_RET_BAD_ALLOC if memory allocation fails, or
RCUTILS_RET_ERROR if an unknown error occurs, or
RCUTILS_RET_INVALID_ARGUMENT for invalid arguments

◆ rcutils_get_symbol()

void* rcutils_get_symbol ( const rcutils_shared_library_t lib,
const char *  symbol_name 
)

Return shared library symbol pointer.

Parameters
[in]libstruct with the shared library pointer and shared library path name
[in]symbol_namename of the symbol inside the shared library
Returns
shared library symbol pointer, if the symbol doesn't exist then returns NULL.

◆ rcutils_has_symbol()

bool rcutils_has_symbol ( const rcutils_shared_library_t lib,
const char *  symbol_name 
)

Return true if the shared library contains a specific symbol name otherwise returns false.

Parameters
[in]libstruct with the shared library pointer and shared library path name
[in]symbol_namename of the symbol inside the shared library
Returns
if symbols exists returns true, otherwise returns false.

◆ rcutils_unload_shared_library()

rcutils_ret_t rcutils_unload_shared_library ( rcutils_shared_library_t lib)

Unload the shared library.

Parameters
[in]librcutils_shared_library_t to be finalized
Returns
RCUTILS_RET_OK if successful, or
RCUTILS_RET_INVALID_ARGUMENT for invalid arguments, or
RCUTILS_RET_ERROR if an unknown error occurs

◆ rcutils_is_shared_library_loaded()

bool rcutils_is_shared_library_loaded ( rcutils_shared_library_t lib)

Check if the library is loaded.

This function only determines if "unload" has been called on the current shared library handle. It could very well be that a second shared library handle is still open and therefore the library being loaded.

Parameters
[in]librcutils_shared_library_t to check
Returns
true if library is loaded, false otherwise

◆ rcutils_get_platform_library_name()

rcutils_ret_t rcutils_get_platform_library_name ( const char *  library_name,
char *  library_name_platform,
unsigned int  buffer_size,
bool  debug 
)

Get the library name for the compiled platform.

Parameters
[in]library_namelibrary base name (without prefix and extension)
[out]library_name_platformlibrary name for the compiled platform
[in]buffer_sizesize of library_name_platform buffer
[in]debugif true the library will return a debug library name, otherwise it returns a normal library path
Returns
RCUTILS_RET_OK if successful, or
RCUTILS_RET_ERROR if an unknown error occurs