From 5b65222edfb2d4eb7378731bfbc7cf078e923af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 4 Sep 2006 07:24:33 +0000 Subject: [PATCH] (hx509_certs_info): print information about the keyset. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17969 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/keyset.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/lib/hx509/keyset.c b/lib/hx509/keyset.c index e6fc9349b..15327cb8d 100644 --- a/lib/hx509/keyset.c +++ b/lib/hx509/keyset.c @@ -330,3 +330,46 @@ hx509_get_one_cert(hx509_context context, hx509_certs certs, hx509_cert *c) hx509_certs_end_seq(context, certs, cursor); return 0; } + +static int +certs_info_stdio(void *ctx, char *str) +{ + FILE *f = ctx; + fprintf(f, "%s\n", str); + return 0; +} + +int +hx509_certs_info(hx509_context context, + hx509_certs certs, + int (*func)(void *, char *), + void *ctx) +{ + if (func == NULL) { + func = certs_info_stdio; + if (ctx == NULL) + ctx = stdout; + } + if (certs->ops->printinfo == NULL) { + (*func)(ctx, "No info function for certs"); + return 0; + } + return (*certs->ops->printinfo)(context, certs, certs->ops_data, + func, ctx); +} + +void +_hx509_pi_printf(int (*func)(void *, char *), void *ctx, + char *fmt, ...) +{ + va_list ap; + char *str; + + va_start(ap, fmt); + vasprintf(&str, fmt, ap); + va_end(ap); + if (str == NULL) + return; + (*func)(ctx, str); + free(str); +}