1#![allow(clippy::all)]
4#![allow(warnings)]
5
6use std::{ffi::c_void, os::raw::c_char};
7
8pub const ZEND_MM_ALIGNMENT: isize = 8;
9pub const ZEND_MM_ALIGNMENT_MASK: isize = -8;
10
11#[link(name = "wrapper")]
15unsafe extern "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_compiler_globals() -> *mut zend_compiler_globals;
30 pub fn ext_php_rs_process_globals() -> *mut php_core_globals;
31 pub fn ext_php_rs_sapi_globals() -> *mut sapi_globals_struct;
32 pub fn ext_php_rs_file_globals() -> *mut php_file_globals;
33 pub fn ext_php_rs_sapi_module() -> *mut sapi_module_struct;
34 pub fn ext_php_rs_output_activated() -> bool;
35 pub fn ext_php_rs_zend_try_catch(
36 func: unsafe extern "C" fn(*const c_void) -> *const c_void,
37 ctx: *const c_void,
38 result: *mut *mut c_void,
39 ) -> bool;
40
41 pub fn ext_php_rs_zend_first_try_catch(
42 func: unsafe extern "C" fn(*const c_void) -> *const c_void,
43 ctx: *const c_void,
44 result: *mut *mut c_void,
45 ) -> bool;
46
47 pub fn ext_php_rs_zend_bailout() -> !;
48 pub fn ext_php_rs_zend_compile_string(
49 source: *mut zend_string,
50 filename: *const c_char,
51 ) -> *mut zend_op_array;
52 pub fn ext_php_rs_zend_execute(op_array: *mut zend_op_array);
53}
54
55include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
56
57#[cfg(php86)]
58pub use php86::*;
59
60#[cfg(php86)]
61mod php86 {
62 use super::{
63 HashTable, zend_call_known_function_ex, zend_class_entry, zend_function,
64 zend_is_callable_ex, zend_object, zend_string, zval,
65 };
66 use std::ptr;
67
68 pub use super::{
69 zend_result_FAILURE as ZEND_RESULT_CODE_FAILURE,
70 zend_result_SUCCESS as ZEND_RESULT_CODE_SUCCESS,
71 };
72
73 pub const ZEND_INTERNAL_FUNCTION: u32 = 1;
74 pub const ZEND_USER_FUNCTION: u32 = 2;
75 pub const ZEND_EVAL_CODE: u32 = 4;
76
77 pub unsafe fn zend_call_known_function(
78 fn_: *mut zend_function,
79 object: *mut zend_object,
80 called_scope: *mut zend_class_entry,
81 retval_ptr: *mut zval,
82 param_count: u32,
83 params: *mut zval,
84 named_params: *mut HashTable,
85 ) {
86 unsafe {
87 zend_call_known_function_ex(
88 fn_,
89 object,
90 called_scope,
91 retval_ptr,
92 param_count,
93 params,
94 named_params,
95 0,
96 );
97 }
98 }
99
100 pub unsafe fn zend_is_callable(
101 callable: *const zval,
102 check_flags: u32,
103 callable_name: *mut *mut zend_string,
104 ) -> bool {
105 unsafe {
106 zend_is_callable_ex(
107 callable,
108 ptr::null_mut(),
109 check_flags,
110 callable_name,
111 ptr::null_mut(),
112 ptr::null_mut(),
113 )
114 }
115 }
116}