]>
Commit | Line | Data |
---|---|---|
486aef08 MK |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * (C) Copyright 2022 | |
4 | * Max Krummenacher, Toradex | |
5 | * | |
6 | * Snippets taken from tools/env/fw_env.c | |
7 | * | |
8 | * This prints the list of default environment variables as currently | |
9 | * configured. | |
10 | * | |
11 | */ | |
12 | ||
13 | #include <stdio.h> | |
14 | ||
15 | /* Pull in the current config to define the default environment */ | |
16 | #include <linux/kconfig.h> | |
17 | ||
18 | #ifndef __ASSEMBLY__ | |
19 | #define __ASSEMBLY__ /* get only #defines from config.h */ | |
20 | #include <config.h> | |
21 | #undef __ASSEMBLY__ | |
22 | #else | |
23 | #include <config.h> | |
24 | #endif | |
25 | ||
26 | #define DEFAULT_ENV_INSTANCE_STATIC | |
27 | #include <generated/environment.h> | |
28 | #include <env_default.h> | |
29 | ||
30 | int main(void) | |
31 | { | |
32 | char *env, *nxt; | |
33 | ||
34 | for (env = default_environment; *env; env = nxt + 1) { | |
35 | for (nxt = env; *nxt; ++nxt) { | |
36 | if (nxt >= &default_environment[sizeof(default_environment)]) { | |
37 | fprintf(stderr, "## Error: environment not terminated\n"); | |
38 | return -1; | |
39 | } | |
40 | } | |
41 | printf("%s\n", env); | |
42 | } | |
43 | return 0; | |
44 | } |