Changeset View
Changeset View
Standalone View
Standalone View
tests/run-genkey.c
Context not available. | |||||
" for addkey: FPR [ALGO [USAGE [EXPIRESECONDS]]]\n" | " for addkey: FPR [ALGO [USAGE [EXPIRESECONDS]]]\n" | ||||
" for adduid: FPR USERID\n" | " for adduid: FPR USERID\n" | ||||
" for revuid: FPR USERID\n" | " for revuid: FPR USERID\n" | ||||
" for set-expire: FPR EXPIRE [SUBFPRS]\n" | |||||
" for set-primary: FPR USERID\n" | " for set-primary: FPR USERID\n" | ||||
"Options:\n" | "Options:\n" | ||||
" --addkey add a subkey to the key with FPR\n" | " --addkey add a subkey to the key with FPR\n" | ||||
" --adduid add a user id to the key with FPR\n" | " --adduid add a user id to the key with FPR\n" | ||||
" --revuid revoke a user id from the key with FPR\n" | " --revuid revoke a user id from the key with FPR\n" | ||||
" --set-primary set the primary key flag on USERID\n" | " --set-primary set the primary key flag on USERID\n" | ||||
" --set-expire set the expiry date of the key FPR\n" | |||||
" --verbose run in verbose mode\n" | " --verbose run in verbose mode\n" | ||||
" --status print status lines from the backend\n" | " --status print status lines from the backend\n" | ||||
" --progress print progress info\n" | " --progress print progress info\n" | ||||
Context not available. | |||||
int adduid = 0; | int adduid = 0; | ||||
int revuid = 0; | int revuid = 0; | ||||
int setpri = 0; | int setpri = 0; | ||||
int setexpire = 0; | |||||
const char *userid; | const char *userid; | ||||
const char *algo = NULL; | const char *algo = NULL; | ||||
const char *newuserid = NULL; | const char *newuserid = NULL; | ||||
const char *fpr = NULL; | |||||
const char *subfprs = NULL; | |||||
unsigned int flags = 0; | unsigned int flags = 0; | ||||
unsigned long expire = 0; | unsigned long expire = 0; | ||||
gpgme_genkey_result_t result; | gpgme_genkey_result_t result; | ||||
Context not available. | |||||
} | } | ||||
else if (!strcmp (*argv, "--help")) | else if (!strcmp (*argv, "--help")) | ||||
show_usage (0); | show_usage (0); | ||||
else if (!strcmp (*argv, "--set-expire")) | |||||
{ | |||||
setexpire = 1; | |||||
adduid = 0; | |||||
revuid = 0; | |||||
setpri = 0; | |||||
argc--; argv++; | |||||
} | |||||
else if (!strcmp (*argv, "--addkey")) | else if (!strcmp (*argv, "--addkey")) | ||||
{ | { | ||||
addkey = 1; | addkey = 1; | ||||
Context not available. | |||||
userid = argv[0]; | userid = argv[0]; | ||||
newuserid = argv[1]; | newuserid = argv[1]; | ||||
} | } | ||||
else if (setexpire) | |||||
{ | |||||
if (argc < 2) | |||||
{ | |||||
show_usage (1); | |||||
} | |||||
fpr = argv[0]; | |||||
expire = parse_expire_string (argv[1]); | |||||
if (argc == 3) | |||||
{ | |||||
subfprs = argv[2]; | |||||
} | |||||
} | |||||
else | else | ||||
{ | { | ||||
if (!argc || argc > 4) | if (!argc || argc > 4) | ||||
Context not available. | |||||
gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL); | gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL); | ||||
} | } | ||||
if (addkey || adduid || revuid || setpri) | |||||
if (setexpire) | |||||
{ | |||||
err = gpgme_op_set_expire (ctx, fpr, expire, subfprs); | |||||
if (err) | |||||
{ | |||||
fprintf (stderr, PGM ": gpgme_op_set_expire failed: %s\n", | |||||
gpg_strerror (err)); | |||||
exit (1); | |||||
} | |||||
} | |||||
else if (addkey || adduid || revuid || setpri) | |||||
{ | { | ||||
gpgme_key_t akey; | gpgme_key_t akey; | ||||
Context not available. | |||||
} | } | ||||
} | } | ||||
if (!setpri) | if (!setpri && !setexpire) | ||||
{ | { | ||||
result = gpgme_op_genkey_result (ctx); | result = gpgme_op_genkey_result (ctx); | ||||
if (!result) | if (!result) | ||||
Context not available. |