2023-01-16 22:37:05 +00:00
|
|
|
pub mod format;
|
2023-01-15 21:18:52 +00:00
|
|
|
pub mod gettext;
|
2023-01-15 00:34:49 +00:00
|
|
|
mod wcstoi;
|
|
|
|
|
2023-02-18 01:21:44 +00:00
|
|
|
use std::io::Write;
|
|
|
|
|
2023-01-16 22:37:05 +00:00
|
|
|
pub(crate) use format::printf::sprintf;
|
|
|
|
pub(crate) use gettext::{wgettext, wgettext_fmt};
|
2023-01-15 00:34:49 +00:00
|
|
|
pub use wcstoi::*;
|
2023-02-18 01:21:44 +00:00
|
|
|
|
|
|
|
/// Port of the wide-string wperror from `src/wutil.cpp` but for rust `&str`.
|
|
|
|
pub fn perror(s: &str) {
|
|
|
|
let e = errno::errno().0;
|
|
|
|
let mut stderr = std::io::stderr().lock();
|
|
|
|
if !s.is_empty() {
|
|
|
|
let _ = write!(stderr, "{s}: ");
|
|
|
|
}
|
|
|
|
let slice = unsafe {
|
|
|
|
let msg = libc::strerror(e) as *const u8;
|
|
|
|
let len = libc::strlen(msg as *const _);
|
|
|
|
std::slice::from_raw_parts(msg, len)
|
|
|
|
};
|
|
|
|
let _ = stderr.write_all(slice);
|
|
|
|
let _ = stderr.write_all(b"\n");
|
|
|
|
}
|