diff options
| author | Teddy Wing | 2018-10-27 00:30:59 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-10-27 00:30:59 +0200 | 
| commit | f2f4e4ad357a2bfdffb6ae5e06f2a211f6d6fbdb (patch) | |
| tree | 9515d8de69b27fc96b4fcdc8960ac8a90c9112d6 | |
| parent | 775344e98cb3f88c3c1339bb7bd4998ca6d33b93 (diff) | |
| download | dome-key-map-f2f4e4ad357a2bfdffb6ae5e06f2a211f6d6fbdb.tar.bz2 | |
Make `do_trial()` accessible via FFI
Wrap the function in an `extern "C"` function, make it public, and
export it.
| -rw-r--r-- | dome_key_map.h | 2 | ||||
| -rw-r--r-- | src/cocoa_bridge.rs | 6 | ||||
| -rw-r--r-- | src/trial.rs | 2 | 
3 files changed, 9 insertions, 1 deletions
| diff --git a/dome_key_map.h b/dome_key_map.h index 0d7fdc2..6233be7 100644 --- a/dome_key_map.h +++ b/dome_key_map.h @@ -50,6 +50,8 @@ Config *config_get(void);  extern void dkess_press_key(int16_t key, CGEventFlags modifier_flags); +void do_trial(void); +  void logger_init(void);  void state_free(State *ptr); diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs index cd1dafa..4b1bd0b 100644 --- a/src/cocoa_bridge.rs +++ b/src/cocoa_bridge.rs @@ -15,6 +15,7 @@ use xdg;  use {Action, HeadphoneButton, MapAction, MapGroup, MapKind};  use config::{self, Config}; +use trial;  #[repr(C)]  struct renameMeMapGroup { @@ -352,6 +353,11 @@ pub extern "C" fn config_free(ptr: *mut Config) {      unsafe { CString::from_raw(config.args.license); }  } +#[no_mangle] +pub extern "C" fn do_trial() { +    trial::do_trial(); +} +  mod tests {      use super::*; diff --git a/src/trial.rs b/src/trial.rs index 59ff785..6358f23 100644 --- a/src/trial.rs +++ b/src/trial.rs @@ -19,7 +19,7 @@ const KEY: &'static str = "TODO SECRET";  /// Entry point to the trial handler. Initialises a trial file or reads a  /// timestamp from the existing one. If a trial is ongoing, print the number of  /// days remaining. If expired, exit the program. Print any errors encountered. -fn do_trial() { +pub fn do_trial() {      // Try to read trial start from file      let date = match get_trial_start() {          Ok(date) => date, | 
