1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Raw FFI bindings to the Zend API.

#![allow(clippy::all)]
#![allow(warnings)]

use std::{ffi::c_void, os::raw::c_char};

pub const ZEND_MM_ALIGNMENT: u32 = 8;
pub const ZEND_MM_ALIGNMENT_MASK: i32 = -8;

// These are not generated by Bindgen as everything in `bindings.rs` will have
// the `#[link(name = "php")]` attribute appended. This will cause the wrapper
// functions to fail to link.
#[link(name = "wrapper")]
extern "C" {
    pub fn ext_php_rs_zend_string_init(
        str_: *const c_char,
        len: usize,
        persistent: bool,
    ) -> *mut zend_string;
    pub fn ext_php_rs_zend_string_release(zs: *mut zend_string);
    pub fn ext_php_rs_is_known_valid_utf8(zs: *const zend_string) -> bool;
    pub fn ext_php_rs_set_known_valid_utf8(zs: *mut zend_string);

    pub fn ext_php_rs_php_build_id() -> *const c_char;
    pub fn ext_php_rs_zend_object_alloc(obj_size: usize, ce: *mut zend_class_entry) -> *mut c_void;
    pub fn ext_php_rs_zend_object_release(obj: *mut zend_object);
    pub fn ext_php_rs_executor_globals() -> *mut zend_executor_globals;
    pub fn ext_php_rs_process_globals() -> *mut php_core_globals;
    pub fn ext_php_rs_sapi_globals() -> *mut sapi_globals_struct;
    pub fn ext_php_rs_file_globals() -> *mut php_file_globals;
    pub fn ext_php_rs_sapi_module() -> *mut sapi_module_struct;
    pub fn ext_php_rs_zend_try_catch(
        func: unsafe extern "C" fn(*const c_void) -> *const c_void,
        ctx: *const c_void,
        result: *mut *mut c_void,
    ) -> bool;

    pub fn ext_php_rs_zend_first_try_catch(
        func: unsafe extern "C" fn(*const c_void) -> *const c_void,
        ctx: *const c_void,
        result: *mut *mut c_void,
    ) -> bool;

    pub fn ext_php_rs_zend_bailout() -> !;
}

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));