kdk_conf_get_value3
获取指定配置项的值
Usage
#include <libkyconf.h>
Functions
const char* kdk_conf_get_value (int id, const char * group, const char * key)
获取指定配置项的值
Parameters
id 由kdk_conf_init返回的配置文件句柄
group key所在的组名称
key 配置项名称
Returns
const char* 配置项所拥有的值,若key不存在,则返回一个空字符串
Link with -lkyconf.
Detailed Description
接口的主要功能是获取指定配置项的值
Examples
#include <libkyconf.h>
#include <stdio.h>
#include <string.h>
int main()
{
char **keylist = NULL;
int id = kdk_conf_init("struct.conf");
ASSERT_NOT_NULL(id, -1);
char **grouplist = kdk_conf_list_group(id);
ASSERT_NOT_NULL(grouplist, -1);
char *tmpgroup;
int index = 0;
while ((tmpgroup = grouplist[index]))
{
printf("Group: %s0, tmpgroup);
keylist = kdk_conf_list_key(id, tmpgroup);
ASSERT_NOT_NULL(keylist, -1);
char *tmpkey;
int k_index = 0;
while ((tmpkey = keylist[k_index]))
{
const char *tmpval = kdk_conf_get_value(id, tmpgroup, tmpkey);
printf("%s = %s0, tmpkey , tmpval);
k_index ++;
}
kdk_config_freeall(keylist);
index ++;
}
kdk_conf_destroy(id);
kdk_config_freeall(grouplist);
return 0;
}