From e60aa0c5779bce199020236c0ac3a4beace571cb Mon Sep 17 00:00:00 2001 From: cbdev Date: Thu, 20 Jun 2019 08:19:29 +0200 Subject: Implement additional framing functions (Fixes #3) --- plugin.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'plugin.c') diff --git a/plugin.c b/plugin.c index d8500fe..f48707f 100644 --- a/plugin.c +++ b/plugin.c @@ -18,6 +18,7 @@ static char** framing_function_name = NULL; static size_t attached_libraries = 0; static void** attached_library = NULL; +/* Attach a shared object and register it to be unloaded at shutdown */ static void* plugin_attach(char* path){ void* module = dlopen(path, RTLD_NOW); @@ -39,6 +40,12 @@ static void* plugin_attach(char* path){ return module; } +/* + * Try to load all framing plugins by attaching all shared objects in the + * plugin path that + * * are not backend plugins + * * have a filename ending in .so + */ int plugin_framing_load(char* path){ DIR* directory = opendir(path); struct dirent* file = NULL; @@ -74,6 +81,10 @@ int plugin_framing_load(char* path){ return 0; } +/* + * Load an external backend plugin by constructing it's module path and attaching it, + * then try to resolve the required backend symbols + */ int plugin_backend_load(char* path, char* backend_requested, ws_backend* backend){ char plugin_path[MAX_PLUGIN_PATH] = ""; void* handle = NULL; @@ -103,6 +114,7 @@ int plugin_backend_load(char* path, char* backend_requested, ws_backend* backend return 0; } +/* Register a new framing function to the library */ int plugin_register_framing(char* name, ws_framing func){ size_t u; @@ -129,6 +141,7 @@ int plugin_register_framing(char* name, ws_framing func){ return 0; } +/* Query the framing function library */ ws_framing plugin_framing(char* name){ size_t u; @@ -146,6 +159,7 @@ ws_framing plugin_framing(char* name){ return plugin_framing("auto"); } +/* Release all allocated memory, detach all loaded shared objects */ void plugin_cleanup(){ size_t u; -- cgit v1.2.3