void find(int (*match_fn)(char*)) { int i; puts("Результаты поиска:"); puts("---------------------------------"); for(i = 0; i < NUM_ADS; i++){ if(match_fn(ADS[i])) { printf("%s\n", ADS[i]); } } puts("---------------------------------"); }
/* * precedence based dequeue with match function. Passing a NULL pointer * for the match function parameter is considered to be a wildcard so * any packet on the queue is returned. In that case it is no different * from brcmu_pktq_pdeq() above. */ struct sk_buff *brcmu_pktq_pdeq_match(struct pktq *pq, int prec, bool (*match_fn)(struct sk_buff *skb, void *arg), void *arg) { struct sk_buff_head *q; struct sk_buff *p, *next; q = &pq->q[prec].skblist; skb_queue_walk_safe(q, p, next) { if (match_fn == NULL || match_fn(p, arg)) { skb_unlink(p, q); pq->len--; return p; } } return NULL; }
GeneralName::MatchResult GeneralName::matches(const X509_Certificate& cert) const { std::vector<std::string> nam; std::function<bool(const GeneralName*,const std::string&)> match_fn; if(type() == "DNS") { match_fn = std::mem_fn(&GeneralName::matches_dns); nam = cert.subject_info("DNS"); if(nam.empty()) { nam = cert.subject_info("CN"); } } else if(type() == "DN") { match_fn = std::mem_fn(&GeneralName::matches_dn); std::stringstream ss; ss << cert.subject_dn(); nam.push_back(ss.str()); } else if(type() == "IP") { match_fn = std::mem_fn(&GeneralName::matches_ip); nam = cert.subject_info("IP"); } else { return MatchResult::UnknownType; } if(nam.empty()) { return MatchResult::NotFound; } bool some = false; bool all = true; for(const std::string& n: nam) { bool m = match_fn(this,n); some |= m; all &= m; } if(all) { return MatchResult::All; } else if(some) { return MatchResult::Some; } else { return MatchResult::None; } }