2026-03-11 21:03:46 +01:00
|
|
|
#pragma once
|
2026-03-25 21:57:10 +01:00
|
|
|
#include "include/plugins/plugin_utils.h"
|
2026-03-11 21:03:46 +01:00
|
|
|
|
2026-03-15 14:48:54 +01:00
|
|
|
/**
|
|
|
|
|
* A plugin structure, keeps tabs on the handler
|
|
|
|
|
* given by dlopen() and the path
|
|
|
|
|
*/
|
|
|
|
|
typedef struct _Plugin {
|
|
|
|
|
char* path; /*!< Path of the loaded plugin */
|
|
|
|
|
void* handle; /*!< Handle of the .so file, used to dlclose */
|
|
|
|
|
} Plugin;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A plugin registry, used to keep in memory
|
|
|
|
|
* handles to all plugins loaded.
|
|
|
|
|
*/
|
|
|
|
|
typedef struct _PluginRegistry {
|
|
|
|
|
int count; /*!< Number of loaded and active plugins */
|
|
|
|
|
int size; /*!< Size of the plugin registry */
|
|
|
|
|
Plugin* plugins; /*!< Array of Plugin structs with all their handles. */
|
|
|
|
|
} PluginRegistry;
|
|
|
|
|
|
2026-03-12 21:17:56 +01:00
|
|
|
/**
|
|
|
|
|
* A "plugin init function" type.
|
|
|
|
|
*/
|
2026-03-13 23:51:29 +01:00
|
|
|
typedef int (*plugin_init_fn)(PlugAPI*);
|
2026-03-18 20:39:23 +01:00
|
|
|
typedef int (*plugin_shutdown_fn)(void);
|
2026-03-12 21:17:56 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Union used to convert between void* and plugin_init_fn
|
|
|
|
|
* without violating ISO C standards.
|
|
|
|
|
*/
|
2026-03-18 20:39:23 +01:00
|
|
|
union init_fn_ptr {
|
2026-03-15 14:48:54 +01:00
|
|
|
void* obj; /*!< Object pointer */
|
|
|
|
|
plugin_init_fn fn; /*!< Function pointer */
|
2026-03-12 21:17:56 +01:00
|
|
|
};
|
|
|
|
|
|
2026-03-18 20:39:23 +01:00
|
|
|
/**
|
|
|
|
|
* Union used to convert between void* and plugin_shutdown_fn
|
|
|
|
|
* without violating ISO C standards.
|
|
|
|
|
*/
|
|
|
|
|
union shutdown_fn_ptr {
|
|
|
|
|
void* obj; /*!< Object pointer */
|
|
|
|
|
plugin_shutdown_fn fn; /*!< Function pointer */
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-11 21:03:46 +01:00
|
|
|
void load_plugins(void);
|
2026-03-15 14:48:54 +01:00
|
|
|
int unload_plugins(void);
|
2026-03-12 21:17:56 +01:00
|
|
|
|
|
|
|
|
int initialize_plugin(const char* path);
|
2026-03-15 14:48:54 +01:00
|
|
|
int initialize_plugin_registry(void);
|