예제 #1
0
int GProfile::ChangeNotify(const char *pzSection, const char *pzEntry, const char *pzValue)
{
	if (!m_pTreeNotify)	// this can only happen if you DetatchNotification()
		return 0;

	GString strKey(pzSection);
	strKey << pzEntry;
	strKey.MakeUpper();
	fnChangeNotify fn  = (fnChangeNotify)m_pTreeNotify->search(strKey);
	if (fn)
	{
		return fn(pzSection, pzEntry, pzValue);
	}
	else 
	{
		// check for [section] monitors
		GString strKey(pzSection);
		strKey.MakeUpper();
		fnChangeNotify fn  = (fnChangeNotify)m_pTreeNotify->search(strKey);
		if (fn)
		{
			return fn(pzSection, pzEntry, pzValue);
		}
	}

	return 0;
}
예제 #2
0
// Create all keys down to the one specified
bool CProperties::CreateKey(LPCTSTR pszKey,HKEY hKey/*=HKEY_CURRENT_USER*/)
{
  bool rc=true;
  LPCTSTR pcStart=pszKey;
  LPCTSTR pcEnd;
  do {
    HKEY hKey2;
    pcEnd=_tcschr(pcStart,_TCHAR('\\'));
    if(NULL==pcEnd){
      pcEnd=pcStart+_tcslen(pcStart);
    }
    String strKey(pcStart,pcEnd-pcStart);
    if(ERROR_SUCCESS!=RegCreateKeyEx(hKey,                // handle to an open key
      strKey,         // address of subkey name
      0,           // reserved
      0,           // address of class string
      REG_OPTION_NON_VOLATILE,          // special options flag
      KEY_ALL_ACCESS,        // desired security access
      NULL,
      // address of key security structure
      &hKey2,          // address of buffer for opened handle
      NULL// address of disposition value buffer);
      )){
      rc=false;
      break;
    }
    RegCloseKey(hKey);
    hKey=hKey2;
    pcStart=pcEnd+1;
  } while (_TCHAR('\0')!=*pcEnd);
  RegCloseKey(hKey);
  return rc;
}
예제 #3
0
//
// CFunctionUseLogger::OnFunctionUse
//
void CFunctionUseLogger::OnFunctionUse( lua_State* luaVM, const char* szFunctionName, const char* szArgs, uint uiArgsSize )
{
    if ( m_strLogFilename.empty() )
        return;

    CResource* pResource = g_pGame->GetResourceManager()->GetResourceFromLuaState( luaVM );
    SString strResourceName = pResource ? pResource->GetName() : "Unknown";

    SString strKey( "%s-%s", szFunctionName, *strResourceName );

    SFuncCallRecord* pItem = MapFind( m_FuncCallRecordMap, strKey );
    if ( !pItem )
    {
        // Create new entry for this resource/function combo
        MapSet( m_FuncCallRecordMap, strKey, SFuncCallRecord() );
        pItem = MapFind( m_FuncCallRecordMap, strKey );
        pItem->strFunctionName = szFunctionName;
        pItem->strResourceName = strResourceName;
        pItem->uiCallCount = 0;
        pItem->timeFirstUsed = CTickCount::Now();
    }
    pItem->uiCallCount++;

    if ( pItem->strExampleArgs.empty() )
        pItem->strExampleArgs = SStringX( szArgs ).Left( 40 );
}
BOOL CFileBasedProjectTemplateItem::InitItem(LPCTSTR lpszPath, CImageList &ImageList32, CImageList &ImageList16)
{
	m_strPath = lpszPath;

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	//extract description, if available
	CTextSourceFile TextFile;
	if (TextFile.Create(lpszPath))
	{
		LPCTSTR lpLine;
		int nLength;
		if (TextFile.GetNextLine(lpLine, nLength))
		{
			CString strLine(lpLine, nLength);
			CString strKey(_T("%DESCRIPTION: "));
			CString strStartOfLine = strLine.Left(strKey.GetLength());
			strStartOfLine.MakeUpper();

			if (strStartOfLine == strKey)
				m_strDescription = strLine.Right(strLine.GetLength() - strKey.GetLength());
		}
	}

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	//generate title
	m_strTitle = CPathTool::GetFileTitle(m_strPath);

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	//add image to image list and remember index
	HICON hIcon = theApp.LoadIcon(IDR_LATEXDOCTYPE);
	m_nImageIndex = hIcon ? ImageList32.Add(hIcon) : -1;
	ImageList16.Add(hIcon);

	return TRUE;
}
예제 #5
0
void GProfile::ExecuteAllNotifications()
{
	if (!m_pTreeNotify)	// this can only happen if you DetatchNotification()
		return;

	GListIterator itSections(&m_lstSections);
	while ( itSections() )
	{
		GProfileSection *pSection = (GProfileSection *)itSections++;

		GListIterator itNVP(&pSection->m_lstNVP);
		while (itNVP())
		{
			GProfileEntry *pNVP = (GProfileEntry *)itNVP++;

			GString strKey(pSection->m_strName);
			strKey << pNVP->m_strName;
			strKey.MakeUpper();
			fnChangeNotify fn  = (fnChangeNotify)m_pTreeNotify->search(strKey);
			if (fn)
			{
				fn(pSection->m_strName, pNVP->m_strName, pNVP->m_strValue);
			}
		}
	}
}
예제 #6
0
파일: Remote.cpp 프로젝트: GetEnvy/Envy
void CRemote::Add(LPCTSTR pszKey, LPCTSTR pszValue)
{
	CString strKey( pszKey );
	ToLower( strKey );

	m_pKeys.SetAt( strKey, pszValue );
}
예제 #7
0
파일: main.cpp 프로젝트: kpi/ExLibris
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    // Read DB settings from config.ini
    // !!! config file must be in the same directory as the executable program
    QSettings settings("config.ini", QSettings::IniFormat);
    QString strKey("DB.config/");
    QString strHost = settings.value( strKey + "host", "localhost").toString();
    QString strDatabase = settings.value( strKey + "database", "exlibris").toString();
    QString strUser = settings.value( strKey + "user").toString();
    QString strPassword = settings.value( strKey + "password").toString();

    // Connecting to DB
    if (!createConnection(strHost, strDatabase, strUser, strPassword))
        return 1;

    LoginForm login;
    login.show();

//    MainWindow w;
//    w.show();

    return a.exec();
}
예제 #8
0
//-----------------------------------------------------------------------------------------------
/// Npc String
//-----------------------------------------------------------------------------------------------
const char*	CStringManager::GetNpcName( int iIndex )
{
	if( NPC_STRING_ID( iIndex ) == NULL )
		return m_strNull.c_str();

	std::string strKey( NPC_STRING_ID( iIndex ) );

	return GetNormalTypeTableString( LIST_NPC_S_TB, strKey );
}
예제 #9
0
bool CWizHtmlFileMap::Lookup(const QString& strUrl, QString& strFileName)
{
    QString strKey(strUrl.toLower());
    CWizHtmlFileDataMap::const_iterator it = m_map.find(strKey);
    if (it == m_map.end())
        return false;

    strFileName = it->second.strFileName;
    return true;
}
예제 #10
0
파일: Remote.cpp 프로젝트: GetEnvy/Envy
void CRemote::AddText(LPCTSTR pszKey, LPCTSTR pszDefault /*NULL*/)
{
	CString strKey( pszKey ), str;
	ToLower( strKey );

	if ( Skin.LoadRemoteText( str, strKey ) )
		m_pKeys.SetAt( strKey, str );
	else if ( pszDefault )
		m_pKeys.SetAt( strKey, pszDefault );
}
예제 #11
0
const std::string& CStringManager::GetItemPrefix( int iIndex )
{
	std::string strKey( CStr::Printf("%d",iIndex));

	stNormalTypeTable* pNormalTypeTable = m_NormalTypeTables[ STR_ITEMPREFIX ].GetObjectByName( strKey.c_str() );
	if( pNormalTypeTable == NULL )
		return m_strNull; 
	
	return pNormalTypeTable->strString;
}
예제 #12
0
//---------------------------------------------------------------------------------------
///
/// For item type string table function
///
//---------------------------------------------------------------------------------------
stQuestTypeTable* CStringManager::GetStatusStringData( int iStatusNo )
{
	if( iStatusNo < 0 || iStatusNo >= g_TblSTATE.m_nDataCnt )
		return NULL;

	if( STATE_STRING_ID( iStatusNo ) == NULL )
		return NULL;

	std::string strKey( STATE_STRING_ID( iStatusNo ) );
	return m_QuestTypeTables[ LIST_STATUS_S ].GetObjectByName( strKey.c_str() );
}
예제 #13
0
//从注册表中读取盘符对应的标识串
bool CUsbHelper::ClearUsbRegKey(char szDriveName)
{
	wstring strSKey1(_T("SYSTEM\\MountedDevices"));
	CString strKey(_T("\\DosDevices\\H:"));
	strKey.SetAt(12, szDriveName);

	return DelRegKey(strSKey1, strKey.GetString());
	//BYTE bValue[20] = {0};
	//SetRegKeyValue(strSKey1, strKey.GetString(), REG_BINARY, bValue, 20);
	//return true;
}
예제 #14
0
CmdLineParser::CmdSwitch* CmdLineParser::getCmdSwitch(const char* key) {
	string strKey(key);
	if(!starts_with(strKey, "--"))
		strKey = "--" + strKey;

	if(m_mapKeySwitch.find(strKey) != m_mapKeySwitch.end())
		return m_mapKeySwitch[strKey];
	else
		return NULL;

}
예제 #15
0
void CWizHtmlFileMap::Add(const QString& strUrl, const QString& strFileName,
                          WIZHTMLFILEDATA::HtmlFileType eType, bool bProcessed)
{
    QString strKey(strUrl.toLower());

    WIZHTMLFILEDATA data;
    data.strUrl = strUrl;
    data.strFileName = strFileName;
    data.eType = eType;
    data.bProcessed = bProcessed;
    m_map[strKey] = data;
}
예제 #16
0
const char* CStringManager::GetClassName( int iIndex )
{
	if( iIndex < 0 || iIndex >= g_TblClass.m_nDataCnt )
		return m_strNull.c_str();

	if( CLASS_STRING_ID( iIndex ) )
	{
		std::string strKey( CLASS_STRING_ID( iIndex ) );
		return GetNormalTypeTableString( LIST_CLASS_S, strKey );
	}
	return m_strNull.c_str();
}
예제 #17
0
const char* CStringManager::GetUnionName( int iIndex )
{
	if( iIndex < 0 || iIndex >= g_TblUnion.m_nDataCnt )
		return m_strNull.c_str();

	if( UNION_STRING_ID( iIndex ) )
	{
		std::string strKey( UNION_STRING_ID( iIndex ) );
		return GetNormalTypeTableString( LIST_UNION_S, strKey );
	}
	return m_strNull.c_str();
}
예제 #18
0
const char* CStringManager::GetStoreTabName( int iIndex )
{
	if( iIndex < 0 || iIndex > g_TblStore.m_nDataCnt )
		return m_strNull.c_str();

	if( g_TblStore.m_ppVALUE[ iIndex ][ 1 ].GetSTR() )
	{
		std::string strKey( g_TblStore.m_ppVALUE[ iIndex ][ 1 ].GetSTR() );
		return GetNormalTypeTableString( LIST_SELL_S, strKey );
	}
	return m_strNull.c_str();
}
예제 #19
0
bool ConfigFile::GetIntValue(const char* szKey, int& nValue)
{
    string strKey(szKey);

    map<string, string>::iterator iter = m_dicoValue.find(strKey);

    if(m_dicoValue.count(strKey) == 0)
        return false;

    nValue = atoi(iter->second.c_str());
    return true;
}
예제 #20
0
bool ConfigFile::GetStringValue(const char* szKey, string& strValue)
{
    string strKey(szKey);

    map<string, string>::iterator iter = m_dicoValue.find(strKey);

    if(m_dicoValue.count(strKey) == 0)
        return false;

    strValue = iter->second;
    return true;
}
예제 #21
0
string CmdLineParser::value(const char* key) {

	string strKey(key);
	if(!starts_with(strKey, "--"))
		strKey = "--" + strKey;

	if(m_mapKeySwitch.find(strKey) != m_mapKeySwitch.end())
		return m_mapKeySwitch[strKey]->value;
	else {
		LogWarn("The input key %s is not recognized!", strKey.c_str());
		return string("");
	}
}
예제 #22
0
bool CmdLineParser::isValid(const char* key) {
	string strKey(key);
	if(!starts_with(strKey, "--"))
		strKey = "--" + strKey;

	if(m_mapKeySwitch.find(strKey) != m_mapKeySwitch.end())
		return m_mapKeySwitch[strKey]->isvalid;
	else {
        vlogwarn("The input key %s is not recognized!", strKey.c_str());
		return false;
	}

}
예제 #23
0
STDMETHODIMP NetworkAdapter::SetProperty(IN_BSTR aKey, IN_BSTR aValue)
{
    LogFlowThisFunc(("\n"));

    AutoCaller autoCaller(this);
    if (FAILED(autoCaller.rc())) return autoCaller.rc();

    /* The machine needs to be mutable. */
    AutoMutableStateDependency adep(mParent);
    if (FAILED(adep.rc())) return adep.rc();

    Bstr key = aKey;

    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);

    bool fGenericChange = (mData->mAttachmentType == NetworkAttachmentType_Generic);

    /* Generic properties processing.
     * Look up the old value first; if nothing's changed then do nothing.
     */
    Utf8Str strValue(aValue);
    Utf8Str strKey(aKey);
    Utf8Str strOldValue;

    settings::StringsMap::const_iterator it = mData->mGenericProperties.find(strKey);
    if (it != mData->mGenericProperties.end())
        strOldValue = it->second;

    if (strOldValue != strValue)
    {
        if (strValue.isEmpty())
            mData->mGenericProperties.erase(strKey);
        else
            mData->mGenericProperties[strKey] = strValue;

        /* leave the lock before informing callbacks */
        alock.release();

        AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);
        mParent->setModified(Machine::IsModified_NetworkAdapters);
        mlock.release();

        /* Avoid deadlock when the event triggers a call to a method of this
         * interface. */
        adep.release();

        mParent->onNetworkAdapterChange(this, fGenericChange);
    }

    return S_OK;
}
예제 #24
0
stQuestTypeTable* CStringManager::GetQuestStringData( int iQuestNo )
{
	if( g_QuestList.m_STB.m_ppDESC[ iQuestNo ] == NULL )
		return NULL;

	std::string strKey( g_QuestList.m_STB.m_ppDESC[ iQuestNo ] );
	
	stQuestTypeTable* pQuestTypeTable = m_QuestTypeTables[ LIST_QUEST_S_TB ].GetObjectByName( strKey.c_str() );
	if( pQuestTypeTable == NULL )
	{
		return NULL; 
	}	

	return pQuestTypeTable;
}
예제 #25
0
CString CDrawRStockTitle::GetTipText(int nCellID, int nItemID)
{
	CString strText("");
	CString strKey("");
	strKey.Format("%04x%s",m_stkInfo.m_ciStockCode.m_cCodeType, m_stkInfo.GetCode());
	const HsCodeMark* pMark = m_iUserDefCfg->SearchMark(strKey);
	if (pMark)
	{
		if (pMark->m_nType == -1)
		{// 文字标识
			strText = pMark->m_strContent;
		}
	}
	return strText;
}
예제 #26
0
파일: main.cpp 프로젝트: BillXu/simple_win
void test_aes()
{
	const int nAESKeyLen = 16;
	unsigned char aesKey[nAESKeyLen + 1] = { 0 };
	RAND_pseudo_bytes((unsigned char*)aesKey, nAESKeyLen);
	std::string strKey((char*)aesKey, 16);
	std::cout << "key:  " << aesKey << std::endl << std::endl;
	std::string strAesKey((char*)aesKey, nAESKeyLen);
	std::string strNaked = "I am cswuyg.....";
	std::cout << "nake:  " << strNaked << std::endl;
	std::string strEncode = Encryption::EncodeAES(strAesKey, strNaked);
	std::cout << "encode:  " << strEncode << std::endl;
	std::string strDecode = Encryption::DecodeAES(strAesKey, strEncode);
	std::cout << "decode  " << strDecode << std::endl << std::endl;
}
예제 #27
0
//-----------------------------------------------------------------------------------------------
/// Zone String
//-----------------------------------------------------------------------------------------------
stItemTypeTable* CStringManager::GetZoneStringData( int iZoneNO )
{
	if( ZONE_STRING_ID( iZoneNO ) == NULL )
		return NULL;

	std::string strKey( ZONE_STRING_ID( iZoneNO ) );

	stItemTypeTable* pItemTypeTable = m_ItemTypeTables[ LIST_ZONE_S_TB ].GetObjectByName( strKey.c_str() );
	if( pItemTypeTable == NULL )
	{
		return NULL;
	}

	return pItemTypeTable;
}
예제 #28
0
//---------------------------------------------------------------------------------------
/// skill...
//---------------------------------------------------------------------------------------
stItemTypeTable* CStringManager::GetSkillStringData( int iSkillNo )
{
	if( g_SkillList.m_SkillDATA.m_ppDESC[ iSkillNo ] == NULL )
		return NULL;

	std::string strKey( g_SkillList.m_SkillDATA.m_ppDESC[ iSkillNo ] );

	stItemTypeTable* pItemTypeTable = m_ItemTypeTables[ LIST_SKILL_S_TB ].GetObjectByName( strKey.c_str() );
	if( pItemTypeTable == NULL )
	{
		return NULL; 
	}

	return pItemTypeTable;
}
예제 #29
0
EC_U32 ECConfig::WriteToFile()
{
    if(EC_Err_None == m_sFile.Open((EC_PCHAR)"rt"))
    {
        for(EC_U32 i = 0; i < m_nCount; ++i)
        {
            ECString strKey(m_pConfigItem[i].m_sKey);
            ECString strVal(m_pConfigItem[i].m_sVal);
            ECString strLine(strKey + strVal + (EC_PCHAR)"\n");
            m_sFile.WriteBuffer(strLine.ToCStr(), strLine.Length(), 1);
        };

        m_sFile.Close();
    }

    return EC_Err_None;
}
예제 #30
0
//******************************************************************
void CBCGKeyHelper::AddVirtKeyStr (CStringW& str, UINT uiVirtKey, BOOL bLast) const
{
	//
	// This file was modified by Sven Ritter
	//

	#define BUFFER_LEN 50
	TCHAR szBuffer [BUFFER_LEN + 1];

	TRACE("KeyboardLayout: 0x%x\n", ::GetKeyboardLayout (0));

	UINT nScanCode = ::MapVirtualKeyEx (uiVirtKey, 0, 
		::GetKeyboardLayout (0)) <<16 | 0x1;
	
	if (uiVirtKey >= VK_PRIOR && uiVirtKey <= VK_HELP)
	{
		nScanCode |= 0x01000000;
	}
	
	::GetKeyNameText (nScanCode, szBuffer, BUFFER_LEN);
	
	CStringW strKey(szBuffer);
	strKey.MakeLower();
	
	//--------------------------------------
	// The first letter should be uppercase:
	//--------------------------------------
	for (int nCount = 0; nCount < strKey.GetLength(); nCount++)
	{
		TCHAR c = strKey[nCount];
		if (IsCharLower (c))
		{
			c = (TCHAR) toupper (c); // Convert single character JY 4-Dec-99
			strKey.SetAt (nCount, c);
			break;
		}
	}

	str += strKey;
	
	if (!bLast)
	{
		str += '+';
	}
}