summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 181a5bd)
raw | patch | inline | side by side (parent: 181a5bd)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 24 Sep 2009 15:38:02 +0000 (17:38 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 24 Sep 2009 15:38:02 +0000 (17:38 +0200) |
src/configfile.c | patch | blob | history | |
src/configfile.h | patch | blob | history |
diff --git a/src/configfile.c b/src/configfile.c
index df04289446ccfba23d598d14e80c29ce5a5fa882..1a957f67463f138c673cc5dd5f23ebcbabffa8c3 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
return (0);
} /* }}} int cf_util_get_string */
+
+/* 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. */
+int cf_util_get_port_number (const oconfig_item_t *ci) /* {{{ */
+{
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
+ {
+ ERROR ("cf_util_get_port_number: The %s plugin requires "
+ "exactly one string argument.", ci->key);
+ return (-1);
+ }
+
+ return (service_name_to_port_number (ci->values[0].value.string));
+} /* }}} int cf_util_get_port_number */
diff --git a/src/configfile.h b/src/configfile.h
index aca58770efbdc9dbd530d06b399fd2d6510158f2..74d074ed2fb746d7b4fe9596e7589532da966799 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 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. */
+int cf_util_get_port_number (const oconfig_item_t *ci);
+
#endif /* defined(CONFIGFILE_H) */