pub struct RtldValue {
pub(crate) main: RtldMain,
pub(crate) ors: Vec<RtldOr>,
}
impl RtldValue {
pub fn new(main: RtldMain) -> Self {
Self {
main,
ors: Vec::new(),
}
}
pub fn with(mut self, or: RtldOr) -> Self {
self.ors.push(or);
self
}
pub fn to_libc(&self) -> ::libc::c_int {
let mut ret = self.main.to_libc();
for or in &self.ors {
ret |= or.to_libc();
}
ret
}
}
pub enum RtldMain {
Lazy,
Now,
}
impl RtldMain {
pub fn to_libc(&self) -> ::libc::c_int {
match *self {
RtldMain::Lazy => ::libc::RTLD_LAZY,
RtldMain::Now => ::libc::RTLD_NOW,
}
}
}
pub enum RtldOr {
Global,
Local,
NoDelete,
NoLoad,
DeepBind,
}
impl RtldOr {
pub fn to_libc(&self) -> ::libc::c_int {
match *self {
RtldOr::Global => ::libc::RTLD_GLOBAL,
RtldOr::Local => ::libc::RTLD_LOCAL,
RtldOr::NoDelete => ::libc::RTLD_NODELETE,
RtldOr::NoLoad => ::libc::RTLD_NOLOAD,
RtldOr::DeepBind => ::libc::RTLD_DEEPBIND,
}
}
}