summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c63882d)
raw | patch | inline | side by side (parent: c63882d)
author | Florian Forster <octo@huhu.verplant.org> | |
Tue, 1 Dec 2009 11:07:07 +0000 (12:07 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 1 Dec 2009 11:07:07 +0000 (12:07 +0100) |
src/configfile.c | patch | blob | history | |
src/configfile.h | patch | blob | history |
diff --git a/src/configfile.c b/src/configfile.c
index 1a957f67463f138c673cc5dd5f23ebcbabffa8c3..592ecbf97adec802b425fb7e6d8e8b1223e4ed56 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
return (0);
} /* }}} int cf_util_get_string */
+int cf_util_get_boolean (const oconfig_item_t *ci, _Bool *ret_bool) /* {{{ */
+{
+ if ((ci == NULL) || (ret_bool == NULL))
+ return (EINVAL);
+
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
+ {
+ ERROR ("cf_util_get_boolean: The %s option requires "
+ "exactly one string argument.", ci->key);
+ return (-1);
+ }
+
+ *ret_bool = ci->values[0].value.boolean ? true : false;
+
+ return (0);
+} /* }}} int cf_util_get_boolean */
+
/* Assures that the config option is a string. The string is then converted to
* a port number using `service_name_to_port_number' and returned. Returns the
* port number in the range [1-65535] or less than zero upon failure. */
diff --git a/src/configfile.h b/src/configfile.h
index 74d074ed2fb746d7b4fe9596e7589532da966799..a73def21760f8efbf0a642002c7f8ee5a45aec1d 100644 (file)
--- a/src/configfile.h
+++ b/src/configfile.h
* success. */
int cf_util_get_string (const oconfig_item_t *ci, char **ret_string);
+/* Assures the config option is a boolean and assignes it to `ret_bool'.
+ * Otherwise, `ret_bool' is not changed and non-zero is returned. */
+int cf_util_get_boolean (const oconfig_item_t *ci, _Bool *ret_bool);
+
/* Assures that the config option is a string. The string is then converted to
* a port number using `service_name_to_port_number' and returned. Returns the
* port number in the range [1-65535] or less than zero upon failure. */