Skip to content

Commit

Permalink
Update conf.c
Browse files Browse the repository at this point in the history
Comment parse_boolean() and add support for "0" and "1" string values there, for good measure
  • Loading branch information
jimklimov authored and dougnazar committed Sep 9, 2021
1 parent 237b3fb commit 296f9dd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,16 @@ static void ups_update(const char *fn, const char *name, const char *desc)
temp->retain = 1;
}

/* returns 1 if "arg" was usable as a boolean value, 0 if not
* saves converted meaning of "arg" into referenced "result"
*/
static int parse_boolean(char *arg, int *result)
{
if ( (!strcasecmp(arg, "true")) || (!strcasecmp(arg, "on")) || (!strcasecmp(arg, "yes"))) {
if ( (!strcasecmp(arg, "true")) || (!strcasecmp(arg, "on")) || (!strcasecmp(arg, "yes")) || (!strcasecmp(arg, "1"))) {
*result = 1;
return 1;
}
if ( (!strcasecmp(arg, "false")) || (!strcasecmp(arg, "off")) || (!strcasecmp(arg, "no"))) {
if ( (!strcasecmp(arg, "false")) || (!strcasecmp(arg, "off")) || (!strcasecmp(arg, "no")) || (!strcasecmp(arg, "0"))) {
*result = 0;
return 1;
}
Expand Down

0 comments on commit 296f9dd

Please sign in to comment.