pub mod config_paths;
pub mod environment;
mod environment_impl;
pub mod var;
pub use environment::*;
use fish_widestring::ToCString;
use std::sync::{atomic::AtomicUsize, Mutex};
pub use var::*;
pub const DEFAULT_READ_BYTE_LIMIT: usize = 1024 * 1024 * 1024;
pub static READ_BYTE_LIMIT: AtomicUsize = AtomicUsize::new(DEFAULT_READ_BYTE_LIMIT);
static SETENV_LOCK: Mutex<()> = Mutex::new(());
pub fn setenv_lock<S1: ToCString, S2: ToCString>(name: S1, value: S2, overwrite: bool) {
let name = name.to_cstring();
let value = value.to_cstring();
let _lock = SETENV_LOCK.lock();
unsafe {
libc::setenv(name.as_ptr(), value.as_ptr(), libc::c_int::from(overwrite));
}
}
pub fn unsetenv_lock<S: ToCString>(name: S) {
let name = name.to_cstring();
let _lock = SETENV_LOCK.lock();
unsafe {
libc::unsetenv(name.as_ptr());
}
}