示例#1
0
static int64_t _find_config_int64(const struct config_node *cn1,
				  const struct config_node *cn2,
				  const char *path, int64_t fail)
{
	const struct config_node *n = _find_first_config_node(cn1, cn2, path);

	if (n && n->v && n->v->type == CFG_INT) {
		log_very_verbose("Setting %s to %" PRId64, path, n->v->v.i);
		return n->v->v.i;
	}

	log_very_verbose("%s not found in config: defaulting to %" PRId64,
			 path, fail);
	return fail;
}
示例#2
0
static const char *_find_config_str(const struct config_node *cn1,
				    const struct config_node *cn2,
				    const char *path, const char *fail)
{
	const struct config_node *n = _find_first_config_node(cn1, cn2, path);

	/* Empty strings are ignored */
	if ((n && n->v && n->v->type == CFG_STRING) && (*n->v->v.str)) {
		log_very_verbose("Setting %s to %s", path, n->v->v.str);
		return n->v->v.str;
	}

	if (fail)
		log_very_verbose("%s not found in config: defaulting to %s",
				 path, fail);
	return fail;
}
示例#3
0
static float _find_config_float(const struct config_node *cn1,
				const struct config_node *cn2,
				const char *path, float fail)
{
	const struct config_node *n = _find_first_config_node(cn1, cn2, path);

	if (n && n->v && n->v->type == CFG_FLOAT) {
		log_very_verbose("Setting %s to %f", path, n->v->v.r);
		return n->v->v.r;
	}

	log_very_verbose("%s not found in config: defaulting to %f",
			 path, fail);

	return fail;

}
示例#4
0
static int _find_config_bool(const struct config_node *cn1,
			     const struct config_node *cn2,
			     const char *path, int fail)
{
	const struct config_node *n = _find_first_config_node(cn1, cn2, path);
	const struct config_value *v;

	if (!n)
		return fail;

	v = n->v;

	switch (v->type) {
	case CFG_INT:
		return v->v.i ? 1 : 0;

	case CFG_STRING:
		return _str_to_bool(v->v.str, fail);
	}

	return fail;
}
示例#5
0
const struct config_node *find_config_tree_node(struct cmd_context *cmd,
					  const char *path)
{
	return _find_first_config_node(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path);
}
示例#6
0
const struct dm_config_node *dm_config_tree_find_node(const struct dm_config_tree *cft,
						      const char *path)
{
	return _find_first_config_node(cft, path);
}