mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-11-22 06:27:08 +00:00
proper macro usage
deletekey now accepts a secret key in procedural mode fixed erealloc in addencryptkey
This commit is contained in:
parent
6803be309c
commit
f98e3c57e4
4 changed files with 44 additions and 44 deletions
50
gnupg.c
50
gnupg.c
|
@ -192,29 +192,29 @@ zend_object_value gnupg_obj_new(zend_class_entry *class_type TSRMLS_DC){
|
|||
|
||||
/* {{{ methodlist gnupg */
|
||||
static zend_function_entry gnupg_methods[] = {
|
||||
ZEND_ME(gnupg, keyinfo, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, verify, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, geterror, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, clearsignkeys, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, clearencryptkeys, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, cleardecryptkeys, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, setarmor, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, encrypt, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, decrypt, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, export, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, import, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, getprotocol, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, setsignmode, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, sign, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, encryptsign, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, decryptverify, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, addsignkey, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, addencryptkey, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, adddecryptkey, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, deletekey, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, gettrustlist, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, listsignatures, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg, seterrormode, NULL, ZEND_ACC_PUBLIC)
|
||||
PHP_FALIAS(keyinfo, gnupg_keyinfo, NULL)
|
||||
PHP_FALIAS(verify, gnupg_verify, NULL)
|
||||
PHP_FALIAS(geterror, gnupg_geterror, NULL)
|
||||
PHP_FALIAS(clearsignkeys, gnupg_clearsignkeys, NULL)
|
||||
PHP_FALIAS(clearencryptkeys, gnupg_clearencryptkeys, NULL)
|
||||
PHP_FALIAS(cleardecryptkeys, gnupg_cleardecryptkeys, NULL)
|
||||
PHP_FALIAS(setarmor, gnupg_setarmor, NULL)
|
||||
PHP_FALIAS(encrypt, gnupg_encrypt, NULL)
|
||||
PHP_FALIAS(decrypt, gnupg_decrypt, NULL)
|
||||
PHP_FALIAS(export, gnupg_export, NULL)
|
||||
PHP_FALIAS(import, gnupg_import, NULL)
|
||||
PHP_FALIAS(getprotocol, gnupg_getprotocol, NULL)
|
||||
PHP_FALIAS(setsignmode, gnupg_setsignmode, NULL)
|
||||
PHP_FALIAS(sign, gnupg_sign, NULL)
|
||||
PHP_FALIAS(encryptsign, gnupg_encryptsign, NULL)
|
||||
PHP_FALIAS(decryptverify, gnupg_decryptverify, NULL)
|
||||
PHP_FALIAS(addsignkey, gnupg_addsignkey, NULL)
|
||||
PHP_FALIAS(addencryptkey, gnupg_addencryptkey, NULL)
|
||||
PHP_FALIAS(adddecryptkey, gnupg_adddecryptkey, NULL)
|
||||
PHP_FALIAS(deletekey, gnupg_deletekey, NULL)
|
||||
PHP_FALIAS(gettrustlist, gnupg_gettrustlist, NULL)
|
||||
PHP_FALIAS(listsignatures, gnupg_listsignatures, NULL)
|
||||
PHP_FALIAS(seterrormode, gnupg_seterrormode, NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
@ -804,7 +804,7 @@ PHP_FUNCTION(gnupg_addencryptkey){
|
|||
GNUPG_ERR("get_key failed");
|
||||
return;
|
||||
}
|
||||
intern->encryptkeys = erealloc(intern->encryptkeys, sizeof(intern->encryptkeys) * (intern->encrypt_size + 1));
|
||||
intern->encryptkeys = erealloc(intern->encryptkeys, sizeof(intern->encryptkeys) * (intern->encrypt_size + 2));
|
||||
intern->encryptkeys[intern->encrypt_size] = gpgme_key;
|
||||
intern->encrypt_size++;
|
||||
intern->encryptkeys[intern->encrypt_size] = NULL;
|
||||
|
@ -1416,7 +1416,7 @@ PHP_FUNCTION(gnupg_deletekey){
|
|||
return;
|
||||
}
|
||||
}else{
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &res, &key, &key_len, &allow_secret) == FAILURE){
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &res, &key, &key_len, &allow_secret) == FAILURE){
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern,gnupg_object *, &res, -1, "ctx", le_gnupg);
|
||||
|
|
|
@ -82,12 +82,12 @@ zend_object_value gnupg_keylistiterator_objects_new(zend_class_entry *class_type
|
|||
|
||||
/* {{{ methodlist gnupg_keylistiterator */
|
||||
static zend_function_entry gnupg_keylistiterator_methods[] = {
|
||||
ZEND_ME(gnupg_keylistiterator, __construct, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg_keylistiterator, current, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg_keylistiterator, key, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg_keylistiterator, next, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg_keylistiterator, rewind, NULL, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(gnupg_keylistiterator, valid, NULL, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(gnupg_keylistiterator, __construct, NULL, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(gnupg_keylistiterator, current, NULL, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(gnupg_keylistiterator, key, NULL, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(gnupg_keylistiterator, next, NULL, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(gnupg_keylistiterator, rewind, NULL, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(gnupg_keylistiterator, valid, NULL, ZEND_ACC_PUBLIC)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
@ -112,7 +112,7 @@ int _gnupg_keylistiterator_init(INIT_FUNC_ARGS)
|
|||
/* }}} */
|
||||
|
||||
|
||||
PHP_FUNCTION(gnupg_keylistiterator___construct){
|
||||
PHP_METHOD(gnupg_keylistiterator,__construct){
|
||||
zval *pattern;
|
||||
|
||||
int args = ZEND_NUM_ARGS();
|
||||
|
@ -129,19 +129,19 @@ PHP_FUNCTION(gnupg_keylistiterator___construct){
|
|||
ZVAL_EMPTY_STRING(&intern->pattern);
|
||||
}
|
||||
}
|
||||
PHP_FUNCTION(gnupg_keylistiterator_current){
|
||||
PHP_METHOD(gnupg_keylistiterator,current){
|
||||
GNUPG_GET_ITERATOR();
|
||||
|
||||
RETURN_STRING(intern->gpgkey->uids[0].uid,1);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(gnupg_keylistiterator_key){
|
||||
PHP_METHOD(gnupg_keylistiterator,key){
|
||||
GNUPG_GET_ITERATOR();
|
||||
|
||||
RETURN_STRING(intern->gpgkey->subkeys[0].fpr,1);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(gnupg_keylistiterator_next){
|
||||
PHP_METHOD(gnupg_keylistiterator,next){
|
||||
GNUPG_GET_ITERATOR();
|
||||
|
||||
if(intern->gpgkey){
|
||||
|
@ -155,7 +155,7 @@ PHP_FUNCTION(gnupg_keylistiterator_next){
|
|||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
PHP_FUNCTION(gnupg_keylistiterator_rewind){
|
||||
PHP_METHOD(gnupg_keylistiterator,rewind){
|
||||
GNUPG_GET_ITERATOR();
|
||||
|
||||
if((intern->err = gpgme_op_keylist_start(intern->ctx, Z_STRVAL(intern->pattern), 0)) != GPG_ERR_NO_ERROR){
|
||||
|
@ -167,7 +167,7 @@ PHP_FUNCTION(gnupg_keylistiterator_rewind){
|
|||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
PHP_FUNCTION(gnupg_keylistiterator_valid){
|
||||
PHP_METHOD(gnupg_keylistiterator,valid){
|
||||
GNUPG_GET_ITERATOR();
|
||||
|
||||
if(intern->gpgkey!=NULL){
|
||||
|
|
|
@ -49,7 +49,6 @@ PHP_MINIT_FUNCTION(gnupg);
|
|||
PHP_MSHUTDOWN_FUNCTION(gnupg);
|
||||
PHP_MINFO_FUNCTION(gnupg);
|
||||
|
||||
PHP_FUNCTION(gnupg_construct);
|
||||
PHP_FUNCTION(gnupg_keyinfo);
|
||||
PHP_FUNCTION(gnupg_verify);
|
||||
PHP_FUNCTION(gnupg_geterror);
|
||||
|
|
|
@ -42,12 +42,13 @@ typedef struct _gnupg_keylistiterator_object{
|
|||
|
||||
zend_class_entry *gnupg_keylistiterator_class_entry;
|
||||
|
||||
PHP_FUNCTION(gnupg_keylistiterator___construct);
|
||||
PHP_FUNCTION(gnupg_keylistiterator_current);
|
||||
PHP_FUNCTION(gnupg_keylistiterator_next);
|
||||
PHP_FUNCTION(gnupg_keylistiterator_rewind);
|
||||
PHP_FUNCTION(gnupg_keylistiterator_key);
|
||||
PHP_FUNCTION(gnupg_keylistiterator_valid);
|
||||
PHP_METHOD(gnupg_keylistiterator, __construct);
|
||||
PHP_METHOD(gnupg_keylistiterator, current);
|
||||
PHP_METHOD(gnupg_keylistiterator, next);
|
||||
PHP_METHOD(gnupg_keylistiterator, rewind);
|
||||
PHP_METHOD(gnupg_keylistiterator, key);
|
||||
PHP_METHOD(gnupg_keylistiterator, valid);
|
||||
|
||||
|
||||
#ifdef ZTS
|
||||
#define GNUPG_G(v) TSRMG(gnupg_globals_id, zend_gnupg_globals *, v)
|
||||
|
|
Loading…
Reference in a new issue