14187
|
1 |
extern crate libloading;
|
|
2 |
|
|
3 |
use libloading::{Library, Symbol};
|
|
4 |
use std::ops::Deref;
|
|
5 |
|
|
6 |
struct EngineInstance {}
|
|
7 |
|
|
8 |
struct Engine<'a> {
|
|
9 |
protocol_version: Symbol<'a, unsafe fn() -> u32>,
|
|
10 |
start_engine: Symbol<'a, unsafe fn() -> *mut EngineInstance>,
|
|
11 |
cleanup: Symbol<'a, unsafe fn(engine_state: *mut EngineInstance)>,
|
|
12 |
}
|
|
13 |
|
|
14 |
fn main() {
|
|
15 |
let hwlib = Library::new("libhedgewars_engine.so").unwrap();
|
|
16 |
|
|
17 |
unsafe {
|
|
18 |
let engine = Engine {
|
|
19 |
protocol_version: hwlib.get(b"protocol_version").unwrap(),
|
|
20 |
start_engine: hwlib.get(b"start_engine").unwrap(),
|
|
21 |
cleanup: hwlib.get(b"cleanup").unwrap(),
|
|
22 |
};
|
|
23 |
|
|
24 |
println!("Hedgewars engine, protocol version {}", engine.protocol_version.deref()());
|
|
25 |
}
|
|
26 |
}
|