summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/networking
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-05-31 19:07:17 +0000
committerdteske <dteske@FreeBSD.org>2013-05-31 19:07:17 +0000
commita0eece46063b1db33804c35b64793e3afc2424c1 (patch)
tree2634f68f77f7c057b30aa67f1c494a01df2e22a7 /usr.sbin/bsdconfig/networking
parent838ba827a2bbb59d8184419cf6632b7afa203afa (diff)
downloadFreeBSD-src-a0eece46063b1db33804c35b64793e3afc2424c1.zip
FreeBSD-src-a0eece46063b1db33804c35b64793e3afc2424c1.tar.gz
Improve portion of the dialog(1) API in dialog.subr responsible for
calculating widget sizes. Instead of forking a sub-shell to calculate the optimum size for a widget, use a byRef style call-out to set variables in the parent namespace. For example, instead of: size=$( f_dialog_buttonbox_size title btitle msg ) $DIALOG --title title --backtitle btitle --msgbox msg $size The new API replaces the above with the following: f_dialog_buttonbox_size height width title btitle msg $DIALOG --title title --backtitle btitle --msgbox msg $height $width This reduces the number of forks, improves performance, and makes the code more readable by revealing the argument-order for widget sizing. It also makes performing minor adjustments to the calculated values easier as you no longer have to split-out the response (which required knowledge of ordering so was counter-intuitive).
Diffstat (limited to 'usr.sbin/bsdconfig/networking')
-rwxr-xr-xusr.sbin/bsdconfig/networking/networking19
-rw-r--r--usr.sbin/bsdconfig/networking/share/device.subr35
-rw-r--r--usr.sbin/bsdconfig/networking/share/resolv.subr19
3 files changed, 41 insertions, 32 deletions
diff --git a/usr.sbin/bsdconfig/networking/networking b/usr.sbin/bsdconfig/networking/networking
index 8c9468d..5f69ccb 100755
--- a/usr.sbin/bsdconfig/networking/networking
+++ b/usr.sbin/bsdconfig/networking/networking
@@ -48,7 +48,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
#
dialog_menu_main()
{
- local menu_list size
+ local menu_list
local hline="$hline_arrows_tab_enter"
menu_list="
@@ -59,12 +59,13 @@ dialog_menu_main()
'4' '$msg_dns_nameservers'
" # END-QUOTE
- size=$( eval f_dialog_menu_size \
- \"\$DIALOG_TITLE\" \
- \"\$DIALOG_BACKTITLE\" \
- \"\" \
- \"\$hline\" \
- $menu_list )
+ local height width rows
+ eval f_dialog_menu_size height width rows \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\" \
+ \"\$hline\" \
+ $menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
@@ -74,7 +75,9 @@ dialog_menu_main()
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
--default-item \"\$DEFAULTITEM_$$\" \
- --menu \"\" $size $menu_list \
+ --menu \"\" \
+ $height $width $rows \
+ $menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr
index b47bfc9..f248c39 100644
--- a/usr.sbin/bsdconfig/networking/share/device.subr
+++ b/usr.sbin/bsdconfig/networking/share/device.subr
@@ -142,14 +142,15 @@ f_dialog_menu_netdev()
#
# Ask user to select an interface
#
- local prompt size
+ local prompt
prompt="$msg_select_network_interface"
- size=$( eval f_dialog_menu_size \
- \"\$DIALOG_TITLE\" \
- \"\$DIALOG_BACKTITLE\" \
- \"\$prompt\" \
- \"\$hline\" \
- $interfaces )
+ local height width rows
+ eval f_dialog_menu_size height width rows \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $interfaces
local dialog_menu
dialog_menu=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
@@ -158,7 +159,8 @@ f_dialog_menu_netdev()
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
--default-item \"\$defaultitem\" \
- --menu \"\$prompt\" $size \
+ --menu \"\$prompt\" \
+ $height $width $rows \
$interfaces \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
@@ -175,7 +177,7 @@ f_dialog_menu_netdev()
f_dialog_menu_netdev_edit()
{
local interface="$1" ipaddr="$2" netmask="$3" options="$4" dhcp="$5"
- local prompt menu_list size
+ local prompt menu_list height width rows
#
# Create a duplicate set of variables for change-tracking...
@@ -216,12 +218,12 @@ f_dialog_menu_netdev_edit()
'4 $msg_netmask' '$netmask'
'5 $msg_options' '$options'
"
- size=$( eval f_dialog_menu_size \
- \"\$DIALOG_TITLE\" \
- \"\$DIALOG_BACKTITLE\" \
- \"\$prompt\" \
- \"\$hline\" \
- $menu_list )
+ eval f_dialog_menu_size height width rows \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
@@ -233,7 +235,8 @@ f_dialog_menu_netdev_edit()
--help-label \"\$msg_help\" \
${USE_XDIALOG:+--help \"\"} \
--default-item \"\$defaultitem\" \
- --menu \"\$prompt\" $size \
+ --menu \"\$prompt\" \
+ $height $width $rows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
diff --git a/usr.sbin/bsdconfig/networking/share/resolv.subr b/usr.sbin/bsdconfig/networking/share/resolv.subr
index c37e719..e439d38 100644
--- a/usr.sbin/bsdconfig/networking/share/resolv.subr
+++ b/usr.sbin/bsdconfig/networking/share/resolv.subr
@@ -393,10 +393,12 @@ f_dialog_input_nameserver()
#
f_dialog_menu_nameservers()
{
+
+ local height width rows
local opt_exit="$msg_return_to_previous_menu"
local opt_add="$msg_add_nameserver"
local hline="$hline_arrows_tab_enter"
- local prompt size defaultitem=
+ local prompt defaultitem=
#
# Loop forever until the user has finished configuring nameservers
@@ -427,12 +429,12 @@ f_dialog_menu_nameservers()
#
# Display configuration-edit menu
#
- size=$( eval f_dialog_menu_size \
- \"\$DIALOG_TITLE\" \
- \"\$DIALOG_BACKTITLE\" \
- \"\$prompt\" \
- \"\$hline\" \
- $menu_list )
+ eval f_dialog_menu_size height width rows \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
@@ -441,7 +443,8 @@ f_dialog_menu_nameservers()
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
--default-item \"\$defaultitem\" \
- --menu \"\$prompt\" $size \
+ --menu \"\$prompt\" \
+ $height $width $rows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
OpenPOWER on IntegriCloud