ext_php_rs/
ffi.rs

1//! Raw FFI bindings to the Zend API.
2
3#![allow(clippy::all)]
4#![allow(warnings)]
5
6use std::{ffi::c_void, os::raw::c_char};
7
8pub const ZEND_MM_ALIGNMENT: u32 = 8;
9pub const ZEND_MM_ALIGNMENT_MASK: i32 = -8;
10
11// These are not generated by Bindgen as everything in `bindings.rs` will have
12// the `#[link(name = "php")]` attribute appended. This will cause the wrapper
13// functions to fail to link.
14#[link(name = "wrapper")]
15extern "C" {
16    pub fn ext_php_rs_zend_string_init(
17        str_: *const c_char,
18        len: usize,
19        persistent: bool,
20    ) -> *mut zend_string;
21    pub fn ext_php_rs_zend_string_release(zs: *mut zend_string);
22    pub fn ext_php_rs_is_known_valid_utf8(zs: *const zend_string) -> bool;
23    pub fn ext_php_rs_set_known_valid_utf8(zs: *mut zend_string);
24
25    pub fn ext_php_rs_php_build_id() -> *const c_char;
26    pub fn ext_php_rs_zend_object_alloc(obj_size: usize, ce: *mut zend_class_entry) -> *mut c_void;
27    pub fn ext_php_rs_zend_object_release(obj: *mut zend_object);
28    pub fn ext_php_rs_executor_globals() -> *mut zend_executor_globals;
29    pub fn ext_php_rs_process_globals() -> *mut php_core_globals;
30    pub fn ext_php_rs_sapi_globals() -> *mut sapi_globals_struct;
31    pub fn ext_php_rs_file_globals() -> *mut php_file_globals;
32    pub fn ext_php_rs_sapi_module() -> *mut sapi_module_struct;
33    pub fn ext_php_rs_zend_try_catch(
34        func: unsafe extern "C" fn(*const c_void) -> *const c_void,
35        ctx: *const c_void,
36        result: *mut *mut c_void,
37    ) -> bool;
38
39    pub fn ext_php_rs_zend_first_try_catch(
40        func: unsafe extern "C" fn(*const c_void) -> *const c_void,
41        ctx: *const c_void,
42        result: *mut *mut c_void,
43    ) -> bool;
44
45    pub fn ext_php_rs_zend_bailout() -> !;
46}
47
48include!(concat!(env!("OUT_DIR"), "/bindings.rs"));