diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-08-11 22:09:11 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-08-11 22:09:11 +0000 |
commit | 4163894f0011cd4b0b6a27e617ace2c2caa8f2d4 (patch) | |
tree | e6c37b3ab5fb50c671c9c392dc6e964bd31a5f75 /package/jshn/files | |
parent | 6f64e87d8ad1486ff0dfea4908a88b1a9db6cc89 (diff) | |
download | upstream-4163894f0011cd4b0b6a27e617ace2c2caa8f2d4.tar.gz upstream-4163894f0011cd4b0b6a27e617ace2c2caa8f2d4.tar.bz2 upstream-4163894f0011cd4b0b6a27e617ace2c2caa8f2d4.zip |
update libubox and ubus to latest, libubox now includes jshn
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@27963 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/jshn/files')
-rw-r--r-- | package/jshn/files/jshn.sh | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/package/jshn/files/jshn.sh b/package/jshn/files/jshn.sh deleted file mode 100644 index 2dddfe8bf6..0000000000 --- a/package/jshn/files/jshn.sh +++ /dev/null @@ -1,109 +0,0 @@ -[ -z "$N" ] && . /etc/functions.sh - -# functions for parsing and generating json - -json_init() { - [ -n "$JSON_UNSET" ] && eval "unset $JSON_UNSET" - export -- JSON_SEQ=0 JSON_STACK= JSON_CUR="JSON_VAR" JSON_UNSET= -} - -json_add_generic() { - local type="$1" - local var="$2" - local val="$3" - local cur="${4:-$JSON_CUR}" - - export ${NO_EXPORT:+-n} -- "${cur}_$var=$val" - export ${NO_EXPORT:+-n} -- "TYPE_${cur}_$var=$type" - append JSON_UNSET "${cur}_$var TYPE_${cur}_$var" - append "KEYS_${cur}" "$var" -} - -json_add_table() { - JSON_SEQ=$(($JSON_SEQ + 1)) - append JSON_STACK "$JSON_CUR" - local table="JSON_TABLE$JSON_SEQ" - export ${NO_EXPORT:+-n} -- "UP_$table=$JSON_CUR" - JSON_CUR="$table" -} - -json_add_object() { - local cur="$JSON_CUR" - json_add_table - json_add_generic object "$1" "$JSON_CUR" "$cur" -} - -json_close_object() { - local oldstack="$JSON_STACK" - export "KEYS_${JSON_CUR}" - JSON_CUR="${JSON_STACK##* }" - JSON_STACK="${JSON_STACK% *}" - [[ "$oldstack" == "$JSON_STACK" ]] && JSON_STACK= -} - -json_add_array() { - local cur="$JSON_CUR" - json_add_table - json_add_generic array "$1" "$JSON_CUR" "$cur" -} - -json_close_array() { - json_close_object -} - -json_add_string() { - json_add_generic string "$1" "$2" -} - -json_add_int() { - json_add_generic int "$1" "$2" -} - -json_add_boolean() { - json_add_generic boolean "$1" "$2" -} - -# functions read access to json variables - -json_load() { - eval `jshn -r "$1"` -} - -json_dump() { - jshn -w -} - -json_get_type() { - local dest="$1" - local var="$2" - eval "export ${NO_EXPORT:+-n} -- \"$dest=\${TYPE_${JSON_CUR}_$var}\"" -} - -json_get_var() { - local dest="$1" - local var="$2" - eval "export ${NO_EXPORT:+-n} -- \"$dest=\${${JSON_CUR}_$var}\"" -} - -json_select() { - local target="$1" - local type - - [ -z "$1" ] && { - JSON_CUR="JSON_VAR" - return - } - [[ "$1" == ".." ]] && { - eval "JSON_CUR=\"\${UP_$JSON_CUR}\"" - return; - } - json_get_type type "$target" - case "$type" in - object|array) - json_get_var JSON_CUR "$target" - ;; - *) - echo "WARNING: Variable '$target' does not exist or is not an array/object" - ;; - esac -} |