static inline int ep_parse_param_assign_intfloat(struct effect_parser *ep, struct ep_param *param, bool is_float) { int code; bool is_negative = false; if (!cf_next_valid_token(&ep->cfp)) return PARSE_EOF; if (cf_token_is(&ep->cfp, "-")) { is_negative = true; if (!cf_next_token(&ep->cfp)) return PARSE_EOF; } code = cf_token_is_type(&ep->cfp, CFTOKEN_NUM, "numeric value", ";"); if (code != PARSE_SUCCESS) return code; if (is_float) { float f = (float)os_strtod(ep->cfp.cur_token->str.array); if (is_negative) f = -f; da_push_back_array(param->default_val, &f, sizeof(float)); } else { long l = strtol(ep->cfp.cur_token->str.array, NULL, 10); if (is_negative) l = -l; da_push_back_array(param->default_val, &l, sizeof(long)); } return PARSE_SUCCESS; }
double config_get_default_double(const config_t *config, const char *section, const char *name) { const char *value = config_get_default_string(config, section, name); if (value) return os_strtod(value); return 0.0; }