diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-11-04 14:44:27 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-11-04 14:49:24 +0100 |
commit | a75b1af2bff4e4c770a37198f399c3cc7c438aec (patch) | |
tree | 9a25f3be6e28524d83921e1cdcd652606675aa09 /src/common.c | |
parent | 7716aff4a3d08065e806c8e2304f183a2b273c23 (diff) | |
download | gnutls-a75b1af2bff4e4c770a37198f399c3cc7c438aec.tar.gz |
enhanced gnutls-cli-debug verbose output (uses files for mass text)
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/common.c b/src/common.c index dd61d45dd9..736ff4df81 100644 --- a/src/common.c +++ b/src/common.c @@ -101,7 +101,7 @@ static void print_x509_info_compact(gnutls_session_t session) } static void -print_x509_info(gnutls_session_t session, int flag, int print_cert) +print_x509_info(gnutls_session_t session, FILE *out, int flag, int print_cert) { gnutls_x509_crt_t crt; const gnutls_datum_t *cert_list; @@ -114,8 +114,8 @@ print_x509_info(gnutls_session_t session, int flag, int print_cert) return; } - printf("- Certificate type: X.509\n"); - printf("- Got a certificate list of %d certificates.\n", + fprintf(out, "- Certificate type: X.509\n"); + fprintf(out, "- Got a certificate list of %d certificates.\n", cert_list_size); for (j = 0; j < cert_list_size; j++) { @@ -131,13 +131,13 @@ print_x509_info(gnutls_session_t session, int flag, int print_cert) return; } - printf("- Certificate[%d] info:\n - ", j); + fprintf(out, "- Certificate[%d] info:\n - ", j); if (flag == GNUTLS_CRT_PRINT_COMPACT && j > 0) flag = GNUTLS_CRT_PRINT_ONELINE; ret = gnutls_x509_crt_print(crt, flag, &cinfo); if (ret == 0) { - printf("%s\n", cinfo.data); + fprintf(out, "%s\n", cinfo.data); gnutls_free(cinfo.data); } @@ -168,9 +168,9 @@ print_x509_info(gnutls_session_t session, int flag, int print_cert) } p[size] = 0; - fputs("\n", stdout); - fputs(p, stdout); - fputs("\n", stdout); + fputs("\n", out); + fputs(p, out); + fputs("\n", out); gnutls_free(p); } @@ -215,7 +215,7 @@ static void print_openpgp_info_compact(gnutls_session_t session) } static void -print_openpgp_info(gnutls_session_t session, int flag, int print_cert) +print_openpgp_info(gnutls_session_t session, FILE *out, int flag, int print_cert) { gnutls_openpgp_crt_t crt; @@ -223,7 +223,7 @@ print_openpgp_info(gnutls_session_t session, int flag, int print_cert) unsigned int cert_list_size = 0; int ret; - printf("- Certificate type: OpenPGP\n"); + fprintf(out, "- Certificate type: OpenPGP\n"); cert_list = gnutls_certificate_get_peers(session, &cert_list_size); @@ -241,7 +241,7 @@ print_openpgp_info(gnutls_session_t session, int flag, int print_cert) ret = gnutls_openpgp_crt_print(crt, flag, &cinfo); if (ret == 0) { - printf("- %s\n", cinfo.data); + fprintf(out, "- %s\n", cinfo.data); gnutls_free(cinfo.data); } @@ -271,8 +271,8 @@ print_openpgp_info(gnutls_session_t session, int flag, int print_cert) return; } - fputs(p, stdout); - fputs("\n", stdout); + fputs(p, out); + fputs("\n", out); gnutls_free(p); } @@ -607,6 +607,11 @@ int print_info(gnutls_session_t session, int verbose, int print_cert) void print_cert_info(gnutls_session_t session, int verbose, int print_cert) { + return print_cert_info2(session, verbose, stdout, print_cert); +} + +void print_cert_info2(gnutls_session_t session, int verbose, FILE *out, int print_cert) +{ int flag; if (verbose) @@ -619,11 +624,11 @@ void print_cert_info(gnutls_session_t session, int verbose, int print_cert) switch (gnutls_certificate_type_get(session)) { case GNUTLS_CRT_X509: - print_x509_info(session, flag, print_cert); + print_x509_info(session, out, flag, print_cert); break; #ifdef ENABLE_OPENPGP case GNUTLS_CRT_OPENPGP: - print_openpgp_info(session, flag, print_cert); + print_openpgp_info(session, out, flag, print_cert); break; #endif default: |