From c226612caafae7d17bfd4bfbf4aa90ef6f306d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Sat, 4 Nov 2006 23:27:49 +0000 Subject: [PATCH] (hx509_query_match_cmp_func): allow setting the match function. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18909 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/cert.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/hx509/cert.c b/lib/hx509/cert.c index edc533498..aece06098 100644 --- a/lib/hx509/cert.c +++ b/lib/hx509/cert.c @@ -1852,6 +1852,20 @@ hx509_query_match_friendly_name(hx509_query *q, const char *name) return 0; } +int +hx509_query_match_cmp_func(hx509_query *q, + int (*func)(void *, hx509_cert), + void *ctx) +{ + if (func) + q->match |= HX509_QUERY_MATCH_FUNCTION; + else + q->match &= ~HX509_QUERY_MATCH_FUNCTION; + q->cmp_func = func; + q->cmp_func_ctx = ctx; +} + + void hx509_query_free(hx509_context context, hx509_query *q) { @@ -1953,7 +1967,7 @@ _hx509_query_match_cert(hx509_context context, const hx509_query *q, hx509_cert return 0; } if (q->match & HX509_QUERY_MATCH_FUNCTION) { - int ret = (*q->cmp_func)(cert); + int ret = (*q->cmp_func)(q->cmp_func_ctx, cert); if (ret != 0) return 0; }