projects
/
project
/
uci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
constify
[project/uci.git]
/
uci.h
diff --git
a/uci.h
b/uci.h
index
4855170
..
be816fd
100644
(file)
--- a/
uci.h
+++ b/
uci.h
@@
-15,6
+15,8
@@
#ifndef __LIBUCI_H
#define __LIBUCI_H
#ifndef __LIBUCI_H
#define __LIBUCI_H
+#include "uci_config.h"
+
/*
* you can use these defines to enable debugging behavior for
* apps compiled against libuci:
/*
* you can use these defines to enable debugging behavior for
* apps compiled against libuci:
@@
-24,18
+26,14
@@
*
*/
*
*/
-#ifdef DEBUG_ALL
-#define UCI_DEBUG
-#define UCI_DEBUG_TYPECAST
-#endif
-
#include <stdbool.h>
#include <setjmp.h>
#include <stdio.h>
#define UCI_CONFDIR "/etc/config"
#define UCI_SAVEDIR "/tmp/.uci"
#include <stdbool.h>
#include <setjmp.h>
#include <stdio.h>
#define UCI_CONFDIR "/etc/config"
#define UCI_SAVEDIR "/tmp/.uci"
-#define UCI_FILEMODE 0600
+#define UCI_DIRMODE 0700
+#define UCI_FILEMODE 0600
enum
{
enum
{
@@
-148,7
+146,7
@@
extern int uci_unload(struct uci_context *ctx, struct uci_package *p);
* If section is omitted, then a pointer to the config package is returned
* If option is omitted, then a pointer to the config section is returned
*/
* If section is omitted, then a pointer to the config package is returned
* If option is omitted, then a pointer to the config section is returned
*/
-extern int uci_lookup(struct uci_context *ctx, struct uci_element **res, struct uci_package *package, c
har *section,
char *option);
+extern int uci_lookup(struct uci_context *ctx, struct uci_element **res, struct uci_package *package, c
onst char *section, const
char *option);
/**
* uci_add_section: Add an unnamed section
/**
* uci_add_section: Add an unnamed section
@@
-264,7
+262,7
@@
extern int uci_add_history_path(struct uci_context *ctx, const char *dir);
* @section: section name (optional)
* @option option name (optional)
*/
* @section: section name (optional)
* @option option name (optional)
*/
-extern int uci_revert(struct uci_context *ctx, struct uci_package **p, c
har *section,
char *option);
+extern int uci_revert(struct uci_context *ctx, struct uci_package **p, c
onst char *section, const
char *option);
/**
* uci_parse_argument: parse a shell-style argument, with an arbitrary quoting style
/**
* uci_parse_argument: parse a shell-style argument, with an arbitrary quoting style
@@
-275,6
+273,15
@@
extern int uci_revert(struct uci_context *ctx, struct uci_package **p, char *sec
*/
extern int uci_parse_argument(struct uci_context *ctx, FILE *stream, char **str, char **result);
*/
extern int uci_parse_argument(struct uci_context *ctx, FILE *stream, char **str, char **result);
+/**
+ * uci_set_backend: change the default backend
+ * @ctx: uci context
+ * @name: name of the backend
+ *
+ * The default backend is "file", which uses /etc/config for config storage
+ */
+extern int uci_set_backend(struct uci_context *ctx, const char *name);
+
/* UCI data structures */
enum uci_type {
UCI_TYPE_HISTORY = 0,
/* UCI data structures */
enum uci_type {
UCI_TYPE_HISTORY = 0,
@@
-305,6
+312,10
@@
struct uci_backend
char **(*list_configs)(struct uci_context *ctx);
struct uci_package *(*load)(struct uci_context *ctx, const char *name);
void (*commit)(struct uci_context *ctx, struct uci_package **p, bool overwrite);
char **(*list_configs)(struct uci_context *ctx);
struct uci_package *(*load)(struct uci_context *ctx, const char *name);
void (*commit)(struct uci_context *ctx, struct uci_package **p, bool overwrite);
+
+ /* private: */
+ const void *ptr;
+ void *priv;
};
struct uci_context
};
struct uci_context
@@
-329,7
+340,7
@@
struct uci_context
struct uci_list history_path;
/* private: */
struct uci_list history_path;
/* private: */
- int err
no
;
+ int err;
const char *func;
jmp_buf trap;
bool internal;
const char *func;
jmp_buf trap;
bool internal;
@@
-384,17
+395,6
@@
struct uci_history
char *value;
};
char *value;
};
-#define UCI_BACKEND(_var, _name, ...) \
-struct uci_backend _var = { \
- .e.list = { \
- .next = &_var.e.list, \
- .prev = &_var.e.list, \
- }, \
- .e.name = _name, \
- .e.type = UCI_TYPE_BACKEND, \
- __VA_ARGS__ \
-}
-
/* linked list handling */
#ifndef offsetof
/* linked list handling */
#ifndef offsetof