Exemple #1
0
String TPropertyHandler::GetNameValue(String prName)
{
	if (!DefaultComponentExists()) return "";
	return GetNameValue(FDefaultComponent, prName);
}
Exemple #2
0
void CLogArchiver::Add(CCmdSession* pSession, const char *sCmdLine, const char* sCmdArg)
{
	//LogName, LogDir, MaxLogNo, LogSize, NeedArch, ArchDir, MaxArchNo
	CString oLogName, oLogDir, oArchDir;
	uint32 nMaxLogNo=FOCP_LOG_FILENO, nLogSize=FOCP_LOG_MAXFILE, nNeedArch=0, nMaxArchNo=FOCP_LOG_FILENO;

	while(sCmdArg[0])
	{
		uint32 nName, nValue;
		CString oValue;
		if(GetNameValue(sCmdArg, nName, oValue, nValue))
		{
			pSession->Print("Invalid command line arguments\r\n");
			return;
		}
		switch(nName)
		{
		case 0:
			oLogName = oValue;
			break;
		case 1:
			oLogDir = oValue;
			break;
		case 2:
			nMaxLogNo = nValue;
			break;
		case 3:
			nLogSize = nValue;
			break;
		case 4:
			nNeedArch = nValue;
			break;
		case 5:
			oArchDir = oValue;
			break;
		case 6:
			nMaxArchNo = nValue;
			break;
		}
		SkipWhiteSpace(sCmdArg);
		if(sCmdArg[0])
		{
			if(sCmdArg[0] == ',')
				++sCmdArg;
			else
			{
				pSession->Print("Invalid command line arguments\r\n");
				return;
			}
		}
	}
	if(oLogName.Empty())
	{
		pSession->Print("Missing logname\r\n");
		return;
	}
	if(!oLogName.IsIdentifierOfC())
	{
		pSession->Print("Invalid logname\r\n");
		return;
	}
	if(oLogDir.Empty())
	{
		CStringFormatter oFmt(&oLogDir);
		oFmt.Print("%s/log", CFilePathInfo::GetInstance()->GetHome());
	}
	CArchiverTable* pTable = CArchiverTable::GetInstance();
	pTable->m_oMutex.Enter();
	CRbTreeNode* pIt = pTable->m_oArchiverTable.Find(oLogName);
	if(pIt != pTable->m_oArchiverTable.End())
	{
		pTable->m_oMutex.Leave();
		pSession->Print("The logname is existed\r\n");
		return;
	}
	CLogArchiver* pItem = new CLogArchiver;
	if(!pItem->Initialize(oLogName.GetStr(), oLogDir.GetStr(), nMaxLogNo, nLogSize, (nNeedArch!=0), oArchDir.GetStr(), nMaxArchNo))
	{
		pTable->m_oMutex.Leave();
		pSession->Print("Initialize CLogArchiver failure\r\n");
		return;
	}
	pTable->m_oArchiverTable[oLogName] = pItem;
	if(nNeedArch)
		pItem->DoArchive(false);
	pTable->m_oMutex.Leave();
}