Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
System

Abstraction to usual system calls such as library loading and time. More...

Collaboration diagram for System:

Detailed Description

Topics

 Events
 
 Windows
 

Functions

bj_bool bj_begin (bj_error **p_error)
 Initializes the system.
 
void bj_end (bj_error **p_error)
 De-initializes the system.
 
void * bj_load_library (const char *p_path)
 Load the provided dynamic library and returns and opaque handle to it.
 
void bj_unload_library (void *p_handle)
 Unload a library loaded with bj_load_library from memory.
 
void * bj_get_symbol (void *p_handle, const char *p_name)
 Get the address of a function exported by p_handle given its name.
 

Function Documentation

◆ bj_begin()

bj_bool bj_begin ( bj_error ** p_error)
Parameters
p_errorAn optional location to an error object.

The initialization process will iteratively try to initialize a subsystem among the ones available and returns on the first that succeeded.

Returns
true if the system is properly initialized, BJ_FALSE otherswise.
Examples
audio_pcm.c, bitmap_blit.c, drawing_2d.c, events.c, load_bmp.c, shaders.c, sprite_animation.c, time.c, and window.c.

◆ bj_end()

void bj_end ( bj_error ** p_error)
Parameters
p_errorAn optional location to an error object.
Examples
audio_pcm.c, bitmap_blit.c, drawing_2d.c, events.c, load_bmp.c, shaders.c, sprite_animation.c, time.c, and window.c.

◆ bj_get_symbol()

void * bj_get_symbol ( void * p_handle,
const char * p_name )

This function is an abstraction over the platform specific function like dlsym and GetProcAddress.

Parameters
p_handleA library handle provided by bj_load_library.
p_nameC-String name of the function to retrieve
Returns
0 or the address of the retrieved function.
Behaviour
  • On Unix platforms, p_handle and p_name are passed to dlsym().
  • On Windows, p_handle and p_name are passed to GetProcAddress().
Memory Management

The caller is responsible for release the loaded function using bj_unload_library with p_handle.

See also
bj_load_library, bj_unload_library
dlsym(), GetProcAddress()

◆ bj_load_library()

void * bj_load_library ( const char * p_path)

This function is an abstraction over the platform specific function like dlopen and LoadLibrary. The provided pointer can be used with bj_get_symbol to get a function from the loaded library.

Parameters
p_pathA C-string path to the library to load.
Returns
0 or a handle to the loaded library.
Behaviour
  • On Unix platforms, p_path is passed to dlopen() with RTLD_LAZY and RTLD_LOCAL flags.
  • On Windows, p_path is passed to LoadLibraryA().
Memory Management

The caller is responsible for release the loaded library using bj_unload_library.

See also
bj_get_symbol, bj_unload_library
dlopen(), LoadLibraryA()

◆ bj_unload_library()

void bj_unload_library ( void * p_handle)

This function is an abstraction over the platform specific function like dlclose and FreeLibrary.

Parameters
p_handleThe library to unload.
Behaviour
  • On Unix platforms, p_handle is passed to dlclose().
  • On Windows, p_path is passed to FreeLibrary().
Memory Management

The caller is responsible for release the loaded library using bj_unload_library.

See also
bj_get_symbol, bj_unload_library
dlclose(), FreeLibrary()