freecwmp
[Top] [All Lists]

[PATCH] simplify function configuration

To: freecwmp@linux-mips.org
Subject: [PATCH] simplify function configuration
From: Luka Perkov <freecwmp@lukaperkov.net>
Date: Mon, 10 Dec 2012 01:56:10 +0100
Cc: jogo@openwrt.org
Mail-followup-to: freecwmp@linux-mips.org, jogo@openwrt.org
Original-recipient: rfc822;freecwmp@linux-mips.org
Sender: freecwmp-bounce@linux-mips.org
User-agent: Mutt/1.5.21 (2010-09-15)
simplify function configuration

Support for get_ and set_ function prototypes only (for now).

Signed-off-by: Luka Perkov <freecwmp@lukaperkov.net>
---
 ext/openwrt/config/freecwmp                  | 29 +++++++++++-----------------
 ext/openwrt/scripts/freecwmp.sh              | 13 +++++++++----
 ext/openwrt/scripts/functions/device_hosts   |  2 ++
 ext/openwrt/scripts/functions/device_ip      |  2 ++
 ext/openwrt/scripts/functions/device_routing |  2 ++
 ext/openwrt/scripts/functions/device_users   |  2 ++
 ext/openwrt/scripts/functions/misc           |  2 ++
 7 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index ba6fbda..a64ee63 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -28,30 +28,23 @@ config scripts
        list location /usr/share/freecwmp/functions/common
        # freecwmp specific functions
        list location /usr/share/freecwmp/functions/device_info
-       list get_value_function get_device_info
-       list set_value_function set_device_info
-       list get_value_function get_device_info_generic
-       list set_value_function set_device_info_generic
+       list function device_info
+       list function device_info_generic
        list location /usr/share/freecwmp/functions/lan_device
-       list get_value_function get_lan_device
-       list set_value_function set_lan_device
+       list function lan_device
        list location /usr/share/freecwmp/functions/management_server
-       list get_value_function get_management_server
-       list set_value_function set_management_server
-       list get_value_function get_management_server_generic
-       list set_value_function set_management_server_generic
+       list function management_server
+       list function management_server_generic
        list location /usr/share/freecwmp/functions/wan_device
-       list get_value_function get_wan_device
-       list set_value_function set_wan_device
+       list function wan_device
        list location /usr/share/freecwmp/functions/misc
-       list get_value_function get_misc
+       list function misc
        list location /usr/share/freecwmp/functions/device_users
-       list get_value_function get_device_users
-       list set_value_function set_device_users
+       list function device_users
        list location /usr/share/freecwmp/functions/device_hosts
-       list get_value_function get_device_hosts
+       list function device_hosts
        list location /usr/share/freecwmp/functions/device_routing
-       list get_value_function get_device_routing
+       list function device_routing
        list location /usr/share/freecwmp/functions/device_ip
-       list get_value_function get_device_ip
+       list function device_ip
 
diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index ccab19f..3d16c4b 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -96,18 +96,23 @@ if [ ${FLAGS_debug} -eq ${FLAGS_TRUE} ]; then
        echo "[debug] started at \"`date`\""
 fi
 
+get_value_functions=""
+set_value_functions=""
+
 load_script() {
        . $1 
 }
 
-get_value_functions=""
-set_value_functions=""
+load_function() {
+       get_value_functions="$get_value_functions get_$1"
+       set_value_functions="$set_value_functions set_$1"
+}
+
 handle_scripts() {
        local section="$1"
        config_get prefix "$section" "prefix"
        config_list_foreach "$section" 'location' load_script
-       config_get get_value_functions "$section" "get_value_function"
-       config_get set_value_functions "$section" "set_value_function"
+       config_list_foreach "$section" 'function' load_function
 }
 
 config_load freecwmp
diff --git a/ext/openwrt/scripts/functions/device_hosts 
b/ext/openwrt/scripts/functions/device_hosts
index 4c3fcd4..542e6e7 100644
--- a/ext/openwrt/scripts/functions/device_hosts
+++ b/ext/openwrt/scripts/functions/device_hosts
@@ -189,3 +189,5 @@ fi
 # TODO: Device.Hosts.Host.{i}.IPv6Address.{i}.IPAddress (no IPv6 support yet)
 
 }
+
+set_device_hosts() { echo -n > /dev/null; }
diff --git a/ext/openwrt/scripts/functions/device_ip 
b/ext/openwrt/scripts/functions/device_ip
index 5915012..af9033f 100644
--- a/ext/openwrt/scripts/functions/device_ip
+++ b/ext/openwrt/scripts/functions/device_ip
@@ -121,3 +121,5 @@ fi
 # TODO: Device.IP.Interface.{i}.Stats.
 
 }
+
+set_device_ip() { echo -n > /dev/null; }
diff --git a/ext/openwrt/scripts/functions/device_routing 
b/ext/openwrt/scripts/functions/device_routing
index 3dfa418..70246fd 100644
--- a/ext/openwrt/scripts/functions/device_routing
+++ b/ext/openwrt/scripts/functions/device_routing
@@ -351,3 +351,5 @@ if [ $rc -eq 0 ]; then
 fi
 
 }
+
+set_device_routing() { echo -n > /dev/null; }
diff --git a/ext/openwrt/scripts/functions/device_users 
b/ext/openwrt/scripts/functions/device_users
index 0d377f7..e4949bd 100644
--- a/ext/openwrt/scripts/functions/device_users
+++ b/ext/openwrt/scripts/functions/device_users
@@ -124,3 +124,5 @@ fi
 
 # TODO: Device.Users.User.{i}.Language (why? look at the get value function 
for this parameter)
 }
+
+set_device_users() { echo -n > /dev/null; }
diff --git a/ext/openwrt/scripts/functions/misc 
b/ext/openwrt/scripts/functions/misc
index 2e0210c..a4df841 100644
--- a/ext/openwrt/scripts/functions/misc
+++ b/ext/openwrt/scripts/functions/misc
@@ -21,3 +21,5 @@ case "$1" in
        ;;
 esac
 }
+
+set_misc() { echo -n > /dev/null; }

<Prev in Thread] Current Thread [Next in Thread>