added dump function

This commit is contained in:
TLINDEN
2014-05-06 11:49:59 +02:00
parent 729c137e3c
commit 9d2d02221b
2 changed files with 24 additions and 3 deletions

View File

@@ -91,5 +91,6 @@ void fatals_reset(PCPCTX *ptx);
/* same as fatal() but dies immediately */ /* same as fatal() but dies immediately */
void final(const char * fmt, ...); void final(const char * fmt, ...);
void ptx_dump(PCPCTX *ptx);
#endif // _HAVE_PCP_CONTEXT_H #endif // _HAVE_PCP_CONTEXT_H

View File

@@ -44,14 +44,34 @@ PCPCTX *ptx_new() {
} }
void ptx_clean(PCPCTX *ptx) { void ptx_clean(PCPCTX *ptx) {
if(ptx->pcp_errset) if(ptx->pcp_errset) {
if(ptx->pcp_err != NULL)
free(ptx->pcp_err); free(ptx->pcp_err);
}
pcphash_clean(ptx); pcphash_clean(ptx);
free(ptx); free(ptx);
} }
void ptx_dump(PCPCTX *ptx) {
fprintf(stderr, "ERRSET: %d\n", ptx->pcp_errset);
if(ptx->pcp_errset)
fprintf(stderr, " ERR: %s\n", ptx->pcp_err);
fprintf(stderr, " sk:\n");
pcp_key_t *k = NULL;
pcphash_iterate(ptx, k) {
fprintf(stderr, " id: 0x%s\n", k->id);
}
fprintf(stderr, " pk:\n");
pcp_pubkey_t *p = NULL;
pcphash_iteratepub(ptx, p) {
fprintf(stderr, " id: 0x%s\n", p->id);
}
}
void fatal(PCPCTX *ptx, const char * fmt, ...) { void fatal(PCPCTX *ptx, const char * fmt, ...) {
va_list ap; va_list ap;