From ffb4ebbe1f683c4cf0e7c23a67bf5ca82d297a38 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 4 Jun 2002 14:01:11 +0000 Subject: [PATCH] * gpgsm/t-encrypt.c (main): Add a simple option parser and allow to specify an encryption key. --- trunk/tests/ChangeLog | 5 +++++ trunk/tests/gpgsm/t-encrypt.c | 27 +++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/trunk/tests/ChangeLog b/trunk/tests/ChangeLog index c511ae1..e1538b3 100644 --- a/trunk/tests/ChangeLog +++ b/trunk/tests/ChangeLog @@ -1,3 +1,8 @@ +2002-06-04 Werner Koch + + * gpgsm/t-encrypt.c (main): Add a simple option parser and allow + to specify an encryption key. + 2002-05-26 Marcus Brinkmann * gpg/Makefile.am (all-local): Remove dependency on ./secring.gpg. diff --git a/trunk/tests/gpgsm/t-encrypt.c b/trunk/tests/gpgsm/t-encrypt.c index bec71eb..9a7358c 100644 --- a/trunk/tests/gpgsm/t-encrypt.c +++ b/trunk/tests/gpgsm/t-encrypt.c @@ -71,6 +71,25 @@ main (int argc, char **argv ) GpgmeError err; GpgmeData in, out; GpgmeRecipients rset; + int loop = 0; + + /* simple option parser; ignoring unknown options */ + if (argc) + { + argc--; + argv++; + } + while (argc && **argv == '-' ) + { + if (!strcmp (*argv, "--loop")) + loop++; + + argc--; + argv++; + if (!strcmp (argv[-1], "--")) + break; + } + err = gpgme_engine_check_version (GPGME_PROTOCOL_CMS); fail_if_err (err); @@ -90,7 +109,11 @@ main (int argc, char **argv ) err = gpgme_recipients_new (&rset); fail_if_err (err); - err = gpgme_recipients_add_name_with_validity (rset, + if (argc) + err = gpgme_recipients_add_name_with_validity (rset, *argv, + GPGME_VALIDITY_FULL); + else + err = gpgme_recipients_add_name_with_validity (rset, "/CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=Düsseldorf,C=DE", GPGME_VALIDITY_FULL); fail_if_err (err); @@ -108,7 +131,7 @@ main (int argc, char **argv ) gpgme_data_release (in); gpgme_data_release (out); gpgme_release (ctx); - } while ( argc > 1 && !strcmp( argv[1], "--loop" ) ); + } while (loop); return 0; } -- 2.26.2