libvlc-sys: declare vsnprintf outside the generated block
vsnprintf is a C-runtime symbol, not a libvlc export, so it has no business sitting in the block of bindings generated from libvlc's headers. It only ended up there because the Windows link workaround needed a declaration. Drop it from the allowlist and declare it by hand in lib.rs.master
parent
7f8a2dd64d
commit
832a715d79
|
|
@ -1611,12 +1611,6 @@ const _: () = {
|
||||||
[::core::mem::offset_of!(libvlc_log_message_t, psz_message) - 32usize];
|
[::core::mem::offset_of!(libvlc_log_message_t, psz_message) - 32usize];
|
||||||
};
|
};
|
||||||
unsafe extern "C" {
|
unsafe extern "C" {
|
||||||
pub fn vsnprintf(
|
|
||||||
__s: *mut libc::c_char,
|
|
||||||
__maxlen: libc::c_ulong,
|
|
||||||
__format: *const libc::c_char,
|
|
||||||
__arg: VaList,
|
|
||||||
) -> libc::c_int;
|
|
||||||
pub fn libvlc_errmsg() -> *const libc::c_char;
|
pub fn libvlc_errmsg() -> *const libc::c_char;
|
||||||
pub fn libvlc_clearerr();
|
pub fn libvlc_clearerr();
|
||||||
pub fn libvlc_vprinterr(
|
pub fn libvlc_vprinterr(
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,14 @@ pub mod valist;
|
||||||
// The bindings are a committed source file, regenerated out of band with
|
// The bindings are a committed source file, regenerated out of band with
|
||||||
// `cargo xtask bindgen`.
|
// `cargo xtask bindgen`.
|
||||||
include!("../bindings.rs");
|
include!("../bindings.rs");
|
||||||
|
|
||||||
|
// `libc` does not expose vsnprintf and libvlc advises to use it to handle logs in the log
|
||||||
|
// callbacks. Expose it for convenience.
|
||||||
|
unsafe extern "C" {
|
||||||
|
pub fn vsnprintf(
|
||||||
|
s: *mut libc::c_char,
|
||||||
|
n: usize,
|
||||||
|
fmt: *const libc::c_char,
|
||||||
|
ap: VaList,
|
||||||
|
) -> libc::c_int;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ unsafe extern "C" fn logging_cb(
|
||||||
let f: &Box<dyn Fn(LogLevel, Log, Cow<str>) + Send + 'static> = ::std::mem::transmute(data);
|
let f: &Box<dyn Fn(LogLevel, Log, Cow<str>) + Send + 'static> = ::std::mem::transmute(data);
|
||||||
let mut buf: [c_char; BUF_SIZE] = [0; BUF_SIZE];
|
let mut buf: [c_char; BUF_SIZE] = [0; BUF_SIZE];
|
||||||
|
|
||||||
sys::vsnprintf(buf.as_mut_ptr(), BUF_SIZE.try_into().unwrap(), fmt, args);
|
sys::vsnprintf(buf.as_mut_ptr(), BUF_SIZE, fmt, args);
|
||||||
|
|
||||||
f((level as u32).into(), Log{ptr: ctx}, from_cstr_ref(buf.as_ptr()).unwrap());
|
f((level as u32).into(), Log{ptr: ctx}, from_cstr_ref(buf.as_ptr()).unwrap());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,6 @@ fn generate_bindings() {
|
||||||
.ctypes_prefix("libc")
|
.ctypes_prefix("libc")
|
||||||
// Allowlist every (lib)vlc symbol.
|
// Allowlist every (lib)vlc symbol.
|
||||||
.allowlist_item("(lib|LIB)?(vlc|VLC)_.*")
|
.allowlist_item("(lib|LIB)?(vlc|VLC)_.*")
|
||||||
// Required by the Windows `legacy_stdio_definitions` link workaround
|
|
||||||
// (see libvlc-sys/build.rs).
|
|
||||||
.allowlist_function("vsnprintf")
|
|
||||||
// libvlc only uses FILE behind a pointer. Map it
|
// libvlc only uses FILE behind a pointer. Map it
|
||||||
// to libc's opaque, per-platform FILE rather than emitting glibc's
|
// to libc's opaque, per-platform FILE rather than emitting glibc's
|
||||||
// plain _IO_FILE, whose baked-in layout breaks non-Linux builds.
|
// plain _IO_FILE, whose baked-in layout breaks non-Linux builds.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue