Skip to main content

IniEntryDef

Type Alias IniEntryDef 

Source
pub type IniEntryDef = zend_ini_entry_def;
Expand description

A Zend ini entry definition.

Register ini definitions from your module’s startup_function with IniEntryDef::register. The table is borrowed by the engine for the life of the process — PHP 8.5 stores it as zend_ini_entry.def and the CLI SAPI reads def->value for php --ini — so it must be a static, exactly like a C extension’s zend_ini_entry_def[]:

ⓘ
static INI: IniEntryDefs<2> = IniEntryDefs::new([
    IniEntryDef::new(c"my_ext.enabled", c"1", IniEntryPermission::All),
    IniEntryDef::end(),
]);

pub fn startup(_ty: i32, mod_num: i32) -> i32 {
    IniEntryDef::register(INI.as_slice(), mod_num);
    0
}

Aliased Type§

#[repr(C)]
pub struct IniEntryDef { pub name: *const i8, pub on_modify: Option<unsafe extern "C" fn(*mut _zend_ini_entry, *mut _zend_string, *mut c_void, *mut c_void, *mut c_void, i32) -> i32>, pub mh_arg1: *mut c_void, pub mh_arg2: *mut c_void, pub mh_arg3: *mut c_void, pub value: *const i8, pub displayer: Option<unsafe extern "C" fn(*mut _zend_ini_entry, i32)>, pub value_length: u32, pub name_length: u16, pub modifiable: u8, }

Fields§

§name: *const i8§on_modify: Option<unsafe extern "C" fn(*mut _zend_ini_entry, *mut _zend_string, *mut c_void, *mut c_void, *mut c_void, i32) -> i32>§mh_arg1: *mut c_void§mh_arg2: *mut c_void§mh_arg3: *mut c_void§value: *const i8§displayer: Option<unsafe extern "C" fn(*mut _zend_ini_entry, i32)>§value_length: u32§name_length: u16§modifiable: u8

Implementations§

Source§

impl IniEntryDef

Source

pub const fn new( name: &'static CStr, default_value: &'static CStr, permission: IniEntryPermission, ) -> Self

Creates a new ini entry definition.

§Panics
  • If the name is longer than u16::MAX or the value longer than u32::MAX.
Source

pub const fn end() -> Self

Returns an empty ini entry def, signifying the end of a ini list.

Source

pub fn register(entries: &'static [Self], module_number: i32)

Registers a list of ini entries.

entries must be terminated by IniEntryDef::end and must live for the whole process: zend_register_ini_entries_ex interns the names and values, but PHP 8.5 also keeps the table itself as zend_ini_entry.def.

§Panics

If entries is empty or its last element is not IniEntryDef::end.