本文整理汇总了C++中KConfig::create方法的典型用法代码示例。如果您正苦于以下问题:C++ KConfig::create方法的具体用法?C++ KConfig::create怎么用?C++ KConfig::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KConfig
的用法示例。
在下文中一共展示了KConfig::create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
//.........这里部分代码省略.........