forked from firmadyne/libnvram
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.c
56 lines (32 loc) · 1.05 KB
/
test.c
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
#include <stdio.h>
#include "nvram.h"
// Prototypes from "alias.c"
char *nvram_nget(const char *fmt, ...);
int nvram_nset(const char *val, const char *fmt, ...);
int foreach_nvram_from(const char *file, void (*fp)(const char *, const char *, void *), void *data);
void test(const char *key, const char*val, void* data) {
printf("%s = %s, %s\n", key, val, (char *) data);
}
int main(int argc, char** argv) {
char buf[256], *ptr;
int tmp;
nvram_init();
nvram_clear();
nvram_set_default();
nvram_getall(buf, 256);
nvram_set("str", "test");
nvram_set_int("int", 2048);
ptr = nvram_get("str");
tmp = nvram_get_int("int");
nvram_commit();
nvram_getall(buf, 256);
nvram_reset();
ptr = nvram_get("is_default");
nvram_close();
nvram_unset("is_default");
ptr = nvram_get("is_default");
nvram_nset("test", "%s_file", "a");
ptr = nvram_nget("%s_file", "a");
foreach_nvram_from("/tmp/test.ini", test, "5");
return 0;
}