mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-12-23 02:11:40 +00:00
Refactore gnupg_deletekey to allow boolean allow_secret
This commit is contained in:
parent
e4ab851f1f
commit
e6c0456610
1 changed files with 12 additions and 4 deletions
16
gnupg.c
16
gnupg.c
|
@ -1845,6 +1845,10 @@ PHP_FUNCTION(gnupg_import)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
#ifndef GPGME_DELETE_ALLOW_SECRET
|
||||
#define GPGME_DELETE_ALLOW_SECRET 1
|
||||
#endif
|
||||
|
||||
/* {{{ proto book gnupg_deletekey(string key)
|
||||
* deletes a key from the keyring
|
||||
*/
|
||||
|
@ -1852,18 +1856,19 @@ PHP_FUNCTION(gnupg_deletekey)
|
|||
{
|
||||
char *key;
|
||||
phpc_str_size_t key_len;
|
||||
phpc_long_t allow_secret = 0;
|
||||
zend_bool allow_secret = 0;
|
||||
gpgme_key_t gpgme_key;
|
||||
unsigned int flags = 0;
|
||||
|
||||
GNUPG_GETOBJ();
|
||||
|
||||
if (this) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l",
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b",
|
||||
&key, &key_len, &allow_secret) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l",
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|b",
|
||||
&res, &key, &key_len, &allow_secret) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
@ -1874,7 +1879,10 @@ PHP_FUNCTION(gnupg_deletekey)
|
|||
GNUPG_ERR("get_key failed");
|
||||
return;
|
||||
}
|
||||
if (!PHP_GNUPG_DO(gpgme_op_delete(PHPC_THIS->ctx, gpgme_key, allow_secret))) {
|
||||
if (allow_secret) {
|
||||
flags = GPGME_DELETE_ALLOW_SECRET;
|
||||
}
|
||||
if (!PHP_GNUPG_DO(gpgme_op_delete(PHPC_THIS->ctx, gpgme_key, flags))) {
|
||||
GNUPG_ERR("delete failed");
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue