]>
Commit | Line | Data |
---|---|---|
1 | use ffi; | |
2 | ||
3 | use cvt_p; | |
4 | use error::ErrorStack; | |
5 | ||
6 | pub struct ConfMethod(*mut ffi::CONF_METHOD); | |
7 | ||
8 | impl ConfMethod { | |
9 | pub fn default() -> ConfMethod { | |
10 | unsafe { | |
11 | ffi::init(); | |
12 | ConfMethod(ffi::NCONF_default()) | |
13 | } | |
14 | } | |
15 | ||
16 | pub unsafe fn from_ptr(ptr: *mut ffi::CONF_METHOD) -> ConfMethod { | |
17 | ConfMethod(ptr) | |
18 | } | |
19 | ||
20 | pub fn as_ptr(&self) -> *mut ffi::CONF_METHOD { | |
21 | self.0 | |
22 | } | |
23 | } | |
24 | ||
25 | foreign_type! { | |
26 | type CType = ffi::CONF; | |
27 | fn drop = ffi::NCONF_free; | |
28 | ||
29 | pub struct Conf; | |
30 | pub struct ConfRef; | |
31 | } | |
32 | ||
33 | impl Conf { | |
34 | pub fn new(method: ConfMethod) -> Result<Conf, ErrorStack> { | |
35 | unsafe { cvt_p(ffi::NCONF_new(method.as_ptr())).map(Conf) } | |
36 | } | |
37 | } |