+/*
+ * Validate a uci name
+ */
+static bool
+rpc_uci_verify_str(const char *name, bool extended, bool type)
+{
+ const char *c;
+ char *e;
+
+ if (!name || !*name)
+ return false;
+
+ if (extended && *name != '@')
+ extended = false;
+
+ for (c = name + extended; *c; c++)
+ if (!isalnum(*c) && *c != '_' && ((!type && !extended) || *c != '-'))
+ break;
+
+ if (extended) {
+ if (*c != '[')
+ return false;
+
+ strtol(++c, &e, 10);
+
+ return (e > c && *e == ']' && *(e+1) == 0);
+ }
+
+ return (*c == 0);
+}
+
+/*
+ * Check that string is a valid, shell compatible uci name
+ */
+static bool rpc_uci_verify_name(const char *name) {
+ return rpc_uci_verify_str(name, false, false);
+}
+
+/*
+ * Check that string is a valid section type name
+ */
+static bool rpc_uci_verify_type(const char *type) {
+ return rpc_uci_verify_str(type, false, true);
+}
+
+/*
+ * Check that the string is a valid section id, optionally in extended
+ * lookup notation
+ */
+static bool rpc_uci_verify_section(const char *section) {
+ return rpc_uci_verify_str(section, true, false);
+}
+
+