From 7c0739ad3f3780ed8ffc630d89c5c2d70855404b Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Wed, 12 Mar 2014 11:32:09 -0700 Subject: [PATCH] config: introduce strtobool() helper. --- minidlna.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/minidlna.c b/minidlna.c index 12b22de..25dbf2d 100644 --- a/minidlna.c +++ b/minidlna.c @@ -455,6 +455,13 @@ writepidfile(const char *fname, int pid, uid_t uid) return ret; } +static int strtobool(const char *str) +{ + return ((strcasecmp(str, "yes") == 0) || + (strcasecmp(str, "true") == 0) || + (atoi(str) == 1)); +} + /* init phase : * 1) read configuration file * 2) read command line arguments @@ -649,15 +656,15 @@ init(int argc, char **argv) log_level = ary_options[i].value; break; case UPNPINOTIFY: - if ((strcmp(ary_options[i].value, "yes") != 0) && !atoi(ary_options[i].value)) + if (!strtobool(ary_options[i].value)) CLEARFLAG(INOTIFY_MASK); break; case ENABLE_TIVO: - if ((strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value)) + if (strtobool(ary_options[i].value)) SETFLAG(TIVO_MASK); break; case ENABLE_DLNA_STRICT: - if ((strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value)) + if (strtobool(ary_options[i].value)) SETFLAG(DLNA_STRICT_MASK); break; case ROOT_CONTAINER: