diff --git a/gnupg.c b/gnupg.c index 1e87896..b438d6e 100644 --- a/gnupg.c +++ b/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_GNUPG_FALIAS(keyinfo, arginfo_gnupg_pattern_method) PHP_GNUPG_FALIAS(verify, arginfo_gnupg_verify_method) + PHP_GNUPG_FALIAS(getengineinfo, NULL) PHP_GNUPG_FALIAS(geterror, NULL) PHP_GNUPG_FALIAS(clearsignkeys, 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_export, arginfo_gnupg_pattern_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_setsignmode, arginfo_gnupg_signmode_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) * returns the last errormessage */ diff --git a/php_gnupg.h b/php_gnupg.h index bb4a24b..1418813 100644 --- a/php_gnupg.h +++ b/php_gnupg.h @@ -52,6 +52,7 @@ PHP_MINFO_FUNCTION(gnupg); PHP_METHOD(gnupg, __construct); PHP_FUNCTION(gnupg_keyinfo); PHP_FUNCTION(gnupg_verify); +PHP_FUNCTION(gnupg_getengineinfo); PHP_FUNCTION(gnupg_geterror); PHP_FUNCTION(gnupg_setsignmode); PHP_FUNCTION(gnupg_setarmor); diff --git a/tests/gnupg_oo_getengineinfo.phpt b/tests/gnupg_oo_getengineinfo.phpt new file mode 100644 index 0000000..4379f98 --- /dev/null +++ b/tests/gnupg_oo_getengineinfo.phpt @@ -0,0 +1,29 @@ +--TEST-- +get keyinfo +--SKIPIF-- + +--FILE-- +getengineinfo($fingerprint); +var_dump($ret); +?> +--EXPECTF-- +array(3) { + ["protocol"]=> + int(0) + ["file_name"]=> + string(%d) %s + ["home_dir"]=> + string(0) "" +} + +--CLEAN-- + + diff --git a/tests/gnupg_res_getengineinfo.phpt b/tests/gnupg_res_getengineinfo.phpt new file mode 100644 index 0000000..e6bc0f7 --- /dev/null +++ b/tests/gnupg_res_getengineinfo.phpt @@ -0,0 +1,29 @@ +--TEST-- +get keyinfo +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(3) { + ["protocol"]=> + int(0) + ["file_name"]=> + string(%d) %s + ["home_dir"]=> + string(0) "" +} + +--CLEAN-- + +