Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper to get the sapi name #261

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/zend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ mod ini_entry_def;
mod module;
mod try_catch;

use crate::{error::Result, ffi::php_printf};
use crate::{
error::Result,
ffi::{php_printf, sapi_module},
};
use std::ffi::CString;

pub use _type::ZendType;
Expand Down Expand Up @@ -51,3 +54,9 @@ pub fn printf(message: &str) -> Result<()> {
};
Ok(())
}

/// Get the name of the SAPI module.
pub fn php_sapi_name() -> String {
let c_str = unsafe { std::ffi::CStr::from_ptr(sapi_module.name) };
c_str.to_str().expect("Unable to parse CStr").to_string()
}