extern crate libc;
extern crate log;
extern crate libsystemd_sys as ffi;
extern crate mbox;
pub use std::io::{Result, Error};
pub fn ffi_result(ret: ffi::c_int) -> Result<ffi::c_int>
{
if ret < 0 {
Err(Error::from_raw_os_error(-ret))
} else {
Ok(ret)
}
}
#[macro_export]
macro_rules! sd_try {
($e:expr) => ({
try!($crate::ffi_result(unsafe{ $e}))
})
}
#[macro_export]
macro_rules! char_or_null {
($e:expr) => (match $e {
Some(p) => ::std::ffi::CString::new(p.as_bytes()).unwrap()
.as_ptr() as *const ::libc::c_char,
None => ptr::null() as *const ::libc::c_char
})
}
pub mod journal;
#[macro_export]
macro_rules! log_with{
($func:expr, $lvl:expr, $($arg:tt),+) => ({
static LOC: ::log::LogLocation = ::log::LogLocation {
__line: line!(),
__file: file!(),
__module_path: module_path!()
};
let lvl = $lvl;
$func(lvl, &LOC, &format_args!($($arg),+))
})
}
#[macro_export]
macro_rules! sd_journal_log{
($lvl:expr, $($arg:tt)+) => (log_with!(::systemd::journal::log, $lvl, $($arg)+))
}
pub mod daemon;
pub mod id128;
pub mod login;
#[cfg(feature = "bus")]
pub mod bus;