libubootenv
libuboot.h
1 /*
2  * (C) Copyright 2019
3  * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
4  *
5  * SPDX-License-Identifier: LGPL-2.1-or-later
6  */
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #pragma once
13 
14 struct uboot_ctx;
15 
16 #define DEVNAME_MAX_LENGTH 256
17 
18 #define DEVNAME_SEPARATOR ':'
19 
25  char *devname;
27  long long int offset;
29  size_t envsize;
31  size_t sectorsize;
33  unsigned long envsectors;
34 };
35 
42 int libuboot_read_config(struct uboot_ctx *ctx, const char *config);
43 
50 int libuboot_configure(struct uboot_ctx *ctx,
51  struct uboot_env_device *envdevs);
52 
65 int libuboot_load_file(struct uboot_ctx *ctx, const char *filename);
66 
75 int libuboot_env_store(struct uboot_ctx *ctx);
76 
85 int libuboot_initialize(struct uboot_ctx **out,
86  struct uboot_env_device *envdevs);
87 
92 void libuboot_exit(struct uboot_ctx *ctx);
93 
99 int libuboot_open(struct uboot_ctx *ctx);
100 
110 void libuboot_close(struct uboot_ctx *ctx);
111 
122 int libuboot_set_env(struct uboot_ctx *ctx, const char *varname, const char *value);
123 
135 char *libuboot_get_env(struct uboot_ctx *ctx, const char *varname);
136 
146 void *libuboot_iterator(struct uboot_ctx *ctx, void *next);
147 
153 const char *libuboot_getname(void *entry);
154 
160 const char *libuboot_getvalue(void *entry);
161 
162 #ifdef __cplusplus
163 }
164 #endif
Definition: uboot_private.h:111
Definition: libuboot.h:23
long long int offset
Definition: libuboot.h:27
size_t envsize
Definition: libuboot.h:29
size_t sectorsize
Definition: libuboot.h:31
char * devname
Definition: libuboot.h:25
unsigned long envsectors
Definition: libuboot.h:33
int libuboot_read_config(struct uboot_ctx *ctx, const char *config)
Read U-Boot environment configuration from a file.
Definition: uboot_env.c:1192
const char * libuboot_getname(void *entry)
Accessor to get variable name from DB entry.
Definition: uboot_env.c:1396
int libuboot_set_env(struct uboot_ctx *ctx, const char *varname, const char *value)
Set a variable.
Definition: uboot_env.c:1327
void libuboot_close(struct uboot_ctx *ctx)
Release an environment.
Definition: uboot_env.c:1483
int libuboot_initialize(struct uboot_ctx **out, struct uboot_env_device *envdevs)
Initialize the library.
Definition: uboot_env.c:1453
char * libuboot_get_env(struct uboot_ctx *ctx, const char *varname)
Get a variable.
Definition: uboot_env.c:1384
int libuboot_configure(struct uboot_ctx *ctx, struct uboot_env_device *envdevs)
Read U-Boot environment configuration from structure.
Definition: uboot_env.c:1419
int libuboot_open(struct uboot_ctx *ctx)
Load an environment.
Definition: uboot_env.c:1475
int libuboot_load_file(struct uboot_ctx *ctx, const char *filename)
Import environment from file.
Definition: uboot_env.c:1141
void libuboot_exit(struct uboot_ctx *ctx)
Release all resources and exit the library.
Definition: uboot_env.c:1501
int libuboot_env_store(struct uboot_ctx *ctx)
Flush environment to the storage.
Definition: uboot_env.c:847
void * libuboot_iterator(struct uboot_ctx *ctx, void *next)
Iterator.
Definition: uboot_env.c:1410
const char * libuboot_getvalue(void *entry)
Accessor to get variable value from DB entry.
Definition: uboot_env.c:1403