aboutsummaryrefslogtreecommitdiffstats
path: root/package/system/procd
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2019-01-13 02:14:22 +0800
committerJo-Philipp Wich <jo@mein.io>2019-01-22 09:05:59 +0100
commitd13e86d4c2d4c1c8970a20cc1f3214b266f57ed0 (patch)
tree4873e6e71897ed65034302a8e4ee349cfee69781 /package/system/procd
parent2bf22b1fb725b71ca1ec2656be4b020efcc29289 (diff)
downloadupstream-d13e86d4c2d4c1c8970a20cc1f3214b266f57ed0.tar.gz
upstream-d13e86d4c2d4c1c8970a20cc1f3214b266f57ed0.tar.bz2
upstream-d13e86d4c2d4c1c8970a20cc1f3214b266f57ed0.zip
procd: Add wrapper for uci_validate_section()
This adds a wrapper (uci_load_validate) for uci_validate_section() that allows callers (through a callback function) to access the values set by uci_validate_section(), without having to manually declare a (potentially long) list of local variables. The callback function receives two arguments when called, the config section name and the return value of uci_validate_section(). If no callback function is given, then the wrapper exits with the value returned by uci_validate_section(). This also updates several init scripts to use the new wrapper function. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Diffstat (limited to 'package/system/procd')
-rw-r--r--package/system/procd/files/procd.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh
index 6f16b746ff..72f25fe0c0 100644
--- a/package/system/procd/files/procd.sh
+++ b/package/system/procd/files/procd.sh
@@ -486,6 +486,23 @@ uci_validate_section()
return $_error
}
+uci_load_validate() {
+ local _package="$1"
+ local _type="$2"
+ local _name="$3"
+ local _function="$4"
+ local _option
+ local _result
+ shift; shift; shift; shift
+ for _option in "$@"; do
+ eval "local ${_option%%:*}"
+ done
+ uci_validate_section "$_package" "$_type" "$_name" "$@"
+ _result=$?
+ [ -n "$_function" ] || return $_result
+ eval "$_function \"\$_name\" \"\$_result\""
+}
+
_procd_wrapper \
procd_open_service \
procd_close_service \