mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-11-22 06:27:08 +00:00
Add gnupg_getengineinfo
This commit is contained in:
parent
60e13bec5a
commit
587a5f9400
4 changed files with 85 additions and 0 deletions
26
gnupg.c
26
gnupg.c
|
@ -287,6 +287,7 @@ phpc_function_entry gnupg_methods[] = {
|
||||||
PHP_ME(gnupg, __construct, arginfo_gnupg_init, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
|
PHP_ME(gnupg, __construct, arginfo_gnupg_init, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
|
||||||
PHP_GNUPG_FALIAS(keyinfo, arginfo_gnupg_pattern_method)
|
PHP_GNUPG_FALIAS(keyinfo, arginfo_gnupg_pattern_method)
|
||||||
PHP_GNUPG_FALIAS(verify, arginfo_gnupg_verify_method)
|
PHP_GNUPG_FALIAS(verify, arginfo_gnupg_verify_method)
|
||||||
|
PHP_GNUPG_FALIAS(getengineinfo, NULL)
|
||||||
PHP_GNUPG_FALIAS(geterror, NULL)
|
PHP_GNUPG_FALIAS(geterror, NULL)
|
||||||
PHP_GNUPG_FALIAS(clearsignkeys, NULL)
|
PHP_GNUPG_FALIAS(clearsignkeys, NULL)
|
||||||
PHP_GNUPG_FALIAS(clearencryptkeys, NULL)
|
PHP_GNUPG_FALIAS(clearencryptkeys, NULL)
|
||||||
|
@ -406,6 +407,7 @@ static zend_function_entry gnupg_functions[] = {
|
||||||
PHP_FE(gnupg_decrypt, arginfo_gnupg_enctext_function)
|
PHP_FE(gnupg_decrypt, arginfo_gnupg_enctext_function)
|
||||||
PHP_FE(gnupg_export, arginfo_gnupg_pattern_function)
|
PHP_FE(gnupg_export, arginfo_gnupg_pattern_function)
|
||||||
PHP_FE(gnupg_import, arginfo_gnupg_key_function)
|
PHP_FE(gnupg_import, arginfo_gnupg_key_function)
|
||||||
|
PHP_FE(gnupg_getengineinfo, arginfo_gnupg_void_function)
|
||||||
PHP_FE(gnupg_getprotocol, arginfo_gnupg_void_function)
|
PHP_FE(gnupg_getprotocol, arginfo_gnupg_void_function)
|
||||||
PHP_FE(gnupg_setsignmode, arginfo_gnupg_signmode_function)
|
PHP_FE(gnupg_setsignmode, arginfo_gnupg_signmode_function)
|
||||||
PHP_FE(gnupg_encryptsign, arginfo_gnupg_text_function)
|
PHP_FE(gnupg_encryptsign, arginfo_gnupg_text_function)
|
||||||
|
@ -819,6 +821,30 @@ PHP_FUNCTION(gnupg_setsignmode)
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
/* {{{ proto array gnupg_getengineinfo(void)
|
||||||
|
* returns the engine info
|
||||||
|
*/
|
||||||
|
PHP_FUNCTION(gnupg_getengineinfo)
|
||||||
|
{
|
||||||
|
gpgme_engine_info_t info;
|
||||||
|
GNUPG_GETOBJ();
|
||||||
|
|
||||||
|
if (!this) {
|
||||||
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GNUPG_RES_FETCH();
|
||||||
|
}
|
||||||
|
|
||||||
|
info = gpgme_ctx_get_engine_info(PHPC_THIS->ctx);
|
||||||
|
|
||||||
|
PHPC_ARRAY_INIT(return_value);
|
||||||
|
PHPC_ARRAY_ADD_ASSOC_LONG(return_value, "protocol", info->protocol);
|
||||||
|
PHPC_ARRAY_ADD_ASSOC_CSTR(return_value, "file_name", info->file_name);
|
||||||
|
PHPC_ARRAY_ADD_ASSOC_CSTR(return_value, "home_dir", info->home_dir ? info->home_dir : "");
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ proto string gnupg_geterror(void)
|
/* {{{ proto string gnupg_geterror(void)
|
||||||
* returns the last errormessage
|
* returns the last errormessage
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -52,6 +52,7 @@ PHP_MINFO_FUNCTION(gnupg);
|
||||||
PHP_METHOD(gnupg, __construct);
|
PHP_METHOD(gnupg, __construct);
|
||||||
PHP_FUNCTION(gnupg_keyinfo);
|
PHP_FUNCTION(gnupg_keyinfo);
|
||||||
PHP_FUNCTION(gnupg_verify);
|
PHP_FUNCTION(gnupg_verify);
|
||||||
|
PHP_FUNCTION(gnupg_getengineinfo);
|
||||||
PHP_FUNCTION(gnupg_geterror);
|
PHP_FUNCTION(gnupg_geterror);
|
||||||
PHP_FUNCTION(gnupg_setsignmode);
|
PHP_FUNCTION(gnupg_setsignmode);
|
||||||
PHP_FUNCTION(gnupg_setarmor);
|
PHP_FUNCTION(gnupg_setarmor);
|
||||||
|
|
29
tests/gnupg_oo_getengineinfo.phpt
Normal file
29
tests/gnupg_oo_getengineinfo.phpt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
--TEST--
|
||||||
|
get keyinfo
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
|
$gpg = new gnupg();
|
||||||
|
$ret = $gpg->getengineinfo($fingerprint);
|
||||||
|
var_dump($ret);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
array(3) {
|
||||||
|
["protocol"]=>
|
||||||
|
int(0)
|
||||||
|
["file_name"]=>
|
||||||
|
string(%d) %s
|
||||||
|
["home_dir"]=>
|
||||||
|
string(0) ""
|
||||||
|
}
|
||||||
|
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
||||||
|
|
29
tests/gnupg_res_getengineinfo.phpt
Normal file
29
tests/gnupg_res_getengineinfo.phpt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
--TEST--
|
||||||
|
get keyinfo
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
|
$gpg = gnupg_init();
|
||||||
|
$ret = gnupg_getengineinfo($gpg);
|
||||||
|
var_dump($ret);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
array(3) {
|
||||||
|
["protocol"]=>
|
||||||
|
int(0)
|
||||||
|
["file_name"]=>
|
||||||
|
string(%d) %s
|
||||||
|
["home_dir"]=>
|
||||||
|
string(0) ""
|
||||||
|
}
|
||||||
|
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
||||||
|
|
Loading…
Reference in a new issue