2023-04-10 16:54:50 +08:00
|
|
|
use std::ffi::c_char;
|
|
|
|
|
2023-04-08 17:46:47 +08:00
|
|
|
use crate::plugins::PLUGIN_REGISTRAR;
|
|
|
|
|
2023-04-08 18:17:13 +08:00
|
|
|
// API provided by RustDesk.
|
2023-04-10 16:54:50 +08:00
|
|
|
pub type LoadPluginFunc = fn(*const c_char) -> i32;
|
|
|
|
pub type UnloadPluginFunc = fn(*const c_char) -> i32;
|
2023-04-08 17:46:47 +08:00
|
|
|
|
2023-04-08 18:17:13 +08:00
|
|
|
#[repr(C)]
|
2023-04-08 17:46:47 +08:00
|
|
|
pub struct RustDeskApiTable {
|
2023-04-13 02:06:42 +08:00
|
|
|
pub(crate) register_plugin: LoadPluginFunc,
|
|
|
|
pub(crate) unload_plugin: UnloadPluginFunc,
|
2023-04-08 17:46:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2023-04-10 16:54:50 +08:00
|
|
|
fn load_plugin(path: *const c_char) -> i32 {
|
2023-04-08 17:46:47 +08:00
|
|
|
PLUGIN_REGISTRAR.load_plugin(path)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2023-04-10 16:54:50 +08:00
|
|
|
fn unload_plugin(path: *const c_char) -> i32 {
|
2023-04-08 17:46:47 +08:00
|
|
|
PLUGIN_REGISTRAR.unload_plugin(path)
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for RustDeskApiTable {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
register_plugin: load_plugin,
|
|
|
|
unload_plugin: unload_plugin,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|