diff options
| -rw-r--r-- | dome_key_map.h | 14 | ||||
| -rw-r--r-- | src/cocoa_bridge.rs | 13 | ||||
| -rw-r--r-- | src/config.rs | 2 | 
3 files changed, 16 insertions, 13 deletions
| diff --git a/dome_key_map.h b/dome_key_map.h index 74369b7..8701b4a 100644 --- a/dome_key_map.h +++ b/dome_key_map.h @@ -20,11 +20,6 @@ typedef enum {  typedef struct State State;  typedef struct { -  const HeadphoneButton *buttons; -  size_t length; -} Trigger; - -typedef struct {    bool reload;    bool daemon;  } Args; @@ -33,12 +28,17 @@ typedef struct {    Args args;  } Config; +typedef struct { +  const HeadphoneButton *buttons; +  size_t length; +} Trigger; + +const Config *c_parse_args(const char *const *args, size_t length); +  void c_run_key_action(State *state, Trigger trigger, const Trigger *mode);  void logger_init(void); -const Config *parse_args(const char *args, size_t length); -  void state_free(State *ptr);  void state_load_map_group(State *ptr); diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs index 529fb5d..2ef4979 100644 --- a/src/cocoa_bridge.rs +++ b/src/cocoa_bridge.rs @@ -299,8 +299,8 @@ fn run_action(map_action: &MapAction) {  // }  #[no_mangle] -pub extern "C" fn parse_args( -    args: *const c_char, +pub extern "C" fn c_parse_args( +    args: *const *const c_char,      length: size_t,  ) -> *const Config {      let args = unsafe { @@ -310,10 +310,13 @@ pub extern "C" fn parse_args(          args              .iter() -            .map(|s| -                CStr::from_ptr(s) +            .map(|s| { +                assert!(!s.is_null()); + +                CStr::from_ptr(*s)                      .to_string_lossy() -                    .into_owned()) +                    .into_owned() +            })              .collect::<Vec<String>>()      }; diff --git a/src/config.rs b/src/config.rs index b7b09ab..6ee2d17 100644 --- a/src/config.rs +++ b/src/config.rs @@ -25,7 +25,7 @@ pub fn parse_args(args: &[String]) -> Config {      opts.optflag("r", "reload-mappings", "reload the mappings file");      opts.optflag("h", "help", "print this help menu"); -    let matches = match opts.parse(args) { +    let matches = match opts.parse(&args[1..]) {          Ok(m) => m,          Err(e) => panic!(e),      }; | 
