summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2014-07-07 10:57:25 -0300
committerRenato Botelho <garga@FreeBSD.org>2014-07-07 10:57:25 -0300
commitff23363dc688b8e9cb96d229121d74943bda4e97 (patch)
treee9b19d380319908db0ead6429715ebd1824386fe /etc
parentaae16684726cefc43d3863aecd58a1037a900fa3 (diff)
downloadpfsense-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')
-rw-r--r--etc/inc/util.inc16
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
OpenPOWER on IntegriCloud