本文整理汇总了C++中CIniParser::GetVar方法的典型用法代码示例。如果您正苦于以下问题:C++ CIniParser::GetVar方法的具体用法?C++ CIniParser::GetVar怎么用?C++ CIniParser::GetVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIniParser
的用法示例。
在下文中一共展示了CIniParser::GetVar方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadSpecificCmds
//Specific Read Cmds for Gateway Caching
bool GatewayConfig::ReadSpecificCmds()
{
m_oSpecificReadCmds.clear();
// **********************CIniParser************************//
CIniParser specificCmdsConfig;
CIniParser::valuesList readSpecificCmds;
if (!specificCmdsConfig.Load(FILE_PATH_CONFIGINI))
{
LOG("------- NO CONFIG.INI FILE -------");
return false;
}
if (!specificCmdsConfig.GetVar("WH_GATEWAY", "READ_SPECIFIC_CMDS", &readSpecificCmds))
{
return false;
}
CIniParser::valuesList::iterator it = readSpecificCmds.begin();
for (; it != readSpecificCmds.end(); it++)
{
CHartCmdWrapper::Ptr cmdTemp(new CHartCmdWrapper);
cmdTemp->LoadRaw((*it), 0, NULL, 0);
m_oSpecificReadCmds.push_back(cmdTemp);
LOG("ReadSpecificCmds: vmdId=%d", (*it));
}
return 1;
}
示例2: BurstSpecificCmds
// Specific Burst cmds for Gateway Caching
bool GatewayConfig::BurstSpecificCmds()
{
m_oSpecificBurstCmds.clear();
CIniParser specificCmdsConfig;
CIniParser::valuesList burstSpecificCmds;
if (!specificCmdsConfig.Load(FILE_PATH_CONFIGINI))
{
LOG("------- NO CONFIG.INI FILE -------");
return 0;
}
if (!specificCmdsConfig.GetVar("WH_GATEWAY", "BURST_SPECIFIC_CMDS", &burstSpecificCmds))
{
return 0;
}
CIniParser::valuesList::iterator it = burstSpecificCmds.begin();
for (; it != burstSpecificCmds.end(); it++)
{
CHartCmdWrapper::Ptr cmdTemp(new CHartCmdWrapper);
cmdTemp->LoadRaw((*it), 0, NULL, 0);
m_oSpecificBurstCmds.push_back(cmdTemp);
}
return 1;
}
示例3: Init
int CDiscoveryApp::Init( const char * p_szInterface )
{
char szBuffer[ 64 ];
sprintf( szBuffer, "/tmp/%s.log", p_szInterface);
if( !CApp::Init( szBuffer ) )
{
LOG("CApp::Init(%s) return 0", szBuffer);
return 0;
}
if( !m_stCfg.Init( "GLOBAL") )
{
LOG("m_stCfg.Init(\"GLOBAL\") return 0");
return 0;
}
//read ETH_NAME
CIniParser configParser;
if(!configParser.Load(RC_NET_INFO) || configParser.GetVar((const char*)NULL, "ETH_NAME", m_szEthInterf, sizeof(m_szEthInterf), 0, false) == 0)
{
strcpy(m_szEthInterf, "eth0");
}
snprintf(m_szEthInterf_0, READ_BUF_SIZE, "%s:0", m_szEthInterf);
snprintf(m_szEthInterf_1, READ_BUF_SIZE, "%s:1", m_szEthInterf);
srand(time(NULL));
LOG( "Init DONE");
return 1; //all went OK
}
示例4: LoadPidList
int CWatchdogMngr::LoadPidList()
{
CIniParser oIniParser;
if ( !oIniParser.Load(m_pPidListFile) )
{
throw CWatchdog::exception::exception("Unable to load pidListFile") ;
}
LOG("Loaded pidListFile [%s]", m_pPidListFile);
char* currentPidList[WTD_PIDLIST_ENTRIES]={0,};
size_t currentPidListLen=0;
char pidFile[256];
for ( unsigned pos=0
; oIniParser.GetVar("WTD", "watch", pidFile, sizeof(pidFile), pos)
&& currentPidListLen < WTD_PIDLIST_ENTRIES
; ++pos )
{
void*key=pidFile;
void *el=lfind( &key,currentPidList,¤tPidListLen,sizeof(currentPidList[0]),qsortcmp ) ;
if ( NULL == el )
{
currentPidList[currentPidListLen] = strdup(pidFile);
LOG( WTD"fw.cfg:[%s]", currentPidList[currentPidListLen] );
++currentPidListLen ;
}
}
qsort( currentPidList, currentPidListLen, sizeof(currentPidList[0]), qsortcmp );
/// Check if any pidFile from m_ppPidList is missing from currentPidList.
for ( unsigned j=0; j < m_nPidListLength && m_ppPidList[j]; ++j )
{
void *el=bsearch( &m_ppPidList[j], currentPidList, currentPidListLen, sizeof(currentPidList[0]), qsortcmp) ;
if ( NULL == el )
{
LOG( WTD "STOP watching pid[%s]", m_ppPidList[j]);
systemf_to( 20, "log2flash 'WTD: STOP watching pid[%s]'&", m_ppPidList[j]);
}
}
/// Free the old list to prepare the copy of the new one.
clearPidList() ;
m_nPidListLength=currentPidListLen ;
m_ppPidList[m_nPidListLength] = 0;
LOG( WTD"WATCH:%d modules", m_nPidListLength );
if ( !m_nPidListLength )
{
return true ;
}
memmove(m_ppPidList, currentPidList, WTD_PIDLIST_ENTRIES*sizeof(currentPidList[0]) );
for ( unsigned j = 0; j< m_nPidListLength ; j++)
{
LOG( WTD "WATCH:[%s]", m_ppPidList[j]);
}
return true ;
}
示例5: LoadConfig
int CWatchdogMngr::LoadConfig( )
{
char wtd[16]={0} ;
int divisor ;
CIniParser oIniParser;
if ( !oIniParser.Load(INI_FILE) )
throw CWatchdog::exception::exception("Unable to parse IniFile") ;
oIniParser.GetVar("GLOBAL","MODULES_WATCH_DOG", wtd, sizeof(wtd) ) ;
if( wtd[0]=='n' || wtd[0]=='N'
|| wtd[0]=='f' || wtd[0]=='F'
|| wtd[0]=='0'
)
{
if ( m_status&CFG_ENABLED )
{
m_status&=~CFG_ENABLED ;
LOG("Disabling watchdog");
}
}
else if ( ! (m_status&CFG_ENABLED) )
{
m_status|=CFG_ENABLED;
LOG("Enabling watchdog");
}
// Set the PingDivisor
if ( oIniParser.GetVar("GLOBAL","WATCH_DOG_DIVISOR", &divisor))
{
SetPingDivisor(divisor) ;
}
if ( ! oIniParser.GetVar("GLOBAL","FREEMEM_THRESHOLD", &m_nMemThreshold) )
{
m_nMemThreshold = 5*1024*1024 ;
}
if ( ! oIniParser.GetVar("GLOBAL","FREETMP_THRESHOLD", &m_nTmpThreshold) )
{
m_nTmpThreshold = 4*1024*1024 ;
}
return (m_status&CFG_ENABLED) ;
}
示例6: strcasecmp
enum CWatchdog::Type CWatchdogMngr::GetType()
{
char wtd[16]={0} ;
CIniParser oIniParser;
if ( !oIniParser.Load(INI_FILE) )
throw CWatchdog::exception::exception("Unable to parse IniFile") ;
if ( ! oIniParser.GetVar("GLOBAL","WATCH_DOG_TYPE", wtd, sizeof(wtd))
|| ! strcasecmp(wtd,"internal") )
{
LOG( WTD "Using the internal watchdog") ;
return CWatchdog::WTD_INTERNAL ;
}
if ( ! strcasecmp(wtd,"max6371") )
{
LOG( WTD "Using the max6371 watchdog") ;
return CWatchdog::WTD_MAX6371 ;
}
return CWatchdog::WTD_INTERNAL ;
}
示例7: ReadGWVariables
// read variables from config.ini file
bool GatewayConfig::ReadGWVariables()
{
// **********************CIniParser************************//
CIniParser gwVarConfig;
net_address stNetAddr;
if (!gwVarConfig.Load(FILE_PATH_CONFIGINI))
{
LOG("------- NO CONFIG.INI FILE -------");
return 0;
}
if (!gwVarConfig.GetVar("NETWORK_MANAGER", "NETWORK_MANAGER", &stNetAddr))
return 0;
m_nNetworkManagerPort = ntohs(stNetAddr.m_dwPortNo);
strcpy(m_szNetworkManagerHost, inet_ntoa(*(in_addr*) &stNetAddr.m_nIP));
// ****************CConfig**********************************//
if (!CConfig::Init("WH_GATEWAY", FILE_PATH_CONFIGINI ))
{
LOG("-------------NO CONFIG.INI FILE--------------");
return 0;
}
READ_MANDATORY_VARIABLE("GATEWAY", stNetAddr);
m_nListenAccessPointPort = ntohs(stNetAddr.m_dwPortNo);
m_u32IpAddress = stNetAddr.m_nIP;
READ_MANDATORY_VARIABLE("NM_CLIENT_LISTEN_PORT",m_nNmClientListenPort );
//READ_MANDATORY_VARIABLE ("LISTEN_AP_PORT", m_nListenAccessPointPort);
READ_MANDATORY_VARIABLE ("AP_CLIENT_MIN_PORT", m_nAccessPointClientMinPort);
READ_MANDATORY_VARIABLE ("AP_CLIENT_MAX_PORT", m_nAccessPointClientMaxPort);
READ_MANDATORY_VARIABLE ("HOSTAPP_LISTEN_PORT", m_nHostApp_ListenPort);
READ_MANDATORY_VARIABLE ("HOSTAPP_MIN_PORT", m_nHostApp_MinPort);
READ_MANDATORY_VARIABLE("HOSTAPP_MAX_PORT", m_nHostApp_MaxPort);
READ_DEFAULT_VARIABLE_INT("GW_REQUEST_SERVICE",m_nGwRequestService, 0);
READ_DEFAULT_VARIABLE_FLOAT("BURST_MODE_NOTIFICATION_RATE", m_fBurstNotificationRate, 0.25);
m_fBurstNotificationRate *= 1000; //miliseconds
READ_DEFAULT_VARIABLE_FLOAT("EVENT_NOTIFICATION_RATE", m_fEventNotificationRate, 1);
m_fEventNotificationRate *= 1000; //miliseconds
READ_DEFAULT_VARIABLE_FLOAT("DEVICE_STATUS_NOTIFICATION_RATE", m_fDeviceStatusNotificationRate, 5);
m_fDeviceStatusNotificationRate *= 1000; //miliseconds
READ_DEFAULT_VARIABLE_FLOAT("DEVICE_CONFIGURATION_NOTIFICATION_RATE", m_fDeviceConfigurationNotificationRate, 5);
m_fDeviceConfigurationNotificationRate *= 1000; //miliseconds
READ_DEFAULT_VARIABLE_FLOAT("TOPOLOGY_NOTIFICATION_RATE", m_fTopologyNotificationRate, 5);
m_fTopologyNotificationRate *= 1000; //miliseconds
READ_DEFAULT_VARIABLE_FLOAT("SCHEDULE_NOTIFICATION_RATE", m_fScheduleNotificationRate, 5);
m_fScheduleNotificationRate *= 1000; //miliseconds
READ_DEFAULT_VARIABLE_INT("GW_MOCK_MODE",m_nMockMode, 0);
READ_DEFAULT_VARIABLE_INT("SEND_ID_INFO_CMDS",m_nSendIdInfoCmds, 1);
return 1;
}
示例8: ReadGWUniversalVariables
bool GatewayConfig::ReadGWUniversalVariables()
{
CIniParser gwVarConfig;
if (!gwVarConfig.Load(FILE_PATH_GW_INFO_UNIV))
{
LOG("------- NO CONFIG.INI FILE -------");
return 0;
}
if (!gwVarConfig.FindGroup("WH_GATEWAY", true))
{
return 0;
}
// variables for C000
int min_req_preambles_no;
if (!(gwVarConfig.GetVar("WH_GATEWAY", "MIN_REQ_PREAMBLES_NO", &min_req_preambles_no)))
min_req_preambles_no = 0; // default value
m_u8MinReqPreamblesNo = (uint8_t) min_req_preambles_no;
int device_revision_level;
if (!gwVarConfig.GetVar("WH_GATEWAY", "DEVICE_REVISION_LEVEL", &device_revision_level))
device_revision_level = 0; // default value
m_u8DevRevisionLevel = (uint8_t) device_revision_level;
int sw_revision_no;
if (!gwVarConfig.GetVar("WH_GATEWAY", "SOFTWARE_REVISION_LEVEL", &sw_revision_no))
sw_revision_no = 0; // default value
m_u8SoftwRevisionLevel = (uint8_t) sw_revision_no;
int hwRevisionLevel_physicalSignalingMode;
if (!gwVarConfig.GetVar("WH_GATEWAY", "HWREVLEVEL_PHYSIGNALMODE", &hwRevisionLevel_physicalSignalingMode))
hwRevisionLevel_physicalSignalingMode = 0; // default value
m_u8HWRevisionLevel_PhysicalSignCode = (uint8_t) hwRevisionLevel_physicalSignalingMode;
if (!(gwVarConfig.GetVar("WH_GATEWAY", "FLAGS", &m_u8Flags, 1) == 1))
m_u8HWRevisionLevel_PhysicalSignCode = 0; // default value
int min_resp_preambles_no;
if (!(gwVarConfig.GetVar("WH_GATEWAY", "MIN_RESP_PREAMBLES_NO", &min_resp_preambles_no)))
min_resp_preambles_no = 0; // default value
m_u8MinRespPreamblesNo = (uint8_t) min_resp_preambles_no;
int max_no_of_devices_var;
if (!(gwVarConfig.GetVar("WH_GATEWAY", "MAX_NO_OF_DEVICES_VARS", &max_no_of_devices_var)))
max_no_of_devices_var = 0; // default value
m_u8MaxNoOfDevicesVar = (uint8_t) max_no_of_devices_var;
int configChangeCounter;
if (!(gwVarConfig.GetVar("WH_GATEWAY", "CHANGE_COUNTER", &configChangeCounter)))
configChangeCounter = 0; // default value
m_u16ConfigChangeCounter = (uint16_t) configChangeCounter;
int field_device_status;
if (!gwVarConfig.GetVar("WH_GATEWAY", "EXTENDED_STATUS", &field_device_status))
field_device_status = 0; // default value
m_u8FlagBits = (uint8_t) field_device_status;
if (!(gwVarConfig.GetVar("WH_GATEWAY", "MANUFACT_ID_CODE", m_u8ManufactCode, sizeof(m_u8ManufactCode))
== sizeof(m_u8ManufactCode)))
memset(m_u8ManufactCode, 0, sizeof(m_u8ManufactCode)); // default value
if (!(gwVarConfig.GetVar("WH_GATEWAY", "PRIVATE_LABEL_CODE", m_u8ManufactLabel, sizeof(m_u8ManufactLabel))
== sizeof(m_u8ManufactLabel)))
memset(m_u8ManufactLabel, 0, sizeof(m_u8ManufactLabel)); // default value
// end of variables for C000
// variables for C020 and C022
char long_tag[33];
if (!(gwVarConfig.GetVar("WH_GATEWAY", "LONG_TAG", long_tag, sizeof(long_tag)) > 0))
memset(long_tag, 0, sizeof(long_tag)); //default value
memcpy(m_szLongTag, long_tag, sizeof(m_szLongTag));
// variables for C016 and C019
int finalAssemblyNumber;
if (!gwVarConfig.GetVar("WH_GATEWAY", "FINAL_ASSEMBLY_NUMBER", &finalAssemblyNumber))
finalAssemblyNumber = 0; //default value
memcpy(&m_u32FinalAssemblyNumber, &finalAssemblyNumber, sizeof(m_u32FinalAssemblyNumber));
// variables for commands 013 and 018
char tag[9];
if (!(gwVarConfig.GetVar("WH_GATEWAY", "TAG", tag, sizeof(tag)) > 0))
memset(tag, 0, sizeof(tag));
memcpy(m_szTag, tag, sizeof(m_szTag));
if (!(gwVarConfig.GetVar("WH_GATEWAY", "MASTER_DESCRIPTOR", m_szMasterDescriptor, sizeof(m_szMasterDescriptor)) > 0))
memset(m_szMasterDescriptor, 0, sizeof(m_szMasterDescriptor)); // default value
int master_date_day;
int master_date_month;
int master_date_year;
if (!gwVarConfig.GetVar("WH_GATEWAY", "MASTER_DATE_DAY", &master_date_day))
master_date_day = 0; // default value
//.........这里部分代码省略.........