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 
9 #pragma once
10 
11 struct uboot_ctx;
12 
13 #define DEVNAME_MAX_LENGTH 40
14 
20  char *devname;
22  long long int offset;
24  size_t envsize;
26  size_t sectorsize;
28  unsigned long envsectors;
29 };
30 
37 int libuboot_read_config(struct uboot_ctx *ctx, const char *config);
38 
45 int libuboot_configure(struct uboot_ctx *ctx,
46  struct uboot_env_device *envdevs);
47 
60 int libuboot_load_file(struct uboot_ctx *ctx, const char *filename);
61 
70 int libuboot_env_store(struct uboot_ctx *ctx);
71 
80 int libuboot_initialize(struct uboot_ctx **out,
81  struct uboot_env_device *envdevs);
82 
87 void libuboot_exit(struct uboot_ctx *ctx);
88 
94 int libuboot_open(struct uboot_ctx *ctx);
95 
105 void libuboot_close(struct uboot_ctx *ctx);
106 
117 int libuboot_set_env(struct uboot_ctx *ctx, const char *varname, const char *value);
118 
130 char *libuboot_get_env(struct uboot_ctx *ctx, const char *varname);
131 
141 void *libuboot_iterator(struct uboot_ctx *ctx, void *next);
142 
148 const char *libuboot_getname(void *entry);
149 
155 const char *libuboot_getvalue(void *entry);
int libuboot_open(struct uboot_ctx *ctx)
Load an environment.
Definition: uboot_env.c:922
int libuboot_set_env(struct uboot_ctx *ctx, const char *varname, const char *value)
Set a variable.
Definition: uboot_env.c:782
long long int offset
Definition: libuboot.h:22
void * libuboot_iterator(struct uboot_ctx *ctx, void *next)
Iterator.
Definition: uboot_env.c:862
const char * libuboot_getname(void *entry)
Accessor to get variable name from DB entry.
Definition: uboot_env.c:848
char * devname
Definition: libuboot.h:20
int libuboot_read_config(struct uboot_ctx *ctx, const char *config)
Read U-Boot environment configuration from a file.
Definition: uboot_env.c:664
char * libuboot_get_env(struct uboot_ctx *ctx, const char *varname)
Get a variable.
Definition: uboot_env.c:836
int libuboot_env_store(struct uboot_ctx *ctx)
Flush environment to the storage.
Definition: uboot_env.c:402
const char * libuboot_getvalue(void *entry)
Accessor to get variable value from DB entry.
Definition: uboot_env.c:855
Definition: uboot_private.h:100
size_t sectorsize
Definition: libuboot.h:26
int libuboot_initialize(struct uboot_ctx **out, struct uboot_env_device *envdevs)
Initialize the library.
Definition: uboot_env.c:900
void libuboot_close(struct uboot_ctx *ctx)
Release an environment.
Definition: uboot_env.c:930
unsigned long envsectors
Definition: libuboot.h:28
void libuboot_exit(struct uboot_ctx *ctx)
Release all resources and exit the library.
Definition: uboot_env.c:947
int libuboot_load_file(struct uboot_ctx *ctx, const char *filename)
Import environment from file.
Definition: uboot_env.c:618
size_t envsize
Definition: libuboot.h:24
int libuboot_configure(struct uboot_ctx *ctx, struct uboot_env_device *envdevs)
Read U-Boot environment configuration from structure.
Definition: uboot_env.c:871
Definition: libuboot.h:18