static void init_bmlut(BmLut *table, size_t n, void *work_mem) { BmLutEntry *p, *endp; table->probes = table->adapts = table->collisions = 0; table->size = bm_lut_size(n); table->entries = (BmLutEntry *) work_mem; for (p = table->entries, endp = p + table->size; p < endp; ++p) p->pos = BM_NPOS; BM_LOG(1, "n(fps): %llu, size: %llu\n", (Llu)n, (Llu)table->size); }
int bmz_bm_dump(const void *src, size_t in_len) { Byte *in = (Byte *)src, *ip = in, *in_end = ip + in_len; UInt64 pos = 0, len, cpos = 0, tot_pte_sz = 0, tot_ptr_sz = 0, nptrs = 0; int is_on = *ip++; printf(BM_COLOR_DBG "%d" BM_COLOR_END, is_on); if (!is_on) { fwrite(ip, 1, in_end - ip, stdout); return BMZ_E_OK; } while (ip < in_end) { if (*ip == BM_ESC) { Byte *ip0 = ip; BM_NEED_IN(1); if (ip[1] != BM_ESC) { ++ip; BM_DECODE_POS(cpos, pos); BM_DECODE_LEN(len); printf(BM_COLOR_DBG "<%llu,%llu>" BM_COLOR_END, (unsigned long long)pos, (unsigned long long)len); cpos += len; tot_pte_sz += len; tot_ptr_sz += ip - ip0; ++nptrs; } else { putchar(*ip++); putchar(*ip++); cpos += 2; } } else { putchar(*ip++); ++cpos; } } BM_LOG(1, "%llu pointers, avg pointee size: %.3f, avg pointer size: %.3f\n", (unsigned long long)nptrs, (double)tot_pte_sz / nptrs, (double)tot_ptr_sz / nptrs); return BMZ_E_OK; input_overrun: return BMZ_E_INPUT_OVERRUN; }
/*------------------------------------------------------------------------------*\ LoadAddons() - loads all available filter-addons \*------------------------------------------------------------------------------*/ void BmFilterList::LoadAddons() { BDirectory addonDir; BPath path; BEntry entry; status_t err; BM_LOG2( BM_LogFilter, BmString("Start of LoadAddons() for FilterList")); // determine the path to the user-config-directory: if (find_directory( B_USER_ADDONS_DIRECTORY, &path) != B_OK) BM_THROW_RUNTIME( "Sorry, could not determine user's addon-dir !?!"); BmString addonPath = BmString(BeamRoster->AppPath()) + "/add-ons/Filters"; SetupFolder( addonPath.String(), &addonDir); // ...and scan through all its entries for filter-add-ons: while ( addonDir.GetNextEntry( &entry, true) == B_OK) { if (entry.IsFile()) { char nameBuf[B_FILE_NAME_LENGTH]; entry.GetName( nameBuf); // try to load addon: const char** filterKinds; const char** defaultFilterName; BmFilterAddonDescr ao; ao.name = nameBuf; ao.name.CapitalizeEachWord(); entry.GetPath( &path); if ((ao.image = load_add_on( path.Path())) < 0) { BM_SHOWERR( BmString("Unable to load filter-addon\n\t") <<ao.name<<"\n\nError:\n\t"<<strerror( ao.image)); continue; } if ((err = get_image_symbol( ao.image, "InstantiateFilter", B_SYMBOL_TYPE_ANY, (void**)&ao.instantiateFilterFunc )) != B_OK) { BM_SHOWERR( BmString("Unable to load filter-addon\n\t") <<ao.name<<"\n\nMissing symbol 'InstantiateFilter'"); continue; } if ((err = get_image_symbol( ao.image, "InstantiateFilterPrefs", B_SYMBOL_TYPE_ANY, (void**)&ao.instantiateFilterPrefsFunc )) != B_OK) { BM_SHOWERR( BmString("Unable to load filter-addon\n\t") <<ao.name <<"\n\nMissing symbol 'InstantiateFilterPrefs'"); continue; } if ((err = get_image_symbol( ao.image, "FilterKinds", B_SYMBOL_TYPE_ANY, (void**)&filterKinds )) != B_OK) { BM_SHOWERR( BmString("Unable to load filter-addon\n\t") <<ao.name<<"\n\nMissing symbol 'FilterKinds'"); continue; } if ((err = get_image_symbol( ao.image, "DefaultFilterName", B_SYMBOL_TYPE_ANY, (void**)&defaultFilterName )) == B_OK) ao.defaultFilterName = *defaultFilterName; else ao.defaultFilterName = "new filter"; #if 0 // we try to set TheBubbleHelper and TheLogHandler globals inside // the addon to our current values: BubbleHelper** bhPtr; if (get_image_symbol( ao.image, "TheBubbleHelper", B_SYMBOL_TYPE_ANY, (void**)&bhPtr) == B_OK) { *bhPtr = TheBubbleHelper; } BmLogHandler** lhPtr; if (get_image_symbol( ao.image, "TheLogHandler", B_SYMBOL_TYPE_ANY, (void**)&lhPtr) == B_OK) { *lhPtr = TheLogHandler; } #endif // now we add the addon to our map (one entry per filter-kind): while( *filterKinds) { BmString kind(*filterKinds); FilterAddonMap[*filterKinds++] = ao; if (kind.ICompare("Spam") == 0) { // a spam-filter requires two internal filters (learnAsSpam // and learnAsTofu) which don't appear as part of filter-list: mLearnAsSpamFilter = new BmFilter( LEARN_AS_SPAM_NAME, "Spam", NULL); BMessage learnAsSpamJob; learnAsSpamJob.AddString("jobSpecifier", "LearnAsSpam"); mLearnAsSpamFilter->JobSpecifier(learnAsSpamJob); mLearnAsTofuFilter = new BmFilter( LEARN_AS_TOFU_NAME, "Spam", NULL); BMessage learnAsTofuJob; learnAsTofuJob.AddString("jobSpecifier", "LearnAsTofu"); mLearnAsTofuFilter->JobSpecifier(learnAsTofuJob); } } BM_LOG( BM_LogFilter, BmString("Successfully loaded addon ") << ao.name); } } BM_LOG2( BM_LogFilter, BmString("End of LoadAddons() for FilterList")); }