diff options
| author | Teddy Wing | 2018-10-20 18:56:39 +0200 |
|---|---|---|
| committer | Teddy Wing | 2018-10-20 18:56:39 +0200 |
| commit | e6b01e84d469fe7d17193e0a03b559a38cc175ee (patch) | |
| tree | cc50e0613ebe152e9c9bf2160a342cbf87fa55bd /src | |
| parent | 2c6c0e13cebe29a56b56522ef9e6f2ccf33011f7 (diff) | |
| download | dome-key-map-e6b01e84d469fe7d17193e0a03b559a38cc175ee.tar.bz2 | |
Add an FFI function to get a `Config` or read if from `config.toml`
Enables us to get a `Config` struct from the config file in the
Objective-C app, which will then be passed to the `parse_args()`
function to be further filled in.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cocoa_bridge.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs index ba7b432..1dbd187 100644 --- a/src/cocoa_bridge.rs +++ b/src/cocoa_bridge.rs @@ -332,6 +332,18 @@ pub extern "C" fn c_parse_args( } #[no_mangle] +pub extern "C" fn config_read_from_file() -> *mut Config { + match config::get_config() { + Ok(config) => Box::into_raw(Box::new(config)), + Err(e) => { + error!("{}", e); + + ptr::null_mut() + }, + } +} + +#[no_mangle] pub extern "C" fn config_free(ptr: *mut Config) { if ptr.is_null() { return } unsafe { Box::from_raw(ptr); } |
