config: introduce strtobool() helper.
This commit is contained in:
parent
e3a53fc8a3
commit
7c0739ad3f
13
minidlna.c
13
minidlna.c
@ -455,6 +455,13 @@ writepidfile(const char *fname, int pid, uid_t uid)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int strtobool(const char *str)
|
||||||
|
{
|
||||||
|
return ((strcasecmp(str, "yes") == 0) ||
|
||||||
|
(strcasecmp(str, "true") == 0) ||
|
||||||
|
(atoi(str) == 1));
|
||||||
|
}
|
||||||
|
|
||||||
/* init phase :
|
/* init phase :
|
||||||
* 1) read configuration file
|
* 1) read configuration file
|
||||||
* 2) read command line arguments
|
* 2) read command line arguments
|
||||||
@ -649,15 +656,15 @@ init(int argc, char **argv)
|
|||||||
log_level = ary_options[i].value;
|
log_level = ary_options[i].value;
|
||||||
break;
|
break;
|
||||||
case UPNPINOTIFY:
|
case UPNPINOTIFY:
|
||||||
if ((strcmp(ary_options[i].value, "yes") != 0) && !atoi(ary_options[i].value))
|
if (!strtobool(ary_options[i].value))
|
||||||
CLEARFLAG(INOTIFY_MASK);
|
CLEARFLAG(INOTIFY_MASK);
|
||||||
break;
|
break;
|
||||||
case ENABLE_TIVO:
|
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);
|
SETFLAG(TIVO_MASK);
|
||||||
break;
|
break;
|
||||||
case ENABLE_DLNA_STRICT:
|
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);
|
SETFLAG(DLNA_STRICT_MASK);
|
||||||
break;
|
break;
|
||||||
case ROOT_CONTAINER:
|
case ROOT_CONTAINER:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user