-
Notifications
You must be signed in to change notification settings - Fork 364
/
scfg.h
82 lines (69 loc) · 2.34 KB
/
scfg.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef H_SCFG_
#define H_SCFG_
#include "config/config.h"
struct scfg_setting {
/** The name of the setting. */
const char *name;
/** Points to the RAM replica of the setting value. */
void *val;
/**
* Only needed for string settings. Indicates the maximum length this
* setting's value can by.
*/
int max_len;
/** This setting's data data. One of the CONF_[...] constants. */
uint8_t type;
/**
* Whether this setting contains private data. If 1, the value is hidden
* in config dump output.
*/
uint8_t f_private:1;
};
struct scfg_group {
/*** Public */
/** This array must be terminated with an `{ 0 }` entry. */
const struct scfg_setting *settings;
/*** Private */
struct conf_handler handler;
};
/**
* Persists a single setting.
*
* @param group The group that the setting belongs to.
* @param setting The setting to save.
*
* @return 0 on success; SYS_E[...] code on failure.
*/
int scfg_save_setting(const struct scfg_group *group,
const struct scfg_setting *setting);
/**
* Persists the setting with the specified name.
*
* @param group The group that the setting belongs to.
* @param setting_name The name of the setting to save.
*
* @return 0 on success; SYS_E[...] code on failure.
*/
int scfg_save_name(const struct scfg_group *group, const char *setting_name);
/**
* Persists the setting whose value is stored in the specified variable. The
* specified value address should be the same one that was specified in the
* `scfg_setting` definition.
*
* @param group The group that the setting belongs to.
* @param val The address of the setting's value variable.
*
* @return 0 on success; SYS_E[...] code on failure.
*/
int scfg_save_val(const struct scfg_group *group, const void *val);
/**
* Registers a group of configuration settings. The group's public members
* must be populated before this function is called.
*
* @param group The group to register
* @param name The name of the settings group.
*
* @return 0 on success; SYS_E[...] code on failure.
*/
int scfg_register(struct scfg_group *group, char *name);
#endif