コード例 #1
0
ファイル: config.c プロジェクト: DavidAlphaFox/mongodb
/*
 * __config_getraw --
 *	Given a config parser, find the final value for a given key.
 */
static int
__config_getraw(
    WT_CONFIG *cparser, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value, bool top)
{
	WT_CONFIG sparser;
	WT_CONFIG_ITEM k, v, subk;
	WT_DECL_RET;
	bool found;

	found = false;
	while ((ret = __config_next(cparser, &k, &v)) == 0) {
		if (k.type != WT_CONFIG_ITEM_STRING &&
		    k.type != WT_CONFIG_ITEM_ID)
			continue;
		if (k.len == key->len && strncmp(key->str, k.str, k.len) == 0) {
			*value = v;
			found = true;
		} else if (k.len < key->len && key->str[k.len] == '.' &&
		    strncmp(key->str, k.str, k.len) == 0) {
			subk.str = key->str + k.len + 1;
			subk.len = (key->len - k.len) - 1;
			WT_RET(__wt_config_initn(
			    cparser->session, &sparser, v.str, v.len));
			if ((ret = __config_getraw(
			    &sparser, &subk, value, false)) == 0)
				found = true;
			WT_RET_NOTFOUND_OK(ret);
		}
	}
	WT_RET_NOTFOUND_OK(ret);

	if (!found)
		return (WT_NOTFOUND);
	return (top ? __config_process_value(cparser, value) : 0);
}
コード例 #2
0
ファイル: config.c プロジェクト: ajdavis/mongo
/*
 * __wt_config_get --
 *	Given a NULL-terminated list of configuration strings, find
 *	the final value for a given key.
 */
int
__wt_config_get(WT_SESSION_IMPL *session,
    const char **cfg_arg, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value)
{
	WT_CONFIG cparser;
	WT_DECL_RET;
	const char **cfg;

	if (cfg_arg[0] == NULL)
		return (WT_NOTFOUND);

	/*
	 * Search the strings in reverse order, that way the first hit wins
	 * and we don't search the base set until there's no other choice.
	 */
	for (cfg = cfg_arg; *cfg != NULL; ++cfg)
		;
	do {
		--cfg;

		__wt_config_init(session, &cparser, *cfg);
		if ((ret = __config_getraw(&cparser, key, value, true)) == 0)
			return (0);
		WT_RET_NOTFOUND_OK(ret);
	} while (cfg != cfg_arg);

	return (WT_NOTFOUND);
}
コード例 #3
0
ファイル: config.c プロジェクト: DavidAlphaFox/mongodb
/*
 * __wt_config_subgetraw --
 *	Get the value for a given key from a config string in a WT_CONFIG_ITEM.
 *	This is useful for dealing with nested structs in config strings.
 */
int
__wt_config_subgetraw(WT_SESSION_IMPL *session,
    WT_CONFIG_ITEM *cfg, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value)
{
	WT_CONFIG cparser;

	WT_RET(__wt_config_initn(session, &cparser, cfg->str, cfg->len));
	return (__config_getraw(&cparser, key, value, true));
}
コード例 #4
0
ファイル: config.c プロジェクト: DavidAlphaFox/mongodb
/*
 * __wt_config_getone --
 *	Get the value for a given key from a single config string.
 */
int
__wt_config_getone(WT_SESSION_IMPL *session,
    const char *config, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value)
{
	WT_CONFIG cparser;

	WT_RET(__wt_config_init(session, &cparser, config));
	return (__config_getraw(&cparser, key, value, true));
}
コード例 #5
0
ファイル: config.c プロジェクト: niumowm/wiredtiger
/*
 * __wt_config_getones --
 *	Get the value for a given string key from a single config string.
 */
 int
__wt_config_getones(WT_SESSION_IMPL *session,
    const char *config, const char *key, WT_CONFIG_ITEM *value)
{
	WT_CONFIG cparser;
	WT_CONFIG_ITEM key_item = { key, strlen(key), 0, ITEM_STRING };

	WT_RET(__wt_config_init(session, &cparser, config));
	return (__config_getraw(&cparser, &key_item, value, 1));
}
コード例 #6
0
ファイル: config.c プロジェクト: DavidAlphaFox/mongodb
/*
 * __wt_config_get --
 *	Given a NULL-terminated list of configuration strings, find
 *	the final value for a given key.
 */
int
__wt_config_get(WT_SESSION_IMPL *session,
    const char **cfg, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value)
{
	WT_CONFIG cparser;
	WT_DECL_RET;
	int found;

	for (found = 0; *cfg != NULL; cfg++) {
		WT_RET(__wt_config_init(session, &cparser, *cfg));
		if ((ret = __config_getraw(&cparser, key, value, true)) == 0)
			found = 1;
		else if (ret != WT_NOTFOUND)
			return (ret);
	}

	return (found ? 0 : WT_NOTFOUND);
}