struct uci_context *uci_alloc_context(void) | Allocate a new UCI context |
void uci_free_context(struct uci_context *ctx) | Free the allocated UCI context, including all of its data |
void uci_perror(struct uci_context *ctx, const char *str) |
Print the last uci error that occured
@ctx: uci context
@str: string to print before the error message
|
void uci_get_errorstr(struct uci_context *ctx, char **dest, const char *str) |
Get an error string for the last uci error
@ctx: uci context
@dest: target pointer for the string
@str: prefix for the error message
Note: string must be freed by the caller
|
int uci_import(struct uci_context *ctx, FILE *stream, const char *name, struct uci_package **package, bool single) |
Import uci config data from a stream
- @ctx: uci context
- @stream: file stream to import from
- @name: (optional) assume the config has the given name
- @package: (optional) store the last parsed config package in this variable
- @single: ignore the 'package' keyword and parse everything into a single package
The name parameter is for config files that don't explicitly use the 'package <...>' keyword
if 'package' points to a non-null struct pointer, enable delta tracking and merge
|
int uci_export(struct uci_context *ctx, FILE *stream, struct uci_package *package, bool header) |
Export one or all uci config packages
- @ctx: uci context
- @stream: output stream
- @package: (optional) uci config package to export
- @header: include the package header
|
int uci_load(struct uci_context *ctx, const char *name, struct uci_package **package)
| Parse an uci config file and store it in the uci context
- @ctx: uci context
- @name: name of the config file (relative to the config directory)
- @package: store the loaded config package in this variable
|
int uci_unload(struct uci_context *ctx, struct uci_package *p)
| Unload a config file from the uci context
- @ctx: uci context
- @package: pointer to the uci_package struct
|
int uci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *str, bool extended)
| Split an uci tuple string and look up an element tree
- @ctx: uci context (IN)
- @ptr: lookup result struct (OUT)
- @str: uci tuple string to look up (IN)
- @extended: allow extended syntax lookup (IN)
if extended is set to true, uci_lookup_ptr supports the following extended syntax:
Examples:
network.@interface[0].ifname ('ifname' option of the first interface section)
network.@interface[-1] (last interface section)
Note: uci_lookup_ptr will automatically load a config package if necessary
@str must not be constant, as it will be modified and used for the strings inside @ptr, thus it must also be available as long as @ptr is in use.
|
int uci_add_section(struct uci_context *ctx, struct uci_package *p, const char *type, struct uci_section **res)
| Add an unnamed section
- @ctx: uci context
- @p: package to add the section to
- @type: section type
- @res: pointer to store a reference to the new section in
|
int uci_set(struct uci_context *ctx, struct uci_ptr *ptr)
| Set an element's value; create the element if necessary
- @ctx: uci context
- @ptr: uci pointer
The updated/created element is stored in ptr->last |
int uci_add_list(struct uci_context *ctx, struct uci_ptr *ptr)
| Append a string to an element list
- @ctx: uci context
- @ptr: uci pointer (with value)
Note: if the given option already contains a string value, it will be converted to an 1-element-list before appending the next element |
int uci_reorder_section(struct uci_context *ctx, struct uci_section *s, int pos)
| Reposition a section
- @ctx: uci context
- @s: uci section to reposition
- @pos: new position in the section list
|
int uci_rename(struct uci_context *ctx, struct uci_ptr *ptr)
| Rename an element
- @ctx: uci context
- @ptr: uci pointer (with value)
|
int uci_delete(struct uci_context *ctx, struct uci_ptr *ptr)
| Delete a section or option
- @ctx: uci context
- @ptr: uci pointer
|
int uci_save(struct uci_context *ctx, struct uci_package *p)
| save change delta for a package
- @ctx: uci context
- @p: uci_package struct
|
int uci_commit(struct uci_context *ctx, struct uci_package **p, bool overwrite)
| commit changes to a package
- @ctx: uci context
- @p: uci_package struct pointer
- @overwrite: overwrite existing config data and flush delta
Committing may reload the whole uci_package data, the supplied pointer is updated accordingly |
int uci_list_configs(struct uci_context *ctx, char ***list)
| List available uci config files
@ctx: uci context
Caller is responsible for freeing the allocated memory behind list |
int uci_set_savedir(struct uci_context *ctx, const char *dir);
| override the default delta save directory
- @ctx: uci context
- @dir: directory name
|
int uci_add_delta_path(struct uci_context *ctx, const char *dir)
| add a directory to the search path for change delta files
- @ctx: uci context
- @dir: directory name
This function allows you to add directories, which contain 'overlays' for the active config, that will never be committed. |
int uci_revert(struct uci_context *ctx, struct uci_ptr *ptr)
| revert all changes to a config item
- @ctx: uci context
- @ptr: uci pointer
|
int uci_parse_argument(struct uci_context *ctx, FILE *stream, char **str, char **result)
| parse a shell-style argument, with an arbitrary quoting style
- @ctx: uci context
- @stream: input stream
- @str: pointer to the current line (use NULL for parsing the next line)
- @result: pointer for the result
|
int uci_set_backend(struct uci_context *ctx, const char *name)
| change the default backend
- @ctx: uci context
- @name: name of the backend
The default backend is "file", which uses /etc/config for config storage |
bool uci_validate_text(const char *str)
| validate a value string for uci options
@str: value
this function checks whether a given string is acceptable as value for uci options |
int uci_add_hook(struct uci_context *ctx, const struct uci_hook_ops *ops)
| add a uci hook
- @ctx: uci context
- @ops: uci hook ops
NB: allocated and freed by the caller |
int uci_remove_hook(struct uci_context *ctx, const struct uci_hook_ops *ops)
| remove a uci hook
- @ctx: uci context
- @ops: uci hook ops
|
int uci_load_plugin(struct uci_context *ctx, const char *filename)
| load an uci plugin
- @ctx: uci context
- @filename: path to the uci plugin
NB: plugin will be unloaded automatically when the context is freed |
int uci_load_plugins(struct uci_context *ctx, const char *pattern)
| load all uci plugins from a directory
- @ctx: uci context
- @pattern: pattern of uci plugin files (optional)
if pattern is NULL, then uci_load_plugins will call uci_load_plugin for uci_*.so in <prefix>/lib/ |
int uci_parse_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *str)
| parse a uci string into a uci_ptr
- @ctx: uci context
- @ptr: target data structure
- @str: string to parse
str is modified by this function |
int uci_lookup_next(struct uci_context *ctx, struct uci_element **e, struct uci_list *list, const char *name)
| lookup a child element
- @ctx: uci context
- @e: target element pointer
- @list: list of elements
- @name: name of the child element
if parent is NULL, the function looks up the package with the given name |
void uci_parse_section(struct uci_section *s, const struct uci_parse_option *opts,
int n_opts, struct uci_option **tb)
| look up a set of options
- @s: uci section
- @opts: list of options to look up
- @n_opts: number of options to look up
- @tb: array of pointers to found options
|
uint32_t uci_hash_options(struct uci_option **tb, int n_opts)
| build a hash over a list of options
- @tb: list of option pointers
- @n_opts: number of options
|