Merge branch 'next'

This commit is contained in:
Jakub Zelenka 2018-05-17 20:24:29 +01:00
commit 337ccfb4a0
30 changed files with 252 additions and 114 deletions

34
gnupg.c
View file

@ -82,13 +82,13 @@ PHPC_OBJ_DEFINE_HANDLER_VAR(gnupg);
} while (0)
/* }}} */
/* {{{ gnupg_free_encryptkeys */
static void gnupg_free_encryptkeys(PHPC_THIS_DECLARE(gnupg) TSRMLS_DC)
/* {{{ php_gnupg_free_encryptkeys */
static void php_gnupg_free_encryptkeys(PHPC_THIS_DECLARE(gnupg) TSRMLS_DC)
{
if (PHPC_THIS) {
int idx;
/* loop through all encryptkeys and unref them in the gpgme-lib */
for (idx=0; idx < PHPC_THIS->encrypt_size; idx++) {
for (idx = 0; idx < PHPC_THIS->encrypt_size; idx++) {
gpgme_key_unref(PHPC_THIS->encryptkeys[idx]);
}
if (PHPC_THIS->encryptkeys != NULL) {
@ -100,8 +100,8 @@ static void gnupg_free_encryptkeys(PHPC_THIS_DECLARE(gnupg) TSRMLS_DC)
}
/* }}} */
/* {{{ gnupg_free_resource_ptr */
static void gnupg_free_resource_ptr(PHPC_THIS_DECLARE(gnupg) TSRMLS_DC)
/* {{{ php_gnupg_free_resource_ptr */
static void php_gnupg_free_resource_ptr(PHPC_THIS_DECLARE(gnupg) TSRMLS_DC)
{
if (PHPC_THIS) {
if (PHPC_THIS->ctx) {
@ -111,7 +111,7 @@ static void gnupg_free_resource_ptr(PHPC_THIS_DECLARE(gnupg) TSRMLS_DC)
PHPC_THIS->ctx = NULL;
}
/* basic cleanup */
gnupg_free_encryptkeys(PHPC_THIS TSRMLS_CC);
php_gnupg_free_encryptkeys(PHPC_THIS TSRMLS_CC);
zend_hash_destroy(PHPC_THIS->signkeys);
FREE_HASHTABLE(PHPC_THIS->signkeys);
zend_hash_destroy(PHPC_THIS->decryptkeys);
@ -120,17 +120,17 @@ static void gnupg_free_resource_ptr(PHPC_THIS_DECLARE(gnupg) TSRMLS_DC)
}
/* }}} */
/* {{{ gnupg_res_dtor */
static void gnupg_res_dtor(phpc_res_entry_t *rsrc TSRMLS_DC) /* {{{ */
/* {{{ php_gnupg_res_dtor */
static void php_gnupg_res_dtor(phpc_res_entry_t *rsrc TSRMLS_DC) /* {{{ */
{
PHPC_THIS_DECLARE(gnupg) = rsrc->ptr;
gnupg_free_resource_ptr(PHPC_THIS TSRMLS_CC);
php_gnupg_free_resource_ptr(PHPC_THIS TSRMLS_CC);
efree(PHPC_THIS);
}
/* }}} */
/* {{{ gnupg_res_init */
static void gnupg_res_init(PHPC_THIS_DECLARE(gnupg) TSRMLS_DC)
/* {{{ php_gnupg_res_init */
static void php_gnupg_res_init(PHPC_THIS_DECLARE(gnupg) TSRMLS_DC)
{
/* init the gpgme-lib and set the default values */
gpgme_ctx_t ctx;
@ -161,7 +161,7 @@ PHPC_OBJ_HANDLER_FREE(gnupg)
{
PHPC_OBJ_HANDLER_FREE_INIT(gnupg);
gnupg_free_resource_ptr(PHPC_THIS TSRMLS_CC);
php_gnupg_free_resource_ptr(PHPC_THIS TSRMLS_CC);
PHPC_OBJ_HANDLER_FREE_DESTROY();
}
@ -171,7 +171,7 @@ PHPC_OBJ_HANDLER_CREATE_EX(gnupg)
{
PHPC_OBJ_HANDLER_CREATE_EX_INIT(gnupg);
gnupg_res_init(PHPC_THIS TSRMLS_CC);
php_gnupg_res_init(PHPC_THIS TSRMLS_CC);
PHPC_OBJ_HANDLER_CREATE_EX_RETURN(gnupg);
}
@ -450,7 +450,7 @@ PHP_MINIT_FUNCTION(gnupg)
/* register resource */
le_gnupg = zend_register_list_destructors_ex(
gnupg_res_dtor, NULL, "ctx", module_number);
php_gnupg_res_dtor, NULL, "ctx", module_number);
if (SUCCESS != gnupg_keylistiterator_init()) {
return FAILURE;
@ -648,7 +648,7 @@ PHP_FUNCTION(gnupg_init)
{
PHPC_THIS_DECLARE(gnupg);
PHPC_THIS = emalloc(sizeof(PHPC_OBJ_STRUCT_NAME(gnupg)));
gnupg_res_init(PHPC_THIS TSRMLS_CC);
php_gnupg_res_init(PHPC_THIS TSRMLS_CC);
PHPC_RES_RETURN(PHPC_RES_REGISTER(PHPC_THIS, le_gnupg));
}
/* }}} */
@ -726,7 +726,7 @@ PHP_FUNCTION(gnupg_seterrormode)
*/
PHP_FUNCTION(gnupg_setsignmode)
{
phpc_long_t signmode;
phpc_long_t signmode;
GNUPG_GETOBJ();
@ -1068,7 +1068,7 @@ PHP_FUNCTION(gnupg_clearencryptkeys)
}
GNUPG_RES_FETCH();
}
gnupg_free_encryptkeys(PHPC_THIS TSRMLS_CC);
php_gnupg_free_encryptkeys(PHPC_THIS TSRMLS_CC);
RETURN_TRUE;
}