summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2009-09-06 21:40:10 +0200
committerFelix Fietkau <nbd@openwrt.org>2009-09-06 21:40:10 +0200
commit97e71a1c1b0a9d50f2dc334e72c89153f8b87d45 (patch)
treea8b7adb6d2f88b4460e30fda2983cdace1321110
parentc434442c9e5467fa428f888591f238d0d2d0908c (diff)
downloaduci-97e71a1c1b0a9d50f2dc334e72c89153f8b87d45.tar.gz
ucimap: simplify the parse/format callbacks. the data argument now always points to the field in the data structure
-rw-r--r--ucimap-example.c4
-rw-r--r--ucimap.c10
2 files changed, 3 insertions, 11 deletions
diff --git a/ucimap-example.c b/ucimap-example.c
index 9b315d0..e04c66d 100644
--- a/ucimap-example.c
+++ b/ucimap-example.c
@@ -56,7 +56,7 @@ network_parse_ip(void *section, struct uci_optmap *om, union ucimap_data *data,
if (!target)
return -1;
- *data->data = target;
+ data->ptr = target;
for (i = 0; i < 4; i++)
target[i] = (char) tmp[i];
@@ -67,7 +67,7 @@ static int
network_format_ip(void *section, struct uci_optmap *om, union ucimap_data *data, char **str)
{
static char buf[16];
- unsigned char *ip = (unsigned char *) data->data[0];
+ unsigned char *ip = (unsigned char *) data->ptr;
if (ip) {
sprintf(buf, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
diff --git a/ucimap.c b/ucimap.c
index 99b8829..52c920b 100644
--- a/ucimap.c
+++ b/ucimap.c
@@ -404,11 +404,10 @@ ucimap_add_value(union ucimap_data *data, struct uci_optmap *om, struct ucimap_s
ucimap_add_fixup(sd, data, om, str);
return;
case UCIMAP_CUSTOM:
- tdata.s = (char *) data;
break;
}
if (om->parse) {
- if (om->parse(ucimap_section_ptr(sd), om, &tdata, str) < 0)
+ if (om->parse(ucimap_section_ptr(sd), om, data, str) < 0)
return;
if (ucimap_is_custom(om->type) && om->free) {
if (tdata.ptr != data->ptr)
@@ -795,13 +794,6 @@ ucimap_data_to_string(struct ucimap_section_data *sd, struct uci_optmap *om, uni
}
if (om->format) {
- union ucimap_data tdata;
-
- if (ucimap_is_custom(om->type)) {
- tdata.s = (char *)data;
- data = &tdata;
- }
-
if (om->format(ucimap_section_ptr(sd), om, data, &str) < 0)
return NULL;