GATE
libraries.h File Reference

Controls access to shared libraries (DLL or SO) More...

#include "gate/gate_core_api.h"
#include "gate/gatetypes.h"
#include "gate/strings.h"
#include "gate/objects.h"

Macros

#define GATE_LIBRARY_EXPORT   GATE_API_EXPORT
 
#define GATE_LIBRARY_IMPORT   GATE_API_IMPORT
 
#define GATE_LIBRARY_LOCAL   GATE_API_LOCAL
 
#define GATE_LIBRARY_FLAG_DEFAULT   0x0000
 Library is opened in a platform-default mode.
 
#define GATE_LIBRARY_FLAG_LOCAL   0x0001
 Library is opened in local mode (POSIX), opposite of global mode.
 
#define GATE_LIBRARY_FLAG_DATA   0x0002
 Library is loaded for data symbols only, code functions may not be available.
 
#define GATE_LIBRARY_LIB_RESULT   gate_result_t
 
#define GATE_LIBRARY_LIB_INIT_FUNCTION   gate_lib_init
 
#define GATE_LIBRARY_LIB_INIT_NAME   GATE_MACRO_TO_STRING(GATE_LIBRARY_LIB_INIT_FUNCTION)
 
#define GATE_LIBRARY_LIB_INIT_SIGNATURE   void
 
#define GATE_LIBARRY_LIB_INIT_PROTOTYPE   GATE_LIBRARY_LIB_RESULT GATE_LIBRARY_LIB_INIT_FUNCTION ( GATE_LIBRARY_LIB_INIT_SIGNATURE )
 
#define GATE_LIBRARY_LIB_UNINIT_FUNCTION   gate_lib_uninit
 
#define GATE_LIBRARY_LIB_UNINIT_NAME   GATE_MACRO_TO_STRING(GATE_LIBRARY_LIB_UNINIT_FUNCTION)
 
#define GATE_LIBRARY_LIB_UNINIT_SIGNATURE   void
 
#define GATE_LIBARRY_LIB_UNINIT_PROTOTYPE   GATE_LIBRARY_LIB_RESULT GATE_LIBRARY_LIB_UNINIT_FUNCTION ( GATE_LIBRARY_LIB_UNINIT_SIGNATURE )
 
#define GATE_LIBRARY_LIB_GET_INFO_FUNCTION   gate_lib_get_info
 
#define GATE_LIBRARY_LIB_GET_INFO_NAME   GATE_MACRO_TO_STRING(GATE_LIBRARY_LIB_GET_INFO_FUNCTION)
 
#define GATE_LIBRARY_LIB_GET_INFO_SIGNATURE   gate_uint32_t info_type, void* ptr_buffer, gate_size_t buffer_length, gate_size_t* buffer_used
 
#define GATE_LIBARRY_LIB_GET_INFO_PROTOTYPE   GATE_LIBRARY_LIB_RESULT GATE_LIBRARY_LIB_GET_INFO_FUNCTION ( GATE_LIBRARY_LIB_GET_INFO_SIGNATURE )
 
#define GATE_LIBRARY_LIB_CREATE_OBJECT_FUNCTION   gate_lib_create_object
 
#define GATE_LIBRARY_LIB_CREATE_OBJECT_NAME   GATE_MACRO_TO_STRING(GATE_LIBRARY_LIB_CREATE_OBJECT_FUNCTION)
 
#define GATE_LIBRARY_LIB_CREATE_OBJECT_SIGNATURE   char const* class_id, void* parameter, gate_object_t** ptr_to_ptrobject
 
#define GATE_LIBARRY_LIB_CREATE_OBJECT_PROTOTYPE   GATE_LIBRARY_LIB_RESULT GATE_LIBRARY_LIB_CREATE_OBJECT_FUNCTION ( GATE_LIBRARY_LIB_CREATE_OBJECT_SIGNATURE )
 

Typedefs

typedef void * gate_library_t
 gate_library_t shared library handle
 
typedef int(* gate_library_function_t) (int)
 gate_library_function_t generic C function used as default datatype for all library functions
 
typedef GATE_LIBRARY_LIB_RESULT(* gate_lib_init_t) (GATE_LIBRARY_LIB_INIT_SIGNATURE)
 
typedef GATE_LIBRARY_LIB_RESULT(* gate_lib_uninit_t) (GATE_LIBRARY_LIB_UNINIT_SIGNATURE)
 
typedef GATE_LIBRARY_LIB_RESULT(* gate_lib_get_info_t) (GATE_LIBRARY_LIB_GET_INFO_SIGNATURE)
 
typedef GATE_LIBRARY_LIB_RESULT(* gate_lib_create_object_t) (GATE_LIBRARY_LIB_CREATE_OBJECT_SIGNATURE)
 

Functions

GATE_CORE_API gate_result_t gate_library_open (gate_string_t const *path, gate_library_t *lib, gate_uint32_t flags)
 Opens a shared library (DLL or SO) and generates a library handle.
 
GATE_CORE_API gate_result_t gate_library_close (gate_library_t lib)
 
GATE_CORE_API gate_result_t gate_library_get_function (gate_library_t lib, gate_string_t const *entryname, gate_library_function_t *ptr_func)
 Loads a function by its name and returns a pointer to it.
 
GATE_CORE_API gate_result_t gate_library_get_data (gate_library_t lib, gate_string_t const *entryname, void **ptr_data)
 Loads a data value by its name and returns a pointer to it.
 
GATE_CORE_API gate_result_t gate_library_get_function_name (gate_library_t lib, char const *funcname, void *ptr_func)
 Loads a function by its c-string name and returns a pointer to it.
 
GATE_CORE_API gate_result_t gate_library_get_data_name (gate_library_t lib, char const *entryname, void *ptr_data)
 Loads a data value by its c-string name and returns a pointer to it.
 

Detailed Description

Controls access to shared libraries (DLL or SO)

Function Documentation

◆ gate_library_close()

GATE_CORE_API gate_result_t gate_library_close ( gate_library_t lib)

Closes an opened library handle

Parameters
libLibrary handle

◆ gate_library_get_data()

GATE_CORE_API gate_result_t gate_library_get_data ( gate_library_t lib,
gate_string_t const * entryname,
void ** ptr_data )

Loads a data value by its name and returns a pointer to it.

Parameters
libLibrary handle
entrynameName of data value to be loaded
ptr_dataPointer to a location where the data pointer is written to
Returns
value GATE_RESULT_* code

◆ gate_library_get_data_name()

GATE_CORE_API gate_result_t gate_library_get_data_name ( gate_library_t lib,
char const * entryname,
void * ptr_data )

Loads a data value by its c-string name and returns a pointer to it.

Parameters
libLibrary handle
entrynameName of data value to be loaded
ptr_dataPointer to a location where the data pointer is written to
Returns
value GATE_RESULT_* code

◆ gate_library_get_function()

GATE_CORE_API gate_result_t gate_library_get_function ( gate_library_t lib,
gate_string_t const * entryname,
gate_library_function_t * ptr_func )

Loads a function by its name and returns a pointer to it.

Parameters
libLibrary handle
entrynameName of function to be loaded
ptr_funcPointer to a location where the function pointer is written to
Returns
value GATE_RESULT_* code

◆ gate_library_get_function_name()

GATE_CORE_API gate_result_t gate_library_get_function_name ( gate_library_t lib,
char const * funcname,
void * ptr_func )

Loads a function by its c-string name and returns a pointer to it.

Parameters
libLibrary handle
funcnameName of function to be loaded
ptr_funcPointer to a location where the function pointer is written to
Returns
value GATE_RESULT_* code

◆ gate_library_open()

GATE_CORE_API gate_result_t gate_library_open ( gate_string_t const * path,
gate_library_t * lib,
gate_uint32_t flags )

Opens a shared library (DLL or SO) and generates a library handle.

Parameters
pathFile path of library to be opened
libpointer to library handle that receives the result
flagsOpening flag to change library behavior
Returns
value GATE_RESULT_* code