You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
2.8 KiB

//! Loads dynamic object plugins for `rngcli` and loads the correct symbol entry point for adding the plugin.
use super::*;
/// The expected function signatures and ABIs of loader/unloader functions found via symbol lookup.
pub mod signatures {
/// The expected signature of the plugin's loader function symbol.
pub type PluginLoaderFunction = unsafe extern "Rust" fn () -> (); //TODO
/// The expected signature of the plugin's unloader function symbol (if it exists.)
pub type PluginUnloaderFunction = unsafe extern "Rust" fn () -> (); //TODO
#[cfg(feature="plugin-ffi")] pub use super::ffi::signatures::*;
}
/// Contains C-interface symbols and their corresponding signatures.
#[cfg(feature="plugin-ffi")]
mod ffi {
/// The names of various symbols needed for lookups in a C-interface plugin's executable object.
///
/// The means of lookup is via `dlsym()`.
pub mod symbols {
/// The C function symbol name to search for if the Rust one was not found which handles registering the plugin.
///
/// The signature of this function **must** be `ForeignPluginLoaderFunction`.
pub static FFI_PLUGIN_SYMBOL_NAME_ADD: &'static str = "_rngcli_plugin_add_c";
/// The C function symbol name to search for if the Rust one was not found which handles unloading the plugin. It is optional to include this (as the Rust one is too.)
/// The signature of this function **must** be `ForeignPluginUnloaderFunction`.
pub static FFI_PLUGIN_SYMBOL_NAME_REMOVE: &'static str = "_rngcli_plugin_remove_c";
}
/// The expected function signatures of a C-interface plugin's loader/unloader symbols found via symbol lookup.
pub mod signatures {
/// The expected signature of the C-interface plugin's loader function symbol.
pub type ForeignPluginLoaderFunction = unsafe extern "C" fn () -> (); //TODO
/// The expected signature of the C-interface plugin's unloader function symbol (if it exists.)
pub type ForeignPluginUnloaderFunction = unsafe extern "C" fn () -> (); //TODO
}
}
/// The names of various symbols needed for lookups in a plugin's executable object.
///
/// The means of the lookup is via `dlsym()`.
pub mod symbols {
/// The Rust function symbol name (non-mangled) to search for in the plugin executable object which handles registering the plugin.
///
/// The signature of this function **must** be `PluginLoaderFunction`.
pub static RUST_PLUGIN_SYMBOL_NAME_ADD: &'static str = "rngcli_plugin_add";
/// The (optional) Rust function symbol name (non-mangled) to search for in the plugin which is ran when the plugin is unloaded.
///
/// The signature of this function **must** be `PluginUnloaderFunction`.
pub static RUST_PLUGIN_SYMBOL_NAME_REMOVE: &'static str = "rngcli_plugin_remove";
#[cfg(feature="plugin-ffi")] pub use super::ffi::symbols::*;
}
use signatures::*;
//TODO: Figure out what signature to use.