diff options
author | Justus Winter <justus@pep-project.org> | 2017-12-06 11:51:42 +0100 |
---|---|---|
committer | Justus Winter <justus@pep-project.org> | 2017-12-06 11:53:01 +0100 |
commit | b0fd3726cf4bc9cfd1651d36a624103e65f3f3e3 (patch) | |
tree | fd537a0bbf97ee00cc473d33ea8a0bcf27e52899 /src/ffi.rs | |
parent | 1c98b651ed00e4638be31206f790f06a4fb5c8af (diff) |
Add 'domain' to the context.
- The domain uniquely identifies the application. It should be a
property of the context.
Diffstat (limited to 'src/ffi.rs')
-rw-r--r-- | src/ffi.rs | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -19,8 +19,12 @@ use super::Context; /// /// Returns `NULL` on errors. #[no_mangle] -pub extern "system" fn sq_context_new(home: *const c_char, +pub extern "system" fn sq_context_new(domain: *const c_char, + home: *const c_char, lib: *const c_char) -> *mut Context { + let domain = unsafe { + if domain.is_null() { None } else { Some(CStr::from_ptr(domain)) } + }; let home = unsafe { if home.is_null() { None } else { Some(CStr::from_ptr(home)) } }; @@ -28,7 +32,11 @@ pub extern "system" fn sq_context_new(home: *const c_char, if lib.is_null() { None } else { Some(CStr::from_ptr(lib)) } }; - let mut pre = Context::new(); + if domain.is_none() { + return ptr::null_mut(); + } + + let mut pre = Context::new(&domain.unwrap().to_string_lossy()); if let Some(home) = home { pre = pre.home(home.to_string_lossy().as_ref()); |