File: none.c

package info (click to toggle)
swupdate 2025.12%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,004 kB
  • sloc: ansic: 66,621; python: 6,291; makefile: 791; sh: 538; javascript: 229
file content (58 lines) | stat: -rw-r--r-- 992 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * (C) Copyright 2017
 * Stefano Babic, stefano.babic@swupdate.org.
 *
 * SPDX-License-Identifier:     GPL-2.0-only
 */

#include <unistd.h>
#include <string.h>
#include "bootloader.h"
#include "swupdate_dict.h"

static struct dict environment;

static int do_env_set(const char *name,
			const char  *value)
{
	dict_set_value(&environment, name, value);

	return 0;
}

static int do_env_unset(const char *name)
{
	dict_remove(&environment, name);

	return 0;
}

static char *do_env_get(const char  *name)
{
	char *value = NULL, *var;

	var = dict_get_value(&environment, name);

	if (var)
		value = strdup(var);

	return value;
}

static int do_apply_list(const char *filename)
{
	return dict_parse_script(&environment, filename);
}

static bootloader none = {
	.env_get = &do_env_get,
	.env_set = &do_env_set,
	.env_unset = &do_env_unset,
	.apply_list = &do_apply_list
};

__attribute__((constructor))
static void none_probe(void)
{
	(void)register_bootloader(BOOTLOADER_NONE, &none);
}