split the iterator into separate file

generic code cleanup
updated package-xmls
This commit is contained in:
Thilo Raufeisen 2005-10-10 17:37:19 +00:00
parent 6bacc28bb6
commit af81003551
7 changed files with 321 additions and 211 deletions

6
README
View file

@ -41,6 +41,9 @@ Notes
- This extension is class based - This extension is class based
No "global" constants are defined. Only class constants No "global" constants are defined. Only class constants
- To specify a custom location of you keyring, simply store the path in the enviroment-variable GNUPGHOME
This should make it easy, to use this extension with the apache-user.
SIG_MODE_NORMAL SIG_MODE_NORMAL
SIG_MODE_DETACH SIG_MODE_DETACH
SIG_MODE_CLEAR SIG_MODE_CLEAR
@ -126,12 +129,13 @@ Methods
- array verify(string text [, string &plaintext]) - array verify(string text [, string &plaintext])
verifies the given clearsigned text and returns information about the result in an array verifies the given clearsigned text and returns information about the result in an array
if plaintext is passed, it is filled with the plaintext (the text without signature) if plaintext is passed, it is filled with the plaintext (the text without signature)
currently only cleartext-signatures are supported
- string decrypt(string enctext) - string decrypt(string enctext)
decrypts the given enctext decrypts the given enctext
- string encryptsign(string text) - string encryptsign(string text)
encrypts and signs the given text with the keys, whicih are set with setencryptkey and setsignerkey encrypts and signs the given text with the keys, which are set with setencryptkey and setsignerkey
- array decryptverify(string text, string &plaintext) - array decryptverify(string text, string &plaintext)
verifies the given clearsigned text and returns information about the result in an array verifies the given clearsigned text and returns information about the result in an array

217
gnupg.c
View file

@ -12,7 +12,7 @@
| obtain it through the world-wide-web, please send a note to | | obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. | | license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+ +----------------------------------------------------------------------+
| Author: Thilo Raufeisen | | Author: Thilo Raufeisen <traufeisen@php.net> |
+----------------------------------------------------------------------+ +----------------------------------------------------------------------+
*/ */
@ -25,16 +25,14 @@
#include "php.h" #include "php.h"
#include "php_ini.h" #include "php_ini.h"
#include "ext/standard/info.h" #include "ext/standard/info.h"
#include "zend_interfaces.h"
#include "php_gnupg.h" #include "php_gnupg.h"
#include "php_gnupg_keylistiterator.h"
static int le_gnupg; static int le_gnupg;
static int le_gnupg_keylistiterator;
static zend_object_handlers gnupg_object_handlers; static zend_object_handlers gnupg_object_handlers;
static zend_object_handlers gnupg_keylistiterator_object_handlers;
/* {{{ macros */ /* {{{ defs */
#define GNUPG_FROM_OBJECT(intern, object){ \ #define GNUPG_FROM_OBJECT(intern, object){ \
ze_gnupg_object *obj = (ze_gnupg_object*) zend_object_store_get_object(object TSRMLS_CC); \ ze_gnupg_object *obj = (ze_gnupg_object*) zend_object_store_get_object(object TSRMLS_CC); \
intern = obj->gnupg_ptr; \ intern = obj->gnupg_ptr; \
@ -43,14 +41,6 @@ static zend_object_handlers gnupg_keylistiterator_object_handlers;
RETURN_FALSE; \ RETURN_FALSE; \
} \ } \
} }
#define GNUPG_GET_ITERATOR(intern, object){ \
ze_gnupg_keylistiterator_object *obj = (ze_gnupg_keylistiterator_object*) zend_object_store_get_object(object TSRMLS_CC); \
intern = obj->gnupg_keylistiterator_ptr; \
if(!intern){ \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or unitialized gnupg iterator object"); \
RETURN_FALSE; \
}\
}
#define GNUPG_ERROR(intern, this){ \ #define GNUPG_ERROR(intern, this){ \
zend_update_property_string(Z_OBJCE_P(this), this, "error", 5, (char*)gpg_strerror(intern->err) TSRMLS_DC); \ zend_update_property_string(Z_OBJCE_P(this), this, "error", 5, (char*)gpg_strerror(intern->err) TSRMLS_DC); \
RETURN_FALSE; \ RETURN_FALSE; \
@ -90,27 +80,6 @@ static void gnupg_object_free_storage(void *object TSRMLS_DC){
} }
/* }}} */ /* }}} */
/* {{{ free_iterator_storage */
static void gnupg_keylistiterator_object_free_storage(void *object TSRMLS_DC){
ze_gnupg_keylistiterator_object *intern = (ze_gnupg_keylistiterator_object *) object;
if(!intern){
return;
}
if(intern->gnupg_keylistiterator_ptr){
gpgme_op_keylist_end(intern->gnupg_keylistiterator_ptr->ctx);
gpgme_key_release(intern->gnupg_keylistiterator_ptr->gpgkey);
gpgme_release(intern->gnupg_keylistiterator_ptr->ctx);
zval_dtor(&intern->gnupg_keylistiterator_ptr->pattern);
efree(intern->gnupg_keylistiterator_ptr);
}
if(intern->zo.properties){
zend_hash_destroy(intern->zo.properties);
FREE_HASHTABLE(intern->zo.properties);
}
efree(intern);
}
/* }}} */
/* {{{ objects_new */ /* {{{ objects_new */
zend_object_value gnupg_objects_new(zend_class_entry *class_type TSRMLS_DC){ zend_object_value gnupg_objects_new(zend_class_entry *class_type TSRMLS_DC){
ze_gnupg_object *intern; ze_gnupg_object *intern;
@ -145,70 +114,28 @@ zend_object_value gnupg_objects_new(zend_class_entry *class_type TSRMLS_DC){
} }
/* }}} */ /* }}} */
/* {{{ keylistiterator_objects_new */
zend_object_value gnupg_keylistiterator_objects_new(zend_class_entry *class_type TSRMLS_DC){
ze_gnupg_keylistiterator_object *intern;
zval *tmp;
zend_object_value retval;
gnupg_keylistiterator_object *gnupg_keylistiterator_ptr;
gpgme_ctx_t ctx;
intern = emalloc(sizeof(ze_gnupg_keylistiterator_object));
intern->zo.ce = class_type;
intern->zo.in_get = 0;
intern->zo.in_set = 0;
intern->zo.properties = NULL;
ALLOC_HASHTABLE(intern->zo.properties);
zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
retval.handle = zend_objects_store_put(intern,NULL,(zend_objects_free_object_storage_t) gnupg_keylistiterator_object_free_storage,NULL TSRMLS_CC);
retval.handlers = (zend_object_handlers *) & gnupg_keylistiterator_object_handlers;
gpgme_new(&ctx);
gnupg_keylistiterator_ptr = emalloc(sizeof(gnupg_keylistiterator_object));
gnupg_keylistiterator_ptr->ctx = ctx;
intern->gnupg_keylistiterator_ptr = gnupg_keylistiterator_ptr;
return retval;
}
/* }}} */
/* {{{ methodlist gnupg */ /* {{{ methodlist gnupg */
static zend_function_entry gnupg_methods[] = { static zend_function_entry gnupg_methods[] = {
PHP_ME_MAPPING(keyinfo, gnupg_keyinfo, NULL) ZEND_ME(gnupg, keyinfo, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(verify, gnupg_verify, NULL) ZEND_ME(gnupg, verify, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getError, gnupg_geterror, NULL) ZEND_ME(gnupg, geterror, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setpassphrase, gnupg_setpassphrase, NULL) ZEND_ME(gnupg, setpassphrase, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setsignerkey, gnupg_setsignerkey, NULL) ZEND_ME(gnupg, setsignerkey, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(clearsignerkey, gnupg_clearsignerkey, NULL) ZEND_ME(gnupg, clearsignerkey, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setencryptkey, gnupg_setencryptkey, NULL) ZEND_ME(gnupg, setencryptkey, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setarmor, gnupg_setarmor, NULL) ZEND_ME(gnupg, setarmor, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(encrypt, gnupg_encrypt, NULL) ZEND_ME(gnupg, encrypt, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(decrypt, gnupg_decrypt, NULL) ZEND_ME(gnupg, decrypt, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(export, gnupg_export, NULL) ZEND_ME(gnupg, export, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getprotocol, gnupg_getprotocol, NULL) ZEND_ME(gnupg, getprotocol, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setsignmode, gnupg_setsignmode, NULL) ZEND_ME(gnupg, setsignmode, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(sign, gnupg_sign, NULL) ZEND_ME(gnupg, sign, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(encryptsign, gnupg_encryptsign, NULL) ZEND_ME(gnupg, encryptsign, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(decryptverify, gnupg_decryptverify, NULL) ZEND_ME(gnupg, decryptverify, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL} {NULL, NULL, NULL}
}; };
/* }}} */ /* }}} */
/* {{{ methodlist gnupg_keylistiterator */
static zend_function_entry gnupg_keylistiterator_methods[] = {
PHP_ME_MAPPING(__construct, gnupg_keylistiterator_construct, NULL)
PHP_ME_MAPPING(current, gnupg_keylistiterator_current, NULL)
PHP_ME_MAPPING(key, gnupg_keylistiterator_key, NULL)
PHP_ME_MAPPING(next, gnupg_keylistiterator_next, NULL)
PHP_ME_MAPPING(rewind, gnupg_keylistiterator_rewind, NULL)
PHP_ME_MAPPING(valid, gnupg_keylistiterator_valid, NULL)
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ class constants */ /* {{{ class constants */
static void gnupg_declare_long_constant(const char *const_name, long value TSRMLS_DC){ static void gnupg_declare_long_constant(const char *const_name, long value TSRMLS_DC){
#if PHP_MAJOR_VERSION > 5 || PHP_MINOR_VERSION >= 1 #if PHP_MAJOR_VERSION > 5 || PHP_MINOR_VERSION >= 1
@ -240,11 +167,11 @@ zend_module_entry gnupg_module_entry = {
NULL, NULL,
PHP_MINIT(gnupg), PHP_MINIT(gnupg),
PHP_MSHUTDOWN(gnupg), PHP_MSHUTDOWN(gnupg),
NULL, /* Replace with NULL if there's nothing to do at request start */ NULL,
NULL, /* Replace with NULL if there's nothing to do at request end */ NULL,
PHP_MINFO(gnupg), PHP_MINFO(gnupg),
#if ZEND_MODULE_API_NO >= 20010901 #if ZEND_MODULE_API_NO >= 20010901
"0.1", /* Replace with version number for your extension */ "0.2",
#endif #endif
STANDARD_MODULE_PROPERTIES STANDARD_MODULE_PROPERTIES
}; };
@ -268,16 +195,10 @@ PHP_MINIT_FUNCTION(gnupg)
gnupg_class_entry = zend_register_internal_class(&ce TSRMLS_CC); gnupg_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
memcpy(&gnupg_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&gnupg_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
le_gnupg = zend_register_list_destructors_ex(NULL, NULL, "ctx", module_number); le_gnupg = zend_register_list_destructors_ex(NULL, NULL, "ctx", module_number);
INIT_CLASS_ENTRY(ce, "gnupg_keylistiterator", gnupg_keylistiterator_methods); if (SUCCESS != gnupg_keylistiterator_init()){
return FAILURE;
ce.create_object = gnupg_keylistiterator_objects_new; }
gnupg_keylistiterator_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
memcpy(&gnupg_keylistiterator_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
le_gnupg_keylistiterator = zend_register_list_destructors_ex(NULL, NULL, "ctx_keylistiterator", module_number);
zend_class_implements (gnupg_keylistiterator_class_entry TSRMLS_DC, 1, zend_ce_iterator);
register_gnupgProperties(TSRMLS_CC); register_gnupgProperties(TSRMLS_CC);
gnupg_declare_long_constant("SIG_MODE_NORMAL", GPGME_SIG_MODE_NORMAL TSRMLS_DC); gnupg_declare_long_constant("SIG_MODE_NORMAL", GPGME_SIG_MODE_NORMAL TSRMLS_DC);
@ -755,11 +676,11 @@ PHP_FUNCTION(gnupg_encryptsign){
} }
sign_result = gpgme_op_sign_result (intern->ctx); sign_result = gpgme_op_sign_result (intern->ctx);
userret = gpgme_data_release_and_get_mem(out,&ret_size); userret = gpgme_data_release_and_get_mem(out,&ret_size);
if(ret_size < 1){
RETURN_FALSE;
}
gpgme_data_release (in); gpgme_data_release (in);
free (out); free (out);
if(ret_size < 1){
RETURN_FALSE;
}
RETURN_STRINGL (userret,ret_size,1); RETURN_STRINGL (userret,ret_size,1);
} }
/* }}} */ /* }}} */
@ -858,9 +779,12 @@ PHP_FUNCTION(gnupg_decrypt){
result = gpgme_op_decrypt_result (intern->ctx); result = gpgme_op_decrypt_result (intern->ctx);
userret = gpgme_data_release_and_get_mem(out,&ret_size); userret = gpgme_data_release_and_get_mem(out,&ret_size);
RETURN_STRINGL (userret,ret_size,1);
gpgme_data_release (in); gpgme_data_release (in);
free (out); free (out);
if(ret_size < 1){
RETURN_FALSE;
}
RETURN_STRINGL (userret,ret_size,1);
} }
/* }}} */ /* }}} */
@ -956,81 +880,6 @@ PHP_FUNCTION(gnupg_export){
} }
/* }}} */ /* }}} */
PHP_FUNCTION(gnupg_keylistiterator_construct){
zval *pattern;
gnupg_keylistiterator_object *intern;
zval *this = getThis();
int args = ZEND_NUM_ARGS();
GNUPG_GET_ITERATOR(intern, this);
if(args > 0){
if (zend_parse_parameters(args TSRMLS_CC, "|z", &pattern) == FAILURE){
return;
}
intern->pattern = *pattern;
zval_copy_ctor(&intern->pattern);
}else{
convert_to_string(&intern->pattern);
}
}
PHP_FUNCTION(gnupg_keylistiterator_current){
zval *this = getThis();
gnupg_keylistiterator_object *intern;
GNUPG_GET_ITERATOR(intern, this);
RETURN_STRING(intern->gpgkey->uids[0].uid,1);
}
PHP_FUNCTION(gnupg_keylistiterator_key){
zval *this = getThis();
gnupg_keylistiterator_object *intern;
GNUPG_GET_ITERATOR(intern, this);
RETURN_STRING(intern->gpgkey->subkeys[0].fpr,1);
}
PHP_FUNCTION(gnupg_keylistiterator_next){
zval *this = getThis();
gnupg_keylistiterator_object *intern;
gpgme_error_t err;
GNUPG_GET_ITERATOR(intern, this);
if(err = gpgme_op_keylist_next(intern->ctx, &intern->gpgkey)){
gpgme_key_release(intern->gpgkey);
intern->gpgkey = NULL;
}
RETURN_TRUE;
}
PHP_FUNCTION(gnupg_keylistiterator_rewind){
zval *this = getThis();
gnupg_keylistiterator_object *intern;
gpgme_error_t err;
GNUPG_GET_ITERATOR(intern, this);
if((err = gpgme_op_keylist_start(intern->ctx, Z_STRVAL(intern->pattern), 0)) != GPG_ERR_NO_ERROR){
zend_throw_exception(zend_exception_get_default(),gpg_strerror(err),1 TSRMLS_CC);
}
if((err = gpgme_op_keylist_next(intern->ctx, &intern->gpgkey))!=GPG_ERR_NO_ERROR){
RETURN_FALSE;
}
RETURN_TRUE;
}
PHP_FUNCTION(gnupg_keylistiterator_valid){
zval *this = getThis();
gnupg_keylistiterator_object *intern;
GNUPG_GET_ITERATOR(intern, this);
if(intern->gpgkey!=NULL){
RETURN_TRUE;
}else{
RETURN_FALSE;
}
}
/* /*
* Local variables: * Local variables:
* tab-width: 4 * tab-width: 4

196
gnupg_keylistiterator.c Normal file
View file

@ -0,0 +1,196 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Thilo Raufeisen <traufeisen@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "zend_interfaces.h"
#include "php_gnupg.h"
#include "php_gnupg_keylistiterator.h"
static int le_gnupg_keylistiterator;
static zend_object_handlers gnupg_keylistiterator_object_handlers;
/* {{{ defs */
#define GNUPG_GET_ITERATOR() \
gnupg_keylistiterator_object *intern; \
ze_gnupg_keylistiterator_object *obj = (ze_gnupg_keylistiterator_object*) zend_object_store_get_object(getThis() TSRMLS_CC); \
intern = obj->gnupg_keylistiterator_ptr; \
if(!intern){ \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or unitialized gnupg iterator object"); \
RETURN_FALSE; \
}
/* }}} */
/* {{{ free_iterator_storage */
static void gnupg_keylistiterator_object_free_storage(void *object TSRMLS_DC){
ze_gnupg_keylistiterator_object *intern = (ze_gnupg_keylistiterator_object *) object;
if(!intern){
return;
}
if(intern->gnupg_keylistiterator_ptr){
gpgme_op_keylist_end(intern->gnupg_keylistiterator_ptr->ctx);
gpgme_key_release(intern->gnupg_keylistiterator_ptr->gpgkey);
gpgme_release(intern->gnupg_keylistiterator_ptr->ctx);
zval_dtor(&intern->gnupg_keylistiterator_ptr->pattern);
efree(intern->gnupg_keylistiterator_ptr);
}
if(intern->zo.properties){
zend_hash_destroy(intern->zo.properties);
FREE_HASHTABLE(intern->zo.properties);
}
efree(intern);
}
/* }}} */
/* {{{ keylistiterator_objects_new */
zend_object_value gnupg_keylistiterator_objects_new(zend_class_entry *class_type TSRMLS_DC){
ze_gnupg_keylistiterator_object *intern;
zend_object_value retval;
gnupg_keylistiterator_object *gnupg_keylistiterator_ptr;
gpgme_ctx_t ctx;
intern = emalloc(sizeof(ze_gnupg_keylistiterator_object));
intern->zo.ce = class_type;
intern->zo.in_get = 0;
intern->zo.in_set = 0;
intern->zo.properties = NULL;
retval.handle = zend_objects_store_put(intern,NULL,(zend_objects_free_object_storage_t) gnupg_keylistiterator_object_free_storage,NULL TSRMLS_CC);
retval.handlers = (zend_object_handlers *) & gnupg_keylistiterator_object_handlers;
gpgme_new(&ctx);
gnupg_keylistiterator_ptr = emalloc(sizeof(gnupg_keylistiterator_object));
gnupg_keylistiterator_ptr->ctx = ctx;
intern->gnupg_keylistiterator_ptr = gnupg_keylistiterator_ptr;
return retval;
}
/* }}} */
/* {{{ 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)
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ _gnupg_keylistiterator_init
*/
int _gnupg_keylistiterator_init(INIT_FUNC_ARGS)
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "gnupg_keylistiterator", gnupg_keylistiterator_methods);
ce.create_object = gnupg_keylistiterator_objects_new;
gnupg_keylistiterator_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
memcpy(&gnupg_keylistiterator_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
le_gnupg_keylistiterator = zend_register_list_destructors_ex(NULL, NULL, "ctx_keylistiterator", module_number);
zend_class_implements (gnupg_keylistiterator_class_entry TSRMLS_DC, 1, zend_ce_iterator);
return SUCCESS;
}
/* }}} */
PHP_FUNCTION(gnupg_keylistiterator___construct){
zval *pattern;
int args = ZEND_NUM_ARGS();
GNUPG_GET_ITERATOR();
if(args > 0){
if (zend_parse_parameters(args TSRMLS_CC, "|z", &pattern) == FAILURE){
return;
}
intern->pattern = *pattern;
zval_copy_ctor(&intern->pattern);
}else{
convert_to_string(&intern->pattern);
}
}
PHP_FUNCTION(gnupg_keylistiterator_current){
GNUPG_GET_ITERATOR();
RETURN_STRING(intern->gpgkey->uids[0].uid,1);
}
PHP_FUNCTION(gnupg_keylistiterator_key){
GNUPG_GET_ITERATOR();
RETURN_STRING(intern->gpgkey->subkeys[0].fpr,1);
}
PHP_FUNCTION(gnupg_keylistiterator_next){
GNUPG_GET_ITERATOR();
if(intern->err = gpgme_op_keylist_next(intern->ctx, &intern->gpgkey)){
gpgme_key_release(intern->gpgkey);
intern->gpgkey = NULL;
}
RETURN_TRUE;
}
PHP_FUNCTION(gnupg_keylistiterator_rewind){
GNUPG_GET_ITERATOR();
if((intern->err = gpgme_op_keylist_start(intern->ctx, Z_STRVAL(intern->pattern), 0)) != GPG_ERR_NO_ERROR){
zend_throw_exception(zend_exception_get_default(),gpg_strerror(intern->err),1 TSRMLS_CC);
}
if((intern->err = gpgme_op_keylist_next(intern->ctx, &intern->gpgkey))!=GPG_ERR_NO_ERROR){
RETURN_FALSE;
}
RETURN_TRUE;
}
PHP_FUNCTION(gnupg_keylistiterator_valid){
GNUPG_GET_ITERATOR();
if(intern->gpgkey!=NULL){
RETURN_TRUE;
}else{
RETURN_FALSE;
}
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/

View file

@ -16,7 +16,7 @@ So you can sign, encrypt, verify directly from php
</maintainers> </maintainers>
<release> <release>
<version>0.2</version> <version>0.2</version>
<date>2005-10-09</date> <date>2005-10-10</date>
<license>PHP License</license> <license>PHP License</license>
<state>beta</state> <state>beta</state>
<notes>added keylistiterator, encryptsign and decryptverify <notes>added keylistiterator, encryptsign and decryptverify
@ -30,7 +30,9 @@ So you can sign, encrypt, verify directly from php
<file role="doc" name="README"/> <file role="doc" name="README"/>
<file role="src" name="config.m4"/> <file role="src" name="config.m4"/>
<file role="src" name="php_gnupg.h"/> <file role="src" name="php_gnupg.h"/>
<file role="src" name="php_gnupg_keylistiterator.h" />
<file role="src" name="gnupg.c"/> <file role="src" name="gnupg.c"/>
<file role="src" name="gnupg_keylistiterator.c" />
<file role="doc" name="examples/main.php"/> <file role="doc" name="examples/main.php"/>
<file role="doc" name="examples/clearsign.php"/> <file role="doc" name="examples/clearsign.php"/>
<file role="doc" name="examples/verify.php"/> <file role="doc" name="examples/verify.php"/>
@ -43,7 +45,7 @@ So you can sign, encrypt, verify directly from php
<changelog> <changelog>
<release> <release>
<version>0.2</version> <version>0.2</version>
<date>2005-10-09</date> <date>2005-10-10</date>
<state>beta</state> <state>beta</state>
<notes>added keylistiterator, encryptsign and decryptverify</notes> <notes>added keylistiterator, encryptsign and decryptverify</notes>
</release> </release>

View file

@ -16,8 +16,8 @@ So you can sign, encrypt, verify directly from php
<email>traufeisen@php.net</email> <email>traufeisen@php.net</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2005-10-09</date> <date>2005-10-10</date>
<time>17:39:05</time> <time>19:34:14</time>
<version> <version>
<release>0.2</release> <release>0.2</release>
<api>0.2</api> <api>0.2</api>
@ -44,8 +44,10 @@ So you can sign, encrypt, verify directly from php
<file name="config.m4" role="src" /> <file name="config.m4" role="src" />
<file name="EXPERIMENTAL" role="doc" /> <file name="EXPERIMENTAL" role="doc" />
<file name="gnupg.c" role="src" /> <file name="gnupg.c" role="src" />
<file name="gnupg_keylistiterator.c" role="src" />
<file name="LICENSE" role="doc" /> <file name="LICENSE" role="doc" />
<file name="php_gnupg.h" role="src" /> <file name="php_gnupg.h" role="src" />
<file name="php_gnupg_keylistiterator.h" role="src" />
<file name="README" role="doc" /> <file name="README" role="doc" />
</dir> <!-- / --> </dir> <!-- / -->
</contents> </contents>
@ -71,7 +73,7 @@ So you can sign, encrypt, verify directly from php
<release>beta</release> <release>beta</release>
<api>beta</api> <api>beta</api>
</stability> </stability>
<date>2005-10-09</date> <date>2005-10-10</date>
<license uri="http://www.php.net/license">PHP License</license> <license uri="http://www.php.net/license">PHP License</license>
<notes>added keylistiterator, encryptsign and decryptverify <notes>added keylistiterator, encryptsign and decryptverify
</notes> </notes>

View file

@ -22,7 +22,6 @@
#define PHP_GNUPG_H #define PHP_GNUPG_H
extern zend_module_entry gnupg_module_entry; extern zend_module_entry gnupg_module_entry;
extern zend_module_entry gnupg_keyiterator_module_entry;
#define phpext_gnupg_ptr &gnupg_module_entry #define phpext_gnupg_ptr &gnupg_module_entry
#ifdef PHP_WIN32 #ifdef PHP_WIN32
@ -50,20 +49,7 @@ typedef struct _ze_gnupg_object{
gnupg_object *gnupg_ptr; gnupg_object *gnupg_ptr;
} ze_gnupg_object; } ze_gnupg_object;
typedef struct _gnupg_keylistiterator_object{
gpgme_ctx_t ctx;
gpgme_error_t err;
gpgme_key_t gpgkey;
zval pattern;
} gnupg_keylistiterator_object;
typedef struct _ze_gnupg_keylistiterator_object{
zend_object zo;
gnupg_keylistiterator_object *gnupg_keylistiterator_ptr;
} ze_gnupg_keylistiterator_object;
zend_class_entry *gnupg_class_entry; zend_class_entry *gnupg_class_entry;
zend_class_entry *gnupg_keylistiterator_class_entry;
PHP_MINIT_FUNCTION(gnupg); PHP_MINIT_FUNCTION(gnupg);
PHP_MSHUTDOWN_FUNCTION(gnupg); PHP_MSHUTDOWN_FUNCTION(gnupg);
@ -87,13 +73,6 @@ PHP_FUNCTION(gnupg_decrypt);
PHP_FUNCTION(gnupg_decryptverify); PHP_FUNCTION(gnupg_decryptverify);
PHP_FUNCTION(gnupg_export); PHP_FUNCTION(gnupg_export);
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);
#ifdef ZTS #ifdef ZTS
#define GNUPG_G(v) TSRMG(gnupg_globals_id, zend_gnupg_globals *, v) #define GNUPG_G(v) TSRMG(gnupg_globals_id, zend_gnupg_globals *, v)
#else #else

View file

@ -0,0 +1,78 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Thilo Raufeisen |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_GNUPG_KEYLISTITERATOR_H
#define PHP_GNUPG_KEYLISTITERATOR_H
extern zend_module_entry gnupg_keyiterator_module_entry;
#ifdef PHP_WIN32
#define PHP_GNUPG_API __declspec(dllexport)
#else
#define PHP_GNUPG_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
#include <gpgme.h>
#define gnupg_keylistiterator_init() _gnupg_keylistiterator_init(INIT_FUNC_ARGS_PASSTHRU)
extern int _gnupg_keylistiterator_init(INIT_FUNC_ARGS);
typedef struct _gnupg_keylistiterator_object{
gpgme_ctx_t ctx;
gpgme_error_t err;
gpgme_key_t gpgkey;
zval pattern;
} gnupg_keylistiterator_object;
typedef struct _ze_gnupg_keylistiterator_object{
zend_object zo;
gnupg_keylistiterator_object *gnupg_keylistiterator_ptr;
} ze_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);
#ifdef ZTS
#define GNUPG_G(v) TSRMG(gnupg_globals_id, zend_gnupg_globals *, v)
#else
#define GNUPG_G(v) (gnupg_globals.v)
#endif
#endif /* PHP_GNUPG_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/