diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run-sign.c | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/tests/run-sign.c b/tests/run-sign.c index 37211d72..73a970d0 100644 --- a/tests/run-sign.c +++ b/tests/run-sign.c @@ -87,6 +87,8 @@ show_usage (int ex) " --sender MBOX use MBOX as sender address\n" " --include-key-block use this option with gpg\n" " --clear create a clear text signature\n" + " --archive create a signed archive with the given file or directory\n" + " --diagnostics print diagnostics\n" , stderr); exit (ex); } @@ -106,6 +108,7 @@ main (int argc, char **argv) int print_status = 0; int use_loopback = 0; int include_key_block = 0; + int diagnostics = 0; const char *sender = NULL; const char *s; @@ -178,6 +181,16 @@ main (int argc, char **argv) sigmode = GPGME_SIG_MODE_CLEAR; argc--; argv++; } + else if (!strcmp (*argv, "--archive")) + { + sigmode = GPGME_SIG_MODE_ARCHIVE; + argc--; argv++; + } + else if (!strcmp (*argv, "--diagnostics")) + { + diagnostics = 1; + argc--; argv++; + } else if (!strncmp (*argv, "--", 2)) show_usage (1); @@ -236,12 +249,20 @@ main (int argc, char **argv) } } - err = gpgme_data_new_from_file (&in, *argv, 1); - if (err) + if (sigmode == GPGME_SIG_MODE_ARCHIVE) { - fprintf (stderr, PGM ": error reading `%s': %s\n", - *argv, gpg_strerror (err)); - exit (1); + const char *path = *argv; + err = gpgme_data_new_from_mem (&in, path, strlen (path), 0); + } + else + { + err = gpgme_data_new_from_file (&in, *argv, 1); + if (err) + { + fprintf (stderr, PGM ": error reading `%s': %s\n", + *argv, gpg_strerror (err)); + exit (1); + } } err = gpgme_data_new (&out); @@ -249,6 +270,28 @@ main (int argc, char **argv) err = gpgme_op_sign (ctx, in, out, sigmode); result = gpgme_op_sign_result (ctx); + + if (diagnostics) + { + gpgme_data_t diag; + gpgme_error_t diag_err; + + gpgme_data_new (&diag); + diag_err = gpgme_op_getauditlog (ctx, diag, GPGME_AUDITLOG_DIAG); + if (diag_err) + { + fprintf (stderr, PGM ": getting diagnostics failed: %s\n", + gpgme_strerror (diag_err)); + } + else + { + fputs ("Begin Diagnostics:\n", stdout); + print_data (diag); + fputs ("End Diagnostics.\n", stdout); + } + gpgme_data_release (diag); + } + if (result) print_result (result, sigmode); if (err) |