/** * Funkce pro jednoduchou praci s funkci pro hledani. * funkce se stara o inicializaci a uvolneni ruznych promennych. * @param param1 TData* zdroj ve kterem hledme retezec * @param param2 TData* hledany retezec * @return index prvku. Pokud je index vyssi, nebo roven delce prohledavaneho retezce, nic nenasel */ TData t_boyer_moor (TData *param1,TData *param2) { TData result_; init_exp_data(&result_); //typova kontrola parametru if(param1->type != STRING || param2->type != STRING) { result_.type=NIL; return result_; } int result=0; char* source=param1->val_str; char* find=param2->val_str; //pokud je hledany retezec 0 rovnou vraci hodnotu 0 if (strlen(find)==0) { result_.type=NUMBER; result_.val_num=0; return result_; } //pokud je hledany retezec vetsi, nez retezec ve kterem hleda, rovnou vraci false if (strlen(source)<strlen(find)) { result_.type=BOOL; result_.val_num=0; return result_; } //tabulka skoku int* table_jump; table_jump=my_malloc (sizeof (int)*ALPHABET); table_jump=t_char_jump(find,table_jump); //funkce na nalezeni podretezce result=find_it(source,find,table_jump); my_free (table_jump); if (result==-1) { result_.type=BOOL; result_.val_num=0; } else { //navarat je result+1, kvuli tomu ze mame indexovat od 1 result_.type=NUMBER; result_.val_num=(double)(result+1); } return result_; }
void ExtensionSecurityBlock::decrypt(dtn::data::Bundle& bundle, const SecurityKey &key, const dtn::data::Number &correlator) { // iterate through all extension security blocks dtn::data::Bundle::find_iterator find_it(bundle.begin(), ExtensionSecurityBlock::BLOCK_TYPE); while (find_it.next(bundle.end())) { const dtn::security::ExtensionSecurityBlock &esb = dynamic_cast<const dtn::security::ExtensionSecurityBlock&>(**find_it); if ((correlator == 0) || (correlator == esb._correlator)) { decrypt(bundle, key, find_it); } } }