void TWBaseScript::link_search(std::vector<TargetObj>* matches, const int from, const char* linkdef) { std::vector<LinkScanWorker> links; bool is_random = false, is_weighted = false, fetch_all = false;; uint fetch_count = 0; LinkMode mode = LM_BOTH; // Parse the link definition, and fetch the list of possible matching links const char* flavour = link_search_setup(linkdef, &is_random, &is_weighted, &fetch_count, &fetch_all, &mode); uint count = link_scan(flavour, from, is_weighted, mode, links); if(count) { // If no fetch count has been explicitly set, use the whole size, unless random is set if(fetch_count < 1) fetch_count = is_random ? 1 : links.size(); // if fetch_all has been set, set the count to the link count even in random mode if(fetch_all) fetch_count = links.size(); if(is_random) { select_random_links(matches, links, fetch_count, fetch_all, count, is_weighted); } else { select_links(matches, links, fetch_count); } } }
int match_link_dump(char *id, tstamp_t tstamp, char *str) { match_link_dump_t desc; /* Send message to all attached links */ desc.id = id; desc.tstamp = tstamp; desc.str = str; desc.len = strlen(str); desc.count = 0; link_scan((link_func_t *) match_link_dump_item, &desc); return desc.count; }