1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
use std::os::raw::c_int;

pub use std::io::{Error, Result};

pub fn to_result(result: c_int) -> Result<c_int> {
    if result < 0 {
        return Err(Error::from_raw_os_error(-result));
    }

    Ok(result)
}

#[macro_export]
macro_rules! ffi_try {
    ($e:expr) => {{
        $crate::to_result(unsafe { $e })
    }};
}

pub mod login;