summaryrefslogtreecommitdiff
path: root/tests/run-genkey.c
diff options
context:
space:
mode:
authorJinWang An <jinwang.an@samsung.com>2023-01-30 13:26:32 +0900
committerJinWang An <jinwang.an@samsung.com>2023-01-30 13:26:32 +0900
commit7068c0ead0c25a9a1fd3ce0b486636d74350e7ca (patch)
tree732edf51b955fd198e4bb7ef46a0782fb3ea1d12 /tests/run-genkey.c
parentd19c360948ede5ffe5974de8abc9da44be617ca1 (diff)
downloadgpgme-7068c0ead0c25a9a1fd3ce0b486636d74350e7ca.tar.gz
gpgme-7068c0ead0c25a9a1fd3ce0b486636d74350e7ca.tar.bz2
gpgme-7068c0ead0c25a9a1fd3ce0b486636d74350e7ca.zip
Imported Upstream version 1.17.0upstream/1.17.0
Diffstat (limited to 'tests/run-genkey.c')
-rw-r--r--tests/run-genkey.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/tests/run-genkey.c b/tests/run-genkey.c
index f0f6e30..8572db2 100644
--- a/tests/run-genkey.c
+++ b/tests/run-genkey.c
@@ -131,15 +131,23 @@ progress_cb (void *opaque, const char *what, int type, int current, int total)
static unsigned long
-parse_expire_string (const char *string)
+parse_expire_string (const char *string, unsigned int *flags)
{
- unsigned long seconds;
+ unsigned long seconds = 0;
- if (!string || !*string || !strcmp (string, "none")
- || !strcmp (string, "never") || !strcmp (string, "-"))
- seconds = 0;
+ if (!string || !*string || !strcmp (string, "-"))
+ ;
+ else if (!strcmp (string, "none") || !strcmp (string, "never"))
+ {
+ if (flags)
+ *flags |= GPGME_CREATE_NOEXPIRE;
+ }
else if (strspn (string, "01234567890") == strlen (string))
- seconds = strtoul (string, NULL, 10);
+ {
+ seconds = strtoul (string, NULL, 10);
+ if (!seconds && flags)
+ *flags |= GPGME_CREATE_NOEXPIRE;
+ }
else
{
fprintf (stderr, PGM ": invalid value '%s'\n", string);
@@ -370,7 +378,7 @@ main (int argc, char **argv)
}
userid = argv[0];
argc--; argv++;
- expire = parse_expire_string (argv[0]);
+ expire = parse_expire_string (argv[0], NULL);
argc--; argv++;
if (argc > 1)
{
@@ -414,7 +422,7 @@ main (int argc, char **argv)
if (argc > 2)
flags |= parse_usage_string (argv[2]);
if (argc > 3)
- expire = parse_expire_string (argv[3]);
+ expire = parse_expire_string (argv[3], &flags);
}
init_gpgme (protocol);