10 unstable releases (3 breaking)
0.4.0 | Aug 5, 2024 |
---|---|
0.3.2 | Jul 4, 2024 |
0.2.0 | May 30, 2024 |
0.1.4 | May 30, 2024 |
#10 in #c-str
Used in mailing-list
14KB
mlpa
mlpa is an API library for writing plugins for mailing-list
Examples
A plugin that says hello:
use std::ffi::CStr;
use std::os::raw::c_char;
use mlpa::Plugin;
#[no_mangle]
pub extern "C" fn get_plugin() -> Plugin {
use mlpa::Optional::Some;
Plugin {
message_handler: Some(message_handler),
}
}
extern "C" fn message_handler(message: *const c_char) {
let message = unsafe { CStr::from_ptr(message) };
let message = String::from_utf8_lossy(message.to_bytes()).to_string();
println!("Hello from plugin!");
println!("Message: {message}");
}
to build and use in mailing-list:
- Add to
Cargo.toml
[lib]
crate-type = ["dylib"]
- Build your plugin
- Add to
daemon.toml
plugins = [
"[your plugin]"
]