Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
d1d9042807
WIP 2023-05-26 22:03:12 +02:00
4 changed files with 21 additions and 13 deletions

View file

@ -1,2 +0,0 @@
/target
/Cargo.lock

View file

@ -1,16 +1,26 @@
use std::{
ffi::{c_char, CString},
sync::RwLock,
};
mod stingray_sdk;
use std::ffi::c_char;
use std::ffi::CString;
use stingray_sdk::GetApiFunction;
use stingray_sdk::PluginApi;
use stingray_sdk::PluginApiID;
use crate::stingray_sdk::LoggingApi;
use crate::stingray_sdk::{GetApiFunction, LoggingApi, PluginApi, PluginApiID};
const PLUGIN_NAME: &str = "dt_p2p";
struct Plugin {
log: Option<LoggingApi>,
}
impl Plugin {
pub const fn new() -> Self {
Self { log: None }
}
}
static PLUGIN: RwLock<Plugin> = RwLock::new(Plugin::new());
#[no_mangle]
pub extern "C" fn get_name() -> *const c_char {
let s = CString::new(PLUGIN_NAME).expect("Failed to create CString from plugin name");
@ -21,7 +31,8 @@ pub extern "C" fn get_name() -> *const c_char {
pub extern "C" fn setup_game(get_engine_api: GetApiFunction) {
println!("setup_game");
let log = LoggingApi::get(get_engine_api);
PLUGIN.log = Some(LoggingApi::get(get_engine_api));
let log = PLUGIN.log.as_ref().unwrap();
log.info(
PLUGIN_NAME,

View file

@ -1,2 +0,0 @@
/target
/Cargo.lock

View file

@ -0,0 +1 @@