diff options
author | Renato Botelho <garga@FreeBSD.org> | 2014-07-07 10:57:25 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2014-07-07 10:57:25 -0300 |
commit | ff23363dc688b8e9cb96d229121d74943bda4e97 (patch) | |
tree | e9b19d380319908db0ead6429715ebd1824386fe /etc/inc/util.inc | |
parent | aae16684726cefc43d3863aecd58a1037a900fa3 (diff) | |
download | pfsense-ff23363dc688b8e9cb96d229121d74943bda4e97.zip pfsense-ff23363dc688b8e9cb96d229121d74943bda4e97.tar.gz |
Add get_single_sysctl(), a wrapper to get_sysctl() to make it simple to get value of a single sysctl
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r-- | etc/inc/util.inc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 4d52e6c..cf624f6 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -1565,6 +1565,22 @@ function get_sysctl($names) { } /* + * get_single_sysctl($name) + * Wrapper for get_sysctl() to simplify read of a single sysctl value + * return the value for sysctl $name or empty string if it doesn't exist + */ +function get_single_sysctl($name) { + if (empty($name)) + return ""; + + $value = get_sysctl($name); + if (empty($value) || !isset($value[$name])) + return ""; + + return $value[$name]; +} + +/* * set_sysctl($value_list) * Set sysctl OID's listed as key/value pairs and return * an array with keys set for those that succeeded |