fi
])
+dnl ----
+dnl PROPRO
+dnl ----
+ HTTP_HAVE_PHP_EXT([propro], [
+ AC_MSG_CHECKING([for php_propro.h])
+ HTTP_EXT_PROPRO_INCDIR=
+ for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../propro; do
+ if test -d $i; then
+ if test -f $i/php_propro.h; then
+ HTTP_EXT_PROPRO_INCDIR=$i
+ break
+ elif test -f $i/ext/propro/php_propro.h; then
+ HTTP_EXT_PROPRO_INCDIR=$i/ext/propro
+ break
+ fi
+ fi
+ done
+ if test "x$HTTP_EXT_PROPRO_INCDIR" = "x"; then
+ AC_MSG_FAILURE([not found])
+ else
+ AC_MSG_RESULT([$HTTP_EXT_PROPRO_INCDIR])
+ AC_DEFINE([PHP_HTTP_HAVE_PHP_PROPRO_H], [1], [Have ext/propro support])
+ PHP_ADD_INCLUDE([$HTTP_EXT_PROPRO_INCDIR])
+ fi
+ ])
+
PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
[ --without-http-shared-deps HTTP: do not depend on extensions like hash
and iconv (when they are built shared)], $PHP_HTTP, $PHP_HTTP)
php_http_object.c \
php_http_options.c \
php_http_params.c \
- php_http_property_proxy.c \
php_http_querystring.c \
php_http_strlist.c \
php_http_url.c \
php_http_object.h \
php_http_options.h \
php_http_params.h \
- php_http_property_proxy.h \
php_http_querystring.h \
php_http_strlist.h \
php_http_url.h \
|| SUCCESS != PHP_MINIT_CALL(http_header)
|| SUCCESS != PHP_MINIT_CALL(http_message)
|| SUCCESS != PHP_MINIT_CALL(http_message_body)
- || SUCCESS != PHP_MINIT_CALL(http_property_proxy)
|| SUCCESS != PHP_MINIT_CALL(http_querystring)
|| SUCCESS != PHP_MINIT_CALL(http_client_interface)
|| SUCCESS != PHP_MINIT_CALL(http_client)
#include <SAPI.h>
#include <ext/raphf/php_raphf.h>
+#include <ext/propro/php_propro.h>
#include <ext/standard/php_string.h>
#include <ext/spl/spl_iterators.h>
#include <ext/date/php_date.h>
#include "php_http_negotiate.h"
#include "php_http_object.h"
#include "php_http_params.h"
-#include "php_http_property_proxy.h"
#include "php_http_querystring.h"
#include "php_http_client_interface.h"
#include "php_http_client.h"
efree(o);
}
+static zval *php_http_client_datashare_object_read_prop(zval *object, zval *member, int type PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
+{
+ zend_property_info *pi;
+
+ if ((pi = zend_get_property_info(php_http_client_datashare_class_entry, member, 1 TSRMLS_CC))) {
+ if (type != BP_VAR_R) {
+ zval *zproxy;
+ php_property_proxy_t *proxy;
+
+ proxy = php_property_proxy_init(object, pi->name, pi->name_length TSRMLS_CC);
+
+ MAKE_STD_ZVAL(zproxy);
+#ifdef Z_SET_REFCOUNT_P
+ Z_SET_REFCOUNT_P(zproxy, 0);
+#else
+ zproxy->refcount = 0;
+#endif
+ ZVAL_OBJVAL(zproxy, php_property_proxy_object_new_ex(php_property_proxy_get_class_entry(), proxy, NULL TSRMLS_CC), 0);
+ return zproxy;
+ }
+ }
+ return zend_get_std_object_handlers()->read_property(object, member, type PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
+}
+
static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
{
zend_property_info *pi;
zend_get_std_object_handlers()->write_property(object, member, value PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
}
-static zval **php_http_client_datashare_object_get_prop_ptr(zval *object, zval *member PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
-{
- zend_property_info *pi;
-
- if ((pi = zend_get_property_info(php_http_client_datashare_class_entry, member, 1 TSRMLS_CC))) {
- return &php_http_property_proxy_init(NULL, object, member, NULL TSRMLS_CC)->myself;
- }
-
- return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
-}
-
-
PHP_METHOD(HttpClientDataShare, __destruct)
{
php_http_client_datashare_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
php_http_client_datashare_class_entry->create_object = php_http_client_datashare_object_new;
memcpy(&php_http_client_datashare_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_http_client_datashare_object_handlers.clone_obj = NULL;
+ php_http_client_datashare_object_handlers.read_property = php_http_client_datashare_object_read_prop;
php_http_client_datashare_object_handlers.write_property = php_http_client_datashare_object_write_prop;
- php_http_client_datashare_object_handlers.get_property_ptr_ptr = php_http_client_datashare_object_get_prop_ptr;
+ php_http_client_datashare_object_handlers.get_property_ptr_ptr = NULL;
zend_class_implements(php_http_client_datashare_class_entry TSRMLS_CC, 1, spl_ce_Countable);
static zval *php_http_message_object_read_prop(zval *object, zval *member, int type PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
static void php_http_message_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
-static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
static HashTable *php_http_message_object_get_props(zval *object TSRMLS_DC);
static zend_class_entry *php_http_message_class_entry;
php_http_message_object_prophandler_t h = { read, write };
return zend_hash_add(&php_http_message_object_prophandlers, prop_str, prop_len + 1, (void *) &h, sizeof(h), NULL);
}
-static int php_http_message_object_has_prophandler(const char *prop_str, size_t prop_len) {
- return zend_hash_exists(&php_http_message_object_prophandlers, prop_str, prop_len + 1);
-}
static STATUS php_http_message_object_get_prophandler(const char *prop_str, size_t prop_len, php_http_message_object_prophandler_t **handler) {
return zend_hash_find(&php_http_message_object_prophandlers, prop_str, prop_len + 1, (void *) handler);
}
php_http_message_object_handlers.read_property = php_http_message_object_read_prop;
php_http_message_object_handlers.write_property = php_http_message_object_write_prop;
php_http_message_object_handlers.get_properties = php_http_message_object_get_props;
- php_http_message_object_handlers.get_property_ptr_ptr = php_http_message_object_get_prop_ptr;
+ php_http_message_object_handlers.get_property_ptr_ptr = NULL;
zend_class_implements(php_http_message_class_entry TSRMLS_CC, 3, spl_ce_Countable, zend_ce_serializable, zend_ce_iterator);
efree(o);
}
-
-static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
-{
- zval *copy = php_http_ztyp(IS_STRING, member);
-
- if (php_http_message_object_has_prophandler(Z_STRVAL_P(copy), Z_STRLEN_P(copy))) {
- zval_ptr_dtor(©);
- return &php_http_property_proxy_init(NULL, object, member, NULL TSRMLS_CC)->myself;
- }
- zval_ptr_dtor(©);
-
- return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
-}
-
static zval *php_http_message_object_read_prop(zval *object, zval *member, int type PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
{
php_http_message_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
if (SUCCESS == php_http_message_object_get_prophandler(Z_STRVAL_P(copy), Z_STRLEN_P(copy), &handler)) {
- if (type == BP_VAR_R) {
- ALLOC_ZVAL(return_value);
- Z_SET_REFCOUNT_P(return_value, 0);
- Z_UNSET_ISREF_P(return_value);
+ ALLOC_ZVAL(return_value);
+ Z_SET_REFCOUNT_P(return_value, 0);
+ Z_UNSET_ISREF_P(return_value);
+ if (type == BP_VAR_R) {
handler->read(obj, return_value TSRMLS_CC);
} else {
- zend_error(E_ERROR, "Cannot access HttpMessage properties by reference or array key/index");
- return_value = NULL;
+ php_property_proxy_t *proxy = php_property_proxy_init(object, Z_STRVAL_P(copy), Z_STRLEN_P(copy) TSRMLS_CC);
+ RETVAL_OBJVAL(php_property_proxy_object_new_ex(php_property_proxy_get_class_entry(), proxy, NULL TSRMLS_CC), 0);
}
} else {
return_value = zend_get_std_object_handlers()->read_property(object, member, type PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | PECL :: http |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted provided that the conditions mentioned |
- | in the accompanying LICENSE file are met. |
- +--------------------------------------------------------------------+
- | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-
-#ifndef PHP_HTTP_PPDBG
-# define PHP_HTTP_PPDBG 0
-#endif
-
-PHP_HTTP_API php_http_property_proxy_t *php_http_property_proxy_init(php_http_property_proxy_t *proxy, zval *object, zval *member, zval *parent TSRMLS_DC)
-{
- if (!proxy) {
- proxy = emalloc(sizeof(*proxy));
- }
- memset(proxy, 0, sizeof(*proxy));
-
- MAKE_STD_ZVAL(proxy->myself);
- ZVAL_OBJVAL(proxy->myself, php_http_property_proxy_object_new_ex(php_http_property_proxy_get_class_entry(), proxy, NULL TSRMLS_CC), 0);
- Z_ADDREF_P(object);
- proxy->object = object;
- proxy->member = php_http_ztyp(IS_STRING, member);
- if (parent) {
- Z_ADDREF_P(parent);
- proxy->parent = parent;
- }
-
-#if PHP_HTTP_PPDBG
- fprintf(stderr, "proxy_init: %s\n", Z_STRVAL_P(proxy->member));
-#endif
- return proxy;
-}
-
-PHP_HTTP_API void php_http_property_proxy_dtor(php_http_property_proxy_t *proxy)
-{
- zval_ptr_dtor(&proxy->object);
- zval_ptr_dtor(&proxy->member);
- zval_ptr_dtor(&proxy->myself);
- if (proxy->parent) {
- zval_ptr_dtor(&proxy->parent);
- }
-}
-
-PHP_HTTP_API void php_http_property_proxy_free(php_http_property_proxy_t **proxy)
-{
- if (*proxy) {
- php_http_property_proxy_dtor(*proxy);
- efree(*proxy);
- *proxy = NULL;
- }
-}
-
-
-#define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpPropertyProxy, method, 0, req_args)
-#define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpPropertyProxy, method, 0)
-#define PHP_HTTP_PP_ME(method, visibility) PHP_ME(HttpPropertyProxy, method, PHP_HTTP_ARGS(HttpPropertyProxy, method), visibility)
-
-PHP_HTTP_EMPTY_ARGS(__construct);
-
-static zend_class_entry *php_http_property_proxy_class_entry;
-
-zend_class_entry *php_http_property_proxy_get_class_entry(void)
-{
- return php_http_property_proxy_class_entry;
-}
-
-static zend_function_entry php_http_property_proxy_method_entry[] = {
- PHP_HTTP_PP_ME(__construct, ZEND_ACC_FINAL|ZEND_ACC_PRIVATE)
- EMPTY_FUNCTION_ENTRY
-};
-
-static zend_object_handlers php_http_property_proxy_object_handlers;
-
-zend_object_value php_http_property_proxy_object_new(zend_class_entry *ce TSRMLS_DC)
-{
- return php_http_property_proxy_object_new_ex(ce, NULL, NULL TSRMLS_CC);
-}
-
-zend_object_value php_http_property_proxy_object_new_ex(zend_class_entry *ce, php_http_property_proxy_t *proxy, php_http_property_proxy_object_t **ptr TSRMLS_DC)
-{
- zend_object_value ov;
- php_http_property_proxy_object_t *o;
-
- o = ecalloc(1, sizeof(*o));
- zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
- object_properties_init((zend_object *) o, ce);
-
- if (ptr) {
- *ptr = o;
- }
- o->proxy = proxy;
-
- ov.handle = zend_objects_store_put(o, NULL, php_http_property_proxy_object_free, NULL TSRMLS_CC);
- ov.handlers = &php_http_property_proxy_object_handlers;
-
- return ov;
-}
-
-void php_http_property_proxy_object_free(void *object TSRMLS_DC)
-{
- php_http_property_proxy_object_t *o = object;
-
- if (o->proxy) {
- php_http_property_proxy_free(&o->proxy);
- }
- zend_object_std_dtor((zend_object *) o TSRMLS_CC);
- efree(o);
-}
-
-static zval *php_http_property_proxy_object_get(zval *object TSRMLS_DC)
-{
- php_http_property_proxy_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
-
-#if PHP_HTTP_PPDBG
- fprintf(stderr, "proxy_get: %s\n", Z_STRVAL_P(obj->proxy->member));
-#endif
- if (Z_TYPE_P(obj->proxy->object) == IS_OBJECT) {
- return zend_read_property(Z_OBJCE_P(obj->proxy->object), obj->proxy->object, Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member), 0 TSRMLS_CC);
- } else {
- zval **data = NULL;
-
- if (SUCCESS == zend_symtable_find(Z_ARRVAL_P(obj->proxy->object), Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member)+1, (void *) &data)) {
- Z_ADDREF_PP(data);
- } else {
- zval *unset;
-
- MAKE_STD_ZVAL(unset);
- ZVAL_NULL(unset);
- zend_symtable_update(Z_ARRVAL_P(obj->proxy->object), Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member)+1, (void *) &unset, sizeof(zval *), (void *) &data);
- Z_ADDREF_PP(data);
- }
-
- return *data;
- }
-
- return NULL;
-}
-
-static void php_http_property_proxy_object_set(zval **object, zval *value TSRMLS_DC)
-{
- php_http_property_proxy_object_t *obj = zend_object_store_get_object(*object TSRMLS_CC);
- zval *target = obj->proxy->parent ? php_http_property_proxy_object_get(obj->proxy->parent TSRMLS_CC) : obj->proxy->object;
-
-#if PHP_HTTP_PPDBG
- fprintf(stderr, "proxy_set: %s\n", Z_STRVAL_P(obj->proxy->member));
-#endif
- Z_ADDREF_P(value);
- if (Z_TYPE_P(target) == IS_OBJECT) {
- zend_update_property(Z_OBJCE_P(target), target, Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member), value TSRMLS_CC);
- } else {
- zend_symtable_update(Z_ARRVAL_P(target), Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member)+1, (void *) &value, sizeof(zval *), NULL);
- }
- /* propagate */
- if (obj->proxy->parent) {
- php_http_property_proxy_object_set(&obj->proxy->parent, target TSRMLS_CC);
- zval_ptr_dtor(&target);
- }
-}
-
-static STATUS php_http_property_proxy_object_cast(zval *object, zval *return_value, int type TSRMLS_DC)
-{
- zval *old_value, *new_value;
-
- old_value = php_http_property_proxy_object_get(object TSRMLS_CC);
- new_value = php_http_ztyp(type, old_value);
-
- if (old_value != new_value) {
- zval_ptr_dtor(&old_value);
- }
-
- RETVAL_ZVAL(new_value, 0, 0);
-
- return SUCCESS;
-}
-
-static zval *php_http_property_proxy_object_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)
-{
- php_http_property_proxy_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
- zval *retval = NULL, *property;
-
-#if PHP_HTTP_PPDBG
- zval *ocpy = php_http_ztyp(IS_STRING, offset);
- fprintf(stderr, "read_dimension: %s.%s (%d)\n", Z_STRVAL_P(obj->proxy->member), Z_STRVAL_P(ocpy), type);
- zval_ptr_dtor(&ocpy);
-#endif
-
- property = php_http_property_proxy_object_get(object TSRMLS_CC);
- if (type != BP_VAR_R) {
- Z_ADDREF_P(property);
- retval = php_http_property_proxy_init(NULL, property, offset, obj->proxy->myself TSRMLS_CC)->myself;
- } else if (Z_TYPE_P(property) == IS_ARRAY) {
- zval **data = NULL;
-
- if (Z_TYPE_P(offset) == IS_LONG) {
- if (SUCCESS == zend_hash_index_find(Z_ARRVAL_P(property), Z_LVAL_P(offset), (void *) &data)) {
- retval = *data;
- }
- } else {
- offset = php_http_ztyp(IS_STRING, offset);
- if (SUCCESS == zend_symtable_find(Z_ARRVAL_P(property), Z_STRVAL_P(offset), Z_STRLEN_P(offset), (void *) &data)) {
- retval = *data;
- }
- zval_ptr_dtor(&offset);
- }
-
- if (data) {
- Z_ADDREF_PP(data);
- }
- }
- zval_ptr_dtor(&property);
-
- return retval;
-}
-
-static void php_http_property_proxy_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC)
-{
- zval *property = php_http_property_proxy_object_get(object TSRMLS_CC);
-
-#if PHP_HTTP_PPDBG
- php_http_property_proxy_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
- zval *ocpy = offset ? php_http_ztyp(IS_STRING, offset) : offset;
- fprintf(stderr, "write_dimension: %s.%s (%d)\n", Z_STRVAL_P(obj->proxy->member), ocpy?Z_STRVAL_P(ocpy):"", Z_TYPE_P(property));
- if(ocpy)zval_ptr_dtor(&ocpy);
-#endif
- switch (Z_TYPE_P(property)) {
- case IS_NULL:
- array_init(property);
- /* no break */
- case IS_ARRAY:
- Z_ADDREF_P(value);
- if (!offset) {
- add_next_index_zval(property, value);
- } else if (Z_TYPE_P(offset) == IS_LONG) {
- add_index_zval(property, Z_LVAL_P(offset), value);
- } else {
- offset = php_http_ztyp(IS_STRING, offset);
- add_assoc_zval_ex(property, Z_STRVAL_P(offset), Z_STRLEN_P(offset) + 1, value);
- zval_ptr_dtor(&offset);
- }
- php_http_property_proxy_object_set(&object, property TSRMLS_CC);
- zval_ptr_dtor(&property);
- break;
-
- default:
- zval_ptr_dtor(&property);
- break;
- }
-}
-
-PHP_METHOD(HttpPropertyProxy, __construct)
-{
-}
-
-PHP_MINIT_FUNCTION(http_property_proxy)
-{
- PHP_HTTP_REGISTER_CLASS(http\\Object, PropertyProxy, http_property_proxy, NULL, ZEND_ACC_FINAL_CLASS);
- php_http_property_proxy_class_entry->create_object = php_http_property_proxy_object_new;
- memcpy(&php_http_property_proxy_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- php_http_property_proxy_object_handlers.set = php_http_property_proxy_object_set;
- php_http_property_proxy_object_handlers.get = php_http_property_proxy_object_get;
- php_http_property_proxy_object_handlers.cast_object = php_http_property_proxy_object_cast;
- php_http_property_proxy_object_handlers.read_dimension = php_http_property_proxy_object_read_dimension;
- php_http_property_proxy_object_handlers.write_dimension = php_http_property_proxy_object_write_dimension;
-
- return SUCCESS;
-}
-
-
-/*
- * 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
- */
-
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | PECL :: http |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted provided that the conditions mentioned |
- | in the accompanying LICENSE file are met. |
- +--------------------------------------------------------------------+
- | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_PROPERTY_PROXY_H
-#define PHP_HTTP_PROPERTY_PROXY_H
-
-typedef struct php_http_property_proxy {
- zval *myself;
- zval *object;
- zval *member;
- zval *parent;
-} php_http_property_proxy_t;
-
-PHP_HTTP_API php_http_property_proxy_t *php_http_property_proxy_init(php_http_property_proxy_t *proxy, zval *object, zval *member, zval *parent TSRMLS_DC);
-PHP_HTTP_API void php_http_property_proxy_dtor(php_http_property_proxy_t *proxy);
-PHP_HTTP_API void php_http_property_proxy_free(php_http_property_proxy_t **proxy);
-
-typedef struct php_http_property_proxy_object {
- zend_object zo;
- php_http_property_proxy_t *proxy;
-} php_http_property_proxy_object_t;
-
-zend_class_entry *php_http_property_proxy_get_class_entry(void);
-
-zend_object_value php_http_property_proxy_object_new(zend_class_entry *ce TSRMLS_DC);
-zend_object_value php_http_property_proxy_object_new_ex(zend_class_entry *ce, php_http_property_proxy_t *proxy, php_http_property_proxy_object_t **ptr TSRMLS_DC);
-void php_http_property_proxy_object_free(void *object TSRMLS_DC);
-
-PHP_METHOD(HttpPropertyProxy, __construct);
-
-PHP_MINIT_FUNCTION(http_property_proxy);
-
-#endif /* PHP_HTTP_PROPERTY_PROXY_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
- */
-