plugin_framework, add block input support

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-05-03 22:37:43 +08:00
parent 08446afc53
commit 71d64a2def
6 changed files with 277 additions and 61 deletions

View File

@@ -2,6 +2,7 @@ use hbb_common::{libc, ResultType};
use std::ffi::{c_char, c_void, CStr};
mod callback_msg;
mod callback_ext;
mod config;
pub mod desc;
mod errno;
@@ -50,6 +51,22 @@ fn str_to_cstr_ret(s: &str) -> *const c_char {
}
}
#[inline]
pub fn make_return_code_msg(code: i32, msg: &str) -> *const c_void {
let mut out = code.to_le_bytes().to_vec();
out.extend(msg.as_bytes());
out.push(0);
unsafe {
let r = libc::malloc(out.len()) as *mut c_char;
libc::memcpy(
r as *mut libc::c_void,
out.as_ptr() as *const libc::c_void,
out.len(),
);
r as *const c_void
}
}
#[inline]
fn get_code_msg_from_ret(ret: *const c_void) -> (i32, String) {
assert!(ret.is_null() == false);