cleanup, move parse_tuple to libuci, add some input validation
[project/uci.git] / uci.h
diff --git a/uci.h b/uci.h
index 4749985..0cb352d 100644 (file)
--- a/uci.h
+++ b/uci.h
@@ -43,6 +43,7 @@ enum
        UCI_ERR_NOTFOUND,
        UCI_ERR_IO,
        UCI_ERR_PARSE,
+       UCI_ERR_DUPLICATE,
        UCI_ERR_UNKNOWN,
        UCI_ERR_LAST
 };
@@ -59,10 +60,24 @@ struct uci_package;
 struct uci_section;
 struct uci_option;
 struct uci_history;
+struct uci_context;
 struct uci_parse_context;
 
 
 /**
+ * uci_parse_tuple: Parse an uci tuple
+ * @ctx: uci context
+ * @str: input string
+ * @package: output package pointer
+ * @section: output section pointer
+ * @option: output option pointer
+ * @value: output value pointer
+ *
+ * format: <package>[.<section>[.<option>]][=<value>]
+ */
+extern int uci_parse_tuple(struct uci_context *ctx, char *str, char **package, char **section, char **option, char **value);
+
+/**
  * uci_alloc_context: Allocate a new uci context
  */
 extern struct uci_context *uci_alloc_context(void);
@@ -85,10 +100,11 @@ extern void uci_perror(struct uci_context *ctx, const char *str);
  * @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
  */
-extern int uci_import(struct uci_context *ctx, FILE *stream, const char *name, struct uci_package **package);
+extern int uci_import(struct uci_context *ctx, FILE *stream, const char *name, struct uci_package **package, bool single);
 
 /**
  * uci_export: Export one or all uci config packages