1mod _type;
4pub mod ce;
5mod class;
6mod ex;
7mod function;
8mod globals;
9mod handlers;
10mod ini_entry_def;
11mod linked_list;
12mod module;
13mod streams;
14mod try_catch;
15
16use crate::{
17 error::Result,
18 ffi::{php_printf, sapi_module},
19};
20use std::ffi::CString;
21
22pub use _type::ZendType;
23pub use class::ClassEntry;
24pub use ex::ExecuteData;
25pub use function::Function;
26pub use function::FunctionEntry;
27pub use globals::ExecutorGlobals;
28pub use globals::FileGlobals;
29pub use globals::ProcessGlobals;
30pub use globals::SapiGlobals;
31pub use globals::SapiModule;
32pub use handlers::ZendObjectHandlers;
33pub use ini_entry_def::IniEntryDef;
34pub use linked_list::ZendLinkedList;
35pub use module::ModuleEntry;
36pub use streams::*;
37#[cfg(feature = "embed")]
38pub(crate) use try_catch::panic_wrapper;
39pub use try_catch::{bailout, try_catch, try_catch_first};
40
41const FORMAT_STR: &[u8] = b"%s\0";
43
44pub fn printf(message: &str) -> Result<()> {
57 let message = CString::new(message)?;
58 unsafe {
59 php_printf(FORMAT_STR.as_ptr().cast(), message.as_ptr());
60 };
61 Ok(())
62}
63
64pub fn php_sapi_name() -> String {
66 let c_str = unsafe { std::ffi::CStr::from_ptr(sapi_module.name) };
67 c_str.to_str().expect("Unable to parse CStr").to_string()
68}