(hx509_certs_info): print information about the keyset.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17969 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user