aboutsummaryrefslogtreecommitdiff
path: root/plugin.c
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-06-20 08:19:29 +0200
committercbdev <cb@cbcdn.com>2019-06-20 08:19:29 +0200
commite60aa0c5779bce199020236c0ac3a4beace571cb (patch)
tree52b5df2816b944ceeeb6bb2762d6e7bd5cea457b /plugin.c
parent303e464579e2fc9961d4d9f4841e916f9aa8963f (diff)
downloadwebsocksy-e60aa0c5779bce199020236c0ac3a4beace571cb.tar.gz
websocksy-e60aa0c5779bce199020236c0ac3a4beace571cb.tar.bz2
websocksy-e60aa0c5779bce199020236c0ac3a4beace571cb.zip
Implement additional framing functions (Fixes #3)
Diffstat (limited to 'plugin.c')
-rw-r--r--plugin.c14
1 files changed, 14 insertions, 0 deletions
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;