예제 #1
0
/****************************************************************************
PARAMETERS:
msg - Message to display for type of event
evt - Event to display

REMARKS:
Function to display the status of the keyboard event to the screen.
****************************************************************************/
void DisplayKey(
    char *msg,
    event_t *evt)
{
    KeyEntry    *ascii,*scan;
    char        ch = EVT_asciiCode(evt->message);

    ascii = FindKey(ch,ASCIICodes);
    scan = FindKey(EVT_scanCode(evt->message),ScanCodes);
    printf("%s: 0x%04X -> %s, %s, '%c'",
	msg, (int)evt->message & 0xFFFF, scan->name, ascii->name, isprint(ch) ? ch : ' ');
    DisplayModifiers(evt);
    printf("\n");
}
예제 #2
0
int IsNeedLoadFunc(const FuncInfo *func)
{
	KeyInfo *key = NULL;
	gboolean load = TRUE;
	if((func != NULL) && (func->func_id != NULL)){
		load = FindKey(func->func_id, g_cngplp_data);
		if((func->func_id->type != NULL) && (0 == strcmp(func->func_id->type, "or"))){
			if(load == TRUE){
				return TRUE;
			}
		}else{
			if(load == TRUE){
				key = func->key_list;
				while(key != NULL){
					load = FindKey(key, g_cngplp_data);
					if((key->type != NULL) && (0 == strcmp(key->type, "or"))){
						if(load == TRUE){
							return TRUE;
						}
					}else{
						if(load != TRUE){
							return FALSE;
						}
					}
					key = key->next;
				}
			}else{
				load = FALSE;
			}
		}
	}else{
		key = func->key_list;
		while(key != NULL){
			load = FindKey(key, g_cngplp_data);
			if((key->type != NULL) && (0 == strcmp(key->type, "or"))){
				if(load == TRUE){
					return TRUE;
				}
			}else{
				if(load != TRUE){
					return FALSE;
				}
			}
			key = key->next;
		}
	}
	return load;
}
예제 #3
0
파일: Ini.cpp 프로젝트: eickegao/avgscript
void CIni::GetStr(const char* pszIndex, const char* pszKey,
			const char* pszDefault,
			char* szBuf, int nBufLen)
{
	if( pszIndex==NULL||pszKey==NULL|| pszDefault==NULL
		||szBuf==NULL||nBufLen<=0) return ;


	int nIndexPos = 0;
	int nKeyPos = 0;
	int nRet= 0 ;
	char szValueBuf[MAX_VALUE_BUF_LEN]={0};
	 if( (nIndexPos =FindIndex(pszIndex))!=-1)
	 {
		 if( (nKeyPos = FindKey(pszKey, nIndexPos))!=-1)
		 {
			if(GetValue(nKeyPos,szValueBuf,MAX_VALUE_BUF_LEN))
			{
				if(strlen(szValueBuf)<=nBufLen)
					strcpy(szBuf, szValueBuf);
				return;
			}
			
		 }
	 }
	if(strlen(pszDefault)<=nBufLen)
		strcpy(szBuf, pszDefault);
	else
		strcpy(szBuf,"");
}
예제 #4
0
/*=========================================================================
   WriteString : Writes a string to the ini file
*========================================================================*/
void CIniFile::WriteString (CCHR *pSection, CCHR *pKey, CCHR *pValue)
{
	EFIND List;
	char  Str [255];

	if (ArePtrValid (pSection, pKey, pValue) == FALSE) { return; }
	if (FindKey  (pSection, pKey, &List) == TRUE)
	{
		sprintf (Str, "%s=%s%s", List.KeyText, pValue, List.Comment);
		FreeMem (List.pKey->pText);
		List.pKey->pText = (char *)malloc (strlen (Str)+1);
		strcpy (List.pKey->pText, Str);
	}
	else
	{
		if ((List.pSec != NULL) && (List.pKey == NULL)) // section exist, Key not 
		{
			AddKey (List.pSec, pKey, pValue);
		}
		else
		{
			AddSectionAndKey (pSection, pKey, pValue);
		}
	}
}
예제 #5
0
파일: scf.cpp 프로젝트: garinh/cs
 size_t FindClass(char const* name, bool assume_sorted = false) const
 {
   if (assume_sorted)
     return FindSortedKey(csArrayCmp<scfFactory*,char const*>(name,
       CompareClass));
   return FindKey(csArrayCmp<scfFactory*,char const*>(name, CompareClass));
 }
예제 #6
0
파일: Dict.cpp 프로젝트: Afr0/idtech4.net
/*
================
idDict::Parse
================
*/
bool idDict::Parse( idParser &parser ) {
	idToken	token;
	idToken	token2;
	bool	errors;

	errors = false;

	parser.ExpectTokenString( "{" );
	parser.ReadToken( &token );
	while( ( token.type != TT_PUNCTUATION ) || ( token != "}" ) ) {
		if ( token.type != TT_STRING ) {
			parser.Error( "Expected quoted string, but found '%s'", token.c_str() );
		}

		if ( !parser.ReadToken( &token2 ) ) {
			parser.Error( "Unexpected end of file" );
		}

		if ( FindKey( token ) ) {
			parser.Warning( "'%s' already defined", token.c_str() );
			errors = true;
		}
		Set( token, token2 );

		if ( !parser.ReadToken( &token ) ) {
			parser.Error( "Unexpected end of file" );
		}
	}

	return !errors;
}
예제 #7
0
//-----------------------------------
/// extract string (in double-quotes) from the list.
// pass the key to find the first string in the list, else NULL to find the next string in the list
// returns NULL if no string found, else returns a temporary copy of the string (without quotes)
char * CConfig::GetString(char *key)
//-----------------------------------
{
    if (!FindKey(key))
		return NULL;


    // look for start of string or end of key
	while (*pCursor && *pCursor != '"' && *pCursor != '[')	
		pCursor++;
	if (*(pCursor++) != '"')
		return NULL;

    // until closing quote
    int c = 0;
	while (*pCursor && c < (int)sizeof(strBuffer))	
	{
		strBuffer[c++] = *pCursor;									// extract string
		if (*pCursor++ == '"')
		{
			strBuffer[--c] = '\0';
			return strBuffer;
		}
	}

	return NULL;
}
예제 #8
0
// function retrieves a boolean from the specified section
bool GProfile::GetBool(const char *szSectionName, const char *szKey, bool bThrowNotFound /* = true */)
{
	GProfileSection *pSection = FindSection(szSectionName);
	if (pSection)
	{
		GProfileEntry *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if (!pNVP->m_strValue.IsEmpty())
			{
				if (pNVP->m_strValue.GetAt(0) == '1')
					return 1;
				if (pNVP->m_strValue.CompareNoCase("Yes") == 0)
					return 1;
				if (pNVP->m_strValue.CompareNoCase("On") == 0)
					return 1;
			}
			return 0;
		}
		else if (bThrowNotFound)
		{
			// throw key not found
			throw GException("Profile", 0, szSectionName, szKey);
		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found
		throw GException("Profile", 1, szSectionName);
	}

	return 0;
}
예제 #9
0
파일: GProfile.cpp 프로젝트: gbaumgart/vt
const char *GProfile::GetPath(const char *szSectionName, const char *szKey, short bThrowNotFound)
{
	Section *pSection = FindSection(szSectionName);
	if (pSection)
	{
		NameValuePair *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if ( !( pNVP->m_strValue.Right(1) == "/" || pNVP->m_strValue.Right(1) == "\\") )
			{
		#ifdef _WIN32
				pNVP->m_strValue += "\\";
		#else
				pNVP->m_strValue += "/";
		#endif
			}
			return pNVP->m_strValue;
		}
		else if (bThrowNotFound)
		{
			// throw key not found

		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found

	}

	return 0;
}
예제 #10
0
string CIniFile::ValueName( string const keyname, unsigned const valueID) const
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return "";
  return ValueName( keyID, valueID);
}
void nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForFolder(nsIMsgFolder *folder, nsMsgKey *newHits, PRUint32 numNewHits)
{
  nsCOMPtr <nsIMsgDatabase> db;
  nsresult rv = folder->GetMsgDatabase(nsnull, getter_AddRefs(db));
  if (NS_SUCCEEDED(rv) && db)
  {
    nsCString searchUri;
    m_viewFolder->GetURI(searchUri);
    PRUint32 numBadHits;
    nsMsgKey *badHits;
    rv = db->RefreshCache(searchUri.get(), numNewHits, newHits,
                     &numBadHits, &badHits);
    if (NS_SUCCEEDED(rv))
    {
      for (PRUint32 badHitIndex = 0; badHitIndex < numBadHits; badHitIndex++)
      {
        // of course, this isn't quite right
        nsMsgViewIndex staleHitIndex = FindKey(badHits[badHitIndex], PR_TRUE);
        if (staleHitIndex != nsMsgViewIndex_None)
          RemoveByIndex(staleHitIndex);
      }
      delete [] badHits;
    }
  }
}
예제 #12
0
int main()
{
    HashTable H;
    H = initializeTable(353);

    int i;
    int key;
    Position P;
    ////insertKey(1,H);
    //insertKey(2,H);
    //insertKey(3,H);

    ////deleteKey(1,H);
    //deleteKey(2,H);
    //deleteKey(3,H);

    for(i=0; i<100; i++)
    {
        key = i;
        insertKey(key, H);
    }
    //deleteKey(100, H);
    //for(i=99; i>=0; i--)
    //	deleteKey(i, H);

    P = FindKey(6,H);
    printf("Index %d is found\n",P);

    PrintHashTable(H);
    DestroyTable(H);
    std::cout<<std::endl;
}
예제 #13
0
unsigned CIniFile::NumValues( string const keyname)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return 0;
  return (unsigned)keys[keyID].names.size();
}
예제 #14
0
const char *GProfile::GetPath(const char *szSectionName, const char *szKey, bool bThrowNotFound)
{
	GProfileSection *pSection = FindSection(szSectionName);
	if (pSection)
	{
		GProfileEntry *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if ( !( pNVP->m_strValue.Right(1) == "/" || pNVP->m_strValue.Right(1) == "\\") )
			{
		#ifdef _WIN32
				pNVP->m_strValue += "\\";
		#else
				pNVP->m_strValue += "/";
		#endif
			}
			return pNVP->m_strValue;
		}
		else if (bThrowNotFound)
		{
			// throw key not found
			throw GException("Profile", 0, szSectionName, szKey);
		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found
		throw GException("Profile", 1, szSectionName);
	}

	return 0;
}
예제 #15
0
int	 GProfile::GetInt(const char *szSectionName, const char *szKey, bool bThrowNotFound/* = true*/)
{
	GProfileSection *pSection = FindSection(szSectionName);
	if (pSection)
	{
		GProfileEntry *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if (!pNVP->m_strValue.IsEmpty())
				return atoi((const char *)pNVP->m_strValue);
		}
		else if (bThrowNotFound)
		{
			// throw key not found
			throw GException("Profile", 0, szSectionName, szKey);
		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found
		throw GException("Profile", 1, szSectionName);
	}

	return 0;
}
예제 #16
0
// function retrieves a boolean from the specified section
bool GProfile::GetBoolean(const char *szSectionName, const char *szKey, bool bThrowNotFound /* = true */)
{
	GProfileSection *pSection = FindSection(szSectionName);
	if (pSection)
	{
		GProfileEntry *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if (pNVP->m_strValue.CompareNoCase("true") == 0 ||
				pNVP->m_strValue.CompareNoCase("on") == 0  ||
				pNVP->m_strValue.CompareNoCase("yes") == 0 ||
				pNVP->m_strValue.CompareNoCase("1") == 0)
			{
				return 1;
			}
			else
			{
				return 0;
			}
		}
		else if (bThrowNotFound)
		{
			// throw key not found
			throw GException("Profile", 0, szSectionName, szKey);
		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found
		throw GException("Profile", 1, szSectionName);
	}

	return 0;
}
예제 #17
0
/*
================
idDict::Delete
================
*/
void idDict::Delete( const char *key )
{
    int hash, i;

    hash = argHash.GenerateKey( key, false );
    for ( i = argHash.First( hash ); i != -1; i = argHash.Next( i ) )
    {
        if ( args[i].GetKey().Icmp( key ) == 0 )
        {
            globalKeys.FreeString( args[i].key );
            globalValues.FreeString( args[i].value );
            args.RemoveIndex( i );
            argHash.RemoveIndex( hash, i );
            break;
        }
    }

#if 0
    // make sure all keys can still be found in the hash index
    for ( i = 0; i < args.Num(); i++ )
    {
        assert( FindKey( args[i].GetKey() ) != NULL );
    }
#endif
}
예제 #18
0
파일: GProfile.cpp 프로젝트: gbaumgart/vt
// function retrieves a boolean from the specified section
short GProfile::GetBoolean(const char *szSectionName, const char *szKey, short bThrowNotFound /* = true */)
{
	Section *pSection = FindSection(szSectionName);
	if (pSection)
	{
		NameValuePair *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if (pNVP->m_strValue.CompareNoCase("true") == 0 ||
				pNVP->m_strValue.CompareNoCase("on") == 0  ||
				pNVP->m_strValue.CompareNoCase("yes") == 0 ||
				pNVP->m_strValue.CompareNoCase("1") == 0)
			{
				return 1;
			}
			else
			{
				return 0;
			}
		}
		else if (bThrowNotFound)
		{

		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found

	}

	return 0;
}
예제 #19
0
unsigned CIniFile::NumKeyComments( string const keyname) const
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return 0;
  return (unsigned)keys[keyID].comments.size();
}
예제 #20
0
파일: RegHooks.cpp 프로젝트: EricSB/ConEmu
	// wowOptions нужен только для HKLM
	RegKeyType IsStored(HKEY hKey, DWORD wowOptions=0 /*KEY_WOW64_64KEY/KEY_WOW64_32KEY*/)
	{
		RegKeyInfo* p;
		if (hKey && (p = FindKey(hKey, wowOptions)))
			return p->rkt;
		return RKT_None;
	};
예제 #21
0
파일: GProfile.cpp 프로젝트: gbaumgart/vt
// function retrieves a boolean from the specified section
short GProfile::GetBool(const char *szSectionName, const char *szKey, short bThrowNotFound /* = true */)
{
	Section *pSection = FindSection(szSectionName);
	if (pSection)
	{
		NameValuePair *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			char chTest = '0';
			if (!pNVP->m_strValue.IsEmpty())
				chTest = pNVP->m_strValue[0];
			return IsTrue(chTest);
		}
		else if (bThrowNotFound)
		{
			// throw key not found

		}
	}
	else if (bThrowNotFound)
	{

	}

	return 0;
}
예제 #22
0
bool CIniFile::KeyComment( string const keyname, string const comment)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return false;
  return KeyComment( unsigned(keyID), comment);
}
예제 #23
0
파일: GProfile.cpp 프로젝트: gbaumgart/vt
// function retrieves a long from the specified section
long GProfile::GetLong(const char *szSectionName, const char *szKey, short bThrowNotFound /* = true */)
{
	Section *pSection = FindSection(szSectionName);
	if (pSection)
	{
		NameValuePair *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if (!pNVP->m_strValue.IsEmpty())
				return atol((const char *)pNVP->m_strValue);
		}
		else if (bThrowNotFound)
		{
			// throw key not found

		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found

	}

	return 0;
}
예제 #24
0
string CIniFile::KeyComment( string const keyname, unsigned const commentID) const
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return "";
  return KeyComment( unsigned(keyID), commentID);
}
예제 #25
0
파일: GProfile.cpp 프로젝트: gbaumgart/vt
void GProfile::SetString(const char *szSectionName, const char *szKey, const char *szValue)
{
	m_bCached = true;

	Section *pSection = FindSection(szSectionName);
	if (!pSection)
	{
		pSection = new Section;
		pSection->m_strName = szSectionName;
		pSection->m_strName.TrimLeftWS();
		pSection->m_strName.TrimRightWS();

		m_lstSections.AddLast(pSection);
	}

	if (pSection)
	{
		NameValuePair *pNVP = FindKey(szKey, pSection);
		if (!pNVP)
		{
			pNVP = new NameValuePair;
			pSection->m_lstNVP.AddLast(pNVP);
			pNVP->m_strName = szKey;
			pNVP->m_strName.TrimLeftWS();
			pNVP->m_strName.TrimRightWS();
		}
			
		if (pNVP)
		{
			pNVP->m_strValue = szValue;
			pNVP->m_strValue.TrimLeftWS();
			pNVP->m_strValue.TrimRightWS();
		}
	}
}
예제 #26
0
bool CIniFile::DeleteKeyComments( string const keyname)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return false;
  return DeleteKeyComments( unsigned(keyID));
}
예제 #27
0
VariableDATA *Array::ModuleGet(const char *key) {
    ARRAY_COUNT_TYPE i = -1;

    i = FindKey(key);

    if (i == -1) {
        AnsiString tmp(key);
        AddKey(&tmp, COUNT);
        ADD_VARIABLE(0, PIF);
    }

    if (i < COUNT) {
        ARRAY_COUNT_TYPE target_node = i / ARRAY_INCREMENT;
        ARRAY_COUNT_TYPE d_count     = i % ARRAY_INCREMENT;
        NODE *CURRENT = FIRST;
        for (ARRAY_COUNT_TYPE k = 0; k < target_node; k++) {
            CURRENT = CURRENT->NEXT;
        }
        ENSURE_ELEMENTS(CURRENT, d_count);
        ArrayElement *ELEMENTS = CURRENT->ELEMENTS;
        if (!ELEMENTS [d_count]) {
            CREATE_VARIABLE(ELEMENTS [d_count], PIF);
        }
        return ELEMENTS [d_count];
    }
    ARRAY_COUNT_TYPE target = i;
    while (COUNT < target) {
        ADD_MULTIPLE_VARIABLE2;
    }
    ADD_VARIABLE(0, PIF);
    return 0;
}
예제 #28
0
CString Environment::GetEnv(const TCHAR* key) const
{
	assert(key);

	std::pair<size_t, size_t> keyPos = FindKey(m_env, key);
	return GetValue(&(m_env[keyPos.first]));
}
예제 #29
0
void Construct(const char* bin_name)
{
        FILE *input=fopen(TMP_OUT, "r");
        NODE *pointer, *tp;
        uint32 key;

        if(!input){
                fprintf(stderr, "%s: Cannot open " TMP_OUT ".\n", bin_name);
                exit(1);
        }
        InitConstruct();
        
        while ( 1 ) {   
                fscanf( input, "%lu", &key );
                if ( feof( input ) ) break;
                pointer = root;
                /* for each key in a keyin sequence */
                for ( ; key != 0; fscanf( input, "%lu", &key ) ) {      
                        if ( ( tp = FindKey( pointer, key ) ) ) {
                                pointer = tp;
                        }
                        else {
                                tp = Insert( pointer, key );
                                pointer = tp;
                        }
                }
                pointer->phraseno = keyin_count++;
        }
}
예제 #30
0
void *KeyValues::GetPtr(const char *keyName, void *defaultValue)
{
	KeyValues *dat = FindKey(keyName, false);

	if (dat)
	{
		switch (dat->m_iDataType)
		{
			case TYPE_PTR:
			{
				return dat->m_pValue;
			}

			case TYPE_WSTRING:
			case TYPE_STRING:
			case TYPE_FLOAT:
			case TYPE_INT:
			case TYPE_UINT64:
			default:
			{
				return NULL;
			}
		}
	}

	return defaultValue;
}