Skip to main content

libubootenv_sys/
lib.rs

1use libc::{c_char, c_int, c_void};
2
3#[repr(C)]
4pub struct uboot_ctx {
5    _private: [u8; 0],
6}
7
8unsafe extern "C" {
9    /// Initialize context using config file (e.g. /etc/fw_env.config)
10    pub fn libuboot_initialize(
11        ctx: *mut *mut uboot_ctx,
12        config: *const c_char,
13    ) -> c_int;
14
15    /// Free context
16    pub fn libuboot_exit(ctx: *mut uboot_ctx);
17
18    /// Get variable value
19    pub fn libuboot_get_env(
20        ctx: *mut uboot_ctx,
21        name: *const c_char,
22    ) -> *const c_char;
23
24    /// Set variable value (not persisted until save)
25    pub fn libuboot_set_env(
26        ctx: *mut uboot_ctx,
27        name: *const c_char,
28        value: *const c_char,
29    ) -> c_int;
30
31    /// Persist changes to storage
32    pub fn libuboot_save(ctx: *mut uboot_ctx) -> c_int;
33
34    /// Delete variable
35    pub fn libuboot_del_env(
36        ctx: *mut uboot_ctx,
37        name: *const c_char,
38    ) -> c_int;
39
40    /// Returns next variable as "key=value". Pass prev=NULL for first call.
41    pub fn libuboot_get_next(
42        ctx: *mut uboot_ctx,
43        prev: *mut *mut i8,
44    ) -> *mut i8;
45}