Returns the numeric version of the uci2 library.
None
None
Numeric version of the uci2 library.
Returns the string version of the uci2 library.
None
None
String version of the uci2 library.
Parses the UCI configuration file and returns the Abstract Syntax Tree (AST) representation of that file.
config
- path to the UCI configuration file.
out
- AST representation of the UCI configuration file.
UE_NONE, UE_INVALID_ARGUMENT, UE_FILE_NOT_FOUND, UE_FILE_IO, UE_PARSER
Removes the UCI configuration file specified by the path in the input parameter.
config
- path to the UCI configuration file.
None
UE_NONE, UE_FILE_NOT_FOUND, UE_FILE_IO
Creates a new AST context with root node only.
None
out
- AST context with root node only.
UE_NONE
Writes the AST representation of the UCI configuration file to the file specified by the path in the input parameter.
-
uci2_ast
- AST representation of the UCI configuration file. -
config
- path to the output UCI configuration file.
None
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_FILE_IO
Releases the memory allocated by the AST context and sets the uci2_ast
to NULL
.
uci2_ast
- AST context.
None
None
uci2_error_e uci2_node_get(uci2_ast_t *uci2_ast, const char *section, const char *option, uci2_node_t **out)
Returns the AST node from the AST context specified by the section name and optionally the option name. If option
parameter is a string then it returns the AST option node, if option
parameter is NULL
then it returns the AST section node.
-
uci2_ast
- AST context. -
section
- UCI section name. -
option
- UCI option name.
out
- AST node.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND
uci2_error_e uci2_node_section_add(uci2_ast_t *uci2_ast, uci2_node_t *parent, const char *type, const char *name, uci2_node_t **out)
Creates a new AST section node specified by the UCI section type and UCI section name and inserts it into the AST context as a child of its parent AST root node.
-
uci2_ast
- AST context. -
parent
- AST root node which is the parent node of theout
node. -
type
- UCI section type. -
name
- UCI section name.
out
- AST section node.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH, UE_NODE_DUPLICATE
uci2_error_e uci2_node_option_add(uci2_ast_t *uci2_ast, uci2_node_t *parent, const char *name, const char *value, uci2_node_t **out)
Creates a new AST option node specified by the UCI option name and UCI option value and inserts it into the AST context as a child of its parent AST section node.
-
uci2_ast
- AST context. -
parent
- AST section node which is the parent node of theout
node. -
name
- UCI option name. -
value
- UCI option value.
out
- AST option node.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH, UE_NODE_DUPLICATE
uci2_error_e uci2_node_list_add(uci2_ast_t *uci2_ast, uci2_node_t *parent, const char *name, uci2_node_t **out)
Creates a new AST list node specified by the UCI list name and inserts it into the AST context as a child of its parent AST section node.
-
uci2_ast
- AST context. -
parent
- AST section node which is the parent node of theout
node. -
name
- UCI list name.
out
- AST list node.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH, UE_NODE_DUPLICATE
uci2_error_e uci2_node_list_element_add(uci2_ast_t *uci2_ast, uci2_node_t *parent, const char *value, uci2_node_t **out)
Creates a new AST list element node specified by the UCI section type and UCI list element value and inserts it into the AST context as a child of its parent AST list node.
-
uci2_ast
- AST context. -
parent
- AST list node which is the parent node of theout
node. -
value
- UCI list element value.
out
- AST list element node.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH
Removes the node by marking its parent as NULL
.
node
- AST node to be removed.
None
None
Creates a new AST node iterator which will iterate over the children of the AST node specified as the input node
parameter.
node
- AST node whose children will be iterated over with theout
iterator.
out
- AST node iterator.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH
Releases the memory allocated by the AST node iterator and sets the node_iterator
to NULL
.
node_iterator
- AST node iterator to be destroyed.
None
None
Returns the next AST node in the iteration.
node_iterator
- AST node iterator.
out
- Next AST node in iteration.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_ITERATOR_END
Returns the AST node type of the node specified as the input node
parameter.
node
- AST node.
out
- AST node type which can be one of the following values:UNT_ROOT, UNT_SECTION, UNT_OPTION, UNT_LIST, UNT_LIST_ELEMENT
.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND
Returns the UCI section type of the node specified as the input node
parameter.
node
- AST section node.
out
- UCI section type.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_ATTRIBUTE_MISSING, UE_NODE_TYPE_MISMATCH
Sets the UCI section type to the node specified as the input node
parameter.
-
node
- AST section node. -
type
- UCI section type.
None
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH
Returns the UCI section name of the node specified as the input node
parameter.
node
- AST section node.
name
- UCI section name.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_ATTRIBUTE_MISSING, UE_NODE_TYPE_MISMATCH
Sets the UCI section name to the node specified as the input node
parameter.
-
node
- AST section node. -
name
- UCI section name.
None
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH, UE_NODE_DUPLICATE
Returns the UCI option name of the node specified as the input node
parameter.
node
- AST option node.
name
- UCI option name.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_ATTRIBUTE_MISSING, UE_NODE_TYPE_MISMATCH
Sets the UCI option name to the node specified as the input node
parameter.
-
node
- AST option node. -
name
- UCI option name.
None
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH, UE_NODE_DUPLICATE
Returns the UCI option value of the node specified as the input node
parameter.
node
- AST option node.
value
- UCI option value.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_ATTRIBUTE_MISSING, UE_NODE_TYPE_MISMATCH
Sets the UCI option value to the node specified as the input node
parameter.
-
node
- AST option node. -
value
- UCI option value.
None
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH
Returns the UCI list name of the node specified as the input node
parameter.
node
- AST list node.
name
- UCI list name.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_ATTRIBUTE_MISSING, UE_NODE_TYPE_MISMATCH
Sets the UCI list name to the node specified as the input node
parameter.
-
node
- AST list node. -
name
- UCI list name.
None
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH, UE_NODE_DUPLICATE
Returns the UCI list element value of the node specified as the input node
parameter.
node
- AST list element node.
value
- UCI list element value.
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_ATTRIBUTE_MISSING, UE_NODE_TYPE_MISMATCH
Sets the UCI list element value to the node specified as the input node
parameter.
-
node
- AST list element node. -
value
- UCI list element value.
None
UE_NONE, UE_INVALID_ARGUMENT, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH
Returns the boolean value of the UCI string representation of the boolean value specified as the input string_value
parameter.
string_value
- UCI string representation of a boolean value.
out
- Boolean value.
UE_NONE, UE_INVALID_ARGUMENT
Returns the string description of the uci2 library error.
error
- uci2 library error which can be one of the following values:UE_NONE, UE_INVALID_ARGUMENT, UE_FILE_NOT_FOUND, UE_FILE_IO, UE_PARSER, UE_NODE_NOT_FOUND, UE_NODE_TYPE_MISMATCH, UE_NODE_ATTRIBUTE_MISSING, UE_NODE_DUPLICATE, UE_ITERATOR_END
.
None
String description of the uci2 library error.
When parsing the UCI configuration file the parser names each unnamed section as @<section_type>[<index>]
where <index>
represents the index of that unnamed section which starts at 0
and increments on each unnamed section with the same section type.
For example, if there is a UCI configuration file with the following content:
config redirect
option src wan
option src_dport 80
option dest lan
option dest_ip 192.168.16.235
option dest_port 80
option proto tcp
config redirect
option src wan
option src_dport 22001
option dest lan
option dest_port 22
option proto tcp
config redirect
option src lan
option src_ip 192.168.45.2
option src_mac 00:11:22:33:44:55
option src_port 1024
option src_dport 80
option dest_ip 194.25.2.129
option dest_port 120
option proto tcp
the sections would be named @redirect[0]
, @redirect[1]
and @redirect[2]
.
If section @redirect[1]
is removed by calling the API call uci2_node_remove
, the remaining sections in the AST will be sections @redirect[0]
and @redirect[2]
as long as the AST is not destroyed.
If the AST with removed section @redirect[1]
is saved to a file that file would have the following content:
config redirect
option src wan
option src_dport 80
option dest lan
option dest_ip 192.168.16.235
option dest_port 80
option proto tcp
config redirect
option src lan
option src_ip 192.168.45.2
option src_mac 00:11:22:33:44:55
option src_port 1024
option src_dport 80
option dest_ip 194.25.2.129
option dest_port 120
option proto tcp
If the file is parsed again by calling the API call uci2_config_parse
the sections would be named @redirect[0]
and @redirect[1]
because that would be the new AST context based on the current content of the UCI configuration file.