示例#1
0
void CSecurityProfile::_SetDbKey(const _QuoteUpdateParams& Params, DBA_KEY *dbaKey)
{
	_bstr_t bsSymbol(Params->Symbol);
	string sSymbol(bsSymbol);

	switch(Params->Type) 
	{
	case enOPT:
		_ConvertOptionNameInKey(sSymbol);
		bsSymbol = sSymbol.c_str();
		break;
	}

	StringToKey(bsSymbol, dbaKey);

	switch(Params->Type) 
	{
	case enSTK:
		dbaKey->type = IT_EQUITY;
		break;
	case enOPT:
		dbaKey->type = IT_EQUITY_OPTION;
		break;
	}

	//CreateSpacedUpper((char*)dbaKey->countryCode, "US", 2);
	//CreateSpacedUpper((char*)dbaKey.currencyCode, "USD", 3);
	//CreateSpaced((char *)dbaKey.symbol, Params->Symbol, MAX_TICKER);
}
示例#2
0
void CProfile::LevelUp()
{
	int nCurrentLevel = AfxGetApp()->GetProfileInt(_T(""), _T("Level"), 0);
	for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {
		CString entry;
		entry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);
		const CString appName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), entry);
		if (appName.IsEmpty())
			continue;
		switch (nCurrentLevel) {
		case 0:
			AddKeyBind2C_(appName, VK_LCONTROL);
			AddKeyBind2C_(appName, VK_RCONTROL);
		// fall through
		case 1:
			// Set kill-ring-max 1 if it is 0.
			if (!AfxGetApp()->GetProfileInt(appName, CString(MAKEINTRESOURCE(IDS_REG_ENTRY_KILL_RING_MAX)), 0))
				AfxGetApp()->WriteProfileInt(appName, CString(MAKEINTRESOURCE(IDS_REG_ENTRY_KILL_RING_MAX)), 1);
		// fall through
		case 2:
			{
				// Chaged a label from Enter to newline.
				const CString subKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName;
				const CString srcKey = subKey + _T("\\") + _T("Enter");
				const CString dstKey = subKey + _T("\\") + _T("newline");
				HKEY hDstKey = NULL;
				if (RegCreateKeyEx(HKEY_CURRENT_USER, dstKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hDstKey, NULL) == ERROR_SUCCESS) {
					SHCopyKey(HKEY_CURRENT_USER, srcKey, hDstKey, NULL);
					SHDeleteKey(HKEY_CURRENT_USER, srcKey);
					RegCloseKey(hDstKey);
				}
			}
		// fall through
		case 3:
			// rename original function to remove IDS_REG_ORIGINAL_PREFIX
			for (int nFuncID = 0; nFuncID < FuncDefs::GetNumOfDefs(); ++nFuncID) {
				HKEY hKey = NULL;
				const CString subKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName + _T("\\") + CString(MAKEINTRESOURCE(IDS_REG_ORIGINAL_PREFIX)) + FuncDefs::GetName(nFuncID);
				if (RegOpenKeyEx(HKEY_CURRENT_USER, subKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
					TCHAR szKeyBind[128];
					DWORD dwKeyBind = sizeof(szKeyBind);
					for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++dwIndex) {
						int nType, nKey;
						StringToKey(szKeyBind, nType, nKey);
						SaveKeyBind(appName, FuncDefs::GetName(nFuncID), nType, nKey);
						dwKeyBind = sizeof(szKeyBind);
					}
					RegCloseKey(hKey);
				}
			}
		}
	}
	AfxGetApp()->WriteProfileInt(_T(""), _T("Level"), 4);
}
示例#3
0
void SetConfigField(config* cfg, string field, string value)
{
	//if(field == "scr_width")	cfg->scr_width	= atoi(value.c_str());
	//else if(field == "scr_height")	cfg->scr_height	= atoi(value.c_str());
	//else if(field == "window_width") cfg->window_width = atoi(value.c_str());
	//else if(field == "window_height") cfg->window_height = atoi(value.c_str());
	//else if(field == "bpp")			cfg->scr_bpp	= atoi(value.c_str());
	//else if(field == "fullscreen")	cfg->fullscreen	= atoi(value.c_str()) != 0;
	if(field == "vert_sync")	cfg->vert_sync	= atoi(value.c_str()) != 0;
	else if(field == "debug")		cfg->debug		= atoi(value.c_str()) != 0;
	else if(field == "show_fps")		cfg->show_fps	= atoi(value.c_str()) != 0;

	else if(field == "left")			cfg->left		= StringToKey(value);
	else if(field == "right")		cfg->right		= StringToKey(value);
	else if(field == "down")			cfg->down		= StringToKey(value);
	else if(field == "jump")			cfg->jump		= StringToKey(value);
	else if(field == "fire")			cfg->fire		= StringToKey(value);
	else if(field == "screenshot")	cfg->screenshot = StringToKey(value);

	else if(field == "bullet_speed")		cfg->bullet_speed = atoi(value.c_str());
	else if(field == "hero_reload")		cfg->hero_reload = atoi(value.c_str());
	else if(field == "enemy_speed")		cfg->enemy_speed = atoi(value.c_str());
	else if(field == "hero_vuln")		cfg->hero_vuln = atoi(value.c_str());

	else if(field == "bullet_damage")	cfg->bullet_damage = atoi(value.c_str());

	else if(field == "gravity")
		cfg->gravity = (float)atof(value.c_str());
}
示例#4
0
/**
 * Assign an action to a hotkey.
 * Hotkey actions are activated in *addition* to any normal action assigned
 * to the key.
 * @param key The string representation of the key.
 * @return The action for the hotkey, or @c nullptr if the key is an invalid
 *         key for a hotkey.
 */
InputEventController::VoidActionPtr InputEventController::Hotkey(const std::string &key)
{
	SDL_Keycode code = StringToKey(key);

	if (code != SDLK_UNKNOWN) {
		auto action = std::make_shared<Action<voidSignal_t>>("", 0);
		hotkeys[code] = action;
		return action;
	}
	else {
		return VoidActionPtr();
	}
}
示例#5
0
void
ka_StringToKey(char *str, char *cell,	/* cell for password */
	       struct ktc_encryptionKey *key)
{
    char realm[MAXKTCREALMLEN];
    afs_int32 code;

    LOCK_GLOBAL_MUTEX;
    code = ka_CellToRealm(cell, realm, 0 /*local */ );
    if (code)			/* just take his word for it */
	strncpy(realm, cell, sizeof(realm));
    else			/* for backward compatibility */
	lcstring(realm, realm, sizeof(realm));
    if (strlen(str) > 8)
	StringToKey(str, realm, key);
    else
	Andrew_StringToKey(str, realm, key);
    UNLOCK_GLOBAL_MUTEX;
}
示例#6
0
bool CJSMethods::GetOptions(ChromeTrayIconOptions &options)
{
	if(m_pScriptableObject == NULL)
	{
		return false;
	}

	NPP pluginInstance				= m_pScriptableObject->GetPluginInstance();
	NPNetscapeFuncs *pBrowserFuncs	= m_pScriptableObject->GetBrowserFuncs();

	if(pluginInstance == NULL || pBrowserFuncs == NULL)
	{
		return false;
	}

	NPVariant varResults;
	NPVariant varArgs;

	bool bResult = CallJSMethod(pBrowserFuncs, pluginInstance, "getOptions", &varArgs, 0, varResults);

	if(bResult)
	{
		if(NPVARIANT_IS_OBJECT(varResults))
		{
			NPObject *pArray = NPVARIANT_TO_OBJECT(varResults);

			if(pArray != NULL)
			{
				wstring strValue;

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "minimizeOnLeftButton", strValue))
				{
					options.bMinimizeOnLeftButton = (strValue == _T("true"));
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "minimizeOnRightButton", strValue))
				{
					options.bMinimizeOnRightButton = (strValue == _T("true"));
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "trayHide", strValue))
				{
					options.bHideTray = (strValue == _T("true"));
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "actLClick", strValue))
				{
					options.actLClick = (TrayAction)_wtoi(strValue.c_str());
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "actRClick", strValue))
				{
					options.actRClick = (TrayAction)_wtoi(strValue.c_str());
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "actLDblClick", strValue))
				{
					options.actLDblClick = (TrayAction)_wtoi(strValue.c_str());
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "displayOptions", strValue))
				{
					options.bShowOptions = (strValue == _T("true"));
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "displayNewWindow", strValue))
				{
					options.bShowNewWindow = (strValue == _T("true"));
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "displayNewTab", strValue))
				{
					options.bShowNewTab = (strValue == _T("true"));
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "displayFavorites", strValue))
				{
					options.bShowFavorites = (strValue == _T("true"));
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "favorites", strValue))
				{
					options.strFavorites = strValue;
				}

				//////////////////////////////////////////////////////////////////////////
				// Boss key
				//////////////////////////////////////////////////////////////////////////

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "enableBossKey", strValue))
				{
					options.bEnableBossKey = (strValue == _T("true"));
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "bossMod1", strValue))
				{
					options.wBossModifier = StringToKey(strValue.c_str());
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "bossMod2", strValue))
				{
					options.wBossModifier |= StringToKey(strValue.c_str());
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "bossKey", strValue))
				{
					if(strValue.empty() == FALSE)
					{
						transform(strValue.begin(), strValue.end(), strValue.begin(), toupper);
						options.wBossKey = (WORD)strValue[0];
					}
				}

				if(CJSValue::GetProperty(pBrowserFuncs, pluginInstance, pArray, "bossHideTrayIcon", strValue))
				{
					options.bBossHideTrayIcon = (strValue == _T("true"));
				}
			}
		}
	}

	pBrowserFuncs->releasevariantvalue(&varArgs);
	pBrowserFuncs->releasevariantvalue(&varResults);

	return bResult;
}
示例#7
0
bool ServerInfo::HandleRequest( char * query_data, WORD packet_key )
{
	KEY   key;
   int   i, data_size;
   int   player_key_index = 0; // number of player keys received
   int   server_key_index = 0; // number of server keys received
   bool  server_query,player_query;
   KEY   player_key_list[MAX_KEYS]; // stores player keys
   KEY   server_key_list[MAX_KEYS]; // stores server keys
   short num_commands, num_players;

	// initialize
   for( i = 0; i < MAX_KEYS; i++ ) { player_key_list[i] = INVALID_KEY; }
   for( i = 0; i < MAX_KEYS; i++ ) { player_key_list[i] = INVALID_KEY; }

   num_commands = *((short *)query_data); // number of command strings sent
   query_data += sizeof(short);

	server_query   = FALSE;
   player_query   = FALSE;
   while( num_commands )
   {
printf("%s ",query_data);
		key = StringToKey(query_data);

      /*-----------------------------------------------------------------*/
      /* We assume that server keys come first, so once we start getting */
      /* to the player keys, all further server keys are invalid.        */
      /*-----------------------------------------------------------------*/

      if( server_key( key ) ) // server info request
      {
      	server_query = TRUE;
      	if( player_query ) // player data already started, so this is treated as invalid player key
            player_key_list[player_key_index++] = INVALID_KEY;
         else
         	server_key_list[server_key_index++] = key;
      }
      else // player request
      {
      	player_query = TRUE;
			player_key_list[player_key_index++] = key; // save up player keys
      }

      query_data  += strlen(query_data) + 1;
      num_commands--;
   }

   if( server_query) // send server packets
   {
      data_size = PackData( server_key_list, server_key_index, 0 );
      SendData( reply_data, data_size, packet_key );
   }

   if ( player_query ) // send player packets
   {
   	num_players  = atoi(KeyToString( NUM_PLAYERS, 0 ));
		for( i = 0; i < num_players; i++ )
      {
      	data_size = PackData( player_key_list, player_key_index, i );
	      SendData( reply_data, data_size, packet_key );
      }
   }

   return FALSE; // succesfull
}
示例#8
0
文件: Opts.cpp 项目: jehb/dxbomns
//gets the newest version of the files, creating defaults if necessary, and copies
//the data from the files into the global opts, so you can call the function
//to get the appropriate opt set and have the latest version
//returns whether it succeeds
BOOL GrabOpts()
{
	//open appopts.dat
	HANDLE hFile = CreateFile(".\\appopts.dat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if(!hFile || hFile == INVALID_HANDLE_VALUE)
	{
		if(!CreateDefaultAppOpts()) //if it doesn't exist, create a default one
			return FALSE;
		
		//open it
		hFile = CreateFile(".\\appopts.dat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
		if(!hFile || hFile == INVALID_HANDLE_VALUE)
		{
			Error("CreateFile", "unable to open appopts.dat");
			return FALSE;
		}
	}

	//read in the appopts struct
	DWORD dwSize = sizeof(g_aoApp);
	if(!ReadFile(hFile, &g_aoApp, sizeof(g_aoApp), &dwSize, NULL) || dwSize != sizeof(g_aoApp))
	{
		CloseHandle(hFile);
		Error("ReadFile", "unable to read appopts.dat");
		return FALSE;
	}
	CloseHandle(hFile);

	//open gamopts.dat
	hFile = CreateFile(".\\gamopts.dat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if(!hFile || hFile == INVALID_HANDLE_VALUE)
	{
		if(!CreateDefaultGamOpts()) //create a new one if it didn't exist
			return FALSE;
		
		//open the default
		hFile = CreateFile(".\\gamopts.dat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
		if(!hFile || hFile == INVALID_HANDLE_VALUE)
		{
			Error("CreateFile", "unable to open gamopts.dat");
			return FALSE;
		}
	}

	//read in game opts
	dwSize = sizeof(g_goGame);
	if(!ReadFile(hFile, &g_goGame, sizeof(g_goGame), &dwSize, NULL) || dwSize != sizeof(g_goGame))
	{
		CloseHandle(hFile);
		Error("ReadFile", "unable to read gamopts.dat");
		return FALSE;
	}
	CloseHandle(hFile);

	//open levopts.dat
	hFile = CreateFile(".\\levopts.dat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if(!hFile || hFile == INVALID_HANDLE_VALUE)
	{
		if(!CreateDefaultLevOpts()) //create a new one if it didn't exist
			return FALSE;

		//then open it
		hFile = CreateFile(".\\levopts.dat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
		if(!hFile || hFile == INVALID_HANDLE_VALUE)
		{
			Error("CreateFile", "unable to open levopts.dat");
			return FALSE;
		}
	}

	//read in levopts
	dwSize = sizeof(g_loLevel);
	if(!ReadFile(hFile, &g_loLevel, sizeof(g_loLevel), &dwSize, NULL) || dwSize != sizeof(g_loLevel))
	{
		CloseHandle(hFile);
		Error("ReadFile", "unable to read levopts.dat");
		return FALSE;
	}
	CloseHandle(hFile);

	if(GetFileAttributes(".\\keys.cfg") == (DWORD)-1) //if keys.cfg doesn't exist, create a new one
	{
		if(!CreateDefaultKeyConfig())
			return FALSE;
	}
	for(INT i = 0; i < 4; i++) //for each player
	{
		CHAR szApp[] = {'p', 'l', 'a', 'y', 'e', 'r', ' ', '0' + i + 1, '\0'}; //the appropriate section
		CHAR szOut[1024];
		GetPrivateProfileString(szApp, "up", "up", szOut, 1024, ".\\keys.cfg"); //get the string
		((PBYTE)&g_kcKeys)[0 + i * 5] = StringToKey(szOut, KEY_UP);             //set the appropriate byte in the key config
		GetPrivateProfileString(szApp, "down", "down", szOut, 1024, ".\\keys.cfg");
		((PBYTE)&g_kcKeys)[1 + i * 5] = StringToKey(szOut, KEY_DOWN);
		GetPrivateProfileString(szApp, "left", "left", szOut, 1024, ".\\keys.cfg");
		((PBYTE)&g_kcKeys)[2 + i * 5] = StringToKey(szOut, KEY_LEFT);
		GetPrivateProfileString(szApp, "right", "right", szOut, 1024, ".\\keys.cfg");
		((PBYTE)&g_kcKeys)[3 + i * 5] = StringToKey(szOut, KEY_RIGHT);
		GetPrivateProfileString(szApp, "drop", "rcontrol", szOut, 1024, ".\\keys.cfg");
		((PBYTE)&g_kcKeys)[4 + i * 5] = StringToKey(szOut, KEY_RCONTROL);
	}

	return TRUE;
}
示例#9
0
void CProfile::LoadRegistry()
{
	bool bDialog = false;
	const CString section(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION));
	ZeroMemory(&m_Config, sizeof(m_Config));
	for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {
		AppConfig& appConfig = m_Config.AppConfig[nAppID];
		CString entry;
		entry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);
		CString appName = AfxGetApp()->GetProfileString(section, entry);
		if (appName.IsEmpty())  {
			if (nAppID) {
				if (bDialog)
					continue;
				appName.LoadString(IDS_DIALOG);
				bDialog = true;
			} else
				appName.LoadString(IDS_DEFAULT);
		} else if (appName == CString(MAKEINTRESOURCE(IDS_DIALOG)))
			bDialog = true;
		_tcsncpy_s(appConfig.AppName, appName, _TRUNCATE);
		entry.LoadString(IDS_REG_ENTRY_APPLICATOIN_TITLE);
		_tcsncpy_s(m_AppTitle[nAppID], AfxGetApp()->GetProfileString(appName, entry), _TRUNCATE);
		entry.LoadString(IDS_REG_ENTRY_WINDOW_TEXT);
		_tcsncpy_s(appConfig.WindowText, AfxGetApp()->GetProfileString(appName, entry, _T("*")), _TRUNCATE);

		const CString regApp = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName;
		for (BYTE nComID = 1; nComID < MAX_COMMAND; ++nComID) {
			entry = CmdTable::Name(nComID);
			HKEY hKey;
			const CString regKey = regApp + _T("\\") + entry;
			if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
				TCHAR szKeyBind[128];
				DWORD dwKeyBind = _countof(szKeyBind);
				for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++dwIndex) {
					int nType, nKey;
					StringToKey(szKeyBind, nType, nKey);
					appConfig.CmdID[nType][nKey] = nComID;
					dwKeyBind = _countof(szKeyBind);
				}
				RegCloseKey(hKey);
			} else {
				// Set the default assignment
				for (int i = 0; i < MAX_KEY_BIND; ++i) {
					KeyBind bind = CmdTable::Bind(nComID, i);
					if (bind.bVk == 0)
						break;
					if (bind.nControlID == IDC_CO2)
						continue;
					appConfig.CmdID[bind.nType][bind.bVk] = nComID;
				}
			}
		}
		memset(appConfig.FuncID, -1, sizeof(appConfig.FuncID));
		for (int nFuncID = 0; nFuncID < FuncDefs::GetNumOfDefs(); ++nFuncID) {
			HKEY hKey;
			CString regKey = regApp + _T("\\") + FuncDefs::GetName(nFuncID);
			if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
				TCHAR szKeyBind[128];
				DWORD dwKeyBind = _countof(szKeyBind);
				for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++dwIndex) {
					int nType, nKey;
					StringToKey(szKeyBind, nType, nKey);
					appConfig.FuncID[nType][nKey] = static_cast<char>(nFuncID);
					dwKeyBind = _countof(szKeyBind);
				}
				RegCloseKey(hKey);
			}
		}

		entry.LoadString(IDS_REG_ENTRY_KILL_RING_MAX);
		int n = AfxGetApp()->GetProfileInt(appName, entry, 1);
		appConfig.KillRingMax = static_cast<BYTE>(n > 255 ? 255 : n);
		entry.LoadString(IDS_REG_ENTRY_DISABLE_XKEYMACS);
		appConfig.SettingStyle = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0) ? SETTING_DISABLE : SETTING_SPECIFIC);
		entry.LoadString(IDS_REG_ENTRY_USE_DIALOG_SETTING);
		appConfig.UseDialogSetting = AfxGetApp()->GetProfileInt(appName, entry, 1) != 0;
		entry.LoadString(IDC_REG_ENTRY_IGNORE_META_CTRL);
		appConfig.IgnoreUndefMetaCtrl = AfxGetApp()->GetProfileInt(appName, entry, 0) != 0;
		entry.LoadString(IDC_REG_ENTRY_IGNORE_C_X);
		appConfig.IgnoreUndefC_x = AfxGetApp()->GetProfileInt(appName, entry, 0) != 0;
		entry.LoadString(IDC_REG_ENTRY_ENABLE_CUA);
		appConfig.EnableCUA = AfxGetApp()->GetProfileInt(appName, entry, 0) != 0;
		entry.LoadString(IDS_REG_ENTRY_326_COMPATIBLE);
		appConfig.Is326Compatible = AfxGetApp()->GetProfileInt(appName, entry, 0) != 0;
	}
}