本文整理汇总了C++中KConfig::GetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ KConfig::GetValue方法的具体用法?C++ KConfig::GetValue怎么用?C++ KConfig::GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KConfig
的用法示例。
在下文中一共展示了KConfig::GetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_redirect
void create_redirect(KConfig &m_config,vector<REDIRECT> &m_redirect)
{
// char tmp[255],tmp2[255];
const char *value;
// char s_file[255];
// char tmp_port[8];
//config s_config;
REDIRECT redirect;
// conf.redirect=NULL;
int index=0;
//printf("create redirect now\n");
while((value=m_config.GetValue("redirect",index++))){
if(strlen(value)<=0)
break;
memset(&redirect,0,sizeof(redirect));
sscanf(value,"%d_%[^:]:%d_%d",&redirect.src_port,redirect.dest_addr,&redirect.dest_port,&redirect.time_out);
m_redirect.push_back(redirect);
}
}
示例2: do_config
void do_config()
{
char tmp[ITEM_WIDTH+1];
memset(tmp,0,sizeof(tmp));
const char *value;
// config m_config;
sprintf(tmp,"%s%s",conf.path,CONFIG_FILE);
printf("Try to read config file:%s ...\n",tmp);
LoadDefault();
if(m_config.open(tmp)!=1){
printf("File:%s not exist, read default conf...\n",tmp);
if (m_config.create(m_config.GetDefaultKingateConf()) != 1)
{
printf("Read config file:%s error\n",tmp);
exit(0);
}
}
printf("success!!\n");
fflush(stdout);
/*
value=m_config.GetValue("locale");
sprintf(tmp,"%s../etc/kingate_locale.%s",conf.path,value);
if(m_locale.open(tmp)!=1){
printf("Read locale file:%s error\n",tmp);
exit(0);
}
printf("Read config file success.\n");
*/
value=m_config.GetValue("http");
if(value!=NULL && strcasecmp(value,"on")==0)
conf.state[HTTP]=1;
value=m_config.GetValue("ftp");
if(value!=NULL && strcasecmp(value,"on")==0)
conf.state[FTP]=1;
value=m_config.GetValue("telnet");
if(value!=NULL && strcasecmp(value,"on")==0)
conf.state[TELNET]=1;
value=m_config.GetValue("pop3");
if(value!=NULL && strcasecmp(value,"on")==0)
conf.state[POP3]=1;
value=m_config.GetValue("smtp");
if(value!=NULL && strcasecmp(value,"on")==0)
conf.state[SMTP]=1;
value=m_config.GetValue("socks");
if(value!=NULL && strcasecmp(value,"on")==0)
conf.state[SOCKS]=1;
value=m_config.GetValue("mms");
if(value!=NULL && strcasecmp(value,"on")==0)
conf.state[MMS]=1;
value=m_config.GetValue("rtsp");
if(value!=NULL && strcasecmp(value,"on")==0)
conf.state[RTSP]=1;
value=m_config.GetValue("manage");
if(value!=NULL && strcasecmp(value,"on")==0)
conf.state[MANAGE]=1;
if((value=m_config.GetValue("http_port"))==NULL)
conf.port[HTTP]=8082;
else
conf.port[HTTP]=atoi(value);
if((value=m_config.GetValue("ftp_port"))==NULL)
conf.port[FTP]=2121;
else
conf.port[FTP]=atoi(value);
if((value=m_config.GetValue("telnet_port"))==NULL)
conf.port[TELNET]=2323;
else
conf.port[TELNET]=atoi(value);
if((value=m_config.GetValue("pop3_port"))==NULL)
conf.port[POP3]=1100;
else
conf.port[POP3]=atoi(value);
if((value=m_config.GetValue("smtp_port"))==NULL)
conf.port[SMTP]=2525;
else
conf.port[SMTP]=atoi(value);
if((value=m_config.GetValue("socks_port"))==NULL)
conf.port[SOCKS]=1082;
else
conf.port[SOCKS]=atoi(value);
if((value=m_config.GetValue("mms_port"))==NULL)
conf.port[MMS]=1755;
else
conf.port[MMS]=atoi(value);
if((value=m_config.GetValue("rtsp_port"))==NULL)
conf.port[RTSP]=5540;
else
conf.port[RTSP]=atoi(value);
if((value=m_config.GetValue("manage_port"))==NULL)
conf.port[MANAGE]=8880;
else
conf.port[MANAGE]=atoi(value);
if((value=m_config.GetValue("max"))!=NULL)
conf.max=atoi(value);
if((value=m_config.GetValue("max_per_ip"))!=NULL)
conf.max_per_ip=atoi(value);
//.........这里部分代码省略.........
示例3: create_http_redirect
/*
split(value,'_',0,m_smtp->src_ip);
split(value,'_',1,m_smtp->smtp_server);
* /
}
}
*/
void create_http_redirect(KConfig &m_config,vector<http_redirect> &http_redirects)
{
const char *value;
int index=0;
char dst_model[100];
char file_model[100];
char hosts_model[256];
// int proxy_flag=0;
char flags[100];
char *tmp;
char *host;
char *ptr;
short port=0;
http_redirect m_http_redirect;
host_infomation m_hosts;
while((value=m_config.GetValue("http_redirect",index++))){
if(strlen(value)<=0)
break;
memset(&m_http_redirect.dst,0,sizeof(m_http_redirect.dst));
m_http_redirect.file_ext=NULL;
m_http_redirect.file_ext_revers=false;
m_http_redirect.flag=0;
m_http_redirect.hosts.clear();
if(sscanf(value,"%100s%100s%256s%100s",dst_model,file_model,hosts_model,flags)<4){
fprintf(stderr,"http_redirect value %s is error,right format is: dst_model file_model hosts_model proxy_flag.\n",value);
m_config.DelName("http_redirect",index-1);
continue;
}
// printf("dst_model=%s.\n",dst_model);
if(!AddIPModel(dst_model,m_http_redirect.dst)){
m_config.DelName("http_redirect",index-1);
continue;
}
if(strcmp(file_model,"*")!=0){
m_http_redirect.file_ext=strdup(file_model);
}
/*
if(proxy_flag==0)
m_http_redirect.proxy_flag=false;
else
m_http_redirect.proxy_flag=true;
*/
if(strstr(flags,"proxy"))
SET(m_http_redirect.flag,USE_PROXY);
if(strstr(flags,"log"))
SET(m_http_redirect.flag,USE_LOG);
tmp=hosts_model;
// int i=m_http_redirect.hosts.size();
while((host=strtok_r(tmp,"|",&ptr))!=NULL){
tmp=NULL;
memset(&m_hosts,0,sizeof(m_hosts));
m_hosts.port=split_host_port(host,':',sizeof(hosts_model));
m_hosts.ip=ConvertIP(host);
m_http_redirect.hosts.push_back(m_hosts);
}
// i=m_http_redirect.hosts.size();
http_redirects.push_back(m_http_redirect);
}
/*
std::vector<http_redirect>::iterator it;
for(it=conf.m_http_redirects.begin();it!=conf.m_http_redirects.end();it++){
printf("dst=%x,mask=%x,dst_port=%d\n",(*it).dst.ip,(*it).dst.mask,(*it).dst.port);
printf("file_ext=%s\n",(*it).file_ext);
for(int i=0;i<(*it).hosts.size();i++){
printf("host=%x,host port=%d\n",(*it).hosts[i].ip,(*it).hosts[i].port);
}
}
*/
}