示例#1
0
BOOL KSndaAgency::LoadConfig()
{
	BOOL        bResult     = false;
	BOOL        bRetCode    = false;
	IIniFile*   piIniFile   = NULL;

	piIniFile = g_OpenIniFile(GATEWAY_CONFIG_FILE);
	LOG_PROCESS_ERROR(piIniFile);

	m_bOpen = true;
	bRetCode = piIniFile->IsSectionExist("SDOA");
	if (!bRetCode)
	{
		m_bOpen = false;
		goto EXIT1;
	}

	bRetCode = piIniFile->GetString("SDOA", "AdultIDCard", "not configed", m_szAdultIDCard, sizeof(m_szAdultIDCard)); 
	LOG_PROCESS_ERROR(bRetCode);

EXIT1:
	bResult = true;
EXIT0:
	SAFE_RELEASE(piIniFile);
	return bResult;
}
示例#2
0
void KGT_g_OpenIniFileFromArgumentsTest::Test_g_OpenFileFromArguments_04()
{
    int nResult = false;
    int nRetCode = false;

    IIniFile *piIniFile = NULL;
    char *pszArgv[] = {
        "KG_GoddessD.exe",
        "--Version.version=2",
        "--Database.name=mysql"
    };
    int nArgc = sizeof(pszArgv) / sizeof(pszArgv[0]);
    char szRetVersion[IIniFile::INI_MAX_SUPPORT_SECTION_AND_KEY_SIZE];
    szRetVersion[0] = '\0';
    char szRetName[IIniFile::INI_MAX_SUPPORT_SECTION_AND_KEY_SIZE];
    szRetName[0] = '\0';

    KG_CASE_INFO("不同的section不同的key", "");

    piIniFile = g_OpenIniFileFromArguments(nArgc, pszArgv);
    KG_PROCESS_ERROR(piIniFile);

    nRetCode = piIniFile->IsSectionExist("Version");
    KG_PROCESS_ERROR(nRetCode);

    nRetCode = piIniFile->IsSectionExist("Database");
    KG_PROCESS_ERROR(nRetCode);

    nRetCode = piIniFile->GetString("Version", "version", "", szRetVersion, sizeof(szRetVersion) / sizeof(szRetVersion[0]));
    KG_PROCESS_ERROR(nRetCode);
    szRetVersion[sizeof(szRetVersion) / sizeof(szRetVersion[0]) -1] = '\0';
    nRetCode = strncmp(szRetVersion, "2", sizeof(szRetVersion) / sizeof(szRetVersion[0]));
    KG_PROCESS_ERROR(nRetCode == 0);

    nRetCode = piIniFile->GetString("Database", "name", "", szRetName, sizeof(szRetName) / sizeof(szRetName[0]));
    KG_PROCESS_ERROR(nRetCode);
    szRetName[sizeof(szRetName) / sizeof(szRetName[0]) -1] = '\0';
    nRetCode = strncmp(szRetName, "mysql", sizeof(szRetName) / sizeof(szRetName[0]));
    KG_PROCESS_ERROR(nRetCode == 0);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    CPPUNIT_ASSERT(nResult);
}