[packages] net/nufw: run of autogen.sh needed with recent versions of libtool
[openwrt/svn-archive/archive.git] / net / freeswitch / files / uci / param_from_config.sh
1 #!/bin/sh
2
3 # Copyright (C) 2010 Vertical Communications
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6
7 fs_parse_param_action() {
8 local cfg="$1"
9 local param_file="$2"
10 local param="$3"
11 local param_type="$4"
12 local default="$5"
13 local value
14
15 if [ -z "$default" ]; then
16 config_get value "$cfg" "$(echo $param|tr - _ )"
17 else
18 config_get value "$cfg" "$(echo $param|tr - _ )" "$default"
19 fi
20
21 if [ "$param_type" = "bool" ]; then
22 if [ "$value" = "0" ] || [ "$value" = "false" ] || [ "$value" = "no" ]; then
23 value="false"
24 elif [ "$value" = "1" ] || [ "$value" = "true" ] || [ "$value" = "yes" ]; then
25 value="true"
26 fi
27 fi
28
29 fs_set_param "$param_file" "$param" "$value"
30 }
31
32 fs_to_xml_param_list() {
33 local cfg="$1"
34 local param_list="$2"
35 local param_file="$3"
36 local i=0
37 local param
38 local default
39 local list_item
40 local param_type
41 echo "$param_list" | {
42 local list_item
43 read -t 1 list_item
44 while [ "$list_item" != '[FS-EOF]' ]; do
45 if [ $i -eq 0 ]; then
46 param="$list_item"
47 i=1
48 elif [ $i -eq 1 ]; then
49 param_type="$list_item"
50 i=2
51 else
52 default="$list_item"
53 fs_parse_param_action "$cfg" "$param_file" "$param" "$param_type" "$default"
54 i=0
55 fi
56 read -t 1 list_item
57 done
58 }
59 }