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-08 17:46:47 +08:00
|
|
|
pub type LoadPluginFunc = fn(*const i8) -> i32;
|
|
|
|
pub type UnloadPluginFunc = fn(*const i8) -> i32;
|
|
|
|
|
2023-04-08 18:17:13 +08:00
|
|
|
#[repr(C)]
|
2023-04-08 17:46:47 +08:00
|
|
|
pub struct RustDeskApiTable {
|
|
|
|
pub register_plugin: LoadPluginFunc,
|
|
|
|
pub unload_plugin: UnloadPluginFunc,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
fn load_plugin(path: *const i8) -> i32 {
|
|
|
|
PLUGIN_REGISTRAR.load_plugin(path)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
fn unload_plugin(path: *const i8) -> i32 {
|
|
|
|
PLUGIN_REGISTRAR.unload_plugin(path)
|
|
|
|
}
|
|
|
|
|
2023-04-08 18:17:13 +08:00
|
|
|
#[no_mangle]
|
|
|
|
fn get_api_table() -> RustDeskApiTable {
|
|
|
|
RustDeskApiTable::default()
|
|
|
|
}
|
|
|
|
|
2023-04-08 17:46:47 +08:00
|
|
|
impl Default for RustDeskApiTable {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
register_plugin: load_plugin,
|
|
|
|
unload_plugin: unload_plugin,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|