LibreSplit/include/plugins/plugin_loading.h

52 lines
1.3 KiB
C
Raw Normal View History

#pragma once
#include "include/plugins/plugin_utils.h"
/**
* 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;
/**
* A "plugin init function" type.
*/
typedef int (*plugin_init_fn)(PlugAPI*);
typedef int (*plugin_shutdown_fn)(void);
/**
* Union used to convert between void* and plugin_init_fn
* without violating ISO C standards.
*/
union init_fn_ptr {
void* obj; /*!< Object pointer */
plugin_init_fn fn; /*!< Function pointer */
};
/**
* 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 */
};
void load_plugins(void);
int unload_plugins(void);
int initialize_plugin(const char* path);
int initialize_plugin_registry(void);