summaryrefslogtreecommitdiffstats
path: root/src/ffi.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@pep-project.org>2017-12-06 11:51:42 +0100
committerJustus Winter <justus@pep-project.org>2017-12-06 11:53:01 +0100
commitb0fd3726cf4bc9cfd1651d36a624103e65f3f3e3 (patch)
treefd537a0bbf97ee00cc473d33ea8a0bcf27e52899 /src/ffi.rs
parent1c98b651ed00e4638be31206f790f06a4fb5c8af (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.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ffi.rs b/src/ffi.rs
index 55911b45..303a0380 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -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());