X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fconfigfile.c;h=46624dc96ce6ac7b4bd9b4fa827db014b6e041fa;hb=91c09b4a499872e92c845859b912dcc049fdf712;hp=afc3e479a7d237603d9bb756f5b2262f83ea1adf;hpb=068146351a826b413ea6dedf1c834e31e0ad11f6;p=collectd.git diff --git a/src/configfile.c b/src/configfile.c index afc3e479..46624dc9 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -1,6 +1,6 @@ /** * collectd - src/configfile.c - * Copyright (C) 2005-2009 Florian octo Forster + * Copyright (C) 2005-2010 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -1009,11 +1009,37 @@ int cf_util_get_boolean (const oconfig_item_t *ci, _Bool *ret_bool) /* {{{ */ return (-1); } - *ret_bool = ci->values[0].value.boolean ? true : false; + *ret_bool = ci->values[0].value.boolean ? 1 : 0; return (0); } /* }}} int cf_util_get_boolean */ +int cf_util_get_flag (const oconfig_item_t *ci, /* {{{ */ + unsigned int *ret_value, unsigned int flag) +{ + int status; + _Bool b; + + if (ret_value == NULL) + return (EINVAL); + + b = 0; + status = cf_util_get_boolean (ci, &b); + if (status != 0) + return (status); + + if (b) + { + *ret_value |= flag; + } + else + { + *ret_value &= ~flag; + } + + return (0); +} /* }}} int cf_util_get_flag */ + /* 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. */