remove obsolete attribute info
[project/netifd.git] / proto / netifd-proto.sh
1 . /usr/share/libubox/jshn.sh
2
3 proto_config_add_int() {
4 json_add_int "$1" 5
5 }
6
7 proto_config_add_string() {
8 json_add_int "$1" 3
9 }
10
11 proto_config_add_boolean() {
12 json_add_int "$1" 7
13 }
14
15 add_default_handler() {
16 case "$(type $1 2>/dev/null)" in
17 *function*) return;;
18 *) eval "$1() { return; }"
19 esac
20 }
21
22 case "$1" in
23 dump)
24 add_protocol() {
25 immediate=0
26
27 add_default_handler "$1_init_config"
28
29 json_init
30 json_add_string "name" "$1"
31 eval "$1_init"
32 json_add_boolean immediate "$immediate"
33 json_add_object "config"
34 eval "$1_init_config"
35 json_close_object
36 json_dump
37 }
38 ;;
39 *)
40 add_protocol() {
41 return;
42 }
43 ;;
44 esac