|
struct cnfresult * | create_cnfresult (struct cnfnode *cn, const char *path) |
| Create a cnfresult structure. More...
|
|
void | destroy_cnfresult (struct cnfresult *cr) |
| Free a single cnfresult element. More...
|
|
void | destroy_cnfresult_list (struct cnfresult *cr_list) |
| Free a cnfresult structure list by calling destroy_cnfresult() for all list members. More...
|
|
struct cnfresult * | cnf_find_entry (struct cnfnode *cn_root, const char *path) |
| Find all matching entries in a tree. More...
|
|
struct cnfnode * | cnf_add_branch (struct cnfnode *cn_root, const char *path, int do_merge) |
| Add a branch to a tree. More...
|
|
int | cnf_del_branch (struct cnfnode *cn_root, const char *path, int del_empty) |
| Delete a branch of the tree. More...
|
|
int | cnf_set_entry (struct cnfnode *cn_root, const char *path, const char *val, int do_create) |
| Set the value of a single entry in the tree. More...
|
|
const char * | cnf_get_entry (struct cnfnode *cn_root, const char *path) |
| Get the value of a single entry in the tree. More...
|
|
struct cnfnode * | cnf_get_node (struct cnfnode *cn_root, const char *path) |
| Get a pointer to a single node in the tree. More...
|
|
void | strip_cnftree (struct cnfnode *cn_root) |
| Strip comments and empty lines from the tree. More...
|
|
struct cnfnode* cnf_add_branch |
( |
struct cnfnode * |
cn_root, |
|
|
const char * |
path, |
|
|
int |
do_merge |
|
) |
| |
Add a branch to a tree.
Add a branch to an existing tree of nodes. If part of the tree already exists, and do_merge==1, the remainder will be created. For example, if path is "iface/eth0/address", and "iface/eth0" already exists and do_merge==1, just "address" will be appended to "iface/eth0". If do_merge==0, a whole new subtree, starting with "iface" will be appended.
- Parameters
-
[in] | cn_root | pointer to the root of the tree |
[in] | path | the path to append to |
[in] | do_merge | flag as described above |
- Returns
- pointer to the last newly created node
int cnf_del_branch |
( |
struct cnfnode * |
cn_root, |
|
|
const char * |
path, |
|
|
int |
del_empty |
|
) |
| |
Delete a branch of the tree.
Deletes a subtree pointed to by path. If more than one matching entry exists, the first one will be deleted. If del_empty==1, and by removing the parent tree becomes empty, the parents will be removed recursively. If del_empty==0, an empty subtree may be left behind. In any case, memory of the subtree and deleted parents will be freed.
- Parameters
-
[in] | cn_root | pointer to the root of the tree |
[in] | path | the path of the tree to be deleted |
[in] | del_empty | set to 1 if empty parents shall be removed. |
int cnf_set_entry |
( |
struct cnfnode * |
cn_root, |
|
|
const char * |
path, |
|
|
const char * |
val, |
|
|
int |
do_create |
|
) |
| |
Set the value of a single entry in the tree.
Set the value of an entry pointed to by path. If more than one matching entry exists, the first one will be set. If do_create==1, a new node (or subtree) will be created, if the entry does not exist. if do_create==0, -1 will be returned, and errno will be set to ENOENT.
- Parameters
-
[in] | cn_root | pointer to the root of the tree |
[in] | path | the path of the entry |
[in] | val | the (new) value of the entry |
[in] | do_create | flag as described above |
- Returns
- 0 on success, and -1 on error.