void airport::BasicCrawler::add_user_dict(const char *key, const char *value) { std::string tkey(key); std::string tValue(value); add_user_dict(tkey, tValue); }
void airport::BasicCrawler::add_parser(const char *key, const char *regxString) { std::string tkey(key); std::string tRegxString(regxString); add_parser(tkey, tRegxString); }
node *CACObject :: CreateNode (char *extnames, PIACC accopt ) { DBExtend *dbext; node *nodeptr = NULL; TypeKey tkey(GetDictionary(),extnames); if ( (dbext = GetDictionary()->ProvideExtendDef(tkey,GetSchemaVersion())) ) nodeptr = CreateNode(dbext,accopt); return(nodeptr); }
/** * @return - nothing * Check repository settings as defined in the config file. For example, * we might expect 37 strings in the repository. Their keys will be * 'StringKey0' through 'StringKey36'. We'll expect to see hex values for * all of these names (or we will LEAVE). Those keys will be expected * to exist in the repository and have values 'StringVal0' through 'StringVal36' * (or whatever). */ void CRepositoryCheckStep::CheckRepositoryStringSettings(CRepository *arepository, TInt ancheck) { // Careful if the prefix here changes, we don't want to // blow this buffer. Also note the 'Delete' at the end of the loop. TBuf<REPCHECKCREATE_KEYBUFLEN> tkey(KStringKeyPrefix); TBuf<REPCHECKCREATE_VALBUFLEN> tval(KStringValPrefix); TInt keyslen = tkey.Length(); TInt valslen = tval.Length(); for( TInt count=0 ; count < ancheck ; count++ ) { tkey.AppendNum(count); // e.g "StringKey21" tval.AppendNum(count); // e.g "StringVal47" TInt r=0; TInt key; TInt bRet = GetHexFromConfig(ConfigSection(), tkey, key ); if(bRet != 1) { ERR_PRINTF2(_L("Failed to get key%d"), count ); SetTestStepResult(EFail); } TBuf<REPCHECKCREATE_MAXSTRINGLEN> expectedbuf; TPtrC expected(expectedbuf); bRet = GetStringFromConfig(ConfigSection(), tval, expected ); TBuf<REPCHECKCREATE_MAXSTRINGLEN> sval; r = arepository->Get( key, sval ); if(r!=KErrNone) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("Repository doesn't have StringKey 0x%x"), key ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } else if(sval!=expected) { INFO_PRINTF1(HTML_RED); ERR_PRINTF4(_L("String match failure, key 0x%x, got %S, expected %S"), key, &sval, &expected); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } // Restore the key and value names (i.e strip the digits from the end) tkey.Delete(keyslen, REPCHECKCREATE_KEYBUFLEN); tval.Delete(valslen, REPCHECKCREATE_VALBUFLEN); } // Should we return something? return; }
/** * keys for basic authentication; * result is: sha256( s2 + sha256( s1 + key ) ); * s1 and s2 are open information **/ void create_key( const std::string &key, const std::string &s1, const std::string &s2, std::string &result ) { std::string tkey(key); std::string ts1 (s1 ); std::string ts2 (s2 ); vtrc::unique_ptr<hash_iface> sha256( hash::sha2::create256( ) ); ts1.append( tkey.begin( ), tkey.end( ) ); ts1.assign( sha256->get_data_hash( ts1.c_str( ), ts1.size( ) ) ); ts2.append( ts1.begin( ), ts1.end( ) ); ts2.assign( sha256->get_data_hash( ts2.c_str( ), ts2.size( ) ) ); result.swap( ts2 ); }
DBExtend *SystemDict :: ProvideExtendDef (SDB_Reference sdbref, logical disjopt, logical unionopt, logical intersopt, logical contr_opt ) { DBStructDef *strdefptr; DBExtend *oldext; DBExtend *dbextdef; BEGINSEQ TypeKey tkey(sdbref.get_ddetype(),SYS_NSID); if ( !(strdefptr = GetStructDef(tkey)) ) SDBERR(20) if ( !(dbextdef = new DBExtend(this,&sdbref,strdefptr,disjopt,unionopt,intersopt,contr_opt)) ) SDBERR(95) if ( oldext = GetExtendDef(dbextdef->fmcbname,SYS_NSID) ) { extdef_list.Remove(oldext); dbextdef->SetPrevious(oldext); } extdef_list.Insert(dbextdef); RECOVER dbextdef = NULL; ENDSEQ return(dbextdef); }
/** * @return - nothing * Modify repository settings as defined in the config file. For example, * we might want to set 37 strings in the repository. Their keys will be * 'StringKey0' through 'StringKey36'. */ void CRepositoryFnStep::ModifyRepositoryStringSettings(CRepository *arepository, TInt anset ) { // Careful if the prefix here changes, we don't want to // blow this buffer. Also note the 'Delete' at the end of the loop. TBuf<REPCHECKCREATE_KEYBUFLEN> tkey(KStringKeyPrefix); TBuf<REPCHECKCREATE_VALBUFLEN> tval(KStringValPrefix); TBuf<REPCHECKCREATE_VALBUFLEN> experr(KStringExpectedError); TBuf<REPCHECKCREATE_VALBUFLEN> function(KStringFunction); TInt keyslen = tkey.Length(); TInt valslen = tval.Length(); TInt experrlen = experr.Length(); TInt fnlen = function.Length(); for( TInt count=0 ; count < anset ; count++ ) { // Append the count to the name of the key/value/expected error // config items.. tkey.AppendNum(count); // e.g "StringKey21" tval.AppendNum(count); // e.g "StringVal47" experr.AppendNum(count); // e.g "StringExpErr204" function.AppendNum(count); // e.g "Stringfn204" // Get the required function config item. We fetch this as a string // and convert it.. TInt fn; // Where to put the string from the config file... TBuf<REPCHECKCREATE_MAXSTRINGLEN> fnbuf; TPtrC fns(fnbuf); if(GetStringFromConfig(ConfigSection(), function, fns) ) fn = FuncToNum(fns); else fn = fn_set; // Get the expected error config item. We fetch this as a string // and convert it.. TInt err; // Where to put the string from the config file... TBuf<REPCHECKCREATE_MAXSTRINGLEN> errbuf; TPtrC errs(errbuf); if(GetStringFromConfig(ConfigSection(), experr, errs) ) err = ErrorToNum(errs); else err = KErrNone; // Get the key. It MUST be defined in the config file. TInt r=0, key; TInt bRet = GetHexFromConfig(ConfigSection(), tkey, key ); if(bRet != 1) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("Failed to get string key %S"), &tkey ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); continue; } // Where to put the string from the config file... TBuf<REPCHECKCREATE_MAXSTRINGLEN> setbuf; TPtrC set(setbuf); // Get it from the config file... bRet = GetStringFromConfig(ConfigSection(), tval, set ); if((bRet != 1) && ( (fn==fn_set) || (fn==fn_create) ) ) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("FAIL: Failed to get config stringval%d"), count ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); continue; } TInt rr; TBuf<REPCHECKCREATE_MAXSTRINGLEN> vals; switch(fn) { case fn_set: INFO_PRINTF3(_L("Setting string, key 0x%x, to %S "), key, &set ); r = arepository->Set( key, set ); break; case fn_create: INFO_PRINTF3(_L("Creating string, key 0x%x, to %S "), key, &set ); r = arepository->Create( key, set ); break; case fn_delete: INFO_PRINTF2(_L("Deleting string, key 0x%x"), key ); r = arepository->Delete( key ); vals.Delete(0, REPCHECKCREATE_KEYBUFLEN); rr = arepository->Get( key, vals ); if( rr != KErrNotFound ) { INFO_PRINTF3(_L("Get following delete gave rc %d, val: %S"), rr, &vals); } break; case fn_reset: INFO_PRINTF2(_L("Resetting string, key 0x%x"), key ); r = arepository->Reset( key ); break; default: INFO_PRINTF1(HTML_RED); ERR_PRINTF3(_L("FAIL: Unknown function %d for string setting %d"), fn, count ); INFO_PRINTF1(HTML_RED_OFF); r = KErrNone; SetTestStepResult(EFail); break; } if(r!=err) { INFO_PRINTF1(HTML_RED); ERR_PRINTF3(_L("Wrong error code. Got %d, expected %d"), r, err); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } else { INFO_PRINTF2(_L("Got expected error code %d"), r ); } // Restore the key and value names (i.e strip the digits from the end) tkey.Delete(keyslen, REPCHECKCREATE_KEYBUFLEN); tval.Delete(valslen, REPCHECKCREATE_VALBUFLEN); experr.Delete(experrlen, REPCHECKCREATE_VALBUFLEN); function.Delete(fnlen, REPCHECKCREATE_VALBUFLEN); } // Should we return something? return; }
/** * @return - nothing * Check repository settings as defined in the config file. For example, * we might expect 37 reals in the repository. Their keys will be * 'RealKey0' through 'RealKey36'. We'll expect to see hex values for * all of these names. Those keys will be expected * to exist in the repository and have values 'RealVal0' through 'RealVal36' * (or whatever). */ void CRepositoryCheckStep::CheckRepositoryRealSettings(CRepository *arepository, TInt ancheck) { // Careful if the prefix here changes, we don't want to // blow this buffer. Also note the 'Delete' at the end of the loop. TBuf<REPCHECKCREATE_KEYBUFLEN> tkey(KRealKeyPrefix); TBuf<REPCHECKCREATE_VALBUFLEN> tval(KRealValPrefix); TBuf<REPCHECKCREATE_VALBUFLEN> tmeta(KRealMetaPrefix); TInt keyslen = tkey.Length(); TInt valslen = tval.Length(); TInt metalen = tmeta.Length(); for( TInt count=0 ; count < ancheck ; count++ ) { tkey.AppendNum(count); // e.g "RealKey21" tval.AppendNum(count); // e.g "RealVal47" tmeta.AppendNum(count); // e.g "RealMeta47" TInt r=0; TInt key; TInt bRet = GetHexFromConfig(ConfigSection(), tkey, key ); if(bRet != 1) { ERR_PRINTF2(_L("Failed to get key%d"), count ); SetTestStepResult(EFail); } TBuf<REPCHECKCREATE_MAXSTRINGLEN> expectedbuf; TPtrC expected(expectedbuf); // Get the real stored in the repository. TReal rval; r = arepository->Get( key, rval ); if(r!=KErrNone) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("Repository doesn't have RealKey 0x%x"), key ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } else { // Unfortunately there is no 'GetRealFromConfig' // so we must fetch the real number as a // string. bRet = GetStringFromConfig(ConfigSection(), tval, expected ); if(bRet!=1) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("Config doesn't have RealVal%d"), count ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } else { TLex tlexp(expected); TReal expectedreal; r = tlexp.Val(expectedreal); // This is of course a little problematic - // obviously one should never compare reals. if(rval!=expectedreal) { INFO_PRINTF1(HTML_RED); ERR_PRINTF4(_L("Real match failure, key 0x%x, got %f, expected %f"), key, rval, expectedreal); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } } } TBuf<REPCHECKCREATE_MAXSTRINGLEN> metabuf; TPtrC meta(metabuf); TUint32 expectedmeta; bRet = GetStringFromConfig(ConfigSection(), tmeta, meta ); if(bRet == 1) { TLex lex(meta); TInt err = lex.Val(expectedmeta, EHex); if (err) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("Meta value couldn't be converted to TUint32 for IntKey 0x%x"), key ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } TUint32 actualmeta; r = arepository->GetMeta( key, actualmeta ); if(r!=KErrNone) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("MetData doesn't exist for key 0x%x"), key ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } else if(actualmeta!=expectedmeta) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("Meta match failure, int%d"), count); INFO_PRINTF2(_L(" - expectedmeta 0x%x"), expectedmeta ); INFO_PRINTF2(_L(" - actualmeta 0x%x"), actualmeta ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } } // Restore the key and value names (i.e strip the digits from the end) tkey.Delete(keyslen, REPCHECKCREATE_KEYBUFLEN); tval.Delete(valslen, REPCHECKCREATE_VALBUFLEN); tmeta.Delete(metalen, REPCHECKCREATE_VALBUFLEN); } // Should we return something? return; }
/** * @return - nothing * Check repository settings as defined in the config file. For example, * we might expect 37 integers in the repository. Their keys will be * 'IntKey0' through 'IntKey36'. We'll expect to see hex values for * all of these names (or we will LEAVE). Those keys will be expected * to exist in the repository and have values 'IntVal0' through 'IntVal36' * (or whatever). */ void CRepositoryCheckStep::CheckRepositoryIntegerSettings(CRepository *arepository, TInt ancheck) { // Careful if the prefix here changes, we don't want to // blow this buffer. Also note the 'Delete' at the end of the loop. TBuf<REPCHECKCREATE_KEYBUFLEN> tkey(KIntKeyPrefix); TBuf<REPCHECKCREATE_VALBUFLEN> tval(KIntValPrefix); TBuf<REPCHECKCREATE_VALBUFLEN> tmeta(KIntMetaPrefix); TInt keyslen = tkey.Length(); TInt valslen = tval.Length(); TInt metalen = tmeta.Length(); for( TInt count=0 ; count < ancheck ; count++ ) { tkey.AppendNum(count); // e.g "IntKey21" tval.AppendNum(count); // e.g "IntVal47" tmeta.AppendNum(count); // e.g "IntMeta47" TInt r=0; TInt key; TInt bRet = GetHexFromConfig(ConfigSection(), tkey, key ); if(bRet != 1) { ERR_PRINTF2(_L("Failed to get key%d"), count ); SetTestStepResult(EFail); } TInt expectedval; bRet = GetHexFromConfig(ConfigSection(), tval, expectedval ); if(bRet!=1) { ERR_PRINTF2(_L("Failed to get config intval%d"), count ); SetTestStepResult(EFail); } TInt intval; r = arepository->Get( key, intval ); if(r!=KErrNone) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("Repository doesn't have IntKey 0x%x"), key ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } else if(intval!=expectedval) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("Integer match failure, int%d"), count); INFO_PRINTF2(_L(" - expectedint 0x%x"), expectedval ); INFO_PRINTF2(_L(" - actualint 0x%x"), intval ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } TBuf<REPCHECKCREATE_MAXSTRINGLEN> metabuf; TPtrC meta(metabuf); TUint32 expectedmeta; bRet = GetStringFromConfig(ConfigSection(), tmeta, meta ); if(bRet == 1) { TLex lex(meta); TInt err = lex.Val(expectedmeta, EHex); if (err) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("Meta value couldn't be converted to TUint32 for IntKey 0x%x"), key ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } TUint32 actualmeta; r = arepository->GetMeta( key, actualmeta ); if(r!=KErrNone) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("MetData doesn't exist for key 0x%x"), key ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } else if(actualmeta!=expectedmeta) { INFO_PRINTF1(HTML_RED); ERR_PRINTF2(_L("Meta match failure, int%d"), count); INFO_PRINTF2(_L(" - expectedmeta 0x%x"), expectedmeta ); INFO_PRINTF2(_L(" - actualmeta 0x%x"), actualmeta ); INFO_PRINTF1(HTML_RED_OFF); SetTestStepResult(EFail); } } // Restore the key and value names (i.e strip the digits from the end) tkey.Delete(keyslen, REPCHECKCREATE_KEYBUFLEN); tval.Delete(valslen, REPCHECKCREATE_VALBUFLEN); tmeta.Delete(metalen, REPCHECKCREATE_VALBUFLEN); } // Should we return something? return; }