summaryrefslogtreecommitdiffstats
path: root/package/swconfig/src
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-01-18 00:38:04 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-01-18 00:38:04 +0000
commit65c8d28d39e590c291f7f40360a9ff2f930925de (patch)
tree4852e7a6d22a337a7c3536452ed2b3a18dcec83c /package/swconfig/src
parent5ab0ca0fd51fd8856f3359956e85178d4c94f5c2 (diff)
swconfig: support providing the switch device name in an option instead of the section name - necessary to support switches that contain characters such as "-"
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19208 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/swconfig/src')
-rw-r--r--package/swconfig/src/uci.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/package/swconfig/src/uci.c b/package/swconfig/src/uci.c
index 2df837d27..e597acebf 100644
--- a/package/swconfig/src/uci.c
+++ b/package/swconfig/src/uci.c
@@ -107,6 +107,7 @@ int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p)
struct uci_element *e;
struct uci_section *s;
struct uci_option *o;
+ struct uci_ptr ptr;
struct switch_val val;
int i;
@@ -114,11 +115,28 @@ int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p)
head = &settings;
uci_foreach_element(&p->sections, e) {
+ struct uci_element *n;
+
s = uci_to_section(e);
if (strcmp(s->type, "switch") != 0)
continue;
+ uci_foreach_element(&s->options, n) {
+ struct uci_option *o = uci_to_option(n);
+
+ if (strcmp(n->name, "name") != 0)
+ continue;
+
+ if (o->type != UCI_TYPE_STRING)
+ continue;
+
+ if (!strcmp(o->v.string, dev->dev_name))
+ goto found;
+
+ break;
+ }
+
if (strcmp(e->name, dev->dev_name) != 0)
continue;