summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2007-11-26 12:00:39 +0100
committerWerner Koch <wk@gnupg.org>2007-11-26 12:00:39 +0100
commit3d4ef0c814698381371c9d5563cf158950af896c (patch)
tree4a85d8ece842de5243f281e644975a2050236332 /common
parentNew command GETAUDITLOG (diff)
downloadgnupg2-3d4ef0c814698381371c9d5563cf158950af896c.tar.xz
gnupg2-3d4ef0c814698381371c9d5563cf158950af896c.zip
Add option --data to GETAUDITLOG command.
Return HTML formatted dummy output.
Diffstat (limited to 'common')
-rw-r--r--common/audit.c29
-rw-r--r--common/audit.h3
2 files changed, 20 insertions, 12 deletions
diff --git a/common/audit.c b/common/audit.c
index baa7d8d51..d82052363 100644
--- a/common/audit.c
+++ b/common/audit.c
@@ -297,18 +297,20 @@ audit_log_cert (audit_ctx_t ctx, audit_event_t event,
/* Print the formatted audit result. THIS IS WORK IN PROGRESS. */
void
-audit_print_result (audit_ctx_t ctx, FILE *fp)
+audit_print_result (audit_ctx_t ctx, estream_t out)
{
int idx;
int maxlen;
size_t n;
+ es_fputs ("<div class=\"GnuPGAuditLog\">\n", out);
+
if (!ctx)
- return;
+ goto leave;
if (!ctx->log || !ctx->logused)
{
- fprintf (fp, "AUDIT-LOG: No entries\n");
- return;
+ es_fprintf (out, "<p>AUDIT-LOG: No entries</p>\n");
+ goto leave;
}
for (idx=0,maxlen=0; idx < DIM (eventstr_msgidx); idx++)
@@ -318,19 +320,24 @@ audit_print_result (audit_ctx_t ctx, FILE *fp)
maxlen = n;
}
+ es_fputs ("<ul>\n", out);
for (idx=0; idx < ctx->logused; idx++)
{
- fprintf (fp, "AUDIT-LOG[%d]: %-*s",
- idx, maxlen, event2str (ctx->log[idx].event));
+ es_fprintf (out, " <li>%-*s",
+ maxlen, event2str (ctx->log[idx].event));
if (ctx->log[idx].have_intvalue)
- fprintf (fp, " i=%d", ctx->log[idx].intvalue);
+ es_fprintf (out, " i=%d", ctx->log[idx].intvalue);
if (ctx->log[idx].string)
- fprintf (fp, " s=`%s'", ctx->log[idx].string);
+ es_fprintf (out, " s=`%s'", ctx->log[idx].string);
if (ctx->log[idx].cert)
- fprintf (fp, " has_cert");
+ es_fprintf (out, " has_cert");
if (ctx->log[idx].have_err)
- fprintf (fp, " err=\"%s\"", gpg_strerror (ctx->log[idx].err));
- putc ('\n', fp);
+ es_fprintf (out, " err=\"%s\"", gpg_strerror (ctx->log[idx].err));
+ es_fputs ("</li>\n", out);
}
+ es_fputs ("</ul>\n", out);
+
+ leave:
+ es_fputs ("</div>\n", out);
}
diff --git a/common/audit.h b/common/audit.h
index ca7b70405..83baa41c7 100644
--- a/common/audit.h
+++ b/common/audit.h
@@ -22,6 +22,7 @@
#include <ksba.h>
+#include "estream.h"
struct audit_ctx_s;
typedef struct audit_ctx_s *audit_ctx_t;
@@ -132,7 +133,7 @@ void audit_log_s (audit_ctx_t ctx, audit_event_t event, const char *value);
void audit_log_cert (audit_ctx_t ctx, audit_event_t event,
ksba_cert_t cert, gpg_error_t err);
-void audit_print_result (audit_ctx_t ctx, FILE *fp);
+void audit_print_result (audit_ctx_t ctx, estream_t stream);