| 1 | |
| 2 |
|
| 3 | |
| 4 | |
| 5 | |
| 6 |
|
| 7 | use crate::{bindings, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
|
| 8 |
|
| 9 | |
| 10 | #[repr(transparent)]
|
| 11 | pub struct SeqFile {
|
| 12 | inner: Opaque<bindings::seq_file>,
|
| 13 | _not_send: NotThreadSafe,
|
| 14 | }
|
| 15 |
|
| 16 | impl SeqFile {
|
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | pub unsafe fn from_raw<'a>(ptr: *mut bindings::seq_file) -> &'a SeqFile {
|
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | unsafe { &*ptr.cast() }
|
| 30 | }
|
| 31 |
|
| 32 | |
| 33 | #[inline]
|
| 34 | pub fn call_printf(&self, args: fmt::Arguments<'_>) {
|
| 35 | |
| 36 | unsafe {
|
| 37 | bindings::seq_printf(
|
| 38 | self.inner.get(),
|
| 39 | c"%pA".as_char_ptr(),
|
| 40 | core::ptr::from_ref(&args).cast::<crate::ffi::c_void>(),
|
| 41 | );
|
| 42 | }
|
| 43 | }
|
| 44 | }
|
| 45 |
|
| 46 | |
| 47 | #[macro_export]
|
| 48 | macro_rules! seq_print {
|
| 49 | ($m:expr, $($arg:tt)+) => (
|
| 50 | $m.call_printf($crate::prelude::fmt!($($arg)+))
|
| 51 | );
|
| 52 | }
|
| 53 | pub use seq_print;
|