Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix update time settings, fixes #2895
  • Loading branch information
perexg committed May 26, 2015
1 parent 8e733a2 commit f8f6235
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
20 changes: 13 additions & 7 deletions src/htsmsg.c
Expand Up @@ -402,6 +402,18 @@ htsmsg_field_get_s64
*
*/

int
bool_check(const char *str)
{
if (str &&
(!strcmp(str, "yes") ||
!strcmp(str, "true") ||
!strcmp(str, "on") ||
!strcmp(str, "1")))
return 1;
return 0;
}

int
htsmsg_field_get_bool
( htsmsg_field_t *f, int *boolp )
Expand All @@ -410,13 +422,7 @@ htsmsg_field_get_bool
default:
return HTSMSG_ERR_CONVERSION_IMPOSSIBLE;
case HMF_STR:
if (!strcmp(f->hmf_str, "yes") ||
!strcmp(f->hmf_str, "true") ||
!strcmp(f->hmf_str, "on") ||
!strcmp(f->hmf_str, "1"))
*boolp = 1;
else
*boolp = 0;
*boolp = bool_check(f->hmf_str);
break;
case HMF_S64:
*boolp = f->hmf_s64 ? 1 : 0;
Expand Down
2 changes: 2 additions & 0 deletions src/htsmsg.h
Expand Up @@ -231,6 +231,8 @@ int htsmsg_field_get_s64(htsmsg_field_t *f, int64_t *s64p);
*/
int64_t htsmsg_get_s64_or_default(htsmsg_t *msg, const char *name, int64_t def);

int bool_check(const char *str);

int htsmsg_field_get_bool(htsmsg_field_t *f, int *boolp);

int htsmsg_get_bool(htsmsg_t *msg, const char *name, int *boolp);
Expand Down
4 changes: 2 additions & 2 deletions src/webui/extjs.c
Expand Up @@ -518,9 +518,9 @@ extjs_config(http_connection_t *hc, const char *remain, void *opaque)

/* Time */
str = http_arg_get(&hc->hc_req_args, "tvhtime_update_enabled");
tvhtime_set_update_enabled(!!str);
tvhtime_set_update_enabled(bool_check(str));
str = http_arg_get(&hc->hc_req_args, "tvhtime_ntp_enabled");
tvhtime_set_ntp_enabled(!!str);
tvhtime_set_ntp_enabled(bool_check(str));
if ((str = http_arg_get(&hc->hc_req_args, "tvhtime_tolerance")))
tvhtime_set_tolerance(atoi(str));

Expand Down

0 comments on commit f8f6235

Please sign in to comment.